Skip to content

Commit d42a28d

Browse files
committed
Add ability to only compile run tests
1 parent 55803b2 commit d42a28d

File tree

5 files changed

+49
-23
lines changed

5 files changed

+49
-23
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 = 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: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@
1010
import dotty.tools.dotc.reporting.TestReporter;
1111
import dotty.Properties;
1212

13-
/** Note that while `ParallelTesting` runs in parallel, JUnit tests cannot with
14-
* this class
13+
/** This class adds summary reports to `ParallelTesting`
14+
*
15+
* It is written in Java because we currently cannot explicitly write static
16+
* methods in Scala without SIP-25 (`@static` fields and methods in Scala)
1517
*/
1618
public class SummaryReport {
1719
public final static boolean isInteractive =
@@ -20,6 +22,7 @@ public class SummaryReport {
2022
private static TestReporter rep = TestReporter.reporter(System.out, -1);
2123
private static ArrayDeque<String> failedTests = new ArrayDeque<>();
2224
private static ArrayDeque<String> reproduceInstructions = new ArrayDeque<>();
25+
private static ArrayDeque<String> startingMessages = new ArrayDeque<>();
2326
private static Supplier<Void> cleanup;
2427
private static int passed;
2528
private static int failed;
@@ -40,6 +43,10 @@ public final static void addReproduceInstruction(String msg) {
4043
reproduceInstructions.offer(msg);
4144
}
4245

46+
public final static void addStartingMessage(String msg) {
47+
startingMessages.offer(msg);
48+
}
49+
4350
public final static void addCleanup(Function0<Unit> func) {
4451
// Wow, look at how neatly we - compose cleanup callbacks:
4552
if (cleanup == null) {
@@ -61,6 +68,10 @@ public final static void addCleanup(Function0<Unit> func) {
6168
rep = TestReporter.reporter(System.out, -1);
6269
failedTests = new ArrayDeque<>();
6370
reproduceInstructions = new ArrayDeque<>();
71+
startingMessages = new ArrayDeque<>();
72+
cleanup = null;
73+
passed = 0;
74+
failed = 0;
6475
}
6576

6677
@AfterClass public final static void teardown() {
@@ -73,6 +84,10 @@ public final static void addCleanup(Function0<Unit> func) {
7384
"\n"
7485
);
7586

87+
startingMessages
88+
.stream()
89+
.forEach(rep::echo);
90+
7691
failedTests
7792
.stream()
7893
.map(x -> " " + x)

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,4 @@ class VulpixTests extends ParallelTesting {
7171

7272
@Test def deadlock: Unit =
7373
compileFile("../tests/partest-test/deadlock.scala", defaultOptions).expectFailure.checkRuns()
74-
75-
@Test def forkbomb: Unit =
76-
compileFile("../tests/partest-test/forkbomb.scala", defaultOptions).expectFailure.checkRuns()
7774
}

tests/partest-test/forkbomb.scala

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)