-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Introduce --redirect-stdout
and --redirect-stderr
CLI options to redirect STDOUT and STDERR
#3637
base: main
Are you sure you want to change the base?
Introduce --redirect-stdout
and --redirect-stderr
CLI options to redirect STDOUT and STDERR
#3637
Conversation
Add method registerMergedStandardStreams in StreamInterceptor to merge stdout and stderr so both can be intercepted in an stdout interceptor. This will keep the relative order for both outputs, which makes it easier to correlate error messages with the corresponding output. Add new configuration parameter junit.platform.output.capture.merge to merge stdout and stderr and publish it as STDOUT_REPORT_ENTRY_KEY to all registered TestExecutionListener instances. Issue: junit-team#3166
Add new CLI options --redirect-stdout and --redirect-stderr to redirect stdout and stderr to a file, if both are set to the same file, stdout and stderr will be merged so we can keep the relative order of messages. This makes it easier to correlate error messages with the corresponding output. Issue: junit-team#3166
Document the changes for the previous two commit in the 5.11.0-M1 release notes and in the user guide. Issue: junit-team#3166
Add @API annotation to new methods. Issue: junit-team#3166
1dc0449
to
ae0fce5
Compare
This comment was marked as off-topic.
This comment was marked as off-topic.
--redirect-stdout
and --redirect-stderr
CLI options to redirect STDOUT and STDERR
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 don't think we should implement this new ConsoleLauncher
feature based on the report entries. Instead, the ConsoleLauncher
should replace System.out
and System.err
prior to calling Launcher.execute
with PrintStreams
writing to files (or the same file). This would allow to configure capturing the output as report entries separately.
|
||
* New optional config parameter `junit.platform.output.capture.merge` that can be used to merge stdout and stderr and | ||
capture it as stdout. | ||
* New optional CLI options `--redirect-stdout` and `--redirect-stderr` to redirect stdout and stderr outputs to a file. |
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.
This needs to go to the release notes of 5.12.0-M1 now
@@ -73,4 +75,24 @@ public void setTheme(Theme theme) { | |||
this.theme = theme; | |||
} | |||
|
|||
@API(status = INTERNAL, since = "5.11") |
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.
@API(status = INTERNAL, since = "5.11") | |
@API(status = INTERNAL, since = "5.12") |
same below
@Option(names = "-redirect-stdout", hidden = true) | ||
private Path stdout2; | ||
|
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.
We're only maintaining this kind of options for backwards compatibility (we switched to option parsers at some point) but we shouldn't introduce them for new options.
@Option(names = "-redirect-stdout", hidden = true) | |
private Path stdout2; |
@Option(names = "-redirect-stderr", hidden = true) | ||
private Path stderr2; | ||
|
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.
@Option(names = "-redirect-stderr", hidden = true) | |
private Path stderr2; |
result.setStdoutPath(choose(stdout, stdout2, null)); | ||
result.setStderrPath(choose(stderr, stderr2, null)); |
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.
result.setStdoutPath(choose(stdout, stdout2, null)); | |
result.setStderrPath(choose(stderr, stderr2, null)); | |
result.setStdoutPath(stdout); | |
result.setStderrPath(stderr); |
@mobounya Thank you for your PR! Sorry it took us so long to review it. Are you still interested in continuing? |
@mobounya We'd like to make progress on this issue. Please let us know if you're interested in continuing on this PR. |
Sorry for the delay, I've been busy with work, yes I will pick this up in the weekend |
@mobounya Any updates? |
Overview
Add new CLI options
--redirect-stdout
and--redirect-stderr
to redirect stdout and stderr respectively to a file,if both are set to the same file, stdout and stderr will be merged using the configuration parameter
CAPTURE_MERGED_STANDARD_STREAMS_PROPERTY_NAME
and captured from stdout keySTDOUT_REPORT_ENTRY_KEY
in a new TestExecutionListener :RedirectStdoutAndStderrListener
Issue: #3166
I hereby agree to the terms of the JUnit Contributor License Agreement.
Definition of Done
@API
annotations