@@ -46,6 +46,7 @@ trait ParallelTesting {
46
46
* in a specific way defined by the `Test`
47
47
*/
48
48
private sealed trait TestSource { self =>
49
+ def name : String
49
50
def outDir : JFile
50
51
def flags : Array [String ]
51
52
@@ -80,7 +81,7 @@ trait ParallelTesting {
80
81
}
81
82
82
83
self match {
83
- case JointCompilationSource (files, _, _) => {
84
+ case JointCompilationSource (_, files, _, _) => {
84
85
files.map(_.getAbsolutePath).foreach { path =>
85
86
sb.append(" \\\n " )
86
87
sb.append(path)
@@ -111,6 +112,7 @@ trait ParallelTesting {
111
112
* and output directory
112
113
*/
113
114
private final case class JointCompilationSource (
115
+ name : String ,
114
116
files : Array [JFile ],
115
117
flags : Array [String ],
116
118
outDir : JFile
@@ -124,6 +126,7 @@ trait ParallelTesting {
124
126
* suffix `_X`
125
127
*/
126
128
private final case class SeparateCompilationSource (
129
+ name : String ,
127
130
dir : JFile ,
128
131
flags : Array [String ],
129
132
outDir : JFile
@@ -164,9 +167,9 @@ trait ParallelTesting {
164
167
private val filteredSources =
165
168
if (! testFilter.isDefined) testSources
166
169
else testSources.filter {
167
- case JointCompilationSource (files, _, _) =>
170
+ case JointCompilationSource (_, files, _, _) =>
168
171
files.exists(file => testFilter.get.findFirstIn(file.getAbsolutePath).isDefined)
169
- case SeparateCompilationSource (dir, _, _) =>
172
+ case SeparateCompilationSource (_, dir, _, _) =>
170
173
testFilter.get.findFirstIn(dir.getAbsolutePath).isDefined
171
174
}
172
175
@@ -206,19 +209,10 @@ trait ParallelTesting {
206
209
207
210
/** The test sources that failed according to the implementing subclass */
208
211
private [this ] val failedTestSources = mutable.ArrayBuffer .empty[String ]
209
- protected final def addFailedCompilationTarget (testSource : String ): Unit =
210
- synchronized { failedTestSources.append(testSource) }
211
-
212
- /** Fails the current `TestSource`, and makes sure it gets logged */
213
- protected final def failTestSource (testSource : TestSource ) =
214
- testSource match {
215
- case JointCompilationSource (files, _, _) =>
216
- files.map(_.getAbsolutePath).foreach(addFailedCompilationTarget)
217
- fail()
218
- case SeparateCompilationSource (dir, _, _) =>
219
- addFailedCompilationTarget(dir.getAbsolutePath)
220
- fail()
221
- }
212
+ protected final def failTestSource (testSource : TestSource ) = synchronized {
213
+ failedTestSources.append(testSource.name)
214
+ fail()
215
+ }
222
216
223
217
/** Prints to `System.err` if we're not suppressing all output */
224
218
protected def echo (msg : String ): Unit =
@@ -252,12 +246,12 @@ trait ParallelTesting {
252
246
/** Wrapper function to make sure that the compiler itself did not crash -
253
247
* if it did, the test should automatically fail.
254
248
*/
255
- protected def tryCompile (op : => Unit ): Unit =
249
+ protected def tryCompile (testSource : TestSource )( op : => Unit ): Unit =
256
250
try op catch {
257
251
case NonFatal (e) => {
258
252
// if an exception is thrown during compilation, the complete test
259
253
// run should fail
260
- fail( )
254
+ failTestSource(testSource )
261
255
e.printStackTrace()
262
256
registerCompilation(1 )
263
257
throw e
@@ -353,12 +347,17 @@ trait ParallelTesting {
353
347
if (didFail) {
354
348
echo {
355
349
""" |
350
+ |
351
+ |
356
352
|================================================================================
357
353
|Test Report
358
354
|================================================================================
359
355
|Failing tests:""" .stripMargin
360
356
}
361
- failedTestSources.toArray.sorted.foreach(echo)
357
+ failedTestSources.toSet.foreach { source : String =>
358
+ echo(" " + source)
359
+ }
360
+ echo(" " )
362
361
reproduceInstructions.iterator.foreach(echo)
363
362
}
364
363
}
@@ -375,17 +374,17 @@ trait ParallelTesting {
375
374
private final class PosTest (testSources : List [TestSource ], times : Int , threadLimit : Option [Int ], suppressAllOutput : Boolean )
376
375
extends Test (testSources, times, threadLimit, suppressAllOutput) {
377
376
protected def compilationRunnable (testSource : TestSource ): Runnable = new Runnable {
378
- def run (): Unit = tryCompile {
377
+ def run (): Unit = tryCompile(testSource) {
379
378
testSource match {
380
- case testSource @ JointCompilationSource (files, flags, outDir) => {
379
+ case testSource @ JointCompilationSource (_, files, flags, outDir) => {
381
380
val reporter = compile(testSource.sourceFiles, flags, false , outDir)
382
381
registerCompilation(reporter.errorCount)
383
382
384
383
if (reporter.errorCount > 0 )
385
384
echoBuildInstructions(reporter, testSource, reporter.errorCount, reporter.warningCount)
386
385
}
387
386
388
- case testSource @ SeparateCompilationSource (dir, flags, outDir) => {
387
+ case testSource @ SeparateCompilationSource (_, dir, flags, outDir) => {
389
388
val reporters = testSource.compilationGroups.map(files => compile(files, flags, false , outDir))
390
389
val errorCount = reporters.foldLeft(0 ) { (acc, reporter) =>
391
390
if (reporter.errorCount > 0 )
@@ -470,9 +469,9 @@ trait ParallelTesting {
470
469
}
471
470
472
471
protected def compilationRunnable (testSource : TestSource ): Runnable = new Runnable {
473
- def run (): Unit = tryCompile {
472
+ def run (): Unit = tryCompile(testSource) {
474
473
val (errorCount, warningCount, hasCheckFile, verifier : Function0 [Unit ]) = testSource match {
475
- case testSource @ JointCompilationSource (files, flags, outDir) => {
474
+ case testSource @ JointCompilationSource (_, files, flags, outDir) => {
476
475
val checkFile = files.flatMap { file =>
477
476
if (file.isDirectory) Nil
478
477
else {
@@ -491,7 +490,7 @@ trait ParallelTesting {
491
490
(reporter.errorCount, reporter.warningCount, checkFile.isDefined, () => verifyOutput(checkFile.get, outDir, testSource, reporter.warningCount))
492
491
}
493
492
494
- case testSource @ SeparateCompilationSource (dir, flags, outDir) => {
493
+ case testSource @ SeparateCompilationSource (_, dir, flags, outDir) => {
495
494
val checkFile = new JFile (dir.getAbsolutePath.reverse.dropWhile(_ == '/' ).reverse + " .check" )
496
495
val (errorCount, warningCount) =
497
496
testSource
@@ -526,7 +525,7 @@ trait ParallelTesting {
526
525
private final class NegTest (testSources : List [TestSource ], times : Int , threadLimit : Option [Int ], suppressAllOutput : Boolean )
527
526
extends Test (testSources, times, threadLimit, suppressAllOutput) {
528
527
protected def compilationRunnable (testSource : TestSource ): Runnable = new Runnable {
529
- def run (): Unit = tryCompile {
528
+ def run (): Unit = tryCompile(testSource) {
530
529
// In neg-tests we allow two types of error annotations,
531
530
// "nopos-error" which doesn't care about position and "error" which
532
531
// has to be annotated on the correct line number.
@@ -579,7 +578,7 @@ trait ParallelTesting {
579
578
}
580
579
581
580
val (expectedErrors, actualErrors, hasMissingAnnotations, errorMap) = testSource match {
582
- case testSource @ JointCompilationSource (files, flags, outDir) => {
581
+ case testSource @ JointCompilationSource (_, files, flags, outDir) => {
583
582
val sourceFiles = testSource.sourceFiles
584
583
val (errorMap, expectedErrors) = getErrorMapAndExpectedCount(sourceFiles)
585
584
val reporter = compile(sourceFiles, flags, true , outDir)
@@ -588,7 +587,7 @@ trait ParallelTesting {
588
587
(expectedErrors, actualErrors, () => getMissingExpectedErrors(errorMap, reporter.errors), errorMap)
589
588
}
590
589
591
- case testSource @ SeparateCompilationSource (dir, flags, outDir) => {
590
+ case testSource @ SeparateCompilationSource (_, dir, flags, outDir) => {
592
591
val compilationGroups = testSource.compilationGroups
593
592
val (errorMap, expectedErrors) = getErrorMapAndExpectedCount(compilationGroups.toArray.flatten)
594
593
val reporters = compilationGroups.map(compile(_, flags, true , outDir))
@@ -837,9 +836,9 @@ trait ParallelTesting {
837
836
*/
838
837
def copyToTarget (): CompilationTest = new CompilationTest (
839
838
targets.map {
840
- case target @ JointCompilationSource (files, _, outDir) =>
839
+ case target @ JointCompilationSource (_, files, _, outDir) =>
841
840
target.copy(files = files.map(copyToDir(outDir,_)))
842
- case target @ SeparateCompilationSource (dir, _, outDir) =>
841
+ case target @ SeparateCompilationSource (_, dir, _, outDir) =>
843
842
target.copy(dir = copyToDir(outDir, dir))
844
843
},
845
844
times, shouldDelete, threadLimit, shouldFail
@@ -950,10 +949,11 @@ trait ParallelTesting {
950
949
951
950
/** Compiles a single file from the string path `f` using the supplied flags */
952
951
def compileFile (f : String , flags : Array [String ])(implicit outDirectory : String ): CompilationTest = {
952
+ val callingMethod = getCallingMethod
953
953
val sourceFile = new JFile (f)
954
954
val parent = sourceFile.getParentFile
955
955
val outDir =
956
- outDirectory + getCallingMethod + " /" +
956
+ outDirectory + callingMethod + " /" +
957
957
sourceFile.getName.substring(0 , sourceFile.getName.lastIndexOf('.' )) + " /"
958
958
959
959
require(
@@ -963,6 +963,7 @@ trait ParallelTesting {
963
963
)
964
964
965
965
val target = JointCompilationSource (
966
+ callingMethod,
966
967
Array (sourceFile),
967
968
flags,
968
969
createOutputDirsForFile(sourceFile, parent, outDir)
@@ -975,7 +976,8 @@ trait ParallelTesting {
975
976
* contained within the directory `f`.
976
977
*/
977
978
def compileDir (f : String , flags : Array [String ])(implicit outDirectory : String ): CompilationTest = {
978
- val outDir = outDirectory + getCallingMethod + " /"
979
+ val callingMethod = getCallingMethod
980
+ val outDir = outDirectory + callingMethod + " /"
979
981
val sourceDir = new JFile (f)
980
982
checkRequirements(f, sourceDir, outDir)
981
983
@@ -987,7 +989,7 @@ trait ParallelTesting {
987
989
val targetDir = new JFile (outDir + " /" + sourceDir.getName + " /" )
988
990
targetDir.mkdirs()
989
991
990
- val target = JointCompilationSource (flatten(sourceDir), flags, targetDir)
992
+ val target = JointCompilationSource (callingMethod, flatten(sourceDir), flags, targetDir)
991
993
new CompilationTest (target)
992
994
}
993
995
@@ -996,14 +998,15 @@ trait ParallelTesting {
996
998
* dissociated
997
999
*/
998
1000
def compileList (testName : String , files : List [String ], flags : Array [String ])(implicit outDirectory : String ): CompilationTest = {
999
- val outDir = outDirectory + getCallingMethod + " /" + testName + " /"
1001
+ val callingMethod = getCallingMethod
1002
+ val outDir = outDirectory + callingMethod + " /" + testName + " /"
1000
1003
1001
1004
// Directories in which to compile all containing files with `flags`:
1002
1005
val targetDir = new JFile (outDir)
1003
1006
targetDir.mkdirs()
1004
1007
assert(targetDir.exists, s " couldn't create target directory: $targetDir" )
1005
1008
1006
- val target = JointCompilationSource (files.map(new JFile (_)).toArray, flags, targetDir)
1009
+ val target = JointCompilationSource (callingMethod, files.map(new JFile (_)).toArray, flags, targetDir)
1007
1010
1008
1011
// Create a CompilationTest and let the user decide whether to execute a pos or a neg test
1009
1012
new CompilationTest (target)
@@ -1027,15 +1030,16 @@ trait ParallelTesting {
1027
1030
* the same name as the directory (with the file extension `.check`)
1028
1031
*/
1029
1032
def compileFilesInDir (f : String , flags : Array [String ])(implicit outDirectory : String ): CompilationTest = {
1030
- val outDir = outDirectory + getCallingMethod + " /"
1033
+ val callingMethod = getCallingMethod
1034
+ val outDir = outDirectory + callingMethod + " /"
1031
1035
val sourceDir = new JFile (f)
1032
1036
checkRequirements(f, sourceDir, outDir)
1033
1037
1034
1038
val (dirs, files) = compilationTargets(sourceDir)
1035
1039
1036
1040
val targets =
1037
- files.map(f => JointCompilationSource (Array (f), flags, createOutputDirsForFile(f, sourceDir, outDir))) ++
1038
- dirs.map(dir => SeparateCompilationSource (dir, flags, createOutputDirsForDir(dir, sourceDir, outDir)))
1041
+ files.map(f => JointCompilationSource (callingMethod, Array (f), flags, createOutputDirsForFile(f, sourceDir, outDir))) ++
1042
+ dirs.map(dir => SeparateCompilationSource (callingMethod, dir, flags, createOutputDirsForDir(dir, sourceDir, outDir)))
1039
1043
1040
1044
// Create a CompilationTest and let the user decide whether to execute a pos or a neg test
1041
1045
new CompilationTest (targets)
@@ -1046,14 +1050,15 @@ trait ParallelTesting {
1046
1050
* tests.
1047
1051
*/
1048
1052
def compileShallowFilesInDir (f : String , flags : Array [String ])(implicit outDirectory : String ): CompilationTest = {
1049
- val outDir = outDirectory + getCallingMethod + " /"
1053
+ val callingMethod = getCallingMethod
1054
+ val outDir = outDirectory + callingMethod + " /"
1050
1055
val sourceDir = new JFile (f)
1051
1056
checkRequirements(f, sourceDir, outDir)
1052
1057
1053
1058
val (_, files) = compilationTargets(sourceDir)
1054
1059
1055
1060
val targets = files.map { file =>
1056
- JointCompilationSource (Array (file), flags, createOutputDirsForFile(file, sourceDir, outDir))
1061
+ JointCompilationSource (callingMethod, Array (file), flags, createOutputDirsForFile(file, sourceDir, outDir))
1057
1062
}
1058
1063
1059
1064
// Create a CompilationTest and let the user decide whether to execute a pos or a neg test
0 commit comments