Skip to content

Commit

Permalink
community build: summarize failed projects at test completion
Browse files Browse the repository at this point in the history
  • Loading branch information
griggt committed Dec 15, 2020
1 parent 1ec8041 commit 780c18c
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package dotty.communitybuild;

import java.util.List;

import org.junit.runner.Description;
import org.junit.runner.Result;
import org.junit.runner.notification.Failure;
import org.junit.runner.notification.RunListener;

public class FailureSummarizer extends RunListener {
@Override
public void testRunFinished(Result result) throws Exception {
super.testRunFinished(result);
if (result.getFailureCount() > 0) {
Thread.sleep(500); // pause to give sbt log buffers some time to flush
summarizeFailures(result.getFailures());
}
}

private void summarizeFailures(List<Failure> failures) {
err("********************************************************************************");
err("Failed projects:");
for (Failure f : failures) {
err(" - " + getProjectName(f.getDescription()));
}
err("********************************************************************************");
}

private String getProjectName(Description desc) {
return desc.getClassName() + "." + desc.getMethodName();
}

private void err(String msg) {
System.err.println(msg);
}
}
1 change: 1 addition & 0 deletions project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1360,6 +1360,7 @@ object Build {
testOptions in Test += Tests.Argument(
TestFrameworks.JUnit,
"--include-categories=dotty.communitybuild.TestCategory",
"--run-listener=dotty.communitybuild.FailureSummarizer",
),
Compile/run := (Compile/run).dependsOn(prepareCommunityBuild).evaluated,
(Test / testOnly) := ((Test / testOnly) dependsOn prepareCommunityBuild).evaluated,
Expand Down

0 comments on commit 780c18c

Please sign in to comment.