From e9a54600f5a8b401ae574056730b7757bcdb6c76 Mon Sep 17 00:00:00 2001 From: Bruno Bieth Date: Thu, 14 Nov 2013 15:42:15 +0100 Subject: [PATCH] made fork-parallel scripted test a little more robust --- .../fork-parallel/project/ForkParallelTest.scala | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/sbt/src/sbt-test/tests/fork-parallel/project/ForkParallelTest.scala b/sbt/src/sbt-test/tests/fork-parallel/project/ForkParallelTest.scala index c54748b65..891658ddf 100644 --- a/sbt/src/sbt-test/tests/fork-parallel/project/ForkParallelTest.scala +++ b/sbt/src/sbt-test/tests/fork-parallel/project/ForkParallelTest.scala @@ -11,8 +11,16 @@ object ForkParallelTest extends Build { libraryDependencies += "com.novocode" % "junit-interface" % "0.10" % "test", fork in Test := true, check := { - if( ! (file("max-concurrent-tests_3").exists() || file("max-concurrent-tests_4").exists() )) { - sys.error("Forked tests were not executed in parallel!") + val nbProc = java.lang.Runtime.getRuntime().availableProcessors() + if( nbProc < 4 ) { + streams.value.log.warn("With fewer than 4 processors this test is meaningless") + } else { + // we've got at least 4 processors, we'll check the upper end but also 3 and 4 as the upper might not + // be reached if the system is under heavy load. + if( ! (file("max-concurrent-tests_3").exists() || file("max-concurrent-tests_4").exists() || + file("max-concurrent-tests_" + (nbProc -1)).exists() || file("max-concurrent-tests_" + nbProc).exists())) { + sys.error("Forked tests were not executed in parallel!") + } } } ))