@@ -226,14 +226,14 @@ trait ParallelTesting extends RunnerOrchestration { self =>
226
226
Try (testSource match {
227
227
case testSource @ JointCompilationSource (name, files, flags, outDir, fromTasty, decompilation) =>
228
228
val reporter =
229
- if (fromTasty) compileFromTasty(flags, suppressErrors, outDir)
230
- else compile(testSource.sourceFiles, flags, suppressErrors, outDir)
229
+ if (fromTasty) compileFromTasty(flags, outDir)
230
+ else compile(testSource.sourceFiles, flags, outDir)
231
231
List (reporter)
232
232
233
233
case testSource @ SeparateCompilationSource (_, dir, flags, outDir) =>
234
234
testSource.compilationGroups.map { (group, files) =>
235
235
if group.compiler.isEmpty then
236
- compile(files, flags, suppressErrors, outDir)
236
+ compile(files, flags, outDir)
237
237
else
238
238
compileWithOtherCompiler(group.compiler, files, flags, outDir)
239
239
}
@@ -469,7 +469,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
469
469
registerCompletion()
470
470
throw e
471
471
472
- protected def compile (files0 : Array [JFile ], flags0 : TestFlags , suppressErrors : Boolean , targetDir : JFile ): TestReporter = {
472
+ protected def compile (files0 : Array [JFile ], flags0 : TestFlags , targetDir : JFile ): TestReporter = {
473
473
import scala .util .Properties .*
474
474
475
475
def flattenFiles (f : JFile ): Array [JFile ] =
@@ -634,7 +634,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
634
634
635
635
reporter
636
636
637
- protected def compileFromTasty (flags0 : TestFlags , suppressErrors : Boolean , targetDir : JFile ): TestReporter = {
637
+ protected def compileFromTasty (flags0 : TestFlags , targetDir : JFile ): TestReporter = {
638
638
val tastyOutput = new JFile (targetDir.getPath + " _from-tasty" )
639
639
tastyOutput.mkdir()
640
640
val flags = flags0 and (" -d" , tastyOutput.getPath) and " -from-tasty"
@@ -653,6 +653,12 @@ trait ParallelTesting extends RunnerOrchestration { self =>
653
653
private def mkLogLevel = if suppressErrors || suppressAllOutput then ERROR + 1 else ERROR
654
654
private def mkReporter = TestReporter .reporter(realStdout, logLevel = mkLogLevel)
655
655
656
+ protected def diffCheckfile (testSource : TestSource , reporters : Seq [TestReporter ], logger : LoggedRunnable ) =
657
+ checkFile(testSource).foreach(diffTest(testSource, _, reporterOutputLines(reporters), reporters, logger))
658
+
659
+ private def reporterOutputLines (reporters : Seq [TestReporter ]): List [String ] =
660
+ reporters.flatMap(_.consoleOutput.split(" \n " )).toList
661
+
656
662
private [ParallelTesting ] def executeTestSuite (): this .type = {
657
663
assert(testSourcesCompleted == 0 , " not allowed to re-use a `CompileRun`" )
658
664
if filteredSources.nonEmpty then
@@ -717,6 +723,12 @@ trait ParallelTesting extends RunnerOrchestration { self =>
717
723
private final class PosTest (testSources : List [TestSource ], times : Int , threadLimit : Option [Int ], suppressAllOutput : Boolean )(implicit summaryReport : SummaryReporting )
718
724
extends Test (testSources, times, threadLimit, suppressAllOutput)
719
725
726
+ private final class WarnTest (testSources : List [TestSource ], times : Int , threadLimit : Option [Int ], suppressAllOutput : Boolean )(implicit summaryReport : SummaryReporting )
727
+ extends Test (testSources, times, threadLimit, suppressAllOutput):
728
+ override def suppressErrors = true
729
+ override def onSuccess (testSource : TestSource , reporters : Seq [TestReporter ], logger : LoggedRunnable ): Unit =
730
+ diffCheckfile(testSource, reporters, logger)
731
+
720
732
private final class RewriteTest (testSources : List [TestSource ], checkFiles : Map [JFile , JFile ], times : Int , threadLimit : Option [Int ], suppressAllOutput : Boolean )(implicit summaryReport : SummaryReporting )
721
733
extends Test (testSources, times, threadLimit, suppressAllOutput) {
722
734
private def verifyOutput (testSource : TestSource , reporters : Seq [TestReporter ], logger : LoggedRunnable ) = {
@@ -808,10 +820,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
808
820
end maybeFailureMessage
809
821
810
822
override def onSuccess (testSource : TestSource , reporters : Seq [TestReporter ], logger : LoggedRunnable ): Unit =
811
- checkFile(testSource).foreach(diffTest(testSource, _, reporterOutputLines(reporters), reporters, logger))
812
-
813
- def reporterOutputLines (reporters : Seq [TestReporter ]): List [String ] =
814
- reporters.flatMap(_.consoleOutput.split(" \n " )).toList
823
+ diffCheckfile(testSource, reporters, logger)
815
824
816
825
// In neg-tests we allow two or three types of error annotations.
817
826
// Normally, `// error` must be annotated on the correct line number.
@@ -1014,20 +1023,11 @@ trait ParallelTesting extends RunnerOrchestration { self =>
1014
1023
* compilation without generating errors and that they do not crash the
1015
1024
* compiler
1016
1025
*/
1017
- def checkCompile ()(implicit summaryReport : SummaryReporting ): this .type = {
1018
- val test = new PosTest (targets, times, threadLimit, shouldFail || shouldSuppressOutput).executeTestSuite()
1019
-
1020
- cleanup()
1021
-
1022
- if (! shouldFail && test.didFail) {
1023
- fail(s " Expected no errors when compiling, failed for the following reason(s): \n ${reasonsForFailure(test)}\n " )
1024
- }
1025
- else if (shouldFail && ! test.didFail && test.skipCount == 0 ) {
1026
- fail(" Pos test should have failed, but didn't" )
1027
- }
1026
+ def checkCompile ()(implicit summaryReport : SummaryReporting ): this .type =
1027
+ checkPass(new PosTest (targets, times, threadLimit, shouldFail || shouldSuppressOutput), " Pos" )
1028
1028
1029
- this
1030
- }
1029
+ def checkWarnings ()( implicit summaryReport : SummaryReporting ) : this . type =
1030
+ checkPass( new WarnTest (targets, times, threadLimit, shouldFail || shouldSuppressOutput), " Warn " )
1031
1031
1032
1032
/** Creates a "neg" test run, which makes sure that each test generates the
1033
1033
* correct number of errors at the correct positions. It also makes sure
@@ -1047,35 +1047,16 @@ trait ParallelTesting extends RunnerOrchestration { self =>
1047
1047
end checkExpectedErrors
1048
1048
1049
1049
/** Creates a "fuzzy" test run, which makes sure that each test compiles (or not) without crashing */
1050
- def checkNoCrash ()(implicit summaryReport : SummaryReporting ): this .type = {
1051
- val test = new NoCrashTest (targets, times, threadLimit, shouldSuppressOutput).executeTestSuite()
1052
-
1053
- cleanup()
1054
-
1055
- if (test.didFail) {
1056
- fail(" Fuzzy test shouldn't have crashed, but did" )
1057
- }
1058
-
1059
- this
1060
- }
1050
+ def checkNoCrash ()(implicit summaryReport : SummaryReporting ): this .type =
1051
+ checkFail(new NoCrashTest (targets, times, threadLimit, shouldSuppressOutput), " Fuzzy" )
1061
1052
1062
1053
/** Creates a "run" test run, which is a superset of "pos". In addition to
1063
1054
* making sure that all tests pass compilation and that they do not crash
1064
1055
* the compiler; it also makes sure that all tests can run with the
1065
1056
* expected output
1066
1057
*/
1067
- def checkRuns ()(implicit summaryReport : SummaryReporting ): this .type = {
1068
- val test = new RunTest (targets, times, threadLimit, shouldFail || shouldSuppressOutput).executeTestSuite()
1069
-
1070
- cleanup()
1071
-
1072
- if ! shouldFail && test.didFail then
1073
- fail(s " Run test failed, but should not, reasons: \n ${ reasonsForFailure(test) }" )
1074
- else if shouldFail && ! test.didFail && test.skipCount == 0 then
1075
- fail(" Run test should have failed, but did not" )
1076
-
1077
- this
1078
- }
1058
+ def checkRuns ()(implicit summaryReport : SummaryReporting ): this .type =
1059
+ checkPass(new RunTest (targets, times, threadLimit, shouldFail || shouldSuppressOutput), " Run" )
1079
1060
1080
1061
/** Tests `-rewrite`, which makes sure that the rewritten files still compile
1081
1062
* and agree with the expected result (if specified).
@@ -1100,15 +1081,34 @@ trait ParallelTesting extends RunnerOrchestration { self =>
1100
1081
target.copy(dir = copyToDir(outDir, dir))
1101
1082
}
1102
1083
1103
- val test = new RewriteTest (copiedTargets, checkFileMap, times, threadLimit, shouldFail || shouldSuppressOutput).executeTestSuite()
1084
+ val test = new RewriteTest (copiedTargets, checkFileMap, times, threadLimit, shouldFail || shouldSuppressOutput)
1085
+
1086
+ checkFail(test, " Rewrite" )
1087
+ }
1088
+
1089
+ def checkPass (test : Test , desc : String ): this .type =
1090
+ test.executeTestSuite()
1104
1091
1105
1092
cleanup()
1106
1093
1107
- if test.didFail then
1108
- fail(" Rewrite test failed" )
1094
+ if ! shouldFail && test.didFail then
1095
+ fail(s " $desc test failed, but should not, reasons: \n ${reasonsForFailure(test)}" )
1096
+ else if shouldFail && ! test.didFail && test.skipCount == 0 then
1097
+ fail(s " $desc test should have failed, but didn't " )
1098
+
1099
+ this
1100
+
1101
+ def checkFail (test : test, desc : String ): this .type =
1102
+ test.executeTestSuite()
1103
+
1104
+ cleanup()
1105
+
1106
+ if shouldFail && ! test.didFail && test.skipCount == 0 then
1107
+ fail(s " $desc test shouldn't have failed, but did. Reasons: \n ${reasonsForFailure(test)}" )
1108
+ else if ! shouldFail && test.didFail then
1109
+ fail(s " $desc test failed " )
1109
1110
1110
1111
this
1111
- }
1112
1112
1113
1113
/** Deletes output directories and files */
1114
1114
private def cleanup (): this .type = {
0 commit comments