stdout/stderr is not captured (only cout/cerr are)
- Dominant language
- C++
- Stars
- 21.5k
- Forks
- 3.5k
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 2
Description
**Describe the bug**
When a test case writes to stdout or stderr, it is never captured by the xml or junit reporters on Windows.
**Expected behavior**
When a test case writes to stdout or stderr, it is captured by the xml or junit reporters on Windows.
**Reproduction steps**
```c++
#include
#include "catch2/catch.hpp"
#include
TEST_CASE("Repro")
{
// via stdlib
printf("Some standard output\n");
fprintf(stderr, "Some standard error\n");
// via Win32 APIs
constexpr std::string_view output{ "More standard output\n" };
WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), output.data(), (DWORD)output.size(), nullptr, nullptr);
constexpr std::string_view error{ "More standard error\n" };
WriteFile(GetStdHandle(STD_ERROR_HANDLE), error.data(), (DWORD)error.size(), nullptr, nullptr);
}
```
**Platform information:**
OS: **Windows 10**
Compiler: **VS 2022 (17.2.2)**
Catch version: **2.13.9**
**Additional context**
The problem occurs regardless of whether -o is used or not; in both cases, stdout/stderr are never redirected. When not using -o, the resulting xml is not always valid (stdout/stderr interleaved in the XML).
Some examples:
**Example 1**
Command:
```repro.exe -r xml```
Output:
```
Some standard output
Some standard error
More standard output
More standard error
```
**Example 2**
Command:
```repro.exe -r junit```
Output:
```
```
**Example 3**
Command:
```repro.exe -r xml -o result.xml```
Output:
```
Some standard output
Some standard error
More standard output
More standard error
```
result.xml:
```
```
**Example 4**
Command:
```repro.exe -r junit -o result.xml```
Output:
```
Some standard output
Some standard error
More standard output
More standard error
```
result.xml:
```
```
Contributor guide
Research direction
Start by reproducing the issue on Windows with the provided C++ test case and XML/JUnit commands, then locate Catch2's Windows output-capture and reporter paths. Done means stdout and stderr from both stdio and Win32 writes are captured in XML and JUnit reports without corrupting report output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- testing-qa
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100