include: Enable ANSI support in console for WINETEST_COLOR.

This lets WINETEST_COLOR works under Windows console (at least, on recent
versions where ANSI support is available).

Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
This commit is contained in:
Eric Pouech 2022-09-01 11:18:00 +02:00 committed by Alexandre Julliard
parent de48020325
commit f20b892ed9

View file

@ -678,7 +678,20 @@ int main( int argc, char **argv )
winetest_platform = "wine";
if (GetEnvironmentVariableA( "WINETEST_COLOR", p, sizeof(p) ))
winetest_color = !strcasecmp(p, "auto") ? isatty(fileno(stdout)) : atoi(p);
{
BOOL automode = !strcasecmp(p, "auto");
winetest_color = automode ? isatty( fileno( stdout ) ) : atoi(p);
/* enable ANSI support for Windows console */
if (winetest_color)
{
HANDLE hOutput = (HANDLE)_get_osfhandle( fileno( stdout ) );
DWORD mode;
if (GetConsoleMode( hOutput, &mode ) &&
!SetConsoleMode( hOutput, mode | ENABLE_PROCESSED_OUTPUT | ENABLE_VIRTUAL_TERMINAL_PROCESSING ) &&
automode)
winetest_color = 0;
}
}
if (GetEnvironmentVariableA( "WINETEST_DEBUG", p, sizeof(p) )) winetest_debug = atoi(p);
if (GetEnvironmentVariableA( "WINETEST_INTERACTIVE", p, sizeof(p) )) winetest_interactive = atoi(p);
if (GetEnvironmentVariableA( "WINETEST_REPORT_SUCCESS", p, sizeof(p) )) winetest_report_success = atoi(p);