Skip to content

Commit 50bee42

Browse files
committed
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/20221117061805.GA4020280@rfd.leadboat.com
1 parent 0f5812d commit 50bee42

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

src/test/perl/TestLib.pm

+7-9
Original file line numberDiff line numberDiff line change
@@ -304,15 +304,13 @@ sub command_exit_is
304304
my $h = start $cmd;
305305
$h->finish();
306306

307-
# On Windows, the exit status of the process is returned directly as the
308-
# process's exit code, while on Unix, it's returned in the high bits
309-
# of the exit code (see WEXITSTATUS macro in the standard <sys/wait.h>
310-
# header file). IPC::Run's result function always returns exit code >> 8,
311-
# assuming the Unix convention, which will always return 0 on Windows as
312-
# long as the process was not terminated by an exception. To work around
313-
# that, use $h->full_result on Windows instead.
314-
my $result = ($Config{osname} eq "MSWin32") ?
315-
($h->full_results)[0] : $h->result(0);
307+
# Normally, if the child called exit(N), IPC::Run::result() returns N. On
308+
# Windows, with IPC::Run v20220807.0 and earlier, full_results() is the
309+
# method that returns N (https://github.com/toddr/IPC-Run/issues/161).
310+
my $result =
311+
($Config{osname} eq "MSWin32" && $IPC::Run::VERSION <= 20220807.0)
312+
? ($h->full_results)[0]
313+
: $h->result(0);
316314
is($result, $expected, $test_name);
317315
}
318316

0 commit comments

Comments
 (0)