pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Noah Misch <noah@leadboat.com>
To: Michael Paquier <michael.paquier@gmail.com>
Cc: Heikki Linnakangas <hlinnaka@iki.fi>
Cc: PostgreSQL mailing lists <pgsql-hackers@postgresql.org>
Subject: Re: Supporting TAP tests with MSVC and Windows
Date: Mon, 22 Aug 2022 00:40:52 +0000
Message-ID: <20220822004052.GA646896@rfd.leadboat.com> (raw)
In-Reply-To: <CAB7nPqRSKMCKP-0C_Z1HPCWU_06XDVTQNNgnZAmb4XLryra-cg@mail.gmail.com>
References: <CAB7nPqSmLEkGvu10ttT1bpgiT_5Hsnef6+6TNfFU_r2T1OPL4A@mail.gmail.com>
	<CAB7nPqSYzUDTj25XvYuTbzMSdCNEwo4-ofmXjXuJipqdiOVrwQ@mail.gmail.com>
	<CAB7nPqRvsJ7WvgNDQk+yFZGNUbAbMi-LRCwgcWaAcfV3R7V2nw@mail.gmail.com>
	<CAB7nPqSmCHA726iMtVuZZ4t0Rd4jkqZhDf52dTv4138iDXy7aQ@mail.gmail.com>
	<55B2758E.1010205@iki.fi>
	<20150725071408.GA1442444@tornado.leadboat.com>
	<CAB7nPqRYn4_AA270BJ8VXryGV_9mzeLMTvdC2LhXJk0CxJx2+A@mail.gmail.com>
	<CAB7nPqR4YxKOSW3zUNLwEexNqOLLFtCVWb0cTF1VKx6q53=pAA@mail.gmail.com>
	<55B90161.5090506@iki.fi>
	<CAB7nPqRSKMCKP-0C_Z1HPCWU_06XDVTQNNgnZAmb4XLryra-cg@mail.gmail.com>

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.





view thread (23+ messages)  latest in thread

Message-ID: <20220822004052.GA646896@rfd.leadboat.com>
Permalink:  ../20220822004052.GA646896@rfd.leadboat.com/
Also on:    postgresql.org/message-id/20220822004052.GA646896@rfd.leadboat.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: noah@leadboat.com, michael.paquier@gmail.com, hlinnaka@iki.fi
  Subject: Re: Supporting TAP tests with MSVC and Windows
  In-Reply-To: <20220822004052.GA646896@rfd.leadboat.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox