Skip to content

Commit 0f8f32a

Browse files
committed
Disable stdout buffering in test_with_catch
Ensure test output appears immediately in CI logs by disabling stdout buffering. Without this, output may be lost if the process is killed by a timeout, making it difficult to diagnose which test was hanging.
1 parent cb5e7d7 commit 0f8f32a

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

tests/test_with_catch/catch.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <pybind11/embed.h>
55

66
#include <chrono>
7+
#include <cstdio>
78
#include <ctime>
89
#include <iomanip>
910
#include <sstream>
@@ -103,6 +104,11 @@ std::string get_utc_timestamp() {
103104
} // namespace
104105

105106
int main(int argc, char *argv[]) {
107+
// Disable stdout buffering to ensure output appears immediately in CI logs.
108+
// Without this, output may be lost if the process is killed by a timeout.
109+
std::cout.setf(std::ios::unitbuf);
110+
setvbuf(stdout, nullptr, _IONBF, 0);
111+
106112
// Setup for TEST_CASE in test_interpreter.cpp, tagging on a large random number:
107113
std::string updated_pythonpath("pybind11_test_with_catch_PYTHONPATH_2099743835476552");
108114
const char *preexisting_pythonpath = getenv("PYTHONPATH");

0 commit comments

Comments
 (0)