Skip to content
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

Write output from JUnit ConsoleRunner when process is terminated #7799

Merged
merged 3 commits into from
May 31, 2019

Conversation

msolomon
Copy link
Contributor

@msolomon msolomon commented May 24, 2019

Problem

Pants enforces test timeouts for JVM JUnit tests by terminating the JVM process (usually sending SIGINT). When this happens today, test output is not consistently written out. In particular, XML output from AntJunitXmlReportListener will not be written.

Unfortunately, this means test tooling that relies on this XML cannot accurately report test results when the global timeout (usually set with --test-junit-timeout-default) is reached.

Solution

Add a JVM shutdown hook to write out test results on JVM termination.

Result

JUnit test results are available even when Pants times out on a given test run.

Notes

This branch also makes the following changes in support of this:

  • Adds close() to the StreamSource interface to ensure we can close output streams before using their values, and uses it
  • Modifies ConsoleRunnerImpl to improve testability (as might be expected, it's tricky to test behavior triggered on SIGINT)
  • Generalizes and simplifies ShutdownListener so that it:
    • Supports parallel test execution
    • Tracks result state across the entire lifecycle
    • Delegates its work instead of extending ConsoleListener
  • Adjusts the counting of tests in AntJunitXmlReportListener to be accurate in the face of abnormal termination

@stuhood stuhood requested review from jsirois, cheister and wisechengyi and removed request for wisechengyi May 29, 2019 22:31
Copy link
Sponsor Member

@stuhood stuhood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the patch!

@stuhood stuhood merged commit 3c21b52 into pantsbuild:master May 31, 2019
@stuhood
Copy link
Sponsor Member

stuhood commented May 31, 2019

Thanks!

stuhood added a commit to twitter/pants that referenced this pull request May 31, 2019
stuhood added a commit that referenced this pull request Jun 2, 2019
Bump to latest junit-runner, including changes from #7799.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants