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 1oPvV1-0003pX-G4 for pgsql-hackers@arkaria.postgresql.org; Mon, 22 Aug 2022 00:41:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oPvUy-0000fp-JB for pgsql-hackers@arkaria.postgresql.org; Mon, 22 Aug 2022 00:41:00 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oPvUx-0000ff-V3 for pgsql-hackers@lists.postgresql.org; Mon, 22 Aug 2022 00:41:00 +0000 Received: from mail-qv1-xf2d.google.com ([2607:f8b0:4864:20::f2d]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1oPvUv-00051f-CI for pgsql-hackers@postgresql.org; Mon, 22 Aug 2022 00:40:58 +0000 Received: by mail-qv1-xf2d.google.com with SMTP id b2so7117186qvp.1 for ; Sun, 21 Aug 2022 17:40:57 -0700 (PDT) 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; bh=WmE4uzY9HYKdl4EWfWvHFAuEgchJuOTVHd50Vf5nYJ8=; b=gD52pOgBcNLZYzmgBGBwV2sKaKKabizYL1kSzIBs3lRy2UWI1nF2ySKmxanTn6uCdK vVHNRQr1o1+vNYxw4U+Q0syKmOliAz8ej+sv5qRrvLPl47gIVVCY5w1TegeN2/jl3tLT 9ZmKG6sP+PZEfA3IrxVEUX77TWn4v+itAmUN8= 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; bh=WmE4uzY9HYKdl4EWfWvHFAuEgchJuOTVHd50Vf5nYJ8=; b=PdVCD7Gx/N56BJoGI91WpzmqO12MeFmvayKNO8SjObPUVp89IUUwVtbqsRST8pXqvg 74p8+b+S5GEg1AmBwmh4Ehbl2aLu8yfMEqBY0f/E2utbMQod7UYOgKUD8K++0IKF6CbA wkvjpyCsc8iWez5BvPl9YG4Jf2dMGaTs/mn6szQUvLf1zHh7hi5xGrd9MpVpMVH0LzJK tZLkUXkSgED/Iu2dZ+YAqsJHVpAE8yHaDvKEEHQaWwSZoMmTyX/fNEoYwqUDyC2DRs4W cLpxEzSYqdK0AzYAzzH04blfxbZMMzyMPTT6MJia2soA+7gB4FAcV6wQHri3DcwQJphS qJbA== X-Gm-Message-State: ACgBeo1VsWVFwMiLx3wv1BUFanSiiP5gLdeAh8laMA8vV7yWwWyHpSfK 9lF2TWBQm2Ex+ePpmGzyegGkGg== X-Google-Smtp-Source: AA6agR6L/OG7V4b84coIktE20inIGkrgGP7kTp0F8szgQcsNP3iK1gjnMHgB21nOyLv5rl6qLHUj3Q== X-Received: by 2002:ad4:5947:0:b0:496:b88d:dd96 with SMTP id eo7-20020ad45947000000b00496b88ddd96mr5439754qvb.77.1661128856545; Sun, 21 Aug 2022 17:40:56 -0700 (PDT) Received: from rfd.leadboat.com ([2600:1702:a20:5750::2e]) by smtp.gmail.com with ESMTPSA id a10-20020ac8108a000000b0034355bb11f2sm7706302qtj.10.2022.08.21.17.40.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 21 Aug 2022 17:40:55 -0700 (PDT) Date: Mon, 22 Aug 2022 00:40:52 +0000 From: Noah Misch To: Michael Paquier Cc: Heikki Linnakangas , PostgreSQL mailing lists Subject: Re: Supporting TAP tests with MSVC and Windows Message-ID: <20220822004052.GA646896@rfd.leadboat.com> References: <55B2758E.1010205@iki.fi> <20150725071408.GA1442444@tornado.leadboat.com> <55B90161.5090506@iki.fi> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 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.