ctest enabling colored output on windows?

Hello guys,

using ctest on Linux and the test output appeared according to the colors being set by the test. This does not happen on Windows, getting the color codes as plain text.
I can see here: https://gitlab.kitware.com/cmake/cmake/-/merge_requests/2577
that Sylvain Joubert writing on this same issue:
I have been conservative and disabled color on Windows as I can't test on that platform. Are ANSI code supported on Windows or is there another way to output color to the console?

Is this feature disabled on windows?


Looks like the current code still doesn’t support coloured output on Windows:

bool cmCTest::ColoredOutputSupportedByConsole()
#if defined(_WIN32)
  // Not supported on Windows
  return false;
  // On UNIX we need a non-dumb tty.
  // ...<implementation omitted>
  return ConsoleIsNotDumb();
1 Like

Part of this is likely that (AFAIK), colors are in-band on VT-alikes and out-of-band on Windows terminals. So color can be managed directly by the data stream on VT but windows requires calls to the terminal handle. Of course, maybe the new terminal understands ANSI color sequences, but I’ve not encountered the need yet either.

1 Like

Thanks Ben for the clarifications,
are there any plan to support Windows and can you think on any possible workaround to use for now?


Answering to myself :slight_smile:
Also thanking Craig as well for pointing to the code culprit.

Using mingw console on Windows and I can see the colors back, so this will be our workaround for now.
Also it surprised me to see that even though Windows and despite the above disabling code it still can work and show colors.