Skip to content

Commit c0f5cd5

Browse files
committed
Keep test and partest as separate sbt targets
1 parent d531ad3 commit c0f5cd5

File tree

7 files changed

+267
-320
lines changed

7 files changed

+267
-320
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,5 @@ classes/
2727
/.worksheet/
2828

2929
# Partest
30-
tests/partest-generated/
30+
tests/partest-generated/
31+
tests/runPartest.flag

project/Build.scala

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,12 @@ object DottyBuild extends Build {
4848
incOptions := incOptions.value.withNameHashing(true),
4949

5050
// enable verbose exception messages for JUnit
51-
// JUnit from sbt only generates partest files, doesn't run tests
52-
testOptions += Tests.Argument(TestFrameworks.JUnit, "-a", "-v", "--run-listener=test.ContextEscapeDetector",
53-
"--exclude-categories=dotty.partest." + (if (isTravisBuild) "" else "Non") + "PartestTarget"),
54-
// test generates files, then we run partest
55-
partest <<= runTask(Test, "dotty.partest.DPConsoleRunner", "") dependsOn (test in Test),
51+
testOptions in Test += Tests.Argument(TestFrameworks.JUnit, "-a", "-v", "--run-listener=test.ContextEscapeDetector"),
52+
// when this file is present, running test generates the files for partest
53+
// otherwise it just executes the tests directly
54+
createPartestFile := { new java.io.File("./tests", "runPartest.flag").createNewFile },
55+
runPartestRunner <<= runTask(Test, "dotty.partest.DPConsoleRunner", "") dependsOn (test in Test),
56+
deletePartestFile := { new java.io.File("./tests", "runPartest.flag").delete },
5657

5758
// Adjust classpath for running dotty
5859
mainClass in (Compile, run) := Some("dotty.tools.dotc.Main"),
@@ -83,9 +84,7 @@ object DottyBuild extends Build {
8384

8485
tuning ::: agentOptions ::: travis_build ::: fullpath
8586
}
86-
) ++ (if (isTravisBuild) Seq() else addCommandAlias("test", "partest"))
87-
// alias so that "sbt test" executes partest (which dependsOn test) - no
88-
// circular dependency because the setting is evaluated before
87+
) ++ addCommandAlias("partest", ";createPartestFile;runPartestRunner;deletePartestFile")
8988

9089
lazy val dotty = Project(id = "dotty", base = file("."), settings = defaults)
9190

@@ -134,5 +133,8 @@ object DottyBuild extends Build {
134133
lazy val benchmarks = Project(id = "dotty-bench", settings = benchmarkSettings,
135134
base = file("bench")) dependsOn(dotty % "compile->test")
136135

137-
lazy val partest = TaskKey[Unit]("partest", "Runs test and partests")
136+
lazy val createPartestFile = TaskKey[Unit]("createPartestFile", "Creates the tests/runPartest.flag file")
137+
lazy val runPartestRunner = TaskKey[Unit]("runPartestRunner", "Runs partests")
138+
lazy val deletePartestFile = TaskKey[Unit]("deletePartestFile", "Deletes the tests/runPartest.flag file")
139+
138140
}

test/dotc/comptest.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ import test._
44

55
object comptest extends CompilerTest {
66

7+
override val generatePartestFiles = false
8+
val defaultOutputDir: String = ""
9+
710
val posDir = "./tests/pos/"
811
val negDir = "./tests/neg/"
912
val dotcDir = "./src/dotty/"

test/dotc/tests.scala

Lines changed: 6 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@ import org.junit.Test
66
import org.junit.experimental.categories._
77

88

9-
object TestOptions {
10-
val outputDir = "./out/"
11-
val testsDir = "./tests/"
12-
val posDir = testsDir + "pos/"
9+
class tests extends CompilerTest {
1310

1411
val noCheckOptions = List(
1512
// "-verbose",
@@ -19,20 +16,13 @@ object TestOptions {
1916
// "-Yshow-suppressed-errors",
2017
"-pagewidth", "160")
2118

19+
val defaultOutputDir = "./out/"
20+
2221
implicit val defaultOptions = noCheckOptions ++ List(
2322
"-Yno-deep-subtypes", "-Yno-double-bindings",
2423
"-Ycheck:tailrec,resolveSuper,mixin,restoreScopes",
25-
"-d", outputDir
24+
"-d", defaultOutputDir
2625
)
27-
}
28-
29-
// Always use this annotation together with a subclass of the test that mixes
30-
// in PartestVersion (see below). This allows the tests to be run by partest
31-
// instead of JUnit when using sbt test.
32-
@Category(Array(classOf[NonPartestTarget]))
33-
class tests extends CompilerTest {
34-
import TestOptions._
35-
3626
val doEmitBytecode = List("-Ystop-before:terminal")
3727
val failedbyName = List("-Ystop-before:collectEntryPoints") // #288
3828
val testPickling = List("-Xprint-types", "-Ytest-pickler", "-Ystop-after:pickler")
@@ -44,6 +34,8 @@ class tests extends CompilerTest {
4434
val allowDeepSubtypes = defaultOptions diff List("-Yno-deep-subtypes")
4535
val allowDoubleBindings = defaultOptions diff List("-Yno-double-bindings")
4636

37+
val testsDir = "./tests/"
38+
val posDir = testsDir + "pos/"
4739
val posSpecialDir = testsDir + "pos-special/"
4840
val negDir = testsDir + "neg/"
4941
val newDir = testsDir + "new/"
@@ -204,18 +196,3 @@ class tests extends CompilerTest {
204196

205197
//@Test def dotc_compilercommand = compileFile(dotcDir + "config/", "CompilerCommand")
206198
}
207-
208-
209-
// Always mix in the PartestVersion trait when the superclass is annotated as
210-
// above. Both together allow the tests to be run by partest instead of JUnit
211-
// when using sbt test.
212-
@Category(Array(classOf[PartestTarget]))
213-
class testsPartest extends tests with DPCompilerTest {
214-
// redirect class file output to partest-generated/kind/testname-kind.obj/
215-
override val defaultOutputDir = TestOptions.outputDir
216-
}
217-
218-
object testsNotPartestable extends CompilerTest {
219-
import TestOptions._
220-
// Add tests here that should always be run by JUnit, not partest
221-
}

test/dotty/partest/DPCompilerTest.scala

Lines changed: 0 additions & 266 deletions
This file was deleted.

0 commit comments

Comments
 (0)