mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-10-07 04:02:23 +03:00
ctest: Simplify progress summary line logic
Avoid relying on separate buffering of `cout` and `printf`.
This commit is contained in:
1 parent
8736d42793
commit
a111f56863
1 file changed
+10
-9
+10
-9
@@ -79,6 +79,10 @@
|
||||
# include <be/kernel/OS.h> /* disable_debugger() API. */
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
cm::string_view const kVT100_EraseLine = "\x1B[K"_s;
|
||||
}
|
||||
|
||||
struct tm;
|
||||
|
||||
struct cmCTest::Private
|
||||
@@ -121,7 +125,7 @@ struct cmCTest::Private
|
||||
bool Failover = false;
|
||||
cmJSONState parseState;
|
||||
|
||||
bool FlushTestProgressLine = false;
|
||||
bool TestProgressNewlinePending = false;
|
||||
|
||||
// these are helper classes
|
||||
cmCTestBuildAndTest BuildAndTest;
|
||||
@@ -3399,22 +3403,19 @@ void cmCTest::Log(LogType logType, std::string msg, bool suppress)
|
||||
if (!this->Impl->Quiet) {
|
||||
if (logType == HANDLER_TEST_PROGRESS_OUTPUT) {
|
||||
if (this->Impl->TestProgressOutput) {
|
||||
if (this->Impl->FlushTestProgressLine) {
|
||||
printf("\r");
|
||||
this->Impl->FlushTestProgressLine = false;
|
||||
std::cout.flush();
|
||||
if (this->Impl->TestProgressNewlinePending) {
|
||||
this->Impl->TestProgressNewlinePending = false;
|
||||
std::cout << '\r';
|
||||
}
|
||||
|
||||
if (msg.find('\n') != std::string::npos) {
|
||||
this->Impl->FlushTestProgressLine = true;
|
||||
this->Impl->TestProgressNewlinePending = true;
|
||||
msg.erase(std::remove(msg.begin(), msg.end(), '\n'), msg.end());
|
||||
}
|
||||
|
||||
std::cout << msg;
|
||||
// ProgressOutputSupportedByConsole() already verified VT100 support.
|
||||
// Erase the rest of the line before printing the message.
|
||||
printf("\x1B[K");
|
||||
std::cout.flush();
|
||||
std::cout << kVT100_EraseLine << msg << std::flush;
|
||||
return;
|
||||
}
|
||||
logType = HANDLER_OUTPUT;
|
||||
|
||||
Reference in new issue
Block a user