print debug output immediately

This helps in the cases when get killed by the ctest timeout.
This commit is contained in:
Dennis Klein 2017-04-20 17:45:48 +02:00 committed by Mohammad Al-Turany
parent a1fe478ce7
commit 91831ff701

View File

@ -34,6 +34,12 @@ auto execute(string cmd, string log_prefix) -> execute_result
stringstream out; stringstream out;
// Log cmd // Log cmd
// print full line thread-safe
stringstream printCmd;
printCmd << log_prefix << cmd << endl;
cout << printCmd.str() << flush;
out << log_prefix << cmd << endl; out << log_prefix << cmd << endl;
// Execute command and capture stderr, add log_prefix line by line // Execute command and capture stderr, add log_prefix line by line
@ -41,6 +47,11 @@ auto execute(string cmd, string log_prefix) -> execute_result
auto line = string{}; auto line = string{};
while (getline(in, line)) while (getline(in, line))
{ {
// print full line thread-safe
stringstream printLine;
printLine << log_prefix << line << endl;
cout << printLine.str() << flush;
out << log_prefix << line << endl; out << log_prefix << line << endl;
} }
in.close(); in.close();