1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-14 02:08:27 +08:00

ctest: Enable color output on Windows Consoles supporting VT100 escapes

Extend commit ffdec37a19 (CTest: Add colored output on tests summary
where supported, 2018-11-07, v3.14.0-rc1~384^2) to enable color on
Windows.

Issue: #26924
This commit is contained in:
Brad King
2025-05-22 11:20:56 -04:00
parent 6be0c6d26a
commit 0b61a17c93
2 changed files with 4 additions and 35 deletions

View File

@@ -34,9 +34,7 @@
#include "cmsys/FStream.hxx"
#include "cmsys/RegularExpression.hxx"
#include "cmsys/SystemInformation.hxx"
#if defined(_WIN32)
# include <windows.h> // IWYU pragma: keep
#else
#ifndef _WIN32
# include <unistd.h> // IWYU pragma: keep
#endif
@@ -61,6 +59,7 @@
#include "cmState.h"
#include "cmStateSnapshot.h"
#include "cmStateTypes.h"
#include "cmStdIoStream.h"
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmUVHandlePtr.h"
@@ -1487,28 +1486,9 @@ bool cmCTest::CheckArgument(std::string const& arg, cm::string_view varg1,
return (arg == varg1) || (varg2 && arg == varg2);
}
#if !defined(_WIN32)
bool cmCTest::ConsoleIsNotDumb()
{
std::string term_env_variable;
if (cmSystemTools::GetEnv("TERM", term_env_variable)) {
return isatty(1) && term_env_variable != "dumb";
}
return false;
}
#endif
bool cmCTest::ProgressOutputSupportedByConsole()
{
#if defined(_WIN32)
// On Windows we need a console buffer.
void* console = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_SCREEN_BUFFER_INFO csbi;
return GetConsoleScreenBufferInfo(console, &csbi);
#else
// On UNIX we need a non-dumb tty.
return ConsoleIsNotDumb();
#endif
return cm::StdIo::Out().Kind() == cm::StdIo::TermKind::VT100;
}
bool cmCTest::ColoredOutputSupportedByConsole()
@@ -1522,13 +1502,7 @@ bool cmCTest::ColoredOutputSupportedByConsole()
if (cmSystemTools::GetEnv("CLICOLOR", clicolor) && clicolor == "0") {
return false;
}
#if defined(_WIN32)
// Not supported on Windows
return false;
#else
// On UNIX we need a non-dumb tty.
return ConsoleIsNotDumb();
#endif
return cm::StdIo::Out().Kind() == cm::StdIo::TermKind::VT100;
}
bool cmCTest::AddVariableDefinition(std::string const& arg)

View File

@@ -455,11 +455,6 @@ private:
/** set command line arguments read from a test preset */
bool SetArgsFromPreset(std::string const& presetName, bool listPresets);
#if !defined(_WIN32)
/** returns true iff the console supports progress output */
static bool ConsoleIsNotDumb();
#endif
/** returns true iff the console supports progress output */
static bool ProgressOutputSupportedByConsole();