Skip to content

Update to the Latest googletest Version and Changed the if define Style#279

Open
fangjunzhou wants to merge 2 commits into
tanzislam:fix-color-output-with-mingw-in-conhostfrom
fangjunzhou:main
Open

Update to the Latest googletest Version and Changed the if define Style#279
fangjunzhou wants to merge 2 commits into
tanzislam:fix-color-output-with-mingw-in-conhostfrom
fangjunzhou:main

Conversation

@fangjunzhou
Copy link
Copy Markdown

I merged your branch to the latest google test main branch. I found they are using a new #if defined style. I changed your macro to the new style. It works perfectly for me. I can finally have colorful test output! Thank you for your PR!!

tanzislam and others added 2 commits December 17, 2022 13:46
When built with MinGW, Google Test emits ANSI escape sequences for color output like non-Windows platforms. This works with MSYS2's terminal ([`mintty.exe`](https://mintty.github.io/)) that intercepts stdout with a pipe and then renders color itself, but not with the native Windows Command Prompt (i.e. [conhost.exe in Windows 7 onwards, and csrss.exe earlier](https://devblogs.microsoft.com/commandline/windows-command-line-inside-the-windows-console/#so-whats-inside-the-windows-console)) that expect the Windows Console API to be used. This is arguably incorrect as the MinGW toolchain is intended for building native Windows programs, independent of any POSIX-like environment.

Change the color-output behavior of MinGW-built Google Test to be conditional:

 - If stdout is a TTY, use the Windows Console API.
 - If stdout is not a TTY but the user specified `--gtest_color=yes`, use ANSI escape sequences.

Behavior when built with any other compiler is unaffected. So Windows desktop toolchains (MSVC, C++Builder, etc.) will continue to use the Windows Console API unconditionally, while Cygwin, MSYS (not MinGW) and all other non-Windows toolchains will continue to use ANSI escape sequences unconditionally.

Fixes: google#2809
Merged tanzislam:fix-color-output-with-mingw-in-conhost into main.
Changed the old if define macro to the new style.
@fangjunzhou
Copy link
Copy Markdown
Author

It seems that your branch is outdated, and GitHub is displaying too many old commits. For your information, this is the change I made: 641f105

@tanzislam tanzislam force-pushed the fix-color-output-with-mingw-in-conhost branch from 43f5258 to 94b7368 Compare September 3, 2023 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants