From patchwork Wed Jun 19 23:30:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 11005567 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 87DFE6C5 for ; Wed, 19 Jun 2019 23:31:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 772E6288BF for ; Wed, 19 Jun 2019 23:31:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6B214288CF; Wed, 19 Jun 2019 23:31:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A4179288BF for ; Wed, 19 Jun 2019 23:31:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730574AbfFSXbA (ORCPT ); Wed, 19 Jun 2019 19:31:00 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:42384 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726449AbfFSXa7 (ORCPT ); Wed, 19 Jun 2019 19:30:59 -0400 Received: by mail-wr1-f66.google.com with SMTP id x17so976802wrl.9 for ; Wed, 19 Jun 2019 16:30:57 -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=M/N0FFdhLsCZdzMrct+e0qucb1zPCPfXo+LSpLrbh7k=; b=dtfWNpLm2P49E/D7W+4dkXX7reQoqqvxbkX14teCSG0riEzua1+v5Zk0mRE2JDNM6V e2MDDA2gpDIq5cmVzbQLHqO7djR3DI34WmWsib+3etjlIBGR4814fSl1Foy3rVxJXX2B s4ZmgpbgzPus8jTzBnBNvHqu+aqJZ4TAfOLpS4T5lYhbe11NYVp3QYH6WHSBPhzA6tXY w5kahDzL5UuwtnzCMjAFZj1yo3B6b3XnkjfsLO5gtBMFM8sh9x3V0UFfQHACAApehUDH 1jt4d9Kg+nisdUvDIKWjOTNzmXVM18kqQJtMF1K9N2buPg9e+l+RqxJGNwJEhjiE/1rj zchg== 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=M/N0FFdhLsCZdzMrct+e0qucb1zPCPfXo+LSpLrbh7k=; b=BQqFYmaN6SQuOLFCWm9xaw2IedPoI7RZGqnph5idznIfP3IYPkATnP9LFs/4EMMjO9 f3+1M1WApsXneKABx4sFGRT4FXAmWUiM7OT5Fr05K5yEkY5CU4bZpVzeIkSYTipA5kVM oYOLEefe+xXgJB1mnOwEroCisa1JyKOmo9xkuhr4rTCrUDG/WG7ZifNz8CrzcW/0LOVv klVP67uROGgWT7Hycj+q5raQ5ASldgz2ontdATIb2IUQC3N78UuhWcbR6AFnWlxoBnaK 0PO512exvVdPAeGThvQHzut5gIzWqrL9fr/Hg4pX19hYWHIqt3MkvLmBfi8FPTkqmv5D 4l5Q== X-Gm-Message-State: APjAAAWBjxGHpB2sEg/WeH0rR5u0FzBihW1dTLKfrlCZ+wcEMN+tNc4q w41fPqH54gnXu3aRHZZ7LYPlg1EM3Zw= X-Google-Smtp-Source: APXvYqx6mGO0BG/bZirIwl/QkZtcrut0QJ6pj0fucSkWoe/W/P0L65+gwWGd5cG78qZzyq/+LlK/BA== X-Received: by 2002:adf:fb8a:: with SMTP id a10mr11796002wrr.235.1560987056543; Wed, 19 Jun 2019 16:30:56 -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.30.55 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 19 Jun 2019 16:30:56 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmc=?= =?utf-8?b?4buNYyBEdXk=?= , Jeff King , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH 1/6] env--helper: new undocumented builtin wrapping git_env_*() Date: Thu, 20 Jun 2019 01:30:41 +0200 Message-Id: <20190619233046.27503-2-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 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We have many GIT_TEST_* variables that accept a because they're implemented in C, and then some that take because they're implemented at least partially in shellscript. Add a helper that wraps git_env_bool() and git_env_ulong() as the first step in fixing this. This isn't being added as a test-tool mode because some of these are used outside the test suite. Part of what this tool does can be done via a trick with "git config" added in 83d842dc8c ("tests: turn on network daemon tests by default", 2014-02-10) for test_tristate(), i.e.: git -c magic.variable="$1" config --bool magic.variable 2>/dev/null But as subsequent changes will show being able to pass along the default value makes all the difference, and we'll be able to replace test_tristate() itself with that. The --mode-bool option will be used by subsequent patches, but not --mode-ulong. I figured it was easy enough to add it & test for it so I left it in so we'd have wrappers for both git_env_*() functions. Signed-off-by: Ævar Arnfjörð Bjarmason --- .gitignore | 1 + Makefile | 1 + builtin.h | 1 + builtin/env--helper.c | 74 +++++++++++++++++++++++++++++++++++++++++++ git.c | 1 + t/t0016-env-helper.sh | 70 ++++++++++++++++++++++++++++++++++++++++ 6 files changed, 148 insertions(+) create mode 100644 builtin/env--helper.c create mode 100755 t/t0016-env-helper.sh diff --git a/.gitignore b/.gitignore index 4470d7cfc0..1f7a83fb3c 100644 --- a/.gitignore +++ b/.gitignore @@ -58,6 +58,7 @@ /git-difftool /git-difftool--helper /git-describe +/git-env--helper /git-fast-export /git-fast-import /git-fetch diff --git a/Makefile b/Makefile index f58bf14c7b..f2cfc8d812 100644 --- a/Makefile +++ b/Makefile @@ -1059,6 +1059,7 @@ BUILTIN_OBJS += builtin/diff-index.o BUILTIN_OBJS += builtin/diff-tree.o BUILTIN_OBJS += builtin/diff.o BUILTIN_OBJS += builtin/difftool.o +BUILTIN_OBJS += builtin/env--helper.o BUILTIN_OBJS += builtin/fast-export.o BUILTIN_OBJS += builtin/fetch-pack.o BUILTIN_OBJS += builtin/fetch.o diff --git a/builtin.h b/builtin.h index ec7e0954c4..93bd49fe4f 100644 --- a/builtin.h +++ b/builtin.h @@ -160,6 +160,7 @@ int cmd_diff_index(int argc, const char **argv, const char *prefix); int cmd_diff(int argc, const char **argv, const char *prefix); int cmd_diff_tree(int argc, const char **argv, const char *prefix); int cmd_difftool(int argc, const char **argv, const char *prefix); +int cmd_env__helper(int argc, const char **argv, const char *prefix); int cmd_fast_export(int argc, const char **argv, const char *prefix); int cmd_fetch(int argc, const char **argv, const char *prefix); int cmd_fetch_pack(int argc, const char **argv, const char *prefix); diff --git a/builtin/env--helper.c b/builtin/env--helper.c new file mode 100644 index 0000000000..2bb65ecf3f --- /dev/null +++ b/builtin/env--helper.c @@ -0,0 +1,74 @@ +#include "builtin.h" +#include "config.h" +#include "parse-options.h" + +static char const * const env__helper_usage[] = { + N_("git env--helper [--mode-bool | --mode-ulong] --env-variable= --env-default= []"), + NULL +}; + +int cmd_env__helper(int argc, const char **argv, const char *prefix) +{ + enum { + ENV_HELPER_BOOL = 1, + ENV_HELPER_ULONG, + } cmdmode = 0; + int exit_code = 0; + int quiet = 0; + const char *env_variable = NULL; + const char *env_default = NULL; + int ret; + int ret_int, tmp_int; + unsigned long ret_ulong, tmp_ulong; + struct option opts[] = { + OPT_CMDMODE(0, "mode-bool", &cmdmode, + N_("invoke git_env_bool(...)"), ENV_HELPER_BOOL), + OPT_CMDMODE(0, "mode-ulong", &cmdmode, + N_("invoke git_env_ulong(...)"), ENV_HELPER_ULONG), + OPT_STRING(0, "variable", &env_variable, N_("name"), + N_("which environment variable to ask git_env_*(...) about")), + OPT_STRING(0, "default", &env_default, N_("value"), + N_("what default value does git_env_*(...) fall back on?")), + OPT_BOOL(0, "exit-code", &exit_code, + N_("exit code determined by truth of the git_env_*() function")), + OPT_BOOL(0, "quiet", &quiet, + N_("don't print the git_env_*() return value")), + OPT_END(), + }; + + if (parse_options(argc, argv, prefix, opts, env__helper_usage, 0)) + usage_with_options(env__helper_usage, opts); + if (!env_variable || !env_default || + !*env_variable || !*env_default) + usage_with_options(env__helper_usage, opts); + + switch (cmdmode) { + case ENV_HELPER_BOOL: + tmp_int = strtol(env_default, (char **)&env_default, 10); + if (*env_default) { + error(_("option `--default' expects a numerical value with `--mode-bool`")); + usage_with_options(env__helper_usage, opts); + } + ret_int = git_env_bool(env_variable, tmp_int); + if (!quiet) + printf("%d\n", ret_int); + ret = ret_int; + break; + case ENV_HELPER_ULONG: + tmp_ulong = strtoll(env_default, (char **)&env_default, 10); + if (*env_default) { + error(_("option `--default' expects a numerical value with `--mode-ulong`")); + usage_with_options(env__helper_usage, opts); + } + ret_ulong = git_env_ulong(env_variable, tmp_ulong); + if (!quiet) + printf("%lu\n", ret_ulong); + ret = ret_ulong; + break; + } + + if (exit_code) + return !ret; + + return 0; +} diff --git a/git.c b/git.c index c2eec470c9..a43e1dd98e 100644 --- a/git.c +++ b/git.c @@ -500,6 +500,7 @@ static struct cmd_struct commands[] = { { "diff-index", cmd_diff_index, RUN_SETUP | NO_PARSEOPT }, { "diff-tree", cmd_diff_tree, RUN_SETUP | NO_PARSEOPT }, { "difftool", cmd_difftool, RUN_SETUP_GENTLY }, + { "env--helper", cmd_env__helper }, { "fast-export", cmd_fast_export, RUN_SETUP }, { "fetch", cmd_fetch, RUN_SETUP }, { "fetch-pack", cmd_fetch_pack, RUN_SETUP | NO_PARSEOPT }, diff --git a/t/t0016-env-helper.sh b/t/t0016-env-helper.sh new file mode 100755 index 0000000000..4dc4ab35e5 --- /dev/null +++ b/t/t0016-env-helper.sh @@ -0,0 +1,70 @@ +#!/bin/sh + +test_description='test env--helper' + +. ./test-lib.sh + + +test_expect_success 'env--helper usage' ' + test_must_fail git env--helper && + test_must_fail git env--helper --mode-bool && + test_must_fail git env--helper --mode-ulong && + test_must_fail git env--helper --mode-bool --variable && + test_must_fail git env--helper --mode-bool --variable --default && + test_must_fail git env--helper --mode-bool --variable= --default= +' + +test_expect_success 'env--helper bad default values' ' + test_must_fail git env--helper --mode-bool --variable=MISSING --default=1xyz && + test_must_fail git env--helper --mode-ulong --variable=MISSING --default=1xyz +' + +test_expect_success 'env--helper --mode-bool' ' + echo 1 >expected && + git env--helper --mode-bool --variable=MISSING --default=1 --exit-code >actual && + test_cmp expected actual && + + echo 0 >expected && + test_must_fail git env--helper --mode-bool --variable=MISSING --default=0 --exit-code >actual && + test_cmp expected actual && + + git env--helper --mode-bool --variable=MISSING --default=0 >actual && + test_cmp expected actual && + + >expected && + git env--helper --mode-bool --variable=MISSING --default=1 --exit-code --quiet >actual && + test_cmp expected actual && + + EXISTS=true git env--helper --mode-bool --variable=EXISTS --default=0 --exit-code --quiet >actual && + test_cmp expected actual && + + echo 1 >expected && + EXISTS=true git env--helper --mode-bool --variable=EXISTS --default=0 --exit-code >actual && + test_cmp expected actual +' + +test_expect_success 'env--helper --mode-ulong' ' + echo 1234567890 >expected && + git env--helper --mode-ulong --variable=MISSING --default=1234567890 --exit-code >actual && + test_cmp expected actual && + + echo 0 >expected && + test_must_fail git env--helper --mode-ulong --variable=MISSING --default=0 --exit-code >actual && + test_cmp expected actual && + + git env--helper --mode-ulong --variable=MISSING --default=0 >actual && + test_cmp expected actual && + + >expected && + git env--helper --mode-ulong --variable=MISSING --default=1234567890 --exit-code --quiet >actual && + test_cmp expected actual && + + EXISTS=1234567890 git env--helper --mode-ulong --variable=EXISTS --default=0 --exit-code --quiet >actual && + test_cmp expected actual && + + echo 1234567890 >expected && + EXISTS=1234567890 git env--helper --mode-ulong --variable=EXISTS --default=0 --exit-code >actual && + test_cmp expected actual +' + +test_done From patchwork Wed Jun 19 23:30:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 11005569 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A000D6C5 for ; Wed, 19 Jun 2019 23:31:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8C6D7288BF for ; Wed, 19 Jun 2019 23:31:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 72A2B288DC; Wed, 19 Jun 2019 23:31:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 14F49288BF for ; Wed, 19 Jun 2019 23:31:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730737AbfFSXbC (ORCPT ); Wed, 19 Jun 2019 19:31:02 -0400 Received: from mail-wm1-f68.google.com ([209.85.128.68]:56115 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730020AbfFSXbB (ORCPT ); Wed, 19 Jun 2019 19:31:01 -0400 Received: by mail-wm1-f68.google.com with SMTP id a15so1120184wmj.5 for ; Wed, 19 Jun 2019 16:30:59 -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=XNlwNqzb2uqwts4IqSXDpS9jIjO0Dc9DfjH1LrnRNVg=; b=tLOzfb1qzYXOTS8QJflYRbqhCAjnWDacI4pLhYiJqb28x/5Hdhn+93pH0t/ad/6BOb NFFE19YA38aRZvbkU0RDs4xvF258eD8gMLwfNrH8xKZttbkb8kCUpvZEJudTSy6OqAg2 9FAs9HBMWVHY2vrCtI2BF/gBDJjc06ezeYY8X91GPuKVTDSO80ebF411f+bTEbMgXH0Q kjmtHu4N6+HyxEQPTTDOS9Ocdq+gUG+qw2xKYt6+7pAg4l4p0OVmmQMv84Q/NRIiEx3F CPmtbx00bpZ5AlWqpCZvRUwQ7cLAyUaQ7v8QdR79P2SVEK9tth5/8NE+kgF84stw+Pr+ I0IQ== 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=XNlwNqzb2uqwts4IqSXDpS9jIjO0Dc9DfjH1LrnRNVg=; b=V6gsILHpyvCwbQfA0G7Sh6bxrIn7I4lIzSh9slpMyXO0LASe6ZuLDmYqpZLLjZAaJz /DeMuZQsHSJRsKLXDpj9NMFv04VNgj6Qcv+e8cqPajpUZUOtNM/Y01fdNT+mufRMU+ED rY51rlSpWpeKCTeNiAW8hUL4LjF/3AIH99ttrz1OvnD6A0PnjlnBCIaCnQHJYBRLZHyu EfItKZm818CBdRzF5NhyXy/wal/+3+2sFw6oJ1vWX4SXk3C9al0a08rwO86zgpjcUZ1y syOFsQOPIcDiyDQQpKAkGMulf72xUsG6dvSGZZXfnIt23NiL+M9lttrK45xoaQqATdWy PW7Q== X-Gm-Message-State: APjAAAWTv1nUfwiqDbdbmhWOYwj879h3irTKRgoEDzFgXpLzpEGocoiB MmiGL3uimuwV+REOB6ab8YIXjswjwFk= X-Google-Smtp-Source: APXvYqww1NjcaspSWDvAcqYf1mZL0nO7HqPXgd+0KkLaPeJL95fW/NdvUoc+qES4kBe70u22RMOF8w== X-Received: by 2002:a1c:a709:: with SMTP id q9mr9699784wme.22.1560987058393; Wed, 19 Jun 2019 16:30:58 -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.30.56 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 19 Jun 2019 16:30:56 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmc=?= =?utf-8?b?4buNYyBEdXk=?= , Jeff King , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH 2/6] t6040 test: stop using global "script" variable Date: Thu, 20 Jun 2019 01:30:42 +0200 Message-Id: <20190619233046.27503-3-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 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Change test code added in c0234b2ef6 ("stat_tracking_info(): clear object flags used during counting", 2008-07-03) to stop using the "script" variable also used for lazy prerequisites in test-lib-functions.sh. Since this test uses test_i18ncmp and expects to use its own "script" variable twice it implicitly depends on the C_LOCALE_OUTPUT prerequisite not being a lazy prerequisite. A follow-up change will make it a lazy prerequisite, so we must remove this landmine before inadvertently stepping on it as we make that change. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/t6040-tracking-info.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/t/t6040-tracking-info.sh b/t/t6040-tracking-info.sh index 716283b274..970b25a289 100755 --- a/t/t6040-tracking-info.sh +++ b/t/t6040-tracking-info.sh @@ -38,7 +38,7 @@ test_expect_success setup ' advance h ' -script='s/^..\(b.\) *[0-9a-f]* \(.*\)$/\1 \2/p' +t6040_script='s/^..\(b.\) *[0-9a-f]* \(.*\)$/\1 \2/p' cat >expect <<\EOF b1 [ahead 1, behind 1] d b2 [ahead 1, behind 1] d @@ -53,7 +53,7 @@ test_expect_success 'branch -v' ' cd test && git branch -v ) | - sed -n -e "$script" >actual && + sed -n -e "$t6040_script" >actual && test_i18ncmp expect actual ' @@ -71,7 +71,7 @@ test_expect_success 'branch -vv' ' cd test && git branch -vv ) | - sed -n -e "$script" >actual && + sed -n -e "$t6040_script" >actual && test_i18ncmp expect actual ' From patchwork Wed Jun 19 23:30:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 11005571 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 793BF76 for ; Wed, 19 Jun 2019 23:31:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6951C288BF for ; Wed, 19 Jun 2019 23:31:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5CBE3288CF; Wed, 19 Jun 2019 23:31:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 37FC9288BF for ; Wed, 19 Jun 2019 23:31:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730752AbfFSXbD (ORCPT ); Wed, 19 Jun 2019 19:31:03 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:51522 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726251AbfFSXbC (ORCPT ); Wed, 19 Jun 2019 19:31:02 -0400 Received: by mail-wm1-f65.google.com with SMTP id 207so1154724wma.1 for ; Wed, 19 Jun 2019 16:31:00 -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=2r0LoHBcuAqe3Ep064Vuw4tbEOXpx407y731AQr6j1w=; b=FGDi21IyVRSCVJmAPRu1el6+VmVTGU6mZzOmrpvqJZKFu57O+ih/QUXLvuVWiRmnMC PBIFyaLElSPz8/1e2IXFdv4nqYK/18l00U/9QgJV466zMdJCvOOjsyxJbsQFvRYF/oTb kaMBrgVpBo48W7tmTQ50ZAOYv7QqIxxqi+Gk6FpwubXMKqWre/4NZy46wOD6Y/V0ZzrS EcVrbGC7ePuqH7ViR9HL5nOfW3QESM44Y6L1hgBk2UyvmDWE5dkPoBJEZstsyzBxADve no0fCN71eUVYESiyzwU5RGWo9ZUg282+GFFzgO8ITB9wSoCGZbLRDA0Ro5MvM4jh9+5D qUfw== 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=2r0LoHBcuAqe3Ep064Vuw4tbEOXpx407y731AQr6j1w=; b=X0EyLkGk2f5U57K5XMxmsopFTJgu3zmSHvnlBV9aFHaOXdaLUF+jmMS/WrEnO4Mc/B LEHwJT2OPZG+zLVcjGaJy0IfbnlXupbaIQacfyDprnt0PcbUjTLNpNDdiTrQqV0oBMrp Mp3SPJc3LGWJGb6PHov3TPQlJKHWEordLV0a5by3hpPy+yzIj61pmmNKCD5l60qYoViy xnsk+ukJ89t8EDgHpou5dKQqJ1UpCV9mL5CYKi/BA4ECJ7vMV5g9aRpmr1Lr2o+oDwj+ sw5DkaXHWeamw2wYJQcrfUnjANlqWjlHbsWNYqOxZkKK+Fnm93Hhtg5nCWUlTi1uCtc5 8Jdw== X-Gm-Message-State: APjAAAUPnfbWfjs3vKTXdwJjsyyPUhIwQ4MC5f9oHdzQZc544JwFlgmn Aj15MFglDwHNX5lOG6DNynRazDH2O9Y= X-Google-Smtp-Source: APXvYqzVwfoNw3ie+gfkFRmDE7zN6D9meruZGzqRL75dpfg34p63xTSe9fIhPAhDL4BNzxV9iYAy8Q== X-Received: by 2002:a1c:3942:: with SMTP id g63mr9040901wma.61.1560987059555; Wed, 19 Jun 2019 16:30:59 -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.30.58 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 19 Jun 2019 16:30:58 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmc=?= =?utf-8?b?4buNYyBEdXk=?= , Jeff King , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH 3/6] tests: make GIT_TEST_GETTEXT_POISON a boolean Date: Thu, 20 Jun 2019 01:30:43 +0200 Message-Id: <20190619233046.27503-4-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 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Change the GIT_TEST_GETTEXT_POISON variable from being "non-empty?" to being a more standard boolean variable. Since it needed to be checked in both C code and shellscript (via test -n) it was one of the remaining shellscript-like variables. Now that we have "git env--helper" we can change that. Signed-off-by: Ævar Arnfjörð Bjarmason --- ci/lib.sh | 2 +- gettext.c | 6 ++---- git-sh-i18n.sh | 4 +++- po/README | 2 +- t/README | 4 ++-- t/t0205-gettext-poison.sh | 2 +- t/t7201-co.sh | 2 +- t/t9902-completion.sh | 2 +- t/test-lib.sh | 4 ++++ 9 files changed, 16 insertions(+), 12 deletions(-) diff --git a/ci/lib.sh b/ci/lib.sh index 288a5b3884..fd799ae663 100755 --- a/ci/lib.sh +++ b/ci/lib.sh @@ -184,7 +184,7 @@ osx-clang|osx-gcc) export GIT_SKIP_TESTS="t9810 t9816" ;; GIT_TEST_GETTEXT_POISON) - export GIT_TEST_GETTEXT_POISON=YesPlease + export GIT_TEST_GETTEXT_POISON=true ;; esac diff --git a/gettext.c b/gettext.c index d4021d690c..5c71f4c8b9 100644 --- a/gettext.c +++ b/gettext.c @@ -50,10 +50,8 @@ const char *get_preferred_languages(void) int use_gettext_poison(void) { static int poison_requested = -1; - if (poison_requested == -1) { - const char *v = getenv("GIT_TEST_GETTEXT_POISON"); - poison_requested = v && strlen(v) ? 1 : 0; - } + if (poison_requested == -1) + poison_requested = git_env_bool("GIT_TEST_GETTEXT_POISON", 0); return poison_requested; } diff --git a/git-sh-i18n.sh b/git-sh-i18n.sh index e1d917fd27..de8ae67d7b 100644 --- a/git-sh-i18n.sh +++ b/git-sh-i18n.sh @@ -17,7 +17,9 @@ export TEXTDOMAINDIR # First decide what scheme to use... GIT_INTERNAL_GETTEXT_SH_SCHEME=fallthrough -if test -n "$GIT_TEST_GETTEXT_POISON" +if test -n "$GIT_TEST_GETTEXT_POISON" && + git env--helper --mode-bool --variable=GIT_TEST_GETTEXT_POISON \ + --default=0 --exit-code --quiet then GIT_INTERNAL_GETTEXT_SH_SCHEME=poison elif test -n "@@USE_GETTEXT_SCHEME@@" diff --git a/po/README b/po/README index aa704ffcb7..07595d369b 100644 --- a/po/README +++ b/po/README @@ -293,7 +293,7 @@ To smoke out issues like these, Git tested with a translation mode that emits gibberish on every call to gettext. To use it run the test suite with it, e.g.: - cd t && GIT_TEST_GETTEXT_POISON=YesPlease prove -j 9 ./t[0-9]*.sh + cd t && GIT_TEST_GETTEXT_POISON=true prove -j 9 ./t[0-9]*.sh If tests break with it you should inspect them manually and see if what you're translating is sane, i.e. that you're not translating diff --git a/t/README b/t/README index 9747971d58..9a131f472e 100644 --- a/t/README +++ b/t/README @@ -343,8 +343,8 @@ whether this mode is active, and e.g. skip some tests that are hard to refactor to deal with it. The "SYMLINKS" prerequisite is currently excluded as so much relies on it, but this might change in the future. -GIT_TEST_GETTEXT_POISON= turns all strings marked for -translation into gibberish if non-empty (think "test -n"). Used for +GIT_TEST_GETTEXT_POISON= turns all strings marked for +translation into gibberish if true. Used for spotting those tests that need to be marked with a C_LOCALE_OUTPUT prerequisite when adding more strings for translation. See "Testing marked strings" in po/README for details. diff --git a/t/t0205-gettext-poison.sh b/t/t0205-gettext-poison.sh index a06269f38a..1675d3e171 100755 --- a/t/t0205-gettext-poison.sh +++ b/t/t0205-gettext-poison.sh @@ -5,7 +5,7 @@ test_description='Gettext Shell poison' -GIT_TEST_GETTEXT_POISON=YesPlease +GIT_TEST_GETTEXT_POISON=true export GIT_TEST_GETTEXT_POISON . ./lib-gettext.sh diff --git a/t/t7201-co.sh b/t/t7201-co.sh index 5990299fc9..b696bae5f5 100755 --- a/t/t7201-co.sh +++ b/t/t7201-co.sh @@ -249,7 +249,7 @@ test_expect_success 'checkout to detach HEAD (with advice declined)' ' test_expect_success 'checkout to detach HEAD' ' git config advice.detachedHead true && git checkout -f renamer && git clean -f && - GIT_TEST_GETTEXT_POISON= git checkout renamer^ 2>messages && + GIT_TEST_GETTEXT_POISON=false git checkout renamer^ 2>messages && grep "HEAD is now at 7329388" messages && test_line_count -gt 1 messages && H=$(git rev-parse --verify HEAD) && diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh index 43cf313a1c..75512c3403 100755 --- a/t/t9902-completion.sh +++ b/t/t9902-completion.sh @@ -1706,7 +1706,7 @@ test_expect_success 'sourcing the completion script clears cached commands' ' ' test_expect_success 'sourcing the completion script clears cached merge strategies' ' - GIT_TEST_GETTEXT_POISON= && + GIT_TEST_GETTEXT_POISON=false && __git_compute_merge_strategies && verbose test -n "$__git_merge_strategies" && . "$GIT_BUILD_DIR/contrib/completion/git-completion.bash" && diff --git a/t/test-lib.sh b/t/test-lib.sh index 4b346467df..bdd5017d24 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -1443,6 +1443,10 @@ then unset GIT_TEST_GETTEXT_POISON_ORIG fi +test_lazy_prereq C_LOCALE_OUTPUT ' + ! git env--helper --mode-bool --variable=GIT_TEST_GETTEXT_POISON --default=0 --exit-code --quiet +' + # Can we rely on git's output in the C locale? if test -z "$GIT_TEST_GETTEXT_POISON" then From patchwork Wed Jun 19 23:30:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 11005575 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E83AE1580 for ; Wed, 19 Jun 2019 23:31:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D80E2288BF for ; Wed, 19 Jun 2019 23:31:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CC28C288C6; Wed, 19 Jun 2019 23:31:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7DCB0288D2 for ; Wed, 19 Jun 2019 23:31:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730785AbfFSXbF (ORCPT ); Wed, 19 Jun 2019 19:31:05 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:33749 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730730AbfFSXbD (ORCPT ); Wed, 19 Jun 2019 19:31:03 -0400 Received: by mail-wr1-f67.google.com with SMTP id n9so1044584wru.0 for ; Wed, 19 Jun 2019 16:31:01 -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=d9nThxCo3McNUGv5wCiOL0FXmnYg5Zi4/7K4VsJ4UGw=; b=rj0zoQYMqCGHkPU6/MCQpE3olwP5Kr+fMUnqGX6SK8dsp6RFL6rd2k1A00k7GkK2PY u07f4zVyq5TY50AT2R9okza27V0ExRqPLBLusy04rfG7z/DaoRWztC46/MXeNa0x5bs/ K21BJowbMNjF1EAuBjKk2yOMiIe7pMGqFJNTQ84t0bdDvO+2PYBZ17aYCRWta2HIY1AN kQhDojWlX2/Hgk1QF7hOCnw2qGeEM+5CG/D6w0jcHyMKO4ZNPtNxJdn+NyJo+BwPV2ZC 1wYiybUe14UNzDpW4bAEoI6i+ZNfuViKdL6a3YR/XpanC9EcjBtG50M7jp/ftrzEa9Zi 0ohg== 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=d9nThxCo3McNUGv5wCiOL0FXmnYg5Zi4/7K4VsJ4UGw=; b=uF07KCsAfL/S4eS5YZAwhQX64NCeEsRSuC2b+TsP4xTs7YR3hRCah33ls8DhqOFh7O /v5uuhYeyWse9WphVysrHskCs/3Scl+lCWeKgiEluQtSzC13AeFp5IZGI0H3d2ZwdvIW lPuP+cv8Pnw7tquRLKPoXvZgiFNbxufgRj/IIc6HSSIcYAOcwonUgpzqGZtC3Acv7ndh C9QFgMZIevUBIAv0TQrVh4RDUjol+10oSwxgB6HOlHGYdG61vmLgLvwnRT/BDkjdSUgo YfrfZ6hz+1tF1F9wWlt6JModT3wAisBTnkOZTlitaQw2TBYuhIb+e9hwuHjOdnH60/ic BJBg== X-Gm-Message-State: APjAAAWK3qEr15RrObKk/6/xAud0a/Z6LIIMvyhgQwrS3bFjyN9x5Ox0 nuRTHiiVBHBKK7z3C0WuE1cUjxjwBUI= X-Google-Smtp-Source: APXvYqxqKmzyUZjum/h188AanxRZwwxKgcYVqURc/9yUOZCDemVRozgtCVhwSuZyXfiV2czxu59Ukw== X-Received: by 2002:adf:b64e:: with SMTP id i14mr36526000wre.248.1560987060779; Wed, 19 Jun 2019 16:31:00 -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.30.59 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 19 Jun 2019 16:30:59 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmc=?= =?utf-8?b?4buNYyBEdXk=?= , Jeff King , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH 4/6] tests README: re-flow a previously changed paragraph Date: Thu, 20 Jun 2019 01:30:44 +0200 Message-Id: <20190619233046.27503-5-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 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP A previous change to the "GIT_TEST_GETTEXT_POISON" variable left this paragraph needing to be re-flowed. Let's do that in this separate change to make it easy to see that there's no change here when viewed with "--word-diff". Signed-off-by: Ævar Arnfjörð Bjarmason --- t/README | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/t/README b/t/README index 9a131f472e..072c9854d1 100644 --- a/t/README +++ b/t/README @@ -344,10 +344,10 @@ refactor to deal with it. The "SYMLINKS" prerequisite is currently excluded as so much relies on it, but this might change in the future. GIT_TEST_GETTEXT_POISON= turns all strings marked for -translation into gibberish if true. Used for -spotting those tests that need to be marked with a C_LOCALE_OUTPUT -prerequisite when adding more strings for translation. See "Testing -marked strings" in po/README for details. +translation into gibberish if true. Used for spotting those tests that +need to be marked with a C_LOCALE_OUTPUT prerequisite when adding more +strings for translation. See "Testing marked strings" in po/README for +details. GIT_TEST_SPLIT_INDEX= forces split-index mode on the whole test suite. Accept any boolean values that are accepted by git-config. From patchwork Wed Jun 19 23:30:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 11005573 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 83E2376 for ; Wed, 19 Jun 2019 23:31:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 718BF288BF for ; Wed, 19 Jun 2019 23:31:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 65DB8288CF; Wed, 19 Jun 2019 23:31:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ABE1D288BF for ; Wed, 19 Jun 2019 23:31:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730812AbfFSXbF (ORCPT ); Wed, 19 Jun 2019 19:31:05 -0400 Received: from mail-wm1-f42.google.com ([209.85.128.42]:55965 "EHLO mail-wm1-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730747AbfFSXbE (ORCPT ); Wed, 19 Jun 2019 19:31:04 -0400 Received: by mail-wm1-f42.google.com with SMTP id a15so1120292wmj.5 for ; Wed, 19 Jun 2019 16:31:03 -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=BOKarEEAdG3LkHbv06JofqJHfsqof2DwY3Sj/B/olYY=; b=h18lc9BjHYfwhz+cboE4wGVux34f6eEV4uj9Xac+1r2UPePJTpeh+7q+2iJVY0IEsr m97WOQ8mHnLxTeA1Q92bkVA6YbkdCveiEft6k9wXFNM+bLi8yd6HvHylU7pB+GkS8oRu qfg2DJNsLDT0WxTceQV9du7A9T28GMhtSUdUe+NHVew1XHhzy574XkVZigTLxEJMYamB OOt78EQSuCz6fiq/jblp5O0sqmtsdd8QD+3/o2Mcku3QZo9rtxMdW1g7wVkDa7aqNv4q e0Jdse0WpWe3RJEZBj/UMVIMExE0/03rE6PJK9QsaHsnJ0s+mvqEO2GHjyXUP76hCAc4 Lv8Q== 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=BOKarEEAdG3LkHbv06JofqJHfsqof2DwY3Sj/B/olYY=; b=ML399ye1Rd+PLfCVU/JZFo51cdQztSqAwB7ll9Beniuk/FUIVWpdWQxIS+gkfKXu2Z WubtD4fG6fSXWhBjX7pKHGXqfYqGZkWee7RM4zi+WlZV8TPwY12839OFowYXVvuEPmTT UG/WR0g5Ut9Lt2ddYQuQKuWt2XjQUv6T2X6tIMZJW+p0m2VPBXEfOk/A76Cy83qp/hoa B3pd3PqJ6YV/PHTOyY5Ln5PvGs93VVKZ8kaR+eyhizEgng8oMZHOGPmY1HlTwkhDRdnt XZ4KeO7UvoHIJbAS2vVLIAl5Yly5EJzD/yfBe2ObdUTnyB3uKxwH/Cfi88+fZExrx24M o+7Q== X-Gm-Message-State: APjAAAVksq/JJz4Amtt289ZxQt8PkbRyY8K9yaVvqT0m5FeQIUcrtrLt EOzQWXDib5HyaK0/nPSJXoPA75P4AyM= X-Google-Smtp-Source: APXvYqzQWSGio/o947YXTc4UiqrS5J/6rF7QZqSXR65kFVDbQDx6Da8rJBSOOIJUCTQlMiSahCPfNg== X-Received: by 2002:a05:600c:2201:: with SMTP id z1mr9519241wml.59.1560987061896; Wed, 19 Jun 2019 16:31:01 -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.00 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 19 Jun 2019 16:31:01 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmc=?= =?utf-8?b?4buNYyBEdXk=?= , Jeff King , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH 5/6] tests: replace test_tristate with "git env--helper" Date: Thu, 20 Jun 2019 01:30:45 +0200 Message-Id: <20190619233046.27503-6-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 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The test_tristate helper introduced in 83d842dc8c ("tests: turn on network daemon tests by default", 2014-02-10) can now be better implemented with "git env--helper" to give the variables in question the standard boolean behavior. The reason for the "tristate" was to have all of false/true/auto, where "auto" meant either "false" or "true" depending on what the fallback was. With the --default option to "git env--helper" we can simply have e.g. GIT_TEST_HTTPD where we know if it's true because the user asked explicitly ("true"), or true implicitly ("auto"). This breaks backwards compatibility for explicitly setting "auto" for these variables, but I don't think anyone cares. That was always intended to be internal. This means the test_normalize_bool() code in test-lib-functions.sh goes away in addition to test_tristate(). We still need the test_skip_or_die() helper, but now it takes the variable name instead of the value, and uses "git env--bool" to distinguish a default "true" from an explicit "true" (in those "explicit true" cases we want to fail the test in question). Signed-off-by: Ævar Arnfjörð Bjarmason --- t/lib-git-daemon.sh | 7 +++--- t/lib-git-svn.sh | 11 +++----- t/lib-httpd.sh | 15 ++++++----- t/t5512-ls-remote.sh | 3 +-- t/test-lib-functions.sh | 56 ++++++----------------------------------- 5 files changed, 22 insertions(+), 70 deletions(-) diff --git a/t/lib-git-daemon.sh b/t/lib-git-daemon.sh index 7b3407134e..770c5218ea 100644 --- a/t/lib-git-daemon.sh +++ b/t/lib-git-daemon.sh @@ -15,8 +15,7 @@ # # test_done -test_tristate GIT_TEST_GIT_DAEMON -if test "$GIT_TEST_GIT_DAEMON" = false +if ! git env--helper --mode-bool --variable=GIT_TEST_GIT_DAEMON --default=1 --exit-code --quiet then skip_all="git-daemon testing disabled (unset GIT_TEST_GIT_DAEMON to enable)" test_done @@ -24,7 +23,7 @@ fi if test_have_prereq !PIPE then - test_skip_or_die $GIT_TEST_GIT_DAEMON "file system does not support FIFOs" + test_skip_or_die GIT_TEST_GIT_DAEMON "file system does not support FIFOs" fi test_set_port LIB_GIT_DAEMON_PORT @@ -73,7 +72,7 @@ start_git_daemon() { kill "$GIT_DAEMON_PID" wait "$GIT_DAEMON_PID" unset GIT_DAEMON_PID - test_skip_or_die $GIT_TEST_GIT_DAEMON \ + test_skip_or_die GIT_TEST_GIT_DAEMON \ "git daemon failed to start" fi } diff --git a/t/lib-git-svn.sh b/t/lib-git-svn.sh index c1271d6863..853d33a57a 100644 --- a/t/lib-git-svn.sh +++ b/t/lib-git-svn.sh @@ -69,14 +69,12 @@ svn_cmd () { maybe_start_httpd () { loc=${1-svn} - test_tristate GIT_SVN_TEST_HTTPD - case $GIT_SVN_TEST_HTTPD in - true) + if git env--helper --mode-bool --variable=GIT_TEST_HTTPD --default=0 --exit-code --quiet + then . "$TEST_DIRECTORY"/lib-httpd.sh LIB_HTTPD_SVN="$loc" start_httpd - ;; - esac + fi } convert_to_rev_db () { @@ -106,8 +104,7 @@ EOF } require_svnserve () { - test_tristate GIT_TEST_SVNSERVE - if ! test "$GIT_TEST_SVNSERVE" = true + if ! git env--helper --mode-bool --variable=GIT_TEST_SVNSERVE --default=0 --exit-code --quiet then skip_all='skipping svnserve test. (set $GIT_TEST_SVNSERVE to enable)' test_done diff --git a/t/lib-httpd.sh b/t/lib-httpd.sh index b3cc62bd36..eef3250552 100644 --- a/t/lib-httpd.sh +++ b/t/lib-httpd.sh @@ -41,15 +41,14 @@ then test_done fi -test_tristate GIT_TEST_HTTPD -if test "$GIT_TEST_HTTPD" = false +if ! git env--helper --mode-bool --variable=GIT_TEST_HTTPD --default=1 --exit-code --quiet then skip_all="Network testing disabled (unset GIT_TEST_HTTPD to enable)" test_done fi if ! test_have_prereq NOT_ROOT; then - test_skip_or_die $GIT_TEST_HTTPD \ + test_skip_or_die GIT_TEST_HTTPD \ "Cannot run httpd tests as root" fi @@ -95,7 +94,7 @@ GIT_TRACE=$GIT_TRACE; export GIT_TRACE if ! test -x "$LIB_HTTPD_PATH" then - test_skip_or_die $GIT_TEST_HTTPD "no web server found at '$LIB_HTTPD_PATH'" + test_skip_or_die GIT_TEST_HTTPD "no web server found at '$LIB_HTTPD_PATH'" fi HTTPD_VERSION=$($LIB_HTTPD_PATH -v | \ @@ -107,19 +106,19 @@ then then if ! test $HTTPD_VERSION -ge 2 then - test_skip_or_die $GIT_TEST_HTTPD \ + test_skip_or_die GIT_TEST_HTTPD \ "at least Apache version 2 is required" fi if ! test -d "$DEFAULT_HTTPD_MODULE_PATH" then - test_skip_or_die $GIT_TEST_HTTPD \ + test_skip_or_die GIT_TEST_HTTPD \ "Apache module directory not found" fi LIB_HTTPD_MODULE_PATH="$DEFAULT_HTTPD_MODULE_PATH" fi else - test_skip_or_die $GIT_TEST_HTTPD \ + test_skip_or_die GIT_TEST_HTTPD \ "Could not identify web server at '$LIB_HTTPD_PATH'" fi @@ -184,7 +183,7 @@ start_httpd() { if test $? -ne 0 then cat "$HTTPD_ROOT_PATH"/error.log >&4 2>/dev/null - test_skip_or_die $GIT_TEST_HTTPD "web server setup failed" + test_skip_or_die GIT_TEST_HTTPD "web server setup failed" fi } diff --git a/t/t5512-ls-remote.sh b/t/t5512-ls-remote.sh index e3c4a48c85..7161148280 100755 --- a/t/t5512-ls-remote.sh +++ b/t/t5512-ls-remote.sh @@ -267,8 +267,7 @@ test_expect_success 'ls-remote --symref omits filtered-out matches' ' ' test_lazy_prereq GIT_DAEMON ' - test_tristate GIT_TEST_GIT_DAEMON && - test "$GIT_TEST_GIT_DAEMON" != false + git env--helper --mode-bool --variable=GIT_TEST_GIT_DAEMON --default=1 --exit-code --quiet ' # This test spawns a daemon, so run it only if the user would be OK with diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh index 0367cec5fd..527508c350 100644 --- a/t/test-lib-functions.sh +++ b/t/test-lib-functions.sh @@ -1035,62 +1035,20 @@ perl () { command "$PERL_PATH" "$@" 2>&7 } 7>&2 2>&4 -# Is the value one of the various ways to spell a boolean true/false? -test_normalize_bool () { - git -c magic.variable="$1" config --bool magic.variable 2>/dev/null -} - -# Given a variable $1, normalize the value of it to one of "true", -# "false", or "auto" and store the result to it. -# -# test_tristate GIT_TEST_HTTPD -# -# A variable set to an empty string is set to 'false'. -# A variable set to 'false' or 'auto' keeps its value. -# Anything else is set to 'true'. -# An unset variable defaults to 'auto'. -# -# The last rule is to allow people to set the variable to an empty -# string and export it to decline testing the particular feature -# for versions both before and after this change. We used to treat -# both unset and empty variable as a signal for "do not test" and -# took any non-empty string as "please test". - -test_tristate () { - if eval "test x\"\${$1+isset}\" = xisset" - then - # explicitly set - eval " - case \"\$$1\" in - '') $1=false ;; - auto) ;; - *) $1=\$(test_normalize_bool \$$1 || echo true) ;; - esac - " - else - eval "$1=auto" - fi -} - # Exit the test suite, either by skipping all remaining tests or by -# exiting with an error. If "$1" is "auto", we then we assume we were -# opportunistically trying to set up some tests and we skip. If it is -# "true", then we report a failure. +# exiting with an error. If our prerequisite variable $1 falls back +# on a default assume we were opportunistically trying to set up some +# tests and we skip. If it is explicitly "true", then we report a failure. # # The error/skip message should be given by $2. # test_skip_or_die () { - case "$1" in - auto) + if ! git env--helper --mode-bool --variable=$1 --default=0 --exit-code --quiet + then skip_all=$2 test_done - ;; - true) - error "$2" - ;; - *) - error "BUG: test tristate is '$1' (real error: $2)" - esac + fi + error "$2" } # The following mingw_* functions obey POSIX shell syntax, but are actually From patchwork Wed Jun 19 23:30:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 11005577 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A92EE76 for ; Wed, 19 Jun 2019 23:31:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 985B2288BF for ; Wed, 19 Jun 2019 23:31:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8CAA8288CF; Wed, 19 Jun 2019 23:31:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 91041288BF 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?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmc=?= =?utf-8?b?4buNYyBEdXk=?= , Jeff King , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= 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 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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" -' From patchwork Thu Jun 20 21:09:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 11008155 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AB82014DB for ; Thu, 20 Jun 2019 21:09:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 95FC22864E for ; Thu, 20 Jun 2019 21:09:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 861E1288EF; Thu, 20 Jun 2019 21:09:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CAC5A2864E for ; Thu, 20 Jun 2019 21:09:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726651AbfFTVJi (ORCPT ); Thu, 20 Jun 2019 17:09:38 -0400 Received: from mail-wm1-f48.google.com ([209.85.128.48]:52195 "EHLO mail-wm1-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726254AbfFTVJh (ORCPT ); Thu, 20 Jun 2019 17:09:37 -0400 Received: by mail-wm1-f48.google.com with SMTP id 207so4404503wma.1 for ; Thu, 20 Jun 2019 14:09:35 -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=ZbsQgxnESEY3YYiMY0agnmvKhmMc3d9HyAlmvav+Onw=; b=ps5pS81kgeQWSQcwCd/clr75ZRrIap3aoIxoXejPBZp/3x8E+bATFEpjWU/TiYPDGf 0FB7kM0ElI4cV7upz0NA7xqXxweSb8gV7sQLs+blA8LB9Y4gKcjAYxqX2UPPy0sPA8Eg DW6Ci/sRVBhr/ArsGRF42ByvUAr+m2c5fgyaMS96+xm+kI4VD2dsqGF7yGxjRU3a/e1q UUFe9qRYKme40206oEc0q4FOpfZn+PypDmuVRIlPElWcsv2jI4SdcA5uLg5mzRO/KdjD AzG5gaOZFFqb9hHXQBxnn8i5ASv9lzeNnlBWw5ZXBFK2Up1cLjugqCOByBjHwKEtgx9J rBiw== 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=ZbsQgxnESEY3YYiMY0agnmvKhmMc3d9HyAlmvav+Onw=; b=mQ/2jarsfchxMYJeEEfE3R8oZvLQtVd0qBcHi6jLfhb78oU77BzPsc/EB1k75M9+DZ a+Q4nQavS5OUf3p/CQk9YCeux9fMphCdJodPtYxgvwvVSpLj05nZ6tbql2nuXclEG0Rc 0MbH1TTzhopBBP+Ybv3wjHfqO4qgOpt9qJ5OjhQRsV7JIiA1S5IdDkfQPJEW8djbLI18 DDmNXbK1/+xO9YlfZDKfPSHgFb04WJwINulgAaw/z74DJLRQFi9k9H1n13IF66m6RMRs wizynmATFQQ9wdXfj5zJW276QSaYxbqLXj2oFdtH4ib9aDkM2Lj1oUFQuvnua4Zi5xT5 s7Uw== X-Gm-Message-State: APjAAAUzNIzcaro+Z1DKg5R0ojBEowb7oYjKrUzJVVb2LR6DmV9zzIEA 5gqJoLFCd3NVFDEyU4Tt86qbrZXm2dw= X-Google-Smtp-Source: APXvYqxpnK1WRoyDyXGLuiC9EQ1Z8ET9/ZR44JmsJLRnvDkN9zse7kAx/Su4sHTqZ2Antfv5H3lemQ== X-Received: by 2002:a7b:c7d7:: with SMTP id z23mr997515wmk.46.1561064974725; Thu, 20 Jun 2019 14:09:34 -0700 (PDT) Received: from vm.nix.is ([2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id x8sm1295781wre.73.2019.06.20.14.09.33 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 20 Jun 2019 14:09:33 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmc=?= =?utf-8?b?4buNYyBEdXk=?= , Jeff King , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v2 7/8] tests: replace test_tristate with "git env--helper" Date: Thu, 20 Jun 2019 23:09:14 +0200 Message-Id: <20190620210915.11297-8-avarab@gmail.com> X-Mailer: git-send-email 2.22.0.455.g172b71a6c5 In-Reply-To: <20190619233046.27503-1-avarab@gmail.com> References: <20190619233046.27503-1-avarab@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The test_tristate helper introduced in 83d842dc8c ("tests: turn on network daemon tests by default", 2014-02-10) can now be better implemented with "git env--helper" to give the variables in question the standard boolean behavior. The reason for the "tristate" was to have all of false/true/auto, where "auto" meant either "false" or "true" depending on what the fallback was. With the --default option to "git env--helper" we can simply have e.g. GIT_TEST_HTTPD where we know if it's true because the user asked explicitly ("true"), or true implicitly ("auto"). This breaks backwards compatibility for explicitly setting "auto" for these variables, but I don't think anyone cares. That was always intended to be internal. This means the test_normalize_bool() code in test-lib-functions.sh goes away in addition to test_tristate(). We still need the test_skip_or_die() helper, but now it takes the variable name instead of the value, and uses "git env--bool" to distinguish a default "true" from an explicit "true" (in those "explicit true" cases we want to fail the test in question). Signed-off-by: Ævar Arnfjörð Bjarmason --- t/lib-git-daemon.sh | 7 +++--- t/lib-git-svn.sh | 11 +++----- t/lib-httpd.sh | 15 ++++++----- t/t5512-ls-remote.sh | 3 +-- t/test-lib-functions.sh | 56 ++++++----------------------------------- 5 files changed, 22 insertions(+), 70 deletions(-) diff --git a/t/lib-git-daemon.sh b/t/lib-git-daemon.sh index 7b3407134e..770c5218ea 100644 --- a/t/lib-git-daemon.sh +++ b/t/lib-git-daemon.sh @@ -15,8 +15,7 @@ # # test_done -test_tristate GIT_TEST_GIT_DAEMON -if test "$GIT_TEST_GIT_DAEMON" = false +if ! git env--helper --mode-bool --variable=GIT_TEST_GIT_DAEMON --default=1 --exit-code --quiet then skip_all="git-daemon testing disabled (unset GIT_TEST_GIT_DAEMON to enable)" test_done @@ -24,7 +23,7 @@ fi if test_have_prereq !PIPE then - test_skip_or_die $GIT_TEST_GIT_DAEMON "file system does not support FIFOs" + test_skip_or_die GIT_TEST_GIT_DAEMON "file system does not support FIFOs" fi test_set_port LIB_GIT_DAEMON_PORT @@ -73,7 +72,7 @@ start_git_daemon() { kill "$GIT_DAEMON_PID" wait "$GIT_DAEMON_PID" unset GIT_DAEMON_PID - test_skip_or_die $GIT_TEST_GIT_DAEMON \ + test_skip_or_die GIT_TEST_GIT_DAEMON \ "git daemon failed to start" fi } diff --git a/t/lib-git-svn.sh b/t/lib-git-svn.sh index c1271d6863..853d33a57a 100644 --- a/t/lib-git-svn.sh +++ b/t/lib-git-svn.sh @@ -69,14 +69,12 @@ svn_cmd () { maybe_start_httpd () { loc=${1-svn} - test_tristate GIT_SVN_TEST_HTTPD - case $GIT_SVN_TEST_HTTPD in - true) + if git env--helper --mode-bool --variable=GIT_TEST_HTTPD --default=0 --exit-code --quiet + then . "$TEST_DIRECTORY"/lib-httpd.sh LIB_HTTPD_SVN="$loc" start_httpd - ;; - esac + fi } convert_to_rev_db () { @@ -106,8 +104,7 @@ EOF } require_svnserve () { - test_tristate GIT_TEST_SVNSERVE - if ! test "$GIT_TEST_SVNSERVE" = true + if ! git env--helper --mode-bool --variable=GIT_TEST_SVNSERVE --default=0 --exit-code --quiet then skip_all='skipping svnserve test. (set $GIT_TEST_SVNSERVE to enable)' test_done diff --git a/t/lib-httpd.sh b/t/lib-httpd.sh index b3cc62bd36..eef3250552 100644 --- a/t/lib-httpd.sh +++ b/t/lib-httpd.sh @@ -41,15 +41,14 @@ then test_done fi -test_tristate GIT_TEST_HTTPD -if test "$GIT_TEST_HTTPD" = false +if ! git env--helper --mode-bool --variable=GIT_TEST_HTTPD --default=1 --exit-code --quiet then skip_all="Network testing disabled (unset GIT_TEST_HTTPD to enable)" test_done fi if ! test_have_prereq NOT_ROOT; then - test_skip_or_die $GIT_TEST_HTTPD \ + test_skip_or_die GIT_TEST_HTTPD \ "Cannot run httpd tests as root" fi @@ -95,7 +94,7 @@ GIT_TRACE=$GIT_TRACE; export GIT_TRACE if ! test -x "$LIB_HTTPD_PATH" then - test_skip_or_die $GIT_TEST_HTTPD "no web server found at '$LIB_HTTPD_PATH'" + test_skip_or_die GIT_TEST_HTTPD "no web server found at '$LIB_HTTPD_PATH'" fi HTTPD_VERSION=$($LIB_HTTPD_PATH -v | \ @@ -107,19 +106,19 @@ then then if ! test $HTTPD_VERSION -ge 2 then - test_skip_or_die $GIT_TEST_HTTPD \ + test_skip_or_die GIT_TEST_HTTPD \ "at least Apache version 2 is required" fi if ! test -d "$DEFAULT_HTTPD_MODULE_PATH" then - test_skip_or_die $GIT_TEST_HTTPD \ + test_skip_or_die GIT_TEST_HTTPD \ "Apache module directory not found" fi LIB_HTTPD_MODULE_PATH="$DEFAULT_HTTPD_MODULE_PATH" fi else - test_skip_or_die $GIT_TEST_HTTPD \ + test_skip_or_die GIT_TEST_HTTPD \ "Could not identify web server at '$LIB_HTTPD_PATH'" fi @@ -184,7 +183,7 @@ start_httpd() { if test $? -ne 0 then cat "$HTTPD_ROOT_PATH"/error.log >&4 2>/dev/null - test_skip_or_die $GIT_TEST_HTTPD "web server setup failed" + test_skip_or_die GIT_TEST_HTTPD "web server setup failed" fi } diff --git a/t/t5512-ls-remote.sh b/t/t5512-ls-remote.sh index e3c4a48c85..7161148280 100755 --- a/t/t5512-ls-remote.sh +++ b/t/t5512-ls-remote.sh @@ -267,8 +267,7 @@ test_expect_success 'ls-remote --symref omits filtered-out matches' ' ' test_lazy_prereq GIT_DAEMON ' - test_tristate GIT_TEST_GIT_DAEMON && - test "$GIT_TEST_GIT_DAEMON" != false + git env--helper --mode-bool --variable=GIT_TEST_GIT_DAEMON --default=1 --exit-code --quiet ' # This test spawns a daemon, so run it only if the user would be OK with diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh index 0367cec5fd..527508c350 100644 --- a/t/test-lib-functions.sh +++ b/t/test-lib-functions.sh @@ -1035,62 +1035,20 @@ perl () { command "$PERL_PATH" "$@" 2>&7 } 7>&2 2>&4 -# Is the value one of the various ways to spell a boolean true/false? -test_normalize_bool () { - git -c magic.variable="$1" config --bool magic.variable 2>/dev/null -} - -# Given a variable $1, normalize the value of it to one of "true", -# "false", or "auto" and store the result to it. -# -# test_tristate GIT_TEST_HTTPD -# -# A variable set to an empty string is set to 'false'. -# A variable set to 'false' or 'auto' keeps its value. -# Anything else is set to 'true'. -# An unset variable defaults to 'auto'. -# -# The last rule is to allow people to set the variable to an empty -# string and export it to decline testing the particular feature -# for versions both before and after this change. We used to treat -# both unset and empty variable as a signal for "do not test" and -# took any non-empty string as "please test". - -test_tristate () { - if eval "test x\"\${$1+isset}\" = xisset" - then - # explicitly set - eval " - case \"\$$1\" in - '') $1=false ;; - auto) ;; - *) $1=\$(test_normalize_bool \$$1 || echo true) ;; - esac - " - else - eval "$1=auto" - fi -} - # Exit the test suite, either by skipping all remaining tests or by -# exiting with an error. If "$1" is "auto", we then we assume we were -# opportunistically trying to set up some tests and we skip. If it is -# "true", then we report a failure. +# exiting with an error. If our prerequisite variable $1 falls back +# on a default assume we were opportunistically trying to set up some +# tests and we skip. If it is explicitly "true", then we report a failure. # # The error/skip message should be given by $2. # test_skip_or_die () { - case "$1" in - auto) + if ! git env--helper --mode-bool --variable=$1 --default=0 --exit-code --quiet + then skip_all=$2 test_done - ;; - true) - error "$2" - ;; - *) - error "BUG: test tristate is '$1' (real error: $2)" - esac + fi + error "$2" } # The following mingw_* functions obey POSIX shell syntax, but are actually From patchwork Thu Jun 20 21:09:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 11008157 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A4A84924 for ; Thu, 20 Jun 2019 21:09:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 962A52864E for ; Thu, 20 Jun 2019 21:09:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 88CEA288ED; Thu, 20 Jun 2019 21:09:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EBF992864E for ; Thu, 20 Jun 2019 21:09:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726254AbfFTVJn (ORCPT ); Thu, 20 Jun 2019 17:09:43 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:46187 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726628AbfFTVJi (ORCPT ); Thu, 20 Jun 2019 17:09:38 -0400 Received: by mail-wr1-f68.google.com with SMTP id n4so4388145wrw.13 for ; Thu, 20 Jun 2019 14:09:37 -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=QjfHRkIGYSR7AXlx4CyOAU2hHCn0rLp4wrt2RXIWR0A=; b=sPQ5IR3jvjsc5UCpQ/FB7z4TLmov4AK/e6vQhCTg1TfCfcq7URnn3I6VKlU1F1WNN9 bavIPVOGu9yeUKZ2YHJbA2x4UWADk4QSjldBKvfpg/W4wROhbcmZKgC9v/z33ZINgKS7 nwtA8E2Gc61wQEzISgoRt1dJ1ItwmQadpbGM/RV43rmZ70+PB1mWaYrnKBsrhqamdoJW KR5PksNFhI73JZ2eTC61dDi/eaL0WaGrRbnnuI+phJITMyvnqGtHqnLcY9vVh+c6smX4 e/nUyzzjMYGF6XsMLrYSVZvfEHznAUsd0cy87fFHR/Zcydu7qUAV64bTjYxuZklcxOKK KEiA== 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=QjfHRkIGYSR7AXlx4CyOAU2hHCn0rLp4wrt2RXIWR0A=; b=ckiZ9eKusyzQZQdT7Q6ideYgSMRmPDJ+CD1tser0N+HvNWEksErE+iIwhGHxWZc5p4 NmaVAKkvL0Bbmqp4adc6O8hO4W1qbzbh5rgoRow0x8ZC9AiIUg3NRN3epbcVGq9HA8FC w5SLOF4l+f/teYYw3O8PChvoYYx4fq0xOSYgwQ2auANRMtFVmu0Cu0jz9xUamAXFpEdm BafxUqO4tcLO6Kjw6yys6SCjPdR3+qPSOEEw0VK1GV4zNnW3aKbBkoTifNhrSl3qi31e 1YBu7bhi3lieoDtrG+n7wh2azCWb64GpeHfmknSyw7vjDI6X5s65RWLuZDtbYdta2nPB 2Wog== X-Gm-Message-State: APjAAAXkid62S0ph6mkqn1VWFhbjsHnn0ex5oRkqGKvqtbp5TDw94VtH zwPB/B5CCbz6ylZunnKPGs5jqZKm8gQ= X-Google-Smtp-Source: APXvYqwmnaHxW0pAswVsNkuxO2KV/vWqNOuiL6miHeoZAqNObxDHWeEnCHqROy29unMt16od+vzBMA== X-Received: by 2002:a5d:6549:: with SMTP id z9mr29578214wrv.63.1561064976869; Thu, 20 Jun 2019 14:09:36 -0700 (PDT) Received: from vm.nix.is ([2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id x8sm1295781wre.73.2019.06.20.14.09.34 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 20 Jun 2019 14:09:34 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmc=?= =?utf-8?b?4buNYyBEdXk=?= , Jeff King , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v2 8/8] tests: make GIT_TEST_FAIL_PREREQS a boolean Date: Thu, 20 Jun 2019 23:09:15 +0200 Message-Id: <20190620210915.11297-9-avarab@gmail.com> X-Mailer: git-send-email 2.22.0.455.g172b71a6c5 In-Reply-To: <20190619233046.27503-1-avarab@gmail.com> References: <20190619233046.27503-1-avarab@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 c45b0d2611..238ef62401 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 @@ -1605,7 +1626,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" -'