blob: 5608b36566aed60bdb84fd7d120596273c1168cb (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
package dotty.tools.dotc;
import org.junit.BeforeClass;
import org.junit.AfterClass;
import java.util.ArrayDeque;
import dotty.tools.dotc.reporting.TestReporter;
import dotty.tools.dotc.reporting.TestReporter$;
/** Note that while `ParallelTesting` runs in parallel, JUnit tests cannot with
* this class
*/
public class ParallelSummaryReport {
public final static boolean isInteractive = !System.getenv().containsKey("DRONE");
private static TestReporter rep = TestReporter.reporter(System.out, -1);
private static ArrayDeque<String> failedTests = new ArrayDeque<>();
private static ArrayDeque<String> reproduceInstructions = new ArrayDeque<>();
private static int passed;
private static int failed;
public final static void reportFailed() {
failed++;
}
public final static void reportPassed() {
passed++;
}
public final static void addFailedTest(String msg) {
failedTests.offer(msg);
}
public final static void addReproduceInstruction(String msg) {
reproduceInstructions.offer(msg);
}
@BeforeClass public final static void setup() {
rep = TestReporter.reporter(System.out, -1);
failedTests = new ArrayDeque<>();
reproduceInstructions = new ArrayDeque<>();
}
@AfterClass public final static void teardown() {
rep.echo(
"\n================================================================================" +
"\nTest Report" +
"\n================================================================================" +
"\n" +
passed + " passed, " + failed + " failed, " + (passed + failed) + " total" +
"\n"
);
failedTests
.stream()
.map(x -> " " + x)
.forEach(rep::echo);
// If we're compiling locally, we don't need reproduce instructions
if (isInteractive) rep.flushToStdErr();
rep.echo("");
reproduceInstructions
.stream()
.forEach(rep::echo);
// If we're on the CI, we want everything
if (!isInteractive) rep.flushToStdErr();
if (failed > 0) rep.flushToFile();
}
}
|