From 15597c38437e99223b37cf7920259e01dd2a02e2 Mon Sep 17 00:00:00 2001 From: Seth Tisue Date: Mon, 28 Jan 2019 17:46:28 -0800 Subject: [PATCH] remove flaky test (fork-parallel) as suggested by Eugene --- .../project/ForkParallelTest.scala | 27 ---------- .../fork-parallel/src/test/scala/tests.scala | 53 ------------------- sbt/src/sbt-test/tests/fork-parallel/test | 7 --- 3 files changed, 87 deletions(-) delete mode 100644 sbt/src/sbt-test/tests/fork-parallel/project/ForkParallelTest.scala delete mode 100644 sbt/src/sbt-test/tests/fork-parallel/src/test/scala/tests.scala delete mode 100644 sbt/src/sbt-test/tests/fork-parallel/test diff --git a/sbt/src/sbt-test/tests/fork-parallel/project/ForkParallelTest.scala b/sbt/src/sbt-test/tests/fork-parallel/project/ForkParallelTest.scala deleted file mode 100644 index 891658ddf..000000000 --- a/sbt/src/sbt-test/tests/fork-parallel/project/ForkParallelTest.scala +++ /dev/null @@ -1,27 +0,0 @@ -import sbt._ -import Keys._ -import Tests._ -import Defaults._ - -object ForkParallelTest extends Build { - val check = taskKey[Unit]("Check that tests are executed in parallel") - - lazy val root = Project("root", file("."), settings = defaultSettings ++ Seq( - scalaVersion := "2.9.2", - libraryDependencies += "com.novocode" % "junit-interface" % "0.10" % "test", - fork in Test := true, - check := { - 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!") - } - } - } - )) -} \ No newline at end of file diff --git a/sbt/src/sbt-test/tests/fork-parallel/src/test/scala/tests.scala b/sbt/src/sbt-test/tests/fork-parallel/src/test/scala/tests.scala deleted file mode 100644 index fd52c63c6..000000000 --- a/sbt/src/sbt-test/tests/fork-parallel/src/test/scala/tests.scala +++ /dev/null @@ -1,53 +0,0 @@ - -import java.io.File -import java.util.concurrent.atomic.AtomicInteger -import org.junit.Test -import scala.annotation.tailrec - -object ParallelTest { - val nbConcurrentTests = new AtomicInteger(0) - val maxConcurrentTests = new AtomicInteger(0) - - private def updateMaxConcurrentTests(currentMax: Int, newMax: Int) : Boolean = { - if( maxConcurrentTests.compareAndSet(currentMax, newMax) ) { - val f = new File("max-concurrent-tests_" + newMax) - f.createNewFile - true - } else { - false - } - } - - @tailrec - def execute(f : => Unit): Unit = { - val nb = nbConcurrentTests.incrementAndGet() - val max = maxConcurrentTests.get() - if( nb <= max || updateMaxConcurrentTests(max, nb)) { - f - nbConcurrentTests.getAndDecrement - } else { - nbConcurrentTests.getAndDecrement - execute(f) - } - } -} - -class Test1 { - @Test - def slow(): Unit = ParallelTest.execute { Thread.sleep(1000) } -} - -class Test2 { - @Test - def slow(): Unit = ParallelTest.execute { Thread.sleep(1000) } -} - -class Test3 { - @Test - def slow(): Unit = ParallelTest.execute { Thread.sleep(1000) } -} - -class Test4 { - @Test - def slow(): Unit = ParallelTest.execute { Thread.sleep(1000) } -} diff --git a/sbt/src/sbt-test/tests/fork-parallel/test b/sbt/src/sbt-test/tests/fork-parallel/test deleted file mode 100644 index 5226713d3..000000000 --- a/sbt/src/sbt-test/tests/fork-parallel/test +++ /dev/null @@ -1,7 +0,0 @@ -> test --> check - -> clean -> set testForkedParallel := true -> test -> check \ No newline at end of file