From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 6618B1F4B6 for ; Tue, 21 Mar 2023 23:07:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1679440064; bh=ZEgarDrDeKRqueDBGyQFWj0be3ZJRHaN6cIcou9fHsE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Tq87+AOVg6pXNCJqpNMHpC37yKfwz7ZwBaGonXh+lcfDCf5QcStvxwD4PnRn5FXeb dSg91apNM+JIEXbJjuo1rdKN1T7rIBQfGBkXDZFcUsNiATH6+6Qti8GrmlSnps53KE 31HcW+1YDUYySWNEigpC1RLFyd0M99MpR8kQXu0g= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 05/28] test_common: create_inbox: use `$!' properly on mkdir failure Date: Tue, 21 Mar 2023 23:07:20 +0000 Message-Id: <20230321230743.3020032-5-e@80x24.org> In-Reply-To: <20230321230743.3020032-1-e@80x24.org> References: <20230321230701.3019936-1-e@80x24.org> <20230321230743.3020032-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: stat(2) may fail and set `$!', too, so we must stash it, first. --- lib/PublicInbox/TestCommon.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/PublicInbox/TestCommon.pm b/lib/PublicInbox/TestCommon.pm index 5807105a..ed28ac48 100644 --- a/lib/PublicInbox/TestCommon.pm +++ b/lib/PublicInbox/TestCommon.pm @@ -709,9 +709,9 @@ sub create_inbox ($$;@) { my ($db) = (PublicInbox::Import::default_branch() =~ m!([^/]+)\z!); my $dir = "t/data-gen/$base.$ident-$db"; my $new = !-d $dir; - if ($new) { - mkdir $dir; # may race - -d $dir or BAIL_OUT "$dir could not be created: $!"; + if ($new && !mkdir($dir)) { + my $err = $!; + -d $dir or xbail "mkdir($dir): $err"; } my $lk = bless { lock_path => "$dir/creat.lock" }, 'PublicInbox::Lock'; $opt{inboxdir} = File::Spec->rel2abs($dir);