diff options
author | Felix Mulder <felix.mulder@gmail.com> | 2017-04-03 17:12:10 +0200 |
---|---|---|
committer | Felix Mulder <felix.mulder@gmail.com> | 2017-04-12 11:21:57 +0200 |
commit | c15b83be52ec2db7369dbdfa3db0044b3de9ff76 (patch) | |
tree | 563041875bb01e4ee8abaa62efe098b7eae33cfa /compiler/test/dotty/tools/dotc/vulpix/SummaryReport.java | |
parent | 5c573d3b5b9f294920bdd7a142219a967c926bb4 (diff) | |
download | dotty-c15b83be52ec2db7369dbdfa3db0044b3de9ff76.tar.gz dotty-c15b83be52ec2db7369dbdfa3db0044b3de9ff76.tar.bz2 dotty-c15b83be52ec2db7369dbdfa3db0044b3de9ff76.zip |
Add cleanup hooks to SummaryReporter
Diffstat (limited to 'compiler/test/dotty/tools/dotc/vulpix/SummaryReport.java')
-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(); } } |