From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-3.9 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_NONE shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by dcvr.yhbt.net (Postfix) with ESMTP id 89CE21F462 for ; Wed, 19 Jun 2019 23:31:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730815AbfFSXbI (ORCPT ); Wed, 19 Jun 2019 19:31:08 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:37927 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730773AbfFSXbG (ORCPT ); Wed, 19 Jun 2019 19:31:06 -0400 Received: by mail-wr1-f65.google.com with SMTP id d18so1006525wrs.5 for ; Wed, 19 Jun 2019 16:31:05 -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=TFwT88Ou4kmA5D2NT2srC2pZRxzicfsioj5+5T6mZTI=; b=aQXEhZUGV0YVFtfDLiUk2GKK62zXpuCO+JdskK5Znjb/CbX9Kg6cmm5OeUr50l1gxs 0HWeb0LjbdZt6N+eKAKW1jFtD2JnqxqxUr0jDzaFLPGTk8dlQDjF5QNW99RpEakAhXOl eaxFR1ENWtXaasad135mL0FghK1Ld6PSnmIeHdgVIiM58mWUty/0PfqQIlELz4qBm/R0 pQZn5UBjtt96i1geyn0B7EtjaPZJ1UhfBhvYgPw5ISVecDYkjEVXN0ZVgWzXyEEBoFS/ OCwqPjxPcjC5SiCUJxIK6T3cosdvtrHq5HBTbe/vNpwAHXYTJ2kWNegeyiIjSKxPxqla L6+Q== 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=TFwT88Ou4kmA5D2NT2srC2pZRxzicfsioj5+5T6mZTI=; b=hbPJCH9115lsY0L/QP8npO5ML6HGPC9uKNPYR9KN7V5WSUab8v2O0qO++ceq+PySMw Q4uBdZycUMWfaa4zcPP02kAIbbiDDnb612s9p3PLyaQy9z8V9ef1K797jQfK0elqFzE+ 6azmeqqWt8qOQZxoVgFwpMvDgWUNZqNxlX7J/hevDfHjonVnepFH4vDKjf9NDCxFA9xL pgoYth+MIeYhai+1UUReQdfGW7+VQ7cykNYn5EjShF9npzAvNOKNBRaT0F4UUVF5y5FG cKmPElDLM882QhA446Q7w8Ms3BsWyq/HODUhUiGeKWkS+q3Rbr1rIsBEVz6cfMdRFM0u vQpw== X-Gm-Message-State: APjAAAWFahCrVy781h1hXHFVqX277QaXXHjuPhxZrXe/xZfZ4r8EcMqo ldDY5it7Ac+D35GzKoeLgaMlQOE+bPw= X-Google-Smtp-Source: APXvYqxmQTDqkvispXap3VdrtbMdgHSHSl9gWJn3/qroqgeDOf1xLkMJsNw9rUtzy49fFW78yXIHWA== X-Received: by 2002:adf:f84a:: with SMTP id d10mr8091256wrq.319.1560987064332; Wed, 19 Jun 2019 16:31:04 -0700 (PDT) Received: from vm.nix.is ([2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id b6sm17964958wrx.85.2019.06.19.16.31.01 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 19 Jun 2019 16:31:02 -0700 (PDT) From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= To: git@vger.kernel.org Cc: Junio C Hamano , =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= , Jeff King , =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Subject: [PATCH 6/6] tests: make GIT_TEST_FAIL_PREREQS a boolean Date: Thu, 20 Jun 2019 01:30:46 +0200 Message-Id: <20190619233046.27503-7-avarab@gmail.com> X-Mailer: git-send-email 2.22.0.rc1.257.g3120a18244 In-Reply-To: <87imt18a2r.fsf@evledraar.gmail.com> References: <87imt18a2r.fsf@evledraar.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Change the GIT_TEST_FAIL_PREREQS variable from being "non-empty?" to being a more standard boolean variable. I recently added the variable in dfe1a17df9 ("tests: add a special setup where prerequisites fail", 2019-05-13), having to add another "non-empty?" special-case is what prompted me to write the "git env--helper" utility being used here. Converting this one is a bit tricky since we use it so early and frequently in the guts of the test code itself, so let's set a GIT_TEST_FAIL_PREREQS_INTERNAL which can be tested with the old "test -n" for the purposes of the shell code, and change the user-exposed and documented GIT_TEST_FAIL_PREREQS variable to a boolean. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/README | 2 +- t/t0000-basic.sh | 10 +++++----- t/test-lib-functions.sh | 2 +- t/test-lib.sh | 25 +++++++++++++++++++++---- 4 files changed, 28 insertions(+), 11 deletions(-) diff --git a/t/README b/t/README index 072c9854d1..60d5b77bcc 100644 --- a/t/README +++ b/t/README @@ -334,7 +334,7 @@ that cannot be easily covered by a few specific test cases. These could be enabled by running the test suite with correct GIT_TEST_ environment set. -GIT_TEST_FAIL_PREREQS fails all prerequisites. This is +GIT_TEST_FAIL_PREREQS= fails all prerequisites. This is useful for discovering issues with the tests where say a later test implicitly depends on an optional earlier test. diff --git a/t/t0000-basic.sh b/t/t0000-basic.sh index 31de7e90f3..e89438e619 100755 --- a/t/t0000-basic.sh +++ b/t/t0000-basic.sh @@ -726,7 +726,7 @@ donthaveit=yes test_expect_success DONTHAVEIT 'unmet prerequisite causes test to be skipped' ' donthaveit=no ' -if test -z "$GIT_TEST_FAIL_PREREQS" -a $haveit$donthaveit != yesyes +if test -z "$GIT_TEST_FAIL_PREREQS_INTERNAL" -a $haveit$donthaveit != yesyes then say "bug in test framework: prerequisite tags do not work reliably" exit 1 @@ -747,7 +747,7 @@ donthaveiteither=yes test_expect_success DONTHAVEIT,HAVEIT 'unmet prerequisites causes test to be skipped' ' donthaveiteither=no ' -if test -z "$GIT_TEST_FAIL_PREREQS" -a $haveit$donthaveit$donthaveiteither != yesyesyes +if test -z "$GIT_TEST_FAIL_PREREQS_INTERNAL" -a $haveit$donthaveit$donthaveiteither != yesyesyes then say "bug in test framework: multiple prerequisite tags do not work reliably" exit 1 @@ -763,7 +763,7 @@ test_expect_success !LAZY_TRUE 'missing lazy prereqs skip tests' ' donthavetrue=no ' -if test -z "$GIT_TEST_FAIL_PREREQS" -a "$havetrue$donthavetrue" != yesyes +if test -z "$GIT_TEST_FAIL_PREREQS_INTERNAL" -a "$havetrue$donthavetrue" != yesyes then say 'bug in test framework: lazy prerequisites do not work' exit 1 @@ -779,7 +779,7 @@ test_expect_success LAZY_FALSE 'missing negative lazy prereqs will skip' ' havefalse=no ' -if test -z "$GIT_TEST_FAIL_PREREQS" -a "$nothavefalse$havefalse" != yesyes +if test -z "$GIT_TEST_FAIL_PREREQS_INTERNAL" -a "$nothavefalse$havefalse" != yesyes then say 'bug in test framework: negative lazy prerequisites do not work' exit 1 @@ -790,7 +790,7 @@ test_expect_success 'tests clean up after themselves' ' test_when_finished clean=yes ' -if test -z "$GIT_TEST_FAIL_PREREQS" -a $clean != yes +if test -z "$GIT_TEST_FAIL_PREREQS_INTERNAL" -a $clean != yes then say "bug in test framework: basic cleanup command does not work reliably" exit 1 diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh index 527508c350..3fba71c358 100644 --- a/t/test-lib-functions.sh +++ b/t/test-lib-functions.sh @@ -309,7 +309,7 @@ test_unset_prereq () { } test_set_prereq () { - if test -n "$GIT_TEST_FAIL_PREREQS" + if test -n "$GIT_TEST_FAIL_PREREQS_INTERNAL" then case "$1" in # The "!" case is handled below with diff --git a/t/test-lib.sh b/t/test-lib.sh index bdd5017d24..552461435e 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -1389,6 +1389,27 @@ yes () { done } +# The GIT_TEST_FAIL_PREREQS code hooks into test_set_prereq(), and +# thus needs to be set up really early, and set an internal variable +# for convenience so the hot test_set_prereq() codepath doesn't need +# to call "git env--helper". Only do that work if needed by seeing if +# GIT_TEST_FAIL_PREREQS is set at all. +GIT_TEST_FAIL_PREREQS_INTERNAL= +if test -n "$GIT_TEST_FAIL_PREREQS" +then + if git env--helper --mode-bool --variable=GIT_TEST_FAIL_PREREQS \ + --default=0 --exit-code --quiet + then + GIT_TEST_FAIL_PREREQS_INTERNAL=true + test_set_prereq FAIL_PREREQS + fi +else + test_lazy_prereq FAIL_PREREQS ' + git env--helper --mode-bool --variable=GIT_TEST_FAIL_PREREQS \ + --default=0 --exit-code --quiet + ' +fi + # Fix some commands on Windows uname_s=$(uname -s) case $uname_s in @@ -1611,7 +1632,3 @@ test_lazy_prereq SHA1 ' test_lazy_prereq REBASE_P ' test -z "$GIT_TEST_SKIP_REBASE_P" ' - -test_lazy_prereq FAIL_PREREQS ' - test -n "$GIT_TEST_FAIL_PREREQS" -' -- 2.22.0.rc1.257.g3120a18244