[PATCH] winetest: Send the tests output to stdout when given "-o -".

Francois Gouget fgouget at codeweavers.com
Mon Dec 20 04:46:18 CST 2021


This makes it easier to use WineTest with tools that capture stdout,
such as the TestBot.

Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
---
In particular this allows checking whether a test fails when run through
WineTest as opposed to running standalone by sending winetest.exe to the
TestBot and specifying "-c -o - -t foo test:unit" as the arguments.
---
 programs/winetest/main.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/programs/winetest/main.c b/programs/winetest/main.c
index 7ced565447b..0c431a903d7 100644
--- a/programs/winetest/main.c
+++ b/programs/winetest/main.c
@@ -1051,7 +1051,8 @@ run_tests (char *logname, char *outdir)
     sa.lpSecurityDescriptor = NULL;
     sa.bInheritHandle = TRUE;
 
-    logfile = CreateFileA( logname, GENERIC_READ|GENERIC_WRITE,
+    logfile = strcmp(logname, "-") == 0 ? GetStdHandle( STD_OUTPUT_HANDLE ) :
+              CreateFileA( logname, GENERIC_READ|GENERIC_WRITE,
                            FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
                            &sa, CREATE_ALWAYS, 0, NULL );
 
@@ -1175,7 +1176,7 @@ run_tests (char *logname, char *outdir)
     report (R_DELTA, 0, "Running: Done");
 
     report (R_STATUS, "Cleaning up - %u failures", failures);
-    CloseHandle( logfile );
+    if (strcmp(logname, "-") != 0) CloseHandle( logfile );
     logfile = 0;
     if (newdir)
         remove_dir (tempdir);
-- 
2.30.2



More information about the wine-devel mailing list