Skip to content

Commit 7966234

Browse files
committed
Add ability to only compile run tests
1 parent 3345c82 commit 7966234

File tree

3 files changed

+41
-11
lines changed

3 files changed

+41
-11
lines changed

compiler/test/dotty/Properties.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ object Properties {
2020
*/
2121
val testsFilter: Option[String] = sys.props.get("dotty.tests.filter")
2222

23+
/** When set, the run tests are only compiled - not run, a warning will be
24+
* issued
25+
*/
26+
val testsNoRun: Boolean = true//sys.props.get("dotty.tests.norun").isDefined
27+
2328
/** Should Unit tests run in safe mode?
2429
*
2530
* For run tests this means that we respawn child JVM processes after each

compiler/test/dotty/tools/vulpix/ParallelTesting.scala

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -426,8 +426,21 @@ trait ParallelTesting extends RunnerOrchestration { self =>
426426

427427
private final class RunTest(testSources: List[TestSource], times: Int, threadLimit: Option[Int], suppressAllOutput: Boolean)
428428
extends Test(testSources, times, threadLimit, suppressAllOutput) {
429+
private[this] var didAddNoRunWarning = false
430+
private[this] def addNoRunWarning() = if (!didAddNoRunWarning) {
431+
didAddNoRunWarning = true
432+
SummaryReport.addStartingMessage {
433+
"""|WARNING
434+
|-------
435+
|Run tests were only compiled, not run - this is due to `dotty.tests.norun`
436+
|property being set
437+
|""".stripMargin
438+
}
439+
}
440+
429441
private def verifyOutput(checkFile: JFile, dir: JFile, testSource: TestSource, warnings: Int) = {
430-
runMain(testSource.classPath) match {
442+
if (Properties.testsNoRun) addNoRunWarning()
443+
else runMain(testSource.classPath) match {
431444
case Success(output) => {
432445
val outputLines = output.lines.toArray
433446
val checkLines: Array[String] = Source.fromFile(checkFile).getLines.toArray
@@ -511,16 +524,19 @@ trait ParallelTesting extends RunnerOrchestration { self =>
511524
}
512525

513526
if (errorCount == 0 && hasCheckFile) verifier()
514-
else if (errorCount == 0) runMain(testSource.classPath) match {
515-
case Success(_) => // success!
516-
case Failure(output) =>
517-
echo(s" failed when running '${testSource.title}'")
518-
echo(output)
519-
failTestSource(testSource)
520-
case Timeout =>
521-
echo(" failed because test " + testSource.title + " timed out")
522-
failTestSource(testSource, Some("test timed out"))
523-
}
527+
else if (errorCount == 0) {
528+
if (Properties.testsNoRun) addNoRunWarning()
529+
else runMain(testSource.classPath) match {
530+
case Success(_) => // success!
531+
case Failure(output) =>
532+
echo(s" failed when running '${testSource.title}'")
533+
echo(output)
534+
failTestSource(testSource)
535+
case Timeout =>
536+
echo(" failed because test " + testSource.title + " timed out")
537+
failTestSource(testSource, Some("test timed out"))
538+
}
539+
}
524540
else if (errorCount > 0) {
525541
echo(s"\n Compilation failed for: '$testSource'")
526542
val buildInstr = testSource.buildInstructions(errorCount, warningCount)

compiler/test/dotty/tools/vulpix/SummaryReport.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public class SummaryReport {
2020
private static TestReporter rep = TestReporter.reporter(System.out, -1);
2121
private static ArrayDeque<String> failedTests = new ArrayDeque<>();
2222
private static ArrayDeque<String> reproduceInstructions = new ArrayDeque<>();
23+
private static ArrayDeque<String> startingMessages = new ArrayDeque<>();
2324
private static Supplier<Void> cleanup;
2425
private static int passed;
2526
private static int failed;
@@ -40,6 +41,10 @@ public final static void addReproduceInstruction(String msg) {
4041
reproduceInstructions.offer(msg);
4142
}
4243

44+
public final static void addStartingMessage(String msg) {
45+
startingMessages.offer(msg);
46+
}
47+
4348
public final static void addCleanup(Function0<Unit> func) {
4449
// Wow, look at how neatly we - compose cleanup callbacks:
4550
if (cleanup == null) {
@@ -73,6 +78,10 @@ public final static void addCleanup(Function0<Unit> func) {
7378
"\n"
7479
);
7580

81+
startingMessages
82+
.stream()
83+
.forEach(rep::echo);
84+
7685
failedTests
7786
.stream()
7887
.map(x -> " " + x)

0 commit comments

Comments
 (0)