From b4be01e7ce4bea02568950f90f760b743d162bad Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Sun, 1 Oct 2017 20:01:50 +0200 Subject: [PATCH 1/4] Allow running long tests with testOnly Improves #3194 --- compiler/test/dotty/tools/dotc/CompilationTests.scala | 3 ++- compiler/test/dotty/tools/dotc/IdempotencyTests.scala | 4 ++-- compiler/test/dotty/tools/dotc/SlowTests.scala | 4 ++++ project/Build.scala | 6 +++--- 4 files changed, 11 insertions(+), 6 deletions(-) create mode 100644 compiler/test/dotty/tools/dotc/SlowTests.scala diff --git a/compiler/test/dotty/tools/dotc/CompilationTests.scala b/compiler/test/dotty/tools/dotc/CompilationTests.scala index cc2a99d3a2b2..d3df0708c0ba 100644 --- a/compiler/test/dotty/tools/dotc/CompilationTests.scala +++ b/compiler/test/dotty/tools/dotc/CompilationTests.scala @@ -5,6 +5,7 @@ package dotc import org.junit.{ Test, BeforeClass, AfterClass } import org.junit.Assert._ import org.junit.Assume._ +import org.junit.experimental.categories.Category import java.nio.file._ import java.util.stream.{ Stream => JStream } @@ -295,8 +296,8 @@ class CompilationTests extends ParallelTesting { tests.foreach(_.delete()) } + @Category(Array(classOf[SlowTests])) @Test def testOptimised: Unit = { - assumeTrue("Only executes on Drone", dotty.Properties.isRunByDrone) val outputDir = defaultOutputDir + "optimised/" compileFilesInDir("../tests/pos", defaultOptimised, outputDir).checkCompile() compileFilesInDir("../tests/run", defaultOptimised, outputDir).checkRuns() diff --git a/compiler/test/dotty/tools/dotc/IdempotencyTests.scala b/compiler/test/dotty/tools/dotc/IdempotencyTests.scala index 96a7b1356dc8..706c80d32524 100644 --- a/compiler/test/dotty/tools/dotc/IdempotencyTests.scala +++ b/compiler/test/dotty/tools/dotc/IdempotencyTests.scala @@ -7,6 +7,7 @@ import java.nio.file.{Files, Path, Paths} import org.junit.Assume.assumeTrue import org.junit.{AfterClass, Test} +import org.junit.experimental.categories.Category import scala.concurrent.duration._ import vulpix.{ParallelTesting, SummaryReport, SummaryReporting, TestConfiguration} @@ -24,9 +25,8 @@ class IdempotencyTests extends ParallelTesting { def isInteractive = SummaryReport.isInteractive def testFilter = Properties.testsFilter - /* TODO: Only run them selectively? */ + @Category(Array(classOf[SlowTests])) @Test def idempotency: Unit = { - assumeTrue("Only executes on Drone", dotty.Properties.isRunByDrone) val opt = defaultOptions.and("-YemitTasty") diff --git a/compiler/test/dotty/tools/dotc/SlowTests.scala b/compiler/test/dotty/tools/dotc/SlowTests.scala new file mode 100644 index 000000000000..37157a1f0f3e --- /dev/null +++ b/compiler/test/dotty/tools/dotc/SlowTests.scala @@ -0,0 +1,4 @@ +package dotty.tools.dotc + +/** SlowTest category for JUnit */ +trait SlowTests diff --git a/project/Build.scala b/project/Build.scala index 0bc6894eda46..3e295f21d999 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -465,13 +465,13 @@ object Build { test in Test := { // Exclude legacy tests by default - (testOnly in Test).toTask(" -- --exclude-categories=java.lang.Exception").value + (testOnly in Test).toTask(" -- --exclude-categories=java.lang.Exception,dotty.tools.dotc.SlowTests").value }, vulpix := Def.inputTaskDyn { val args: Seq[String] = spaceDelimited("").parsed - val cmd = " dotty.tools.dotc.CompilationTests" + { - if (args.nonEmpty) " -- -Ddotty.tests.filter=" + args.mkString(" ") + val cmd = " dotty.tools.dotc.CompilationTests -- --exclude-categories=dotty.tools.dotc.SlowTests" + { + if (args.nonEmpty) " -Ddotty.tests.filter=" + args.mkString(" ") else "" } (testOnly in Test).toTask(cmd) From 1c51fd934bb5139461b431c356bf3cf4a6f998b9 Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Tue, 3 Oct 2017 07:54:48 +0200 Subject: [PATCH 2/4] Add testAll sbt input key to also test SlowTests --- .drone.yml | 6 +++--- project/Build.scala | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.drone.yml b/.drone.yml index 42d2585a216f..2271488f0a6f 100644 --- a/.drone.yml +++ b/.drone.yml @@ -13,7 +13,7 @@ pipeline: image: lampepfl/dotty:2017-09-08 commands: - cp -R . /tmp/1/ && cd /tmp/1/ - - ./project/scripts/sbt test + - ./project/scripts/sbt testAll - ./project/scripts/sbt ";dotty-bench/jmh:run 1 1 tests/run/arrays.scala" test_bootstrapped: @@ -21,7 +21,7 @@ pipeline: image: lampepfl/dotty:2017-09-08 commands: - cp -R . /tmp/2/ && cd /tmp/2/ - - ./project/scripts/sbt dotty-bootstrapped/test + - ./project/scripts/sbt dotty-bootstrapped/testAll - ./project/scripts/sbt ";dotty-bench-bootstrapped/jmh:run 1 1 tests/run/arrays.scala" test_optimised: @@ -29,7 +29,7 @@ pipeline: image: lampepfl/dotty:2017-09-08 commands: - cp -R . /tmp/3/ && cd /tmp/3/ - - ./project/scripts/sbt dotty-optimised/test + - ./project/scripts/sbt dotty-optimised/testAll test_sbt: group: test diff --git a/project/Build.scala b/project/Build.scala index 3e295f21d999..0ea092a5dbf4 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -76,6 +76,9 @@ object Build { // Run tests with filter through vulpix test suite lazy val vulpix = inputKey[Unit]("runs integration test with the supplied filter") + // Run all tests including tests marked with SlowTests + lazy val testAll = inputKey[Unit]("runs all tests including SlowTests") + // Used to compile files similar to ./bin/dotc script lazy val dotc = inputKey[Unit]("run the compiler using the correct classpath, or the user supplied classpath") @@ -468,6 +471,11 @@ object Build { (testOnly in Test).toTask(" -- --exclude-categories=java.lang.Exception,dotty.tools.dotc.SlowTests").value }, + testAll in Test := { + // Exclude legacy tests by default + (testOnly in Test).toTask(" -- --exclude-categories=java.lang.Exception").value + }, + vulpix := Def.inputTaskDyn { val args: Seq[String] = spaceDelimited("").parsed val cmd = " dotty.tools.dotc.CompilationTests -- --exclude-categories=dotty.tools.dotc.SlowTests" + { From aef99eb05dfe6ce5eab67bb7e5e1a4d26bb264f0 Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Tue, 3 Oct 2017 08:56:26 +0200 Subject: [PATCH 3/4] Make legacy tests a proper JUnit category --- compiler/test/dotc/LegacyTests.scala | 4 ++++ compiler/test/dotc/tests.scala | 2 +- project/Build.scala | 4 ++-- 3 files changed, 7 insertions(+), 3 deletions(-) create mode 100644 compiler/test/dotc/LegacyTests.scala diff --git a/compiler/test/dotc/LegacyTests.scala b/compiler/test/dotc/LegacyTests.scala new file mode 100644 index 000000000000..10b9595b2b44 --- /dev/null +++ b/compiler/test/dotc/LegacyTests.scala @@ -0,0 +1,4 @@ +package dotc + +/** Legacy tests category for JUnit */ +trait LegacyTests diff --git a/compiler/test/dotc/tests.scala b/compiler/test/dotc/tests.scala index fa71a5deeece..0077d254301e 100644 --- a/compiler/test/dotc/tests.scala +++ b/compiler/test/dotc/tests.scala @@ -15,7 +15,7 @@ import scala.io.Source * ======= * These are legacy, do not add tests here, see `CompilationTests.scala` */ -@Category(Array(classOf[java.lang.Exception])) +@Category(Array(classOf[LegacyTests])) class tests extends CompilerTest { // tests that match regex '(pos|dotc|run|java|compileStdLib)\.*' would be diff --git a/project/Build.scala b/project/Build.scala index 0ea092a5dbf4..6a94ef98339e 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -468,12 +468,12 @@ object Build { test in Test := { // Exclude legacy tests by default - (testOnly in Test).toTask(" -- --exclude-categories=java.lang.Exception,dotty.tools.dotc.SlowTests").value + (testOnly in Test).toTask(" -- --exclude-categories=dotc.LegacyTests,dotty.tools.dotc.SlowTests").value }, testAll in Test := { // Exclude legacy tests by default - (testOnly in Test).toTask(" -- --exclude-categories=java.lang.Exception").value + (testOnly in Test).toTask(" -- --exclude-categories=dotc.LegacyTests").value }, vulpix := Def.inputTaskDyn { From aeb82a3278e98940a1390bcdfbb7a6741882e42e Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Tue, 3 Oct 2017 11:05:09 +0200 Subject: [PATCH 4/4] Move test categories to TestCategories --- compiler/test/dotc/LegacyTests.scala | 4 ---- compiler/test/dotc/tests.scala | 1 + compiler/test/dotty/TestCategories.scala | 7 +++++++ compiler/test/dotty/tools/dotc/SlowTests.scala | 4 ---- project/Build.scala | 6 +++--- 5 files changed, 11 insertions(+), 11 deletions(-) delete mode 100644 compiler/test/dotc/LegacyTests.scala create mode 100644 compiler/test/dotty/TestCategories.scala delete mode 100644 compiler/test/dotty/tools/dotc/SlowTests.scala diff --git a/compiler/test/dotc/LegacyTests.scala b/compiler/test/dotc/LegacyTests.scala deleted file mode 100644 index 10b9595b2b44..000000000000 --- a/compiler/test/dotc/LegacyTests.scala +++ /dev/null @@ -1,4 +0,0 @@ -package dotc - -/** Legacy tests category for JUnit */ -trait LegacyTests diff --git a/compiler/test/dotc/tests.scala b/compiler/test/dotc/tests.scala index 0077d254301e..7b0672a55939 100644 --- a/compiler/test/dotc/tests.scala +++ b/compiler/test/dotc/tests.scala @@ -1,6 +1,7 @@ package dotc import dotty.Jars +import dotty.LegacyTests import dotty.tools.dotc.CompilerTest import dotty.tools.StdLibSources import org.junit.experimental.categories.Category diff --git a/compiler/test/dotty/TestCategories.scala b/compiler/test/dotty/TestCategories.scala new file mode 100644 index 000000000000..b411fac93ade --- /dev/null +++ b/compiler/test/dotty/TestCategories.scala @@ -0,0 +1,7 @@ +package dotty + +/** SlowTest category for JUnit */ +trait SlowTests + +/** Legacy tests category for JUnit */ +trait LegacyTests diff --git a/compiler/test/dotty/tools/dotc/SlowTests.scala b/compiler/test/dotty/tools/dotc/SlowTests.scala deleted file mode 100644 index 37157a1f0f3e..000000000000 --- a/compiler/test/dotty/tools/dotc/SlowTests.scala +++ /dev/null @@ -1,4 +0,0 @@ -package dotty.tools.dotc - -/** SlowTest category for JUnit */ -trait SlowTests diff --git a/project/Build.scala b/project/Build.scala index 6a94ef98339e..1cfdc5bb2fd6 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -468,17 +468,17 @@ object Build { test in Test := { // Exclude legacy tests by default - (testOnly in Test).toTask(" -- --exclude-categories=dotc.LegacyTests,dotty.tools.dotc.SlowTests").value + (testOnly in Test).toTask(" -- --exclude-categories=dotty.LegacyTests,dotty.SlowTests").value }, testAll in Test := { // Exclude legacy tests by default - (testOnly in Test).toTask(" -- --exclude-categories=dotc.LegacyTests").value + (testOnly in Test).toTask(" -- --exclude-categories=dotty.LegacyTests").value }, vulpix := Def.inputTaskDyn { val args: Seq[String] = spaceDelimited("").parsed - val cmd = " dotty.tools.dotc.CompilationTests -- --exclude-categories=dotty.tools.dotc.SlowTests" + { + val cmd = " dotty.tools.dotc.CompilationTests -- --exclude-categories=dotty.SlowTests" + { if (args.nonEmpty) " -Ddotty.tests.filter=" + args.mkString(" ") else "" }