Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Account for IPC::Run::result() Windows behavior change.
authorNoah Misch <noah@leadboat.com>
Thu, 17 Nov 2022 15:35:06 +0000 (07:35 -0800)
committerNoah Misch <noah@leadboat.com>
Thu, 17 Nov 2022 15:44:36 +0000 (07:44 -0800)
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

src/test/perl/TestLib.pm

index 6dbf3e6fc3b61a0330ccf0bb3be98bed142585dc..76c727b9b1a010518b67b3fe8238e09a30562d00 100644 (file)
@@ -365,15 +365,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);
 }