diff options
author | Noah Misch | 2022-11-17 15:35:06 +0000 |
---|---|---|
committer | Noah Misch | 2022-11-17 15:44:54 +0000 |
commit | 50bee42021b586c8420dc9f4d9488a6c79bd6b2d (patch) | |
tree | 6d68714a23d0b280da62b355e400120df344be3a | |
parent | 0f5812df659b6e40f910d13896584c3e0e765d76 (diff) |
Account for IPC::Run::result() Windows behavior change.
This restores compatibility with the not-yet-released successor of
version 20220807.0. Back-patch to 9.4, which introduced this code.
Reviewed by Andrew Dunstan.
Discussion: https://postgr.es/m/[email protected]
-rw-r--r-- | src/test/perl/TestLib.pm | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/src/test/perl/TestLib.pm b/src/test/perl/TestLib.pm index 35505afe026..7bd353504e7 100644 --- a/src/test/perl/TestLib.pm +++ b/src/test/perl/TestLib.pm @@ -304,15 +304,13 @@ sub command_exit_is my $h = start $cmd; $h->finish(); - # 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); + # Normally, if the child called exit(N), IPC::Run::result() returns N. On + # Windows, with IPC::Run v20220807.0 and earlier, full_results() is the + # method that returns N (https://github.com/toddr/IPC-Run/issues/161). + my $result = + ($Config{osname} eq "MSWin32" && $IPC::Run::VERSION <= 20220807.0) + ? ($h->full_results)[0] + : $h->result(0); is($result, $expected, $test_name); } |