scala - Custom NIO filesystem doesn't load through SBT's test task -
for testing, i'm using in-memory nio filesystem
implementaion ( memoryfs ). i've taken advantage of before, , seems run fine through e.g. maven.
however, now, in sbt project, it's impossible initialize new filesystem
.
here's minimal sbt configuration reproduce problem:
import sbt._ import keys._ name := "testfs" organization := "com.example version := "0.1-snapshot" scalaversion := "2.11.6" librarydependencies ++= { val scalatestversion = "2.2.5" seq( "org.scalatest" %% "scalatest" % scalatestversion % "test", "org.mockito" % "mockito-core" % "1.10.19" % "test", "de.pfabulist.lindwurm" % "memoryfs" % "0.28.3" % "test" )}
and here's test:
import de.pfabulist.lindwurm.memory.memoryfsbuilder import org.scalatest.{flatspec, mustmatchers} class fsdummyspec extends flatspec mustmatchers { must "init fs" in { new memoryfsbuilder().watchservice(true).name("testfs").build() //init here } }
running sbt test
result in:
[info] fsdummyspec: [info] - must init fs *** failed *** [info] java.nio.file.providernotfoundexception: provider "memoryfs" not found [info] @ java.nio.file.filesystems.getfilesystem(filesystems.java:224) [info] @ de.pfabulist.kleinod.paths.pathss.getorcreate(pathss.java:76)
here's thing: this should run without problems. question is: why, , how fix it?
glancing on custom fs provider docs looks sbt borks classpath somehow, hard why.
note: interestingly enough, intellij idea's test runner seems work without hitch, problem on command line (in "sbt proper").
the comment opencage hinted @ solution.
it turns out custom file systems require additional element, i.e. service provider definition file located in meta-inf/services
.
if use custom nio filesystem, need make provider definition file available in test classpath.
the simplest way fork test vm, i.e. add following build.sbt
:
fork in test := true
Comments
Post a Comment