diff options
-rw-r--r-- | compiler/test/dotty/tools/dotc/vulpix/SummaryReport.java | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/compiler/test/dotty/tools/dotc/vulpix/SummaryReport.java b/compiler/test/dotty/tools/dotc/vulpix/SummaryReport.java index 1d900e777..4f2b6350b 100644 --- a/compiler/test/dotty/tools/dotc/vulpix/SummaryReport.java +++ b/compiler/test/dotty/tools/dotc/vulpix/SummaryReport.java @@ -18,6 +18,7 @@ public class SummaryReport { 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 Supplier<Void> cleanup; private static int passed; private static int failed; @@ -37,6 +38,23 @@ public class SummaryReport { reproduceInstructions.offer(msg); } + public final static void addCleanup(Function0<Unit> func) { + // Wow, look at how neatly we - compose cleanup callbacks: + if (cleanup == null) { + cleanup = () -> { + func.apply(); + return null; + }; + } else { + Supplier<Void> oldCleanup = cleanup; + cleanup = () -> { + oldCleanup.get(); + func.apply(); + return null; + }; + } + } + @BeforeClass public final static void setup() { rep = TestReporter.reporter(System.out, -1); failedTests = new ArrayDeque<>(); @@ -71,5 +89,8 @@ public class SummaryReport { if (!isInteractive) rep.flushToStdErr(); if (failed > 0) rep.flushToFile(); + + // Perform cleanup callback: + if (cleanup != null) cleanup.get(); } } |