-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
community build: summarize failed projects at test completion
- Loading branch information
Showing
2 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
community-build/test/java/dotty/communitybuild/FailureSummarizer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters