Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iyIdJ-0003Xj-9q for pgsql-hackers@arkaria.postgresql.org; Sun, 02 Feb 2020 17:02:05 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iyIdH-0004Iq-Vx for pgsql-hackers@arkaria.postgresql.org; Sun, 02 Feb 2020 17:02:03 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iyIdH-0004Ii-Bg for pgsql-hackers@lists.postgresql.org; Sun, 02 Feb 2020 17:02:03 +0000 Received: from mail-pg1-x52a.google.com ([2607:f8b0:4864:20::52a]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1iyIdD-0002r6-Ua for pgsql-hackers@postgresql.org; Sun, 02 Feb 2020 17:02:01 +0000 Received: by mail-pg1-x52a.google.com with SMTP id 4so6470419pgd.6 for ; Sun, 02 Feb 2020 09:01:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leadboat.com; s=google; h=date:from:to:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=k9drPkpJKK2FK8BZdQsZBnhOOvLCP9tYP3wJV7x8Q/s=; b=XXkHlxYZQqRm96yZAbd36Iz5/TCxX0KCnwRzs4CABabx9wH/aKQW8gCYVhSTr63HiQ /krCIxwJYPbxn1TNBIo7g0hdOaLean68wGw4f0rF6bA1UlY/EScJ46Hxgf+9TwPIJkOQ b797C5/me4ByEMLKw0J+LiWTEd1Y2TdTrxkAc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=k9drPkpJKK2FK8BZdQsZBnhOOvLCP9tYP3wJV7x8Q/s=; b=Upyg2KoL1VNYAz2209XviXwBoeTx8OkkFzcpf+/E29u1Bz6IlBz1z0mWYl9GgdegOA lqsQikU6eubNYu5SGiK+/GRY9MsmHH6UeS2SOgg6/45dcaw8KFb2IUZ2JQD4LCLmYLqa ku2kkxTBWjewQJg1bjbI2n+xN8vPr62ksDrhbppJnUZV4LeK/YRcXisQ+ZfBS7AeoN2y AULLLgJtBDvkD+wHBilMq3CoG4WOOTtHwaLnzC+ZpydPkEwOt9YpFtLUlsRJeU+op7mC S8IznDXMRzgZYnEp3/bxjk9ZuKERsElPeajfHXXm3EzMOjiM0JcR+dEZWUiBWgdozvPr yotg== X-Gm-Message-State: APjAAAWiVwVl6PML0mkzhOVRPRZMdExK3sLQyrvCPL9n+dHDWEN/3TiH gvQivQteUEMNhfifw3T5DUSKZXqNT/c= X-Google-Smtp-Source: APXvYqzYN/iC6nOidM9DB4QMqXUMjRbt1fFuqUckjnA5LSOmXR/gERryzgvZVT768Wyk1nts6r3N8w== X-Received: by 2002:a65:4c82:: with SMTP id m2mr20220664pgt.432.1580662917890; Sun, 02 Feb 2020 09:01:57 -0800 (PST) Received: from rfd.leadboat.com (108-233-125-46.lightspeed.sntcca.sbcglobal.net. [108.233.125.46]) by smtp.gmail.com with ESMTPSA id d14sm17676913pfq.117.2020.02.02.09.01.56 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 02 Feb 2020 09:01:57 -0800 (PST) Date: Sun, 2 Feb 2020 09:01:55 -0800 From: Noah Misch To: pgsql-hackers@postgresql.org Subject: TestLib condition for deleting temporary directories Message-ID: <20200202170155.GA3264196@rfd.leadboat.com> References: <20200104185148.GA2270238@rfd.leadboat.com> <20200109053704.GA2502006@rfd.leadboat.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="AhhlLboLdkugWU4S" Content-Disposition: inline In-Reply-To: <20200109053704.GA2502006@rfd.leadboat.com> User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --AhhlLboLdkugWU4S Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Forking thread "logical decoding : exceeded maxAllocatedDescs for .spill files" for this side issue: On Wed, Jan 08, 2020 at 09:37:04PM -0800, Noah Misch wrote: > v10 > deletes PostgresNode base directories at the end of this test file, despite > the failure[1]. > [1] It has the all_tests_passing() logic in an attempt to stop this. I'm > guessing it didn't help because the file failed by calling die "connection > error: ...", not by reporting a failure to Test::More via ok(0) or similar. That is what happened. We should test the exit status to decide whether to keep temporaries, as attached. PostgresNode does that, since commit 90627cf (thread https://postgr.es/m/flat/6205.1492883490%40sss.pgh.pa.us). That thread already discussed $SUBJECT[1] and the __DIE__ handler being redundant[2]. I plan to back-patch, since it's most useful for v10 and v9.6. [1] https://postgr.es/m/CAMsr+YFyFU=+MVFZqhthfMW22x5-h517e6ck6ET+DT+X4bUO7g@mail.gmail.com [2] https://postgr.es/m/FEA925B2-C3AE-4BA9-9194-5F5616AD0794@yesql.se --AhhlLboLdkugWU4S Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="perl-temporaries-v1.patch" Author: Noah Misch Commit: Noah Misch When a TAP file has non-zero exit status, retain temporary directories. PostgresNode already retained base directories in such cases. Stop using $SIG{__DIE__}, which is redundant with the exit status check, in lieu of proliferating it to TestLib. Back-patch to 9.6, where commit 88802e068017bee8cea7a5502a712794e761c7b5 introduced retention on failure. Reviewed by FIXME. Discussion: https://postgr.es/m/FIXME diff --git a/src/test/perl/PostgresNode.pm b/src/test/perl/PostgresNode.pm index 2e0cf4a..ff972d1 100644 --- a/src/test/perl/PostgresNode.pm +++ b/src/test/perl/PostgresNode.pm @@ -1206,20 +1206,6 @@ sub can_bind return $ret; } -# Retain the errno on die() if set, else assume a generic errno of 1. -# This will instruct the END handler on how to handle artifacts left -# behind from tests. -$SIG{__DIE__} = sub { - if ($!) - { - $died = $!; - } - else - { - $died = 1; - } -}; - # Automatically shut down any still-running nodes when the test script exits. # Note that this just stops the postmasters (in the same order the nodes were # created in). Any temporary directories are deleted, in an unspecified @@ -1238,8 +1224,7 @@ END next if defined $ENV{'PG_TEST_NOCLEAN'}; # clean basedir on clean test invocation - $node->clean_node - if TestLib::all_tests_passing() && !defined $died && !$exit_code; + $node->clean_node if $exit_code == 0 && TestLib::all_tests_passing(); } $? = $exit_code; diff --git a/src/test/perl/TestLib.pm b/src/test/perl/TestLib.pm index 458b801..65ee042 100644 --- a/src/test/perl/TestLib.pm +++ b/src/test/perl/TestLib.pm @@ -183,8 +183,13 @@ INIT END { - # Preserve temporary directory for this test on failure - $File::Temp::KEEP_ALL = 1 unless all_tests_passing(); + # Test files have several ways of causing prove_check to fail: + # 1. Exit with a non-zero status. + # 2. Call ok(0) or similar, indicating that a constituent test failed. + # 3. Deviate from the planned number of tests. + # + # Preserve temporary directories after (1) and after (2). + $File::Temp::KEEP_ALL = 1 unless $? == 0 && all_tests_passing(); } =pod --AhhlLboLdkugWU4S--