From ac24b2ab1562b4361fa29bb9b83a370472595d87 Mon Sep 17 00:00:00 2001 From: ManDude <7569514+ManDude@users.noreply.github.com> Date: Mon, 22 Feb 2021 06:03:14 +0000 Subject: [PATCH] [goalc-test] Apply windows cmd color fix (lg::initialize is not called here) (#278) --- test/test_main.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/test/test_main.cpp b/test/test_main.cpp index f72f3572f0..6f08ae89d2 100644 --- a/test/test_main.cpp +++ b/test/test_main.cpp @@ -3,6 +3,9 @@ #include "common/util/FileUtil.h" #include +#ifdef _WIN32 +#include +#endif // Running subsets of tests, see: // - @@ -16,6 +19,22 @@ // to make it easier to test a subset of tests int main(int argc, char** argv) { +#ifdef _WIN32 + // Always enable VIRTUAL_TERMINAL_PROCESSING, this console mode allows the console (stdout) to + // support ANSI colors in the outputted text, which are used by the logging tool. + // This mode may not be enabled by default, and changing that involves modifying the registry, + // so it seems like a better solution would be enabling it ourselves. + + // Get handle to stdout + HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE); + // get current stdout mode + DWORD modeStdOut; + GetConsoleMode(hStdOut, &modeStdOut); + // enable VIRTUAL_TERMINAL_PROCESSING. As a bitwise OR it will not do anything if it is + // already set + modeStdOut |= ENABLE_VIRTUAL_TERMINAL_PROCESSING; + SetConsoleMode(hStdOut, modeStdOut); +#endif ::testing::InitGoogleTest(&argc, argv); // Re-init failed folder @@ -26,4 +45,4 @@ int main(int argc, char** argv) { std::filesystem::create_directory(failedFolder); return RUN_ALL_TESTS(); -} \ No newline at end of file +}