Skip to content

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 1 commit into from
Dec 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Member

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 ?

Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Member

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

Copy link
Contributor Author

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.

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