Forking tests fail because javaOptions seems to be

2019-09-06 15:58发布

Using Play 2.X, I expect my tests to be forked by default (new way from Play 2.X) and especially well run.

However, when using this SBT configuration in my Build.scala, I observe an OOM due to permgen space, like the following:

Uncaught exception when running myspecs.AllSpecs: java.lang.OutOfMemoryError: PermGen space
sbt.ForkMain$ForkError: PermGen space
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:791)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
    at scala.collection.parallel.immutable.LazyParVectorCombiner.result(ParVector.scala:129)
    at scala.collection.parallel.immutable.LazyParVectorCombiner.result(ParVector.scala:105)
    at scala.collection.Parallelizable$class.par(Parallelizable.scala:42)
    at scala.collection.AbstractTraversable.par(Traversable.scala:105)
    at org.specs2.reporter.AllExporting$$anonfun$export$1$$anonfun$2.apply(AllExporting.scala:28)
    at org.specs2.reporter.AllExporting$$anonfun$export$1$$anonfun$2.apply(AllExporting.scala:27)
    at scalaz.syntax.IdOps$class.$bar$greater(IdOps.scala:15)
    at scalaz.syntax.ToIdOps$$anon$1.$bar$greater(IdOps.scala:82)
    at org.specs2.reporter.AllExporting$$anonfun$export$1.apply(AllExporting.scala:32)
    at org.specs2.reporter.AllExporting$$anonfun$export$1.apply(AllExporting.scala:24)
    at scalaz.syntax.IdOps$class.$bar$greater(IdOps.scala:15)
    at scalaz.syntax.ToIdOps$$anon$1.$bar$greater(IdOps.scala:82)
    at org.specs2.reporter.AllExporting$class.report(AllExporting.scala:17)
    at org.specs2.reporter.SbtConsoleReporter.report(SbtReporter.scala:20)
    at org.specs2.runner.SbtRunner.org$specs2$runner$SbtRunner$$specificationRun(SbtRunner.scala:75)
    at org.specs2.runner.SbtRunner$$anonfun$newTask$1$$anon$5.execute(SbtRunner.scala:59)
    at sbt.ForkMain$Run.runTest(ForkMain.java:239)
    at sbt.ForkMain$Run.runTestSafe(ForkMain.java:211)
    at sbt.ForkMain$Run.runTests(ForkMain.java:187)
    at sbt.ForkMain$Run.run(ForkMain.java:251)

My configuration is the following:
- My ApplicationBuild.scala is present here
- My plugins.sbt is present here
- My build.properties is present here

But if I just change this line:

javaOptions in (Test,run) ++= Seq("-Xms512M", "-Xmx2048M", "-XX:MaxPermSize=2048M", "-XX:+CMSClassUnloadingEnabled")

by this line:

javaOptions ++= Seq("-Xms512M", "-Xmx2048M", "-XX:MaxPermSize=2048M", "-XX:+CMSClassUnloadingEnabled")

the whole works.

Why specifying (Test, run) make the whole fail?

Am I missing some specified tasks other than Test and run?

I really would like to well figure it out :)

1条回答
在下西门庆
2楼-- · 2019-09-06 16:54

In your cofiguration

javaOptions in (Test,run) ++= Seq(...)

says configuration Test and for key run, but running the tests are not done with the key run, it is done with the key test, so you have defined the setting for something else than running the tests

javaOptions in (Test,test) ++= Seq(...)

or just

javaOptions in (Test) ++= Seq(...)

should get you there!

查看更多
登录 后发表回答