From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 75634C43460 for ; Sat, 17 Apr 2021 12:54:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 527B6611EF for ; Sat, 17 Apr 2021 12:54:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236432AbhDQMyu (ORCPT ); Sat, 17 Apr 2021 08:54:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54968 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236504AbhDQMyH (ORCPT ); Sat, 17 Apr 2021 08:54:07 -0400 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32BCEC06175F for ; Sat, 17 Apr 2021 05:53:39 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id t14-20020a05600c198eb029012eeb3edfaeso5583861wmq.2 for ; Sat, 17 Apr 2021 05:53:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Ta0evuThQTg4M29M3hH4CZg0VXdOqAv39Nqv+90n7ds=; b=ky/sRrtdmrrl4/BLwuN/JNUWp/PRTfjjyG0amZ90lebBM+2AjH1Wvepxle1GbGH5o1 vibdx6hAqbET7+Yc7XodwYqev/TK91ZTodBHotzZjhfQK4q8pcv+iZto9vmTSefWyhoU 7peqFCET2U5je7P4uwJfXh5wV+4ufFoML5kGfNYDYLA8W285szOp0jFMxU6CdN8JCXec j5gSNxHoe+w0023MCALW3lsUY1hmxdi2vV2s78T9FM0XyzkVxlntGXR67BXprghyQ5A8 8mWrGgz9drSfXJmM2X5vVWTEDWaCdIoVrpGIOu9efclMLTql2WwpFpSeK6Adesfnhao4 gHvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Ta0evuThQTg4M29M3hH4CZg0VXdOqAv39Nqv+90n7ds=; b=mit4fvJd8Me9xiEMrvb7VAVVbDrdxAOWifA+jyY2i7KDURoLM+g/akotyuybEHA6sO DE4VsJvFkOpt0ILa5dEE8VAlh5au4AAU7m3DJ9ztlYGvCSIE3oEhfhniPBJzPKkgA3lb TLdPkB+LKVXhPveJHuYJhOTgPLjwTyj0mvZUV10zT5CwSvnU5/fCzSY/czGA97mHKp7z whxpwXk/NaVCl6BzpjtzcJkruziWF1bzi+pAX0NIlIOmG7yTECMqQ3YufjQWZYEL4NrG e9AdDwMBllumRqsEEYtlGO/s2VuJFlABgvbHMUHwCuXPxXLefMOiYU0KPx8Rp0sW4gm0 8rZQ== X-Gm-Message-State: AOAM530neX+ixcasseYQX7lwunWZeeEAvJXZzq/ko78433L3sFyTku0q FlMrRZMN7obXaW6+XmSaY9hCCPZdrnqg9A== X-Google-Smtp-Source: ABdhPJzPwEWAGp40JUJ+5lrrqF/knDTi5QD7YpbrxyvNlc0KXSHGN8u+iL4cBZ3lYZTqwOXTiPgwjQ== X-Received: by 2002:a1c:b007:: with SMTP id z7mr12572071wme.14.1618664017684; Sat, 17 Apr 2021 05:53:37 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id v4sm11594529wme.14.2021.04.17.05.53.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Apr 2021 05:53:37 -0700 (PDT) From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Matthieu Moy , Johannes Schindelin , Eric Sunshine , =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?= , =?UTF-8?q?SZEDER=20G=C3=A1bor?= , =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Subject: [PATCH v2 02/12] test-lib: bring $remove_trash out of retirement Date: Sat, 17 Apr 2021 14:52:35 +0200 Message-Id: X-Mailer: git-send-email 2.31.1.722.g788886f50a2 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org There's no point in creating a repository or directory only to decide right afterwards that we're skipping all the tests. We can save ourselves the redundant "git init" or "mkdir" and "rm -rf" in this case. We carry around the "$remove_trash" variable because if the directory is unexpectedly gone at test_done time we'll hit the error about it being unexpectedly gone added in df4c0d1a792 (test-lib: abort when can't remove trash directory, 2017-04-20). So let's partially revert 06478dab4c (test-lib: retire $remove_trash variable, 2017-04-23) and move the decision about whether to skip all tests earlier. I tested this with --debug, see 4d0912a206 (test-lib.sh: do not barf under --debug at the end of the test, 2017-04-24) for a bug we don't want to re-introduce. While I'm at it let's move the HOME assignment to just before test_create_repo, it could be lower, but it seems better to set it before calling anything in test-lib-functions.sh Signed-off-by: Ævar Arnfjörð Bjarmason --- t/test-lib.sh | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/t/test-lib.sh b/t/test-lib.sh index 3dec266221c..7522faf39fc 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -1169,7 +1169,7 @@ test_done () { esac fi - if test -z "$debug" + if test -z "$debug" && test -n "$remove_trash" then test -d "$TRASH_DIRECTORY" || error "Tests passed but trash directory already removed before test cleanup; aborting" @@ -1334,6 +1334,21 @@ then exit 1 fi +# Are we running this test at all? +this_test=${0##*/} +this_test=${this_test%%-*} +if match_pattern_list "$this_test" $GIT_SKIP_TESTS +then + say_color info >&3 "skipping test $this_test altogether" + skip_all="skip all tests in $this_test" + test_done +fi + +# Last-minute variable setup +HOME="$TRASH_DIRECTORY" +GNUPGHOME="$HOME/gnupg-home-not-used" +export HOME GNUPGHOME + # Test repository rm -fr "$TRASH_DIRECTORY" || { GIT_EXIT_OK=t @@ -1341,10 +1356,7 @@ rm -fr "$TRASH_DIRECTORY" || { exit 1 } -HOME="$TRASH_DIRECTORY" -GNUPGHOME="$HOME/gnupg-home-not-used" -export HOME GNUPGHOME - +remove_trash=t if test -z "$TEST_NO_CREATE_REPO" then test_create_repo "$TRASH_DIRECTORY" @@ -1356,15 +1368,6 @@ fi # in subprocesses like git equals our $PWD (for pathname comparisons). cd -P "$TRASH_DIRECTORY" || exit 1 -this_test=${0##*/} -this_test=${this_test%%-*} -if match_pattern_list "$this_test" $GIT_SKIP_TESTS -then - say_color info >&3 "skipping test $this_test altogether" - skip_all="skip all tests in $this_test" - test_done -fi - if test -n "$write_junit_xml" then junit_xml_dir="$TEST_OUTPUT_DIRECTORY/out" -- 2.31.1.722.g788886f50a2