Skip to content

Commit 7d8303d

Browse files
committed
Address reviewer feedback on #2125
1 parent 0b65aad commit 7d8303d

File tree

5 files changed

+234
-251
lines changed

5 files changed

+234
-251
lines changed

compiler/test/dotc/comptest.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import dotty.tools.dotc.ParallelTesting
44

55
object comptest extends ParallelTesting {
66

7-
def interactive: Boolean = true
8-
def regex: Option[String] = None
7+
def isInteractive = true
8+
def testFilter = None
99

1010
implicit val defaultOutputDir: String = "."
1111

compiler/test/dotty/tools/dotc/CompilationTests.scala

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,27 @@ package dotc
44

55
import org.junit.Test
66
import java.io.{ File => JFile }
7-
87
import org.junit.experimental.categories.Category
98

9+
import scala.util.matching.Regex
10+
1011
@Category(Array(classOf[ParallelTesting]))
1112
class CompilationTests extends ParallelTesting {
1213
import CompilationTests._
1314

14-
def interactive: Boolean = !sys.env.contains("DRONE")
15+
def isInteractive: Boolean = !sys.env.contains("DRONE")
1516

16-
def regex: Option[String] = sys.props.get("dotty.partest.filter")
17+
def testFilter: Option[Regex] = sys.props.get("dotty.partest.filter").map(r => new Regex(r))
1718

1819
// Positive tests ------------------------------------------------------------
1920

2021
@Test def compilePos: Unit = {
2122
compileList("compileStdLib", StdLibSources.whitelisted, scala2Mode.and("-migration", "-Yno-inline")) +
2223
compileFilesInDir("../tests/pos", defaultOptions)
23-
}.pos()
24+
}.checkCompile()
2425

2526
@Test def compilePosScala2: Unit =
26-
compileFilesInDir("../tests/pos-scala2", scala2Mode).pos()
27+
compileFilesInDir("../tests/pos-scala2", scala2Mode).checkCompile()
2728

2829
@Test def compilePosMixedFlags: Unit = {
2930
compileFile("../tests/pos/nullarify.scala", defaultOptions.and("-Ycheck:nullarify")) +
@@ -56,10 +57,10 @@ class CompilationTests extends ParallelTesting {
5657
),
5758
scala2Mode
5859
)
59-
}.pos()
60+
}.checkCompile()
6061

6162
@Test def compileCoreNoCheck: Unit =
62-
compileDir("../compiler/src/dotty/tools/dotc/core", noCheckOptions ++ classPath).pos()
63+
compileDir("../compiler/src/dotty/tools/dotc/core", noCheckOptions ++ classPath).checkCompile()
6364

6465
@Test def compileDotcInternals: Unit = {
6566
compileDir("../compiler/src/dotty/tools/dotc/ast", defaultOptions) +
@@ -72,7 +73,7 @@ class CompilationTests extends ParallelTesting {
7273
compileDir("../compiler/src/dotty/tools/dotc/typer", defaultOptions) +
7374
compileDir("../compiler/src/dotty/tools/dotc/util", defaultOptions) +
7475
compileDir("../compiler/src/dotty/tools/io", defaultOptions)
75-
}.pos()
76+
}.checkCompile()
7677

7778
@Test def posTwice: Unit = {
7879
compileFile("../tests/pos/Labels.scala", defaultOptions) +
@@ -128,17 +129,17 @@ class CompilationTests extends ParallelTesting {
128129
),
129130
defaultOptions.and("-Xprompt")
130131
)
131-
}.times(2).pos()
132+
}.times(2).checkCompile()
132133

133134
// New tests -----------------------------------------------------------------
134135

135136
@Test def compileNew: Unit =
136-
compileFilesInDir("../tests/new", defaultOptions).pos()
137+
compileFilesInDir("../tests/new", defaultOptions).checkCompile()
137138

138139
// Negative tests ------------------------------------------------------------
139140

140141
@Test def compileNeg: Unit =
141-
compileShallowFilesInDir("../tests/neg", defaultOptions).neg()
142+
compileShallowFilesInDir("../tests/neg", defaultOptions).checkExpectedErrors()
142143

143144
@Test def compileNegCustomFlags: Unit = {
144145
compileFile("../tests/neg/customArgs/typers.scala", allowDoubleBindings) +
@@ -157,14 +158,17 @@ class CompilationTests extends ParallelTesting {
157158
compileFile("../tests/neg/tailcall/tailrec-2.scala", defaultOptions) +
158159
compileFile("../tests/neg/tailcall/tailrec-3.scala", defaultOptions) +
159160
compileDir("../tests/neg/typedIdents", defaultOptions)
160-
}.neg()
161+
}.checkExpectedErrors()
161162

162163
// Run tests -----------------------------------------------------------------
163164

164165
@Test def runAll: Unit =
165-
compileFilesInDir("../tests/run", defaultOptions).run()
166+
compileFilesInDir("../tests/run", defaultOptions).checkRuns()
166167

167168
// Pickling Tests ------------------------------------------------------------
169+
//
170+
// Pickling tests are very memory intensive and as such need to be run with a
171+
// lower level of concurrency as to not kill their running VMs
168172

169173
@Test def testPickling1: Unit = {
170174
compileFilesInDir("../tests/new", picklingOptions) +
@@ -183,21 +187,21 @@ class CompilationTests extends ParallelTesting {
183187
compileDir("../compiler/src/dotty/tools/dotc/util", picklingOptions) +
184188
compileDir("../compiler/src/dotty/tools/io", picklingOptions) +
185189
compileFile("../tests/pos/pickleinf.scala", picklingOptions)
186-
}.limitThreads(4).pos()
190+
}.limitThreads(4).checkCompile()
187191

188192
@Test def testPickling2: Unit = {
189193
compileDir("../compiler/src/dotty/tools/dotc/core/classfile", picklingOptions) +
190194
compileDir("../compiler/src/dotty/tools/dotc/core/tasty", picklingOptions) +
191195
compileDir("../compiler/src/dotty/tools/dotc/core/unpickleScala2", picklingOptions)
192-
}.limitThreads(4).pos()
196+
}.limitThreads(4).checkCompile()
193197

194198
@Test def testPickling3: Unit = {
195199
compileDir("../compiler/src/dotty/tools", picklingOptions)
196-
}.limitThreads(4).pos()
200+
}.limitThreads(4).checkCompile()
197201

198202
@Test def testPickling4: Unit = {
199203
compileDir("../compiler/src/dotty/tools/dotc", picklingOptions)
200-
}.limitThreads(4).pos()
204+
}.limitThreads(4).checkCompile()
201205

202206
/** The purpose of this test is two-fold, being able to compile dotty
203207
* bootstrapped, and making sure that TASTY can link against a compiled
@@ -239,7 +243,7 @@ class CompilationTests extends ParallelTesting {
239243
compileShallowFilesInDir("../compiler/src/dotty/tools/dotc/typer", opt) +
240244
compileShallowFilesInDir("../compiler/src/dotty/tools/dotc/util", opt)
241245
} :: Nil
242-
}.map(_.pos()).foreach(_.delete())
246+
}.map(_.checkCompile()).foreach(_.delete())
243247
}
244248
}
245249

compiler/test/dotty/tools/dotc/ParallelTestTests.scala

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,12 @@ import scala.util.control.NonFatal
1010
class ParallelTestTests extends ParallelTesting {
1111
import CompilationTests._
1212

13-
def interactive: Boolean = !sys.env.contains("DRONE")
14-
15-
def regex: Option[String] = None
13+
def isInteractive = !sys.env.contains("DRONE")
14+
def testFilter = None
1615

1716
@Test def missingFile: Unit =
1817
try {
19-
compileFile("../tests/partest-test/i-dont-exist.scala", defaultOptions).expectFailure.neg()
18+
compileFile("../tests/partest-test/i-dont-exist.scala", defaultOptions).expectFailure.checkExpectedErrors()
2019
fail("didn't fail properly")
2120
}
2221
catch {
@@ -25,29 +24,28 @@ class ParallelTestTests extends ParallelTesting {
2524
}
2625

2726
@Test def pos1Error: Unit =
28-
compileFile("../tests/partest-test/posFail1Error.scala", defaultOptions).expectFailure.pos()
27+
compileFile("../tests/partest-test/posFail1Error.scala", defaultOptions).expectFailure.checkCompile()
2928

30-
@Test def negMissingAnnot: Unit =
31-
compileFile("../tests/partest-test/negMissingAnnot.scala", defaultOptions).expectFailure.neg()
29+
@Test def negMissingAnnot: Unit = compileFile("../tests/partest-test/negMissingAnnot.scala", defaultOptions).expectFailure.checkExpectedErrors()
3230

3331
@Test def negAnnotWrongLine: Unit =
34-
compileFile("../tests/partest-test/negAnnotWrongLine.scala", defaultOptions).expectFailure.neg()
32+
compileFile("../tests/partest-test/negAnnotWrongLine.scala", defaultOptions).expectFailure.checkExpectedErrors()
3533

3634
@Test def negTooManyAnnots: Unit =
37-
compileFile("../tests/partest-test/negTooManyAnnots.scala", defaultOptions).expectFailure.neg()
35+
compileFile("../tests/partest-test/negTooManyAnnots.scala", defaultOptions).expectFailure.checkExpectedErrors()
3836

3937
@Test def negNoPositionAnnot: Unit =
40-
compileFile("../tests/partest-test/negNoPositionAnnots.scala", defaultOptions).expectFailure.neg()
38+
compileFile("../tests/partest-test/negNoPositionAnnots.scala", defaultOptions).expectFailure.checkExpectedErrors()
4139

4240
@Test def runCompileFail: Unit =
43-
compileFile("../tests/partest-test/posFail1Error.scala", defaultOptions).expectFailure.run()
41+
compileFile("../tests/partest-test/posFail1Error.scala", defaultOptions).expectFailure.checkRuns()
4442

4543
@Test def runWrongOutput1: Unit =
46-
compileFile("../tests/partest-test/runWrongOutput1.scala", defaultOptions).expectFailure.run()
44+
compileFile("../tests/partest-test/runWrongOutput1.scala", defaultOptions).expectFailure.checkRuns()
4745

4846
@Test def runWrongOutput2: Unit =
49-
compileFile("../tests/partest-test/runWrongOutput2.scala", defaultOptions).expectFailure.run()
47+
compileFile("../tests/partest-test/runWrongOutput2.scala", defaultOptions).expectFailure.checkRuns()
5048

5149
@Test def runDiffOutput1: Unit =
52-
compileFile("../tests/partest-test/runDiffOutput1.scala", defaultOptions).expectFailure.run()
50+
compileFile("../tests/partest-test/runDiffOutput1.scala", defaultOptions).expectFailure.checkRuns()
5351
}

0 commit comments

Comments
 (0)