-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
The output of failing tests is not redirected to the junit reporter #1514
Comments
FYI, the problem can be fixed by slightly changing the RunContext::runCurrentTest() function: Instead of:
I used this:
Where RedirectedStreams is a RAII-style helper class that simply redirects the test output to redirectedCout and redirectedCerr in its destructor (so that the output gets redirected even if invokeActiveTestCase() throws an exception). |
Feel free to create PR :) |
Sorry about the bug, but apparently it escaped notice for well over a year, the commit that introduced it was done on 6.12.2017: aa9d635. I am going to look at the PR in a moment. |
If the regression comes back, it will only be caught by approvals, but that's better than nothing.
This avoids the problem where writes to stderr/stdout stop being line-buffered when stderr/stdout is redirected to a file, which led to different order of outputs between Linux and Windows in our tests.
This is still an issue with segfaults: TEST_CASE("test") {
std::cout << "Cout!" << std::endl;
std::cerr << "Cerr!" << std::endl;
// Generate a segfault
int *a = nullptr;
*a = 1;
}
|
Describe the bug
Given a test that fails (either via a failing assertion or an uncaught exception), the stdout and stderr output of the test is not redirected to the reporter. For instance, when invoking the test via -r junit, the resulting <system-out> and <system-err> tags are empty.
The output of successful tests is redirected correctly to the reporter, however.
Expected behavior
Personally I expected the output of the failing test to be redirected to the reporter, since having access to the test's output helps when trying to figure out what went wrong (especially when the test is non-deterministic and thus the error is not easy to reproduce). But maybe others have different expectations, so I'm not sure if this is really a bug.
Reproduction steps
Run the above test using the -r junit command-line option. The <system-out> and <system-err> tags will be empty.
Platform information:
The text was updated successfully, but these errors were encountered: