Re: Supporting TAP tests with MSVC and Windows

From: Noah Misch <noah(at)leadboat(dot)com>
To: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
Cc: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Supporting TAP tests with MSVC and Windows
Date: 2022-08-22 00:40:52
Message-ID: 20220822004052.GA646896@rfd.leadboat.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

This (commit 13d856e of 2015-07-29) added the following:

--- a/src/test/perl/TestLib.pm
+++ b/src/test/perl/TestLib.pm
@@ -242,7 +288,17 @@ sub command_exit_is
print("# Running: " . join(" ", @{$cmd}) ."\n");
my $h = start $cmd;
$h->finish();
- is($h->result(0), $expected, $test_name);
+
+ # On Windows, the exit status of the process is returned directly as the
+ # process's exit code, while on Unix, it's returned in the high bits
+ # of the exit code (see WEXITSTATUS macro in the standard <sys/wait.h>
+ # header file). IPC::Run's result function always returns exit code >> 8,
+ # assuming the Unix convention, which will always return 0 on Windows as
+ # long as the process was not terminated by an exception. To work around
+ # that, use $h->full_result on Windows instead.
+ my $result = ($Config{osname} eq "MSWin32") ?
+ ($h->full_results)[0] : $h->result(0);
+ is($result, $expected, $test_name);
}

That behavior came up again in the context of a newer IPC::Run test case. I'm
considering changing the IPC::Run behavior such that the above would have been
unnecessary. However, if I do, the above code would want to adapt to handle
pre-change and post-change IPC::Run versions. If you have an opinion on
whether or how IPC::Run should change, I welcome comments on
https://github.com/toddr/IPC-Run/issues/161.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2022-08-22 00:42:50 Re: pg_receivewal and SIGTERM
Previous Message Michael Paquier 2022-08-22 00:22:52 Re: Fix a comment in WalSnd structure