-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix #10787: List failed projects at community build test completion #10794
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is that still needed if you output with System.out instead of System.err ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was seeing interspersed and/or too early output without it, no matter which file handle I chose. It's a bit hacky, but I don't think there's a way here to route the output via the sbt logger?
sbt/junit-interface has some functionality in current master (option --summary=2) that might also work to solve this issue, but there doesn't seem to have been a release since 0.11 over 6 years ago.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting, I think we should try to push for a new release of junit-interface.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sbt/junit-interface#94. Meanwhile this PR is already a great improvement even if we have to rely on some hacks so I'd be happy to get it in.
Another approach we might to explore would be using the github annotation API to get info from failed tests reported back in the github UI, there's some github actions to do this based on the XML reports that JUnit generates but I haven't tried them: https://github.com/marketplace/actions/junit-report-to-annotations, https://github.com/marketplace/actions/junit-report
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The annotation API is an interesting avenue for exploration; I'll take a look and see how we might make use of it, not just in regards to the community build but for all the JUnit tests. But that will likely take time and experimentation and this PR provides a quick (albeit hacky) fix in the interim.