You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Evaluating Resources.inferRootDir is throwing a NPE when it's run in bloop - I believe this is because (in sbt) the initial new File(getClass.getResource("/").toURI) call returns something like
(project root)/target/scala-2.12/test-classes,
but in Bloop it's
(project root)/src/test/resources - the actual source directory.
So in the latter case, the loop:
while (current.ne(null) && current.getName !="target") {
current = current.getParentFile
}
basically runs until it finds the root directory (/) and its parent, null (because there's usually no target in the path).
It would be great to support the case of running these tests through bloop, as it's often used by users of Metals to avoid duplicate compilations with sbt.
Maybe instead of the fragile classpath-based logic, we could have something compile-time, getting the path of the current file in a sourcecode-like fashion and moving upwards until we hit test, then just adding /resources?
The text was updated successfully, but these errors were encountered:
As a POC, this seems to work well in both environments:
defresourceDirectory(implicitfile: sourcecode.File):File=Monad[cats.Id]
.tailRecM(Paths.get(file.value)) {
case p if p.endsWith("test") =>Right(p)
case p =>Left(p.getParent())
}
.resolve("resources")
.toFile()
println(resourceDirectory)
If this sounds good, I'll be happy to provide a PR (presumably with a forked implementation of sourcecode.File).
Evaluating
Resources.inferRootDir
is throwing a NPE when it's run in bloop - I believe this is because (in sbt) the initialnew File(getClass.getResource("/").toURI)
call returns something like(project root)/target/scala-2.12/test-classes
,but in Bloop it's
(project root)/src/test/resources
- the actual source directory.So in the latter case, the loop:
basically runs until it finds the root directory (
/
) and its parent,null
(because there's usually notarget
in the path).It would be great to support the case of running these tests through bloop, as it's often used by users of Metals to avoid duplicate compilations with sbt.
Maybe instead of the fragile classpath-based logic, we could have something compile-time, getting the path of the current file in a
sourcecode
-like fashion and moving upwards until we hittest
, then just adding/resources
?The text was updated successfully, but these errors were encountered: