Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ovYE8-0006I1-5r for pgsql-hackers@arkaria.postgresql.org; Thu, 17 Nov 2022 06:18:20 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ovYE6-0000fn-8P for pgsql-hackers@arkaria.postgresql.org; Thu, 17 Nov 2022 06:18:18 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ovYE5-0000fc-OE for pgsql-hackers@lists.postgresql.org; Thu, 17 Nov 2022 06:18:17 +0000 Received: from mail-oa1-x36.google.com ([2001:4860:4864:20::36]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1ovYDy-000692-5m for pgsql-hackers@postgresql.org; Thu, 17 Nov 2022 06:18:16 +0000 Received: by mail-oa1-x36.google.com with SMTP id 586e51a60fabf-13be3ef361dso1078294fac.12 for ; Wed, 16 Nov 2022 22:18:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leadboat.com; s=google; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=DtGmMkpgCrDcSzidp2RNZUy1Q+IdqVEi1yO55Gwpl/w=; b=Bf4WvkPao1WmdJ9r5ST4tAFlTSpTw7Ysu6QLeIssLYwaPoE2XUX9B3oIS7qcemb/rY N8uWTMcpU3l6MUNPOdoFd1GBuJQuCwql45v74uyRwMkxFaA8XfQShE3oodCCMoto3Oj4 tZlZKR514lYpYj6pz5FmrUC8uyaSlGqeWYt6g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DtGmMkpgCrDcSzidp2RNZUy1Q+IdqVEi1yO55Gwpl/w=; b=c6HWrlCWexnkSrnfSs7HHvFFPFwAjpXU9Gxf64e43Jk1f/FSdPrLkodfm8KuqTdFji uCnjBjfQu2C1v+l/YineE0fBlmSL7onheQ32AHmnFDRGwSIKbUxZL/mTEhfjMJklSGt0 OFuc+PA1lgepiynhRc3poMGqgL+p/9/CaEuD6Vs9UJPCv87iYbWe7seyZSJ8VN5qe1gq HH6fmMl13r60J+SfVBeY50tS4VhK+8zHBktFocVQgAgbFpiHhyoLAEW+9hom92rmAGGQ h7nJp+FaRueKuZKcLoARaN/F//WcWVgtI6DkEoyxGdFC50lqgSoHHda0syL44yuVDrA4 WR8Q== X-Gm-Message-State: ANoB5plgklyEM1poUhuM89ZgAU1ayYDma59EKZQfMfNiXZpCdc1YSNcl ovo5ZDpRegONFV7QH8iBCrAqmw== X-Google-Smtp-Source: AA0mqf4VOJClzqFlgiIR+/x6xyKosFLV8B/2866u9h/a671sBW6Wh5rLmt70xD3HJSGIncm1OTf6ww== X-Received: by 2002:a05:6870:2f04:b0:13c:2efc:977c with SMTP id qj4-20020a0568702f0400b0013c2efc977cmr568723oab.30.1668665888053; Wed, 16 Nov 2022 22:18:08 -0800 (PST) Received: from rfd.leadboat.com ([2600:1702:a20:5750::2e]) by smtp.gmail.com with ESMTPSA id g37-20020a9d2da8000000b0066cacb8343bsm7608774otb.41.2022.11.16.22.18.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Nov 2022 22:18:07 -0800 (PST) Date: Wed, 16 Nov 2022 22:18:05 -0800 From: Noah Misch To: Andrew Dunstan Cc: Michael Paquier , Heikki Linnakangas , PostgreSQL mailing lists Subject: Re: Supporting TAP tests with MSVC and Windows Message-ID: <20221117061805.GA4020280@rfd.leadboat.com> References: <55B2758E.1010205@iki.fi> <20150725071408.GA1442444@tornado.leadboat.com> <55B90161.5090506@iki.fi> <20220822004052.GA646896@rfd.leadboat.com> <2856ec20-157c-8119-4f4d-fc15e23efe20@dunslane.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="IJpNTDwzlM2Ie8A6" Content-Disposition: inline In-Reply-To: <2856ec20-157c-8119-4f4d-fc15e23efe20@dunslane.net> User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --IJpNTDwzlM2Ie8A6 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Mon, Aug 22, 2022 at 09:44:42AM -0400, Andrew Dunstan wrote: > On 2022-08-21 Su 20:40, Noah Misch wrote: > > 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 > > + # 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. > > Assuming it changes, we'll have to have a version test here. I don't > think we can have a flag day where we suddenly require IPC::Run's > bleeding edge on Windows. So changing it is a good thing, but it won't > help us much. IPC::Run git now has the change, and we may release soon. Here's what I plan to push to make PostgreSQL cope. --IJpNTDwzlM2Ie8A6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="ipc-run-result-w32-v1.patch" Author: Noah Misch Commit: Noah Misch 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 FIXME. Discussion: https://postgr.es/m/FIXME diff --git a/src/test/perl/PostgreSQL/Test/Utils.pm b/src/test/perl/PostgreSQL/Test/Utils.pm index 99d3345..b139190 100644 --- a/src/test/perl/PostgreSQL/Test/Utils.pm +++ b/src/test/perl/PostgreSQL/Test/Utils.pm @@ -782,15 +782,11 @@ sub command_exit_is my $h = IPC::Run::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 - # 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_results on Windows instead. + # 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") + ($Config{osname} eq "MSWin32" && $IPC::Run::VERSION <= 20220807.0) ? ($h->full_results)[0] : $h->result(0); is($result, $expected, $test_name); --IJpNTDwzlM2Ie8A6--