Skip to content

Commit d531ad3

Browse files
committed
Partest for Dotty with pos tests and neg tests with error count
1 parent 52d6ac3 commit d531ad3

File tree

10 files changed

+697
-84
lines changed

10 files changed

+697
-84
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
*.DS_Store
12
*.class
23
*.log
34
*~
@@ -24,3 +25,6 @@ classes/
2425
.idea
2526
.idea_modules
2627
/.worksheet/
28+
29+
# Partest
30+
tests/partest-generated/

project/Build.scala

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import sbt._
44
object DottyBuild extends Build {
55

66
val TRAVIS_BUILD = "dotty.travis.build"
7+
val isTravisBuild = sys.props.isDefinedAt(TRAVIS_BUILD)
78

89
val agentOptions = List(
910
// "-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005"
@@ -32,10 +33,11 @@ object DottyBuild extends Build {
3233
libraryDependencies ++= Seq("org.scala-lang" % "scala-reflect" % scalaVersion.value,
3334
"org.scala-lang.modules" %% "scala-xml" % "1.0.1",
3435
"me.d-d" % "scala-compiler" % "2.11.5-20150402-193021-0c75410da3",
36+
"org.scala-lang.modules" %% "scala-partest" % "1.0.5" % "test",
3537
"jline" % "jline" % "2.12"),
3638

3739
// get junit onboard
38-
libraryDependencies += "com.novocode" % "junit-interface" % "0.11-RC1" % "test",
40+
libraryDependencies += "com.novocode" % "junit-interface" % "0.11" % "test",
3941

4042
// scalac options
4143
scalacOptions in Global ++= Seq("-feature", "-deprecation", "-language:_"),
@@ -46,7 +48,12 @@ object DottyBuild extends Build {
4648
incOptions := incOptions.value.withNameHashing(true),
4749

4850
// enable verbose exception messages for JUnit
49-
testOptions += Tests.Argument(TestFrameworks.JUnit, "-a", "-v", "--run-listener=test.ContextEscapeDetector"),
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),
56+
5057
// Adjust classpath for running dotty
5158
mainClass in (Compile, run) := Some("dotty.tools.dotc.Main"),
5259
fork in run := true,
@@ -65,10 +72,7 @@ object DottyBuild extends Build {
6572
// System.err.println("BOOTPATH: " + fullpath)
6673

6774
val travis_build = // propagate if this is a travis build
68-
if (sys.props.isDefinedAt(TRAVIS_BUILD))
69-
List(s"-D$TRAVIS_BUILD=${sys.props(TRAVIS_BUILD)}")
70-
else
71-
List()
75+
if (isTravisBuild) List(s"-D$TRAVIS_BUILD=${sys.props(TRAVIS_BUILD)}") else List()
7276

7377
val tuning =
7478
if (sys.props.isDefinedAt("Oshort"))
@@ -79,7 +83,9 @@ object DottyBuild extends Build {
7983

8084
tuning ::: agentOptions ::: travis_build ::: fullpath
8185
}
82-
)
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
8389

8490
lazy val dotty = Project(id = "dotty", base = file("."), settings = defaults)
8591

@@ -92,7 +98,7 @@ object DottyBuild extends Build {
9298

9399

94100
libraryDependencies ++= Seq("com.storm-enroute" %% "scalameter" % "0.6" % Test,
95-
"com.novocode" % "junit-interface" % "0.11-RC1"),
101+
"com.novocode" % "junit-interface" % "0.11"),
96102
testFrameworks += new TestFramework("org.scalameter.ScalaMeterFramework"),
97103

98104
// scalac options
@@ -116,10 +122,8 @@ object DottyBuild extends Build {
116122
// System.err.println("BOOTPATH: " + fullpath)
117123

118124
val travis_build = // propagate if this is a travis build
119-
if (sys.props.isDefinedAt(TRAVIS_BUILD))
120-
List(s"-D$TRAVIS_BUILD=${sys.props(TRAVIS_BUILD)}")
121-
else
122-
List()
125+
if (isTravisBuild) List(s"-D$TRAVIS_BUILD=${sys.props(TRAVIS_BUILD)}") else List()
126+
123127
val res = agentOptions ::: travis_build ::: fullpath
124128
println("Running with javaOptions: " + res)
125129
res
@@ -129,4 +133,6 @@ object DottyBuild extends Build {
129133

130134
lazy val benchmarks = Project(id = "dotty-bench", settings = benchmarkSettings,
131135
base = file("bench")) dependsOn(dotty % "compile->test")
136+
137+
lazy val partest = TaskKey[Unit]("partest", "Runs test and partests")
132138
}

test/dotc/comptest.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ object comptest extends CompilerTest {
99
val dotcDir = "./src/dotty/"
1010

1111
def main(args: Array[String]) =
12-
compileArgs(Array(
12+
compileList("comptest", List(
1313
dotcDir + "tools/dotc/CompilationUnit.scala",
1414
dotcDir + "tools/dotc/core/Types.scala",
15-
dotcDir + "tools/dotc/ast/Trees.scala",
15+
dotcDir + "tools/dotc/ast/Trees.scala"), List(
1616
"#runs", "2",
1717
"-Ylog:frontend",
1818
"-Xprompt"))(Nil)
1919

20-
// compileDir(dotcDir + "tools/dotc/printing", List("-Xprompt", "-Ylog:frontend", "#runs", "2", "-uniqid"))
20+
// compileDir(dotcDir + "tools/dotc/", "printing", List("-Xprompt", "-Ylog:frontend", "#runs", "2", "-uniqid"))
2121
}

test/dotc/tests.scala

Lines changed: 83 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
package dotc
22

3-
import org.junit.Test
43
import test._
4+
import dotty.partest._
5+
import org.junit.Test
6+
import org.junit.experimental.categories._
57

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

814
val noCheckOptions = List(
915
// "-verbose",
@@ -16,8 +22,16 @@ class tests extends CompilerTest {
1622
implicit val defaultOptions = noCheckOptions ++ List(
1723
"-Yno-deep-subtypes", "-Yno-double-bindings",
1824
"-Ycheck:tailrec,resolveSuper,mixin,restoreScopes",
19-
"-d", "./out/"
25+
"-d", outputDir
2026
)
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._
2135

2236
val doEmitBytecode = List("-Ystop-before:terminal")
2337
val failedbyName = List("-Ystop-before:collectEntryPoints") // #288
@@ -30,19 +44,21 @@ class tests extends CompilerTest {
3044
val allowDeepSubtypes = defaultOptions diff List("-Yno-deep-subtypes")
3145
val allowDoubleBindings = defaultOptions diff List("-Yno-double-bindings")
3246

33-
val posDir = "./tests/pos/"
34-
val posSpecialDir = "./tests/pos-special/"
35-
val negDir = "./tests/neg/"
36-
val newDir = "./tests/new/"
37-
val dotcDir = "./src/dotty/"
38-
val picklingDir = "./tests/pickling"
47+
val posSpecialDir = testsDir + "pos-special/"
48+
val negDir = testsDir + "neg/"
49+
val newDir = testsDir + "new/"
3950

40-
@Test def pickle_pickleOK = compileDir(picklingDir, testPickling)
41-
@Test def pickle_pickling = compileDir(dotcDir + "tools/dotc/core/pickling/", testPickling)
42-
@Test def pickle_ast = compileDir(dotcDir + "tools/dotc/ast/", testPickling)
51+
val dottyDir = "./src/dotty/"
52+
val toolsDir = dottyDir + "tools/"
53+
val dotcDir = toolsDir + "dotc/"
54+
val coreDir = dotcDir + "core/"
4355

44-
//@Test def pickle_core = compileDir(dotcDir + "tools/dotc/core", testPickling, xerrors = 2) // two spurious comparison errors in Types and TypeOps
56+
@Test def pickle_pickleOK = compileDir(testsDir, "pickling", testPickling)
57+
@Test def pickle_pickling = compileDir(coreDir, "pickling", testPickling)
58+
@Test def pickle_ast = compileDir(dotcDir, "ast", testPickling)
4559

60+
//@Test def pickle_core = compileDir(dotcDir, "core", testPickling, xerrors = 2) // two spurious comparison errors in Types and TypeOps
61+
4662
@Test def pos_t2168_pat = compileFile(posDir, "t2168", twice)
4763
@Test def pos_erasure = compileFile(posDir, "erasure", twice)
4864
@Test def pos_Coder() = compileFile(posDir, "Coder", twice)
@@ -66,12 +82,12 @@ class tests extends CompilerTest {
6682
@Test def pos_packageobject() = compileFile(posDir, "packageobject", twice)
6783
@Test def pos_overloaded() = compileFile(posDir, "overloaded", twice)
6884
@Test def pos_overrides() = compileFile(posDir, "overrides", twice)
69-
@Test def pos_javaOverride() = compileDir(posDir + "java-override", twice)
85+
@Test def pos_javaOverride() = compileDir(posDir, "java-override", twice)
7086
@Test def pos_templateParents() = compileFile(posDir, "templateParents", twice)
7187
@Test def pos_overloadedAccess = compileFile(posDir, "overloadedAccess", twice)
7288
@Test def pos_approximateUnion = compileFile(posDir, "approximateUnion", twice)
73-
@Test def pos_tailcall = compileDir(posDir + "tailcall/", twice)
74-
@Test def pos_nullarify = compileFile(posDir, "nullarify", "-Ycheck:nullarify" :: Nil)
89+
@Test def pos_tailcall = compileDir(posDir, "tailcall", twice)
90+
@Test def pos_nullarify = compileFile(posDir, "nullarify", args = "-Ycheck:nullarify" :: Nil)
7591
@Test def pos_subtyping = compileFile(posDir, "subtyping", twice)
7692
@Test def pos_t2613 = compileFile(posSpecialDir, "t2613")(allowDeepSubtypes)
7793
@Test def pos_packageObj = compileFile(posDir, "i0239", twice)
@@ -92,7 +108,7 @@ class tests extends CompilerTest {
92108
@Test def neg_privates() = compileFile(negDir, "privates", xerrors = 2)
93109
@Test def neg_rootImports = compileFile(negDir, "rootImplicits", xerrors = 2)
94110
@Test def neg_templateParents() = compileFile(negDir, "templateParents", xerrors = 3)
95-
@Test def neg_autoTupling = compileFile(posDir, "autoTuplingTest", "-language:noAutoTupling" :: Nil, xerrors = 4)
111+
@Test def neg_autoTupling = compileFile(posDir, "autoTuplingTest", args = "-language:noAutoTupling" :: Nil, xerrors = 4)
96112
@Test def neg_autoTupling2 = compileFile(negDir, "autoTuplingTest", xerrors = 4)
97113
@Test def neg_companions = compileFile(negDir, "companions", xerrors = 1)
98114
@Test def neg_over = compileFile(negDir, "over", xerrors = 3)
@@ -102,14 +118,18 @@ class tests extends CompilerTest {
102118
@Test def neg_i50_volatile = compileFile(negDir, "i50-volatile", xerrors = 6)
103119
@Test def neg_t0273_doubledefs = compileFile(negDir, "t0273", xerrors = 1)
104120
@Test def neg_zoo = compileFile(negDir, "zoo", xerrors = 12)
105-
@Test def neg_t1192_legalPrefix = compileFile(negDir, "t1192", xerrors = 1)
106-
@Test def neg_tailcall_t1672b = compileFile(negDir, "tailcall/t1672b", xerrors = 6)
107-
@Test def neg_tailcall_t3275 = compileFile(negDir, "tailcall/t3275", xerrors = 1)
108-
@Test def neg_tailcall_t6574 = compileFile(negDir, "tailcall/t6574", xerrors = 2)
109-
@Test def neg_tailcall = compileFile(negDir, "tailcall/tailrec", xerrors = 7)
110-
@Test def neg_tailcall2 = compileFile(negDir, "tailcall/tailrec-2", xerrors = 2)
111-
@Test def neg_tailcall3 = compileFile(negDir, "tailcall/tailrec-3", xerrors = 2)
112-
@Test def nef_t1279a = compileFile(negDir, "t1279a", xerrors = 1)
121+
// TODO: this test file doesn't exist (anymore?), remove?
122+
// @Test def neg_t1192_legalPrefix = compileFile(negDir, "t1192", xerrors = 1)
123+
124+
val negTailcallDir = negDir + "tailcall/"
125+
@Test def neg_tailcall_t1672b = compileFile(negTailcallDir, "t1672b", xerrors = 6)
126+
@Test def neg_tailcall_t3275 = compileFile(negTailcallDir, "t3275", xerrors = 1)
127+
@Test def neg_tailcall_t6574 = compileFile(negTailcallDir, "t6574", xerrors = 2)
128+
@Test def neg_tailcall = compileFile(negTailcallDir, "tailrec", xerrors = 7)
129+
@Test def neg_tailcall2 = compileFile(negTailcallDir, "tailrec-2", xerrors = 2)
130+
@Test def neg_tailcall3 = compileFile(negTailcallDir, "tailrec-3", xerrors = 2)
131+
132+
@Test def neg_t1279a = compileFile(negDir, "t1279a", xerrors = 1)
113133
@Test def neg_t1843_variances = compileFile(negDir, "t1843-variances", xerrors = 1)
114134
@Test def neg_t2660_ambi = compileFile(negDir, "t2660", xerrors = 2)
115135
@Test def neg_t2994 = compileFile(negDir, "t2994", xerrors = 2)
@@ -127,62 +147,75 @@ class tests extends CompilerTest {
127147
@Test def neg_moduleSubtyping = compileFile(negDir, "moduleSubtyping", xerrors = 4)
128148
@Test def neg_escapingRefs = compileFile(negDir, "escapingRefs", xerrors = 2)
129149

130-
@Test def dotc = compileDir(dotcDir + "tools/dotc", failedOther)(allowDeepSubtypes ++ twice) // see dotc_core
131-
@Test def dotc_ast = compileDir(dotcDir + "tools/dotc/ast", failedOther ++ twice)
150+
@Test def dotc = compileDir(toolsDir, "dotc", failedOther)(allowDeepSubtypes ++ twice) // see dotc_core
151+
@Test def dotc_ast = compileDir(dotcDir, "ast", failedOther ++ twice)
132152
//similar to dotc_core_pickling but for another anon class. Still during firstTransform
133-
@Test def dotc_config = compileDir(dotcDir + "tools/dotc/config")
134-
@Test def dotc_core = compileDir(dotcDir + "tools/dotc/core", failedOther)("-Yno-double-bindings" :: allowDeepSubtypes)// twice omitted to make tests run faster
153+
@Test def dotc_config = compileDir(dotcDir, "config")
154+
@Test def dotc_core = compileDir(dotcDir, "core", failedOther)("-Yno-double-bindings" :: allowDeepSubtypes)// twice omitted to make tests run faster
135155
// error: error while loading ConstraintHandling$$anon$1$,
136156
// class file 'target/scala-2.11/dotty_2.11-0.1-SNAPSHOT.jar(dotty/tools/dotc/core/ConstraintHandling$$anon$1.class)'
137157
// has location not matching its contents: contains class $anon
138158

139-
@Test def dotc_core_pickling = compileDir(dotcDir + "tools/dotc/core/pickling", failedOther)(allowDeepSubtypes)// twice omitted to make tests run faster
159+
@Test def dotc_core_pickling = compileDir(coreDir, "pickling", failedOther)(allowDeepSubtypes)// twice omitted to make tests run faster
140160
// exception caught when loading class ClassfileParser$$anon$1: dotty.tools.dotc.core.Denotations$NotDefinedHere:
141161
// demanding denotation of module class ClassfileParser$$anon$1$ at phase frontend(1) outside defined interval:
142162
// defined periods are Period(31..36, run = 2) Period(3..24, run = 2) Period(25..26, run = 2)
143163
// Period(27..28, run = 2) Period(29..29, run = 2) Period(30..30, run = 2)
144164
// inside FirstTransform at dotty.tools.dotc.transform.FirstTransform.transform(FirstTransform.scala:33)
145165
// weird.
146166

147-
@Test def dotc_transform = compileDir(dotcDir + "tools/dotc/transform")// twice omitted to make tests run faster
167+
@Test def dotc_transform = compileDir(dotcDir, "transform")// twice omitted to make tests run faster
148168

149-
@Test def dotc_parsing = compileDir(dotcDir + "tools/dotc/parsing")// twice omitted to make tests run faster
169+
@Test def dotc_parsing = compileDir(dotcDir, "parsing") // twice omitted to make tests run faster
150170

151-
@Test def dotc_printing = compileDir(dotcDir + "tools/dotc/printing") // twice omitted to make tests run faster
171+
@Test def dotc_printing = compileDir(dotcDir, "printing") // twice omitted to make tests run faster
152172

153-
@Test def dotc_reporting = compileDir(dotcDir + "tools/dotc/reporting") // twice omitted to make tests run faster
173+
@Test def dotc_reporting = compileDir(dotcDir, "reporting") // twice omitted to make tests run faster
154174

155-
@Test def dotc_typer = compileDir(dotcDir + "tools/dotc/typer", failedOther) // twice omitted to make tests run faster
175+
@Test def dotc_typer = compileDir(dotcDir, "typer", failedOther)// twice omitted to make tests run faster
156176
// error: error while loading Checking$$anon$2$,
157177
// class file 'target/scala-2.11/dotty_2.11-0.1-SNAPSHOT.jar(dotty/tools/dotc/typer/Checking$$anon$2.class)'
158178
// has location not matching its contents: contains class $anon
159179

160-
@Test def dotc_util = compileDir(dotcDir + "tools/dotc/util", failedOther ++ twice)
180+
@Test def dotc_util = compileDir(dotcDir, "util", failedOther ++ twice)
161181
// java.lang.ClassCastException: dotty.tools.dotc.core.Types$NoType$ cannot be cast to dotty.tools.dotc.core.Types$ClassInfo
162182
// at dotty.tools.dotc.core.SymDenotations$ClassDenotation.classInfo(SymDenotations.scala:1026)
163183
// at dotty.tools.dotc.transform.ExtensionMethods.transform(ExtensionMethods.scala:38)
164184

165-
@Test def tools_io = compileDir(dotcDir + "tools/io", failedOther ++ twice) // inner class has symbol <none>
185+
@Test def tools_io = compileDir(toolsDir, "io", failedOther ++ twice) // inner class has symbol <none>
166186

167187
@Test def helloWorld = compileFile(posDir, "HelloWorld", twice)
168188
@Test def labels = compileFile(posDir, "Labels", twice)
169-
//@Test def tools = compileDir(dotcDir + "tools", "-deep" :: Nil)(allowDeepSubtypes)
189+
//@Test def tools = compileDir(dottyDir, "tools", "-deep" :: Nil)(allowDeepSubtypes)
170190

171-
@Test def testNonCyclic = compileArgs(Array(
172-
dotcDir + "tools/dotc/CompilationUnit.scala",
173-
dotcDir + "tools/dotc/core/Types.scala",
174-
dotcDir + "tools/dotc/ast/Trees.scala",
175-
"-Xprompt"
176-
) ++ staleSymbolError ++ twice)
191+
@Test def testNonCyclic = compileList("testNonCyclic", List(
192+
dotcDir + "CompilationUnit.scala",
193+
coreDir + "Types.scala",
194+
dotcDir + "ast/Trees.scala"
195+
), List("-Xprompt") ++ staleSymbolError ++ twice)
177196

178-
@Test def testIssue_34 = compileArgs(Array(
179-
dotcDir + "tools/dotc/config/Properties.scala",
180-
dotcDir + "tools/dotc/config/PathResolver.scala",
181-
//"-Ylog:frontend",
182-
"-Xprompt") ++ staleSymbolError ++ twice)
197+
@Test def testIssue_34 = compileList("testIssue_34", List(
198+
dotcDir + "config/Properties.scala",
199+
dotcDir + "config/PathResolver.scala"
200+
), List(/* "-Ylog:frontend", */ "-Xprompt") ++ staleSymbolError ++ twice)
183201

184202
val javaDir = "./tests/pos/java-interop/"
185203
@Test def java_all = compileFiles(javaDir, twice)
186204

187-
//@Test def dotc_compilercommand = compileFile(dotcDir + "tools/dotc/config/", "CompilerCommand")
205+
//@Test def dotc_compilercommand = compileFile(dotcDir + "config/", "CompilerCommand")
206+
}
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
188221
}

0 commit comments

Comments
 (0)