From patchwork Fri Jun 21 10:18:05 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: 11009679 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 7C7086C5 for ; Fri, 21 Jun 2019 10:18:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6D0EB289D0 for ; Fri, 21 Jun 2019 10:18:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6180F289EF; Fri, 21 Jun 2019 10:18:30 +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 D955B289D0 for ; Fri, 21 Jun 2019 10:18:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726297AbfFUKS2 (ORCPT ); Fri, 21 Jun 2019 06:18:28 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:37774 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726260AbfFUKS1 (ORCPT ); Fri, 21 Jun 2019 06:18:27 -0400 Received: by mail-wm1-f65.google.com with SMTP id f17so6009772wme.2 for ; Fri, 21 Jun 2019 03:18:26 -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=CRctIvxPgB9PE0jpv4WdLCspT34W7igX1nCADTy4g68=; b=d5bY0gLNGnfdWvUNe2/OpN1VOyyFiCGiE+1vsuRztaIzfEoPjWXyuq3nj2JL/Jfihc bEAQSdq1J+XitmcOANDWQ3jlF72nW8/McJdudSnSfu1j+spnVNgIX9HPxkqQxOiCF+SL /RmehYLK3IQF56JUpVXT05GJt7iBJaC5+qoe+OYLVqwAnHWFP8ChwQa0ImXS7+oRxsFy 9F1nWbiBCIpA3UFf1RS+IdlKSgWIiK6w5dljUovbKVhyR+C7Xr69gtUeUUZPcQqdQ1g5 Duk9y+JF4FNqaEgJY/FAk2czoGSTahrjiPYUN8+8jIkkccoRC+cwc5dEf94W+lSlH2kt t0VQ== 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=CRctIvxPgB9PE0jpv4WdLCspT34W7igX1nCADTy4g68=; b=lp9V6JNlbq6diJtOBS6g7qSz1icfZ6ZjhA+01WpBG740aStcGBK81blaHtz3dbl13b 0mX29CBmSJefMwblQoX3/QByw7El6WPLD9KEjtg+QP7o5RD9FYlM1/KShuOUqETNUngE j45puWXgMDmjx2Nj+0DQS+0EED5Cc4bptrTa8HLTtjoPxmOAT/mJQvkM0oIqsI1nlaVf DqeTZrCJ8W0AEEr76+wanEXF0Kj+vsqOsHYf+mrJmL6vhvcASPkhBY6h3zMEK7/s87zT OOJ1opdOY2n4huKlMyBILfr22ZorULFWJELj0TVr2dqUZk3pIRuMRbSIeGUFStB+kD4t ZsAA== X-Gm-Message-State: APjAAAWkwRCL2EByukshv37Rcg9Sj9qnMPoxjsWH9Wk1sZUf3sRUKthL HNgP0XjFXJ9l2Q8dHWC8SJNAxBO6af8= X-Google-Smtp-Source: APXvYqwV2LKMKmaNoJmjEFEFmXk0Whxw1+hJED2o7E1LGt6m4Pc2UuKhYFN4sLoAfSwX1A8Yy5h0SA== X-Received: by 2002:a1c:6a06:: with SMTP id f6mr3503920wmc.159.1561112305152; Fri, 21 Jun 2019 03:18:25 -0700 (PDT) Received: from vm.nix.is ([2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id y184sm1878193wmg.14.2019.06.21.03.18.24 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 21 Jun 2019 03:18:24 -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 v3 1/8] config tests: simplify include cycle test Date: Fri, 21 Jun 2019 12:18:05 +0200 Message-Id: <20190621101812.27300-2-avarab@gmail.com> X-Mailer: git-send-email 2.22.0.455.g172b71a6c5 In-Reply-To: <20190620210915.11297-1-avarab@gmail.com> References: <20190620210915.11297-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 Simplify an overly verbose test added in 9b25a0b52e ("config: add include directive", 2012-02-06). The "expect" file was never used, and by using .gitconfig it's not as intuitive to reproduce this manually with "-d" as some other tests, since HOME needs to be set in the environment. Also remove the use of test_i18ngrep added in a769bfc74f ("config.c: mark more strings for translation", 2018-07-21) in favor of overriding the GIT_TEST_GETTEXT_POISON value. Using the i18n test wrappers hasn't been needed since my 6cdccfce1e ("i18n: make GETTEXT_POISON a runtime option", 2018-11-08). As a follow-up change to the yet-to-be-added t0017-env-helper.sh will show, doing it this way can hide a regression when combined with trace2's early config reading. That early config reading was added in bce9db6de9 ("trace2: use system/global config for default trace2 settings", 2019-04-15). So let's remove the testing for that potential regression here, I'll instead add it explicitly to t0017-env-helper.sh in a follow-up change. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/t1305-config-include.sh | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/t/t1305-config-include.sh b/t/t1305-config-include.sh index 579a86b7f8..6b388ba2d0 100755 --- a/t/t1305-config-include.sh +++ b/t/t1305-config-include.sh @@ -310,20 +310,13 @@ test_expect_success SYMLINKS 'conditional include, gitdir matching symlink, icas ' test_expect_success 'include cycles are detected' ' - cat >.gitconfig <<-\EOF && - [test]value = gitconfig - [include]path = cycle - EOF - cat >cycle <<-\EOF && - [test]value = cycle - [include]path = .gitconfig - EOF - cat >expect <<-\EOF && - gitconfig - cycle - EOF - test_must_fail git config --get-all test.value 2>stderr && - test_i18ngrep "exceeded maximum include depth" stderr + git init --bare cycle && + git -C cycle config include.path cycle && + git config -f cycle/cycle include.path config && + test_must_fail \ + env GIT_TEST_GETTEXT_POISON= \ + git -C cycle config --get-all test.value 2>stderr && + grep "exceeded maximum include depth" stderr ' test_done From patchwork Fri Jun 21 10:18:06 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: 11009681 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 08CBA186E for ; Fri, 21 Jun 2019 10:18:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EAF23289E8 for ; Fri, 21 Jun 2019 10:18:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D9D58289D0; Fri, 21 Jun 2019 10:18:32 +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 1635A289D0 for ; Fri, 21 Jun 2019 10:18:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726521AbfFUKSa (ORCPT ); Fri, 21 Jun 2019 06:18:30 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:44131 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726260AbfFUKS3 (ORCPT ); Fri, 21 Jun 2019 06:18:29 -0400 Received: by mail-wr1-f67.google.com with SMTP id r16so5982957wrl.11 for ; Fri, 21 Jun 2019 03:18:28 -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=qcsQUaXDjsnX1TGtyFB06xg2DLy7AN2cnzGtGe5cMLE=; b=iTWxldm0PwItMsADtvRiyC8QtcfV0jpS2xzuKUOj9lxQcDofJcNMiVd2o7GPufl5/m Ze30VwFEfp27qLZGOj1YDErgdst2CURPlTDa7rTwInh96X/CoXA+cIgHF6F/blCbIhO6 beJfcMCf5Vu1Rg9xVCQ2a5Y8n8kxa4TCm/NkkRbVeawygw9MrWnehXGpSCzTHq3+BSZf whgv2891XjCrLw6YLBHW2xaDDwAXjaBx/QWShg9i7lIba2r2gbuiPjRs+tee5y/yuJaX M93zluSShNvTrxyrWsYtkCtI0j/famert76oRgs0HXWi0g+U+IhpoUt/CQclLS70Qso/ edug== 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=qcsQUaXDjsnX1TGtyFB06xg2DLy7AN2cnzGtGe5cMLE=; b=rnQ+/05ao9xFVjHJ07mZGIjJYHVKZnRGgxzZDak995isdJmQoHWKLhvDihiCauKTJd LvAacTZp/86Uj5Be4vj9/7XJ5hhqnwnpujr2IrAqkdl0OcsvY6S+cZO8FJ7stWcqCUKe ohDSIN/BbkJPaP500BR8V/EufhlovLpqNKHkTksDrYwMmuksY/N/xxf+0Kr/TvFXSw8t PP+VQkQao3H8O7k6bVgUW4pkroUG8Y/1nPPMgsKpNbnHURwfR5UrAU6lYW39sHMMEIsE 0HSs4HHD4p3o44JM0q93fI72bka1Sea7wsGqMOCqDwOO2yHC195+NKOfykvkiERguPuO TUTw== X-Gm-Message-State: APjAAAWLx/oUr5Px/9mRsvC/N7Z7JwV2KobgZbDsRiPTIPKYTLpSozG5 SbP1QhyqnoQVm90ybFUxvuvrjtr4GC4= X-Google-Smtp-Source: APXvYqwrO+3HuAp8F79t5ah0gk9zfAIZU8lL2bBGB32YAvXYYzUI8Te904Ge1Hsmn6trdhFydiQ0fg== X-Received: by 2002:adf:ce8f:: with SMTP id r15mr84664053wrn.122.1561112307139; Fri, 21 Jun 2019 03:18:27 -0700 (PDT) Received: from vm.nix.is ([2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id y184sm1878193wmg.14.2019.06.21.03.18.25 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 21 Jun 2019 03:18:25 -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 v3 2/8] env--helper: new undocumented builtin wrapping git_env_*() Date: Fri, 21 Jun 2019 12:18:06 +0200 Message-Id: <20190621101812.27300-3-avarab@gmail.com> X-Mailer: git-send-email 2.22.0.455.g172b71a6c5 In-Reply-To: <20190620210915.11297-1-avarab@gmail.com> References: <20190620210915.11297-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 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 --type=bool option will be used by subsequent patches, but not --type=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, and to have a template to make it obvious how we'd add --type=int etc. if it's needed in the future. Signed-off-by: Ævar Arnfjörð Bjarmason --- .gitignore | 1 + Makefile | 1 + builtin.h | 1 + builtin/env--helper.c | 95 +++++++++++++++++++++++++++++++++++++++++++ git.c | 1 + t/t0017-env-helper.sh | 83 +++++++++++++++++++++++++++++++++++++ 6 files changed, 182 insertions(+) create mode 100644 builtin/env--helper.c create mode 100755 t/t0017-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..1083c0f707 --- /dev/null +++ b/builtin/env--helper.c @@ -0,0 +1,95 @@ +#include "builtin.h" +#include "config.h" +#include "parse-options.h" + +static char const * const env__helper_usage[] = { + N_("git env--helper --type=[bool|ulong] "), + NULL +}; + +enum { + ENV_HELPER_TYPE_BOOL = 1, + ENV_HELPER_TYPE_ULONG +} cmdmode = 0; + +static int option_parse_type(const struct option *opt, const char *arg, + int unset) +{ + if (!strcmp(arg, "bool")) + cmdmode = ENV_HELPER_TYPE_BOOL; + else if (!strcmp(arg, "ulong")) + cmdmode = ENV_HELPER_TYPE_ULONG; + else + die(_("unrecognized --type argument, %s"), arg); + + return 0; +} + +int cmd_env__helper(int argc, const char **argv, const char *prefix) +{ + int exit_code = 0; + const char *env_variable = NULL; + const char *env_default = NULL; + int ret; + int ret_int, default_int; + unsigned long ret_ulong, default_ulong; + struct option opts[] = { + OPT_CALLBACK_F(0, "type", &cmdmode, N_("type"), + N_("value is given this type"), PARSE_OPT_NONEG, + option_parse_type), + OPT_STRING(0, "default", &env_default, N_("value"), + N_("default for git_env_*(...) to fall back on")), + OPT_BOOL(0, "exit-code", &exit_code, + N_("be quiet only use git_env_*() value as exit code")), + OPT_END(), + }; + + argc = parse_options(argc, argv, prefix, opts, env__helper_usage, + PARSE_OPT_KEEP_UNKNOWN); + if (env_default && !*env_default) + usage_with_options(env__helper_usage, opts); + if (!cmdmode) + usage_with_options(env__helper_usage, opts); + if (argc != 1) + usage_with_options(env__helper_usage, opts); + env_variable = argv[0]; + + switch (cmdmode) { + case ENV_HELPER_TYPE_BOOL: + if (env_default) { + default_int = git_parse_maybe_bool(env_default); + if (default_int == -1) { + error(_("option `--default' expects a boolean value with `--type=bool`, not `%s`"), + env_default); + usage_with_options(env__helper_usage, opts); + } + } else { + default_int = 0; + } + ret_int = git_env_bool(env_variable, default_int); + if (!exit_code) + puts(ret_int ? "true" : "false"); + ret = ret_int; + break; + case ENV_HELPER_TYPE_ULONG: + if (env_default) { + if (!git_parse_ulong(env_default, &default_ulong)) { + error(_("option `--default' expects an unsigned long value with `--type=ulong`, not `%s`"), + env_default); + usage_with_options(env__helper_usage, opts); + } + } else { + default_ulong = 0; + } + ret_ulong = git_env_ulong(env_variable, default_ulong); + if (!exit_code) + printf("%lu\n", ret_ulong); + ret = ret_ulong; + break; + default: + BUG("unknown value"); + break; + } + + return !ret; +} 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/t0017-env-helper.sh b/t/t0017-env-helper.sh new file mode 100755 index 0000000000..709bbbd275 --- /dev/null +++ b/t/t0017-env-helper.sh @@ -0,0 +1,83 @@ +#!/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 --type=bool && + test_must_fail git env--helper --type=ulong && + test_must_fail git env--helper --type=bool && + test_must_fail git env--helper --type=bool --default && + test_must_fail git env--helper --type=bool --default= && + test_must_fail git env--helper --defaultxyz +' + +test_expect_success 'env--helper bad default values' ' + test_must_fail git env--helper --type=bool --default=1xyz MISSING && + test_must_fail git env--helper --type=ulong --default=1xyz MISSING +' + +test_expect_success 'env--helper --type=bool' ' + # Test various --default bool values + echo true >expected && + git env--helper --type=bool --default=1 MISSING >actual && + test_cmp expected actual && + git env--helper --type=bool --default=yes MISSING >actual && + test_cmp expected actual && + git env--helper --type=bool --default=true MISSING >actual && + test_cmp expected actual && + echo false >expected && + test_must_fail git env--helper --type=bool --default=0 MISSING >actual && + test_cmp expected actual && + test_must_fail git env--helper --type=bool --default=no MISSING >actual && + test_cmp expected actual && + test_must_fail git env--helper --type=bool --default=false MISSING >actual && + test_cmp expected actual && + + # No output with --exit-code + git env--helper --type=bool --default=true --exit-code MISSING >actual.out 2>actual.err && + test_must_be_empty actual.out && + test_must_be_empty actual.err && + test_must_fail git env--helper --type=bool --default=false --exit-code MISSING >actual.out 2>actual.err && + test_must_be_empty actual.out && + test_must_be_empty actual.err && + + # Existing variable + EXISTS=true git env--helper --type=bool --default=false --exit-code EXISTS >actual.out 2>actual.err && + test_must_be_empty actual.out && + test_must_be_empty actual.err && + test_must_fail \ + env EXISTS=false \ + git env--helper --type=bool --default=true --exit-code EXISTS >actual.out 2>actual.err && + test_must_be_empty actual.out && + test_must_be_empty actual.err +' + +test_expect_success 'env--helper --type=ulong' ' + echo 1234567890 >expected && + git env--helper --type=ulong --default=1234567890 MISSING >actual.out 2>actual.err && + test_cmp expected actual.out && + test_must_be_empty actual.err && + + echo 0 >expected && + test_must_fail git env--helper --type=ulong --default=0 MISSING >actual && + test_cmp expected actual && + + git env--helper --type=ulong --default=1234567890 --exit-code MISSING >actual.out 2>actual.err && + test_must_be_empty actual.out && + test_must_be_empty actual.err && + + EXISTS=1234567890 git env--helper --type=ulong --default=0 EXISTS --exit-code >actual.out 2>actual.err && + test_must_be_empty actual.out && + test_must_be_empty actual.err && + + echo 1234567890 >expected && + EXISTS=1234567890 git env--helper --type=ulong --default=0 EXISTS >actual.out 2>actual.err && + test_cmp expected actual.out && + test_must_be_empty actual.err +' + +test_done From patchwork Fri Jun 21 10:18:07 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: 11009683 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 76AE36C5 for ; Fri, 21 Jun 2019 10:18:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 65D9C289D0 for ; Fri, 21 Jun 2019 10:18:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 59F3E289E8; Fri, 21 Jun 2019 10:18:33 +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 F07DB289EF for ; Fri, 21 Jun 2019 10:18:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726549AbfFUKSc (ORCPT ); Fri, 21 Jun 2019 06:18:32 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:33459 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726250AbfFUKSb (ORCPT ); Fri, 21 Jun 2019 06:18:31 -0400 Received: by mail-wr1-f67.google.com with SMTP id n9so6066144wru.0 for ; Fri, 21 Jun 2019 03:18:30 -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=NpzDRG0kZJ9YtaYBUv3fvBA5IBhs5BLuVYzXtQLF3yY=; b=TEAjjrkN48bgHtaSmSs4AkLqmReXY0MFc3iWxyfRWAOP/MSDWvSa0K5faCIGyKGfB1 edmOGkuOmBBIZ/Yoo7Cgq2OrfZ4CxgLvsKEPtNCPv/fFpVrNbvnc7dPNm1zCT3ynvS6H OyKc70wjqa9r2HmaI1T0klp2W3RH4InxvvkEifPYdNTiQupD3hLXzkzcFdKLzAvTQ7j0 Pg3y3wwyEJYhQFjpqnUx7vas3dZEgsomLlvR0H/TDFCkzd3yrZmLrpMSGcBL3Lf0EteE J0zlDXeFCJ72mbcrguIuHpZEXQbfvuvrDtrvIlQR9K6dhwCHe3TiYx17Yyp8wUYeBr1l Q3ug== 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=NpzDRG0kZJ9YtaYBUv3fvBA5IBhs5BLuVYzXtQLF3yY=; b=lgiQblq/LbLltS7CodDEpAgNTDUVjO34XF6TQzhCXrD20kTMjDj/QmNUawv8ES92p/ s4PAPlIxeC7m3gaXOl3YUSlatgMv8RFoh+WfaZCSKSzfuFw20AU1rl3dpH1BBgLa2GxN asItYo7K/Ise3Gx330uMgUZOSwTb0egsaD1L8GmKElUk3yBSYgIOSxVSJEohl76olGII cYBMRaH0mHWe0sATYlR5kEu1N9sIktCNCsgOeTgYqveEGCRxXjPpMQfr4A0oAZ7TisMh H37UtQhk50d/Z2XVFK3+9X4SzLhwqmA1JLV+4FShB0c2YElUz8Zf2VUe9c29s42rxaqP Vr4Q== X-Gm-Message-State: APjAAAWvmoE6blX70IIMonytjguMXft8K8cwxIA+qvUqqoy136nz3Yaj ga/g8r+SgcNkXas2BJ+lqIVv3NKs3WE= X-Google-Smtp-Source: APXvYqxVuT7fTrkZgenX/CPa+14xolBD6f9kwsCFSSV/aE3F/oRsPFxcdsMvaeME7PclxVS7rCH7GA== X-Received: by 2002:adf:f050:: with SMTP id t16mr76814725wro.99.1561112309140; Fri, 21 Jun 2019 03:18:29 -0700 (PDT) Received: from vm.nix.is ([2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id y184sm1878193wmg.14.2019.06.21.03.18.27 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 21 Jun 2019 03:18:27 -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 v3 3/8] config.c: refactor die_bad_number() to not call gettext() early Date: Fri, 21 Jun 2019 12:18:07 +0200 Message-Id: <20190621101812.27300-4-avarab@gmail.com> X-Mailer: git-send-email 2.22.0.455.g172b71a6c5 In-Reply-To: <20190620210915.11297-1-avarab@gmail.com> References: <20190620210915.11297-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 Prepare die_bad_number() for a change to specially handle GIT_TEST_GETTEXT_POISON calling git_env_bool() by making die_bad_number() not call gettext() early, which would in turn call git_env_bool(). There's no meaningful change here yet, just a re-arrangement of the current code to make that subsequent change easier to read. Signed-off-by: Ævar Arnfjörð Bjarmason --- config.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/config.c b/config.c index 296a6d9cc4..374cb33005 100644 --- a/config.c +++ b/config.c @@ -949,34 +949,35 @@ int git_parse_ssize_t(const char *value, ssize_t *ret) NORETURN static void die_bad_number(const char *name, const char *value) { - const char * error_type = (errno == ERANGE)? _("out of range"):_("invalid unit"); + const char *error_type = (errno == ERANGE) ? + N_("out of range") : N_("invalid unit"); + const char *bad_numeric = N_("bad numeric config value '%s' for '%s': %s"); if (!value) value = ""; if (!(cf && cf->name)) - die(_("bad numeric config value '%s' for '%s': %s"), - value, name, error_type); + die(_(bad_numeric), value, name, _(error_type)); switch (cf->origin_type) { case CONFIG_ORIGIN_BLOB: die(_("bad numeric config value '%s' for '%s' in blob %s: %s"), - value, name, cf->name, error_type); + value, name, cf->name, _(error_type)); case CONFIG_ORIGIN_FILE: die(_("bad numeric config value '%s' for '%s' in file %s: %s"), - value, name, cf->name, error_type); + value, name, cf->name, _(error_type)); case CONFIG_ORIGIN_STDIN: die(_("bad numeric config value '%s' for '%s' in standard input: %s"), - value, name, error_type); + value, name, _(error_type)); case CONFIG_ORIGIN_SUBMODULE_BLOB: die(_("bad numeric config value '%s' for '%s' in submodule-blob %s: %s"), - value, name, cf->name, error_type); + value, name, cf->name, _(error_type)); case CONFIG_ORIGIN_CMDLINE: die(_("bad numeric config value '%s' for '%s' in command line %s: %s"), - value, name, cf->name, error_type); + value, name, cf->name, _(error_type)); default: die(_("bad numeric config value '%s' for '%s' in %s: %s"), - value, name, cf->name, error_type); + value, name, cf->name, _(error_type)); } } From patchwork Fri Jun 21 10:18:08 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: 11009687 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 867DB186E for ; Fri, 21 Jun 2019 10:18:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 75B10289D0 for ; Fri, 21 Jun 2019 10:18:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6A3FB289EC; Fri, 21 Jun 2019 10:18:34 +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 142B9289D0 for ; Fri, 21 Jun 2019 10:18:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726452AbfFUKSd (ORCPT ); Fri, 21 Jun 2019 06:18:33 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:44137 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726260AbfFUKSc (ORCPT ); Fri, 21 Jun 2019 06:18:32 -0400 Received: by mail-wr1-f65.google.com with SMTP id r16so5983130wrl.11 for ; Fri, 21 Jun 2019 03:18:31 -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=ugShOYf8Li5vms2a7LuBZrSltUjtVP/P1t4CWD/xlWY=; b=ivYQF+9Cl8uK/87RPhCmRUwDvgua00cCZEMS8FSaT0EOt+GQxhJ289GeL/Q2lVVkbT MxJ72PEwrPV5m5X14bInDfC+p5kFiFMqtUoqwuTNGRGlFIKLMh/5PQAWMIClwvOXVDPk QxwP60/k8kHSSqzJMywBR+rRiiH0apc/48nKn68L3dWEq22N4quR0B8WnhXtP9wZ80RX RN0fwTKCMK0Y1F5VG0jVTApPGJKgeOTAGet7VO1NItHBgIfOuH27JMM4RpRgZdCFIGkU Yx89pZK5uJcVtQy4u2WkC/otxWZKtxACOep4w5Gh2dpW2KWX1wsp+qFvd8Ff+DwfywQ1 vqvA== 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=ugShOYf8Li5vms2a7LuBZrSltUjtVP/P1t4CWD/xlWY=; b=tV6hNsuTRcHaYAmRqvTS+ztHR1QIgQi93+TQd89eSVoiqS4RPwS99N42BVUsgWXINA 4cupYQZxT/PX6q4jTNeybRG7iADjqy+m4Ig0ZqqHtY1t2cHW1P+gp9PK3+4UacgGNwjb Tp/LkS7CwjAZKuNsY5kc7FXrF9YwtERyicSQ1I8eBBYiiceTYE+OzREk8CDrLQGN0e7Z LJv4k8EBF9yr9Jfgv5JHV4OrEZgNoWjLkP8QzoUK1A9hPwzsBpqxxCvznM2+gtmzVowT b7HzWQU1OOvHV8sht22x9F9ONHck1Mi19+tq9ghV5B8DvQuEZxP4EfahECOu1pSnikgV EdwA== X-Gm-Message-State: APjAAAWP3W5EtBRN0IkhKFztMog5WYnmjWg3oW5YL6qJxyIj5eb6LP4h VNi8E/sQRa2Kpb39HiQapAOs8Qovp4s= X-Google-Smtp-Source: APXvYqyKZO8j1HEOWk0X1AuwvW60Uc1dpIJC+2ttmuwlyCdjTTP3Nb5ZOrK7JrORbHm4eDpr3DzVMg== X-Received: by 2002:a5d:618d:: with SMTP id j13mr18335437wru.195.1561112310313; Fri, 21 Jun 2019 03:18:30 -0700 (PDT) Received: from vm.nix.is ([2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id y184sm1878193wmg.14.2019.06.21.03.18.29 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 21 Jun 2019 03:18:29 -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 v3 4/8] t6040 test: stop using global "script" variable Date: Fri, 21 Jun 2019 12:18:08 +0200 Message-Id: <20190621101812.27300-5-avarab@gmail.com> X-Mailer: git-send-email 2.22.0.455.g172b71a6c5 In-Reply-To: <20190620210915.11297-1-avarab@gmail.com> References: <20190620210915.11297-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 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 Fri Jun 21 10:18:09 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: 11009691 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 3F88C6C5 for ; Fri, 21 Jun 2019 10:18:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2EE01289D0 for ; Fri, 21 Jun 2019 10:18:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 22D21289EC; Fri, 21 Jun 2019 10:18:38 +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 4A4D7289D0 for ; Fri, 21 Jun 2019 10:18:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726564AbfFUKSf (ORCPT ); Fri, 21 Jun 2019 06:18:35 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:44140 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726250AbfFUKSe (ORCPT ); Fri, 21 Jun 2019 06:18:34 -0400 Received: by mail-wr1-f66.google.com with SMTP id r16so5983195wrl.11 for ; Fri, 21 Jun 2019 03:18:32 -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=NEx9zZSP0K4r7Yu9Gkx+jdK13o3tdQx951Ls51YsjJ4=; b=q/7qNPhaq4eKlgrF6moSys6Loxo/jY4OfBvB+RsL33LC0s8p+QQohVxjYp41+DiZy3 mxbB1baWEoxIqRbF7b1cqyS+hYFieJSLYMY3sz2T/a3sH0j7TFWU09+jF8NJEOrJLgyh qWejdJX3d718ZyEd/NyCvr5Oh/egvt+EZ238l0SuVs7kCopfUADw0SzlJ7c3PwhuSH8P 9SLtnUOjk02dgYwKVuaFtvbmQDobEVzUsv66YhvUSSXap2G/wqAaHh8YJ45GDw4zUxU/ lrpOv2ifDpVkIJtcYsw8Cwyywfbir2s+rVkhyj2l9UyQodKT4xiQEvE+NPcEPUSxBT9C zzoA== 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=NEx9zZSP0K4r7Yu9Gkx+jdK13o3tdQx951Ls51YsjJ4=; b=WTE0EUsKPECi2U5ankc/ci6cR8COJkmHdrCkt9lAXngVk5n+DuKvGy1t7DSTDLrcWt 9FE1xvifdWYPqmVLwIsU4vB5R9d/Ixx/LyyHyZSq2UpdFaJNPGclNnuCiBE3gS7Gxn4P PbmvBc2Mb0sakEXzU4SVHM9PNs06LgSNHFQIat9HlrP3NNDqZw9BQHiWYZush7p4SWAs j/BlNscwUACqreItwI73OH7xnEVMKgn7LO5EwYbhiBK0gEBOAfS/XmVp5swvryEYOR7E cg7lKmhbcHuhf4Zh5INV2lS7DEQoSVMZWfVcQjE0l4afMEmJipwU2jQKOqE+Im/0yjuf fqfw== X-Gm-Message-State: APjAAAX8S6YWaCoU+NfIsVOL89vpaTGqF4A15MzHVBI+eTmejCOGi1lG kBOOtawpJOLFSynfsTM2PQ05cqEiiRo= X-Google-Smtp-Source: APXvYqxg+cDhGYIDr5GdeTWgn7elwjR6s2NcIFjTbl5ZSqpD4J6GM59UnJYGaxBqJ24Ir728aQ1WRw== X-Received: by 2002:adf:e88e:: with SMTP id d14mr16855698wrm.189.1561112311455; Fri, 21 Jun 2019 03:18:31 -0700 (PDT) Received: from vm.nix.is ([2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id y184sm1878193wmg.14.2019.06.21.03.18.30 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 21 Jun 2019 03:18:30 -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 v3 5/8] tests: make GIT_TEST_GETTEXT_POISON a boolean Date: Fri, 21 Jun 2019 12:18:09 +0200 Message-Id: <20190621101812.27300-6-avarab@gmail.com> X-Mailer: git-send-email 2.22.0.455.g172b71a6c5 In-Reply-To: <20190620210915.11297-1-avarab@gmail.com> References: <20190620210915.11297-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_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 "env--helper" we can change that. There's a couple of tricky edge cases that arise because we're using git_env_bool() early, and the config-reading "env--helper". If GIT_TEST_GETTEXT_POISON is set to an invalid value die_bad_number() will die, but to do so it would usually call gettext(). Let's detect the special case of GIT_TEST_GETTEXT_POISON and always emit that message in the C locale, lest we infinitely loop. As seen in the updated tests in t0017-env-helper.sh there's also a caveat related to "env--helper" needing to read the config for trace2 purposes. Since the C_LOCALE_OUTPUT prerequisite is lazy and relies on "env--helper" we could get invalid results if we failed to read the config (e.g. because we'd loop on includes) when combined with e.g. "test_i18ngrep" wanting to check with "env--helper" if GIT_TEST_GETTEXT_POISON was true or not. I'm crossing my fingers and hoping that a test similar to the one I removed in the earlier "config tests: simplify include cycle test" change in this series won't happen again, and testing for this explicitly in "env--helper"'s own tests. This change breaks existing uses of e.g. GIT_TEST_GETTEXT_POISON=YesPlease, which we've documented in po/README and other places. As noted in [1] we might want to consider also accepting "YesPlease" in "env--helper" as a special-case. But as the lack of uproar over 6cdccfce1e ("i18n: make GETTEXT_POISON a runtime option", 2018-11-08) demonstrates the audience for this option is a really narrow set of git developers, who shouldn't have much trouble modifying their test scripts, so I think it's better to deal with that minor headache now and make all the relevant GIT_TEST_* variables boolean in the same way than carry the "YesPlease" special-case forward. 1. https://public-inbox.org/git/xmqqtvckm3h8.fsf@gitster-ct.c.googlers.com/ Signed-off-by: Ævar Arnfjörð Bjarmason --- ci/lib.sh | 2 +- config.c | 9 +++++++++ gettext.c | 6 ++---- git-sh-i18n.sh | 4 +++- po/README | 2 +- t/README | 4 ++-- t/t0017-env-helper.sh | 16 ++++++++++++++++ t/t0205-gettext-poison.sh | 7 ++++++- t/t1305-config-include.sh | 2 +- t/t7201-co.sh | 2 +- t/t9902-completion.sh | 2 +- t/test-lib.sh | 8 +++----- 12 files changed, 46 insertions(+), 18 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/config.c b/config.c index 374cb33005..b985d60fa4 100644 --- a/config.c +++ b/config.c @@ -956,6 +956,15 @@ static void die_bad_number(const char *name, const char *value) if (!value) value = ""; + if (!strcmp(name, "GIT_TEST_GETTEXT_POISON")) + /* + * We explicitly *don't* use _() here since it would + * cause an infinite loop with _() needing to call + * use_gettext_poison(). This is why marked up + * translations with N_() above. + */ + die(bad_numeric, value, name, error_type); + if (!(cf && cf->name)) die(_(bad_numeric), value, name, _(error_type)); 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..8eef60b43f 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 --type=bool --default=0 --exit-code \ + GIT_TEST_GETTEXT_POISON 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/t0017-env-helper.sh b/t/t0017-env-helper.sh index 709bbbd275..c1ecf6aeac 100755 --- a/t/t0017-env-helper.sh +++ b/t/t0017-env-helper.sh @@ -80,4 +80,20 @@ test_expect_success 'env--helper --type=ulong' ' test_must_be_empty actual.err ' +test_expect_success 'env--helper reads config thanks to trace2' ' + mkdir home && + git config -f home/.gitconfig include.path cycle && + git config -f home/cycle include.path .gitconfig && + + test_must_fail \ + env HOME="$(pwd)/home" GIT_TEST_GETTEXT_POISON=false \ + git config -l 2>err && + grep "exceeded maximum include depth" err && + + test_must_fail \ + env HOME="$(pwd)/home" GIT_TEST_GETTEXT_POISON=true \ + git -C cycle env--helper --type=bool --default=0 --exit-code GIT_TEST_GETTEXT_POISON 2>err && + grep "# GETTEXT POISON #" err +' + test_done diff --git a/t/t0205-gettext-poison.sh b/t/t0205-gettext-poison.sh index a06269f38a..f9fa16ad83 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 @@ -31,4 +31,9 @@ test_expect_success 'eval_gettext: our eval_gettext() fallback has poison semant test_cmp expect actual ' +test_expect_success "gettext: invalid GIT_TEST_GETTEXT_POISON value doesn't infinitely loop" " + test_must_fail env GIT_TEST_GETTEXT_POISON=xyz git version 2>error && + grep \"fatal: bad numeric config value 'xyz' for 'GIT_TEST_GETTEXT_POISON': invalid unit\" error +" + test_done diff --git a/t/t1305-config-include.sh b/t/t1305-config-include.sh index 6b388ba2d0..de294c990e 100755 --- a/t/t1305-config-include.sh +++ b/t/t1305-config-include.sh @@ -314,7 +314,7 @@ test_expect_success 'include cycles are detected' ' git -C cycle config include.path cycle && git config -f cycle/cycle include.path config && test_must_fail \ - env GIT_TEST_GETTEXT_POISON= \ + env GIT_TEST_GETTEXT_POISON=false \ git -C cycle config --get-all test.value 2>stderr && grep "exceeded maximum include depth" stderr ' 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..ed5d69dfe5 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -1443,11 +1443,9 @@ then unset GIT_TEST_GETTEXT_POISON_ORIG fi -# Can we rely on git's output in the C locale? -if test -z "$GIT_TEST_GETTEXT_POISON" -then - test_set_prereq C_LOCALE_OUTPUT -fi +test_lazy_prereq C_LOCALE_OUTPUT ' + ! git env--helper --type=bool --default=0 --exit-code GIT_TEST_GETTEXT_POISON +' if test -z "$GIT_TEST_CHECK_CACHE_TREE" then From patchwork Fri Jun 21 10:18:10 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: 11009689 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 46FFD112C for ; Fri, 21 Jun 2019 10:18:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 30951289D0 for ; Fri, 21 Jun 2019 10:18:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 24C0B289EC; Fri, 21 Jun 2019 10:18:37 +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 CA283289D0 for ; Fri, 21 Jun 2019 10:18:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726579AbfFUKSg (ORCPT ); Fri, 21 Jun 2019 06:18:36 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:46242 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726260AbfFUKSf (ORCPT ); Fri, 21 Jun 2019 06:18:35 -0400 Received: by mail-wr1-f66.google.com with SMTP id n4so5968473wrw.13 for ; Fri, 21 Jun 2019 03:18:33 -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=u3sXNR/uk3730rKhBr46qXt/A79m86WhaGryYWzrqL4=; b=YEnLSfKfOtoKoi/k/nPW+rF2UecWTA6rpCNdaWpsxNJIsc7bYejaDeEIMx7Ql5phf5 4R1iiROw0hgRzLTWIVtvNDGiWThH/iDOU80VAO3XF9dAMVWAIymFU8psZU5C8flTdhos xTLBQO9VGS+ukcrqoAijs2AMlbqNZiHS4nen9SzyNKS/6dhzDkwXui4Zh2cylQgkPzv+ FCN7t94kW+Nd/j8l7OfYpJT3vLmsac71HgmbY2rTMNUip81PtZJURUhPAARYVLHmXEol kb2IpPF6yThzoRPXnU1lI7/b5EBZATepKI9CYuFsrExXOC0r8lGkCzmfUhhntlcjP/7P rjPw== 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=u3sXNR/uk3730rKhBr46qXt/A79m86WhaGryYWzrqL4=; b=azePSwnKcR7LxUjuDRZvrrbqlL9dggMj2afZeWxkfjWKkKL9G5GOdNkLx17uSVwLhy MUnGwXR9xF2JZkdD5rRA49zQdYrP2BfdNrN7Ld9nXkJyYmyRdYtWZkYBNRnOPc+CcZgy juxTwSvgIb0Cn6HFHLG9wnp+/naRUJbgTy5Kk2iJPtbAu8vybnIE7zeCABnwqwj/xL94 8NBXeXNQFC+sHiBSZyECljbm9ASq91uiq3FEMJgdedabKgyL11GUOsHmpPvBDAZ2rUOs ytXDZIS3fmNPsGOsb8wIW43ASxoCT6EkBPUcFUgZJ0yNEhWWOOYOhCqEAoSLgj2PubQt Nc9w== X-Gm-Message-State: APjAAAVEfibkKpdZv6QshdRW4eGgPu+tFsHtCjDodollok0gLFHTx8rh RL2/hWS44YS/SibU/nUj0FS/FVNJcVk= X-Google-Smtp-Source: APXvYqz26u7Zz+zYHn5W0pxLHyQeqod5Meu8zQ2d6XiqtOMfW+x/YkxfCn2qT++N8Kt08sVn7opN1Q== X-Received: by 2002:a5d:4ec1:: with SMTP id s1mr42158194wrv.19.1561112312629; Fri, 21 Jun 2019 03:18:32 -0700 (PDT) Received: from vm.nix.is ([2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id y184sm1878193wmg.14.2019.06.21.03.18.31 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 21 Jun 2019 03:18:31 -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 v3 6/8] tests README: re-flow a previously changed paragraph Date: Fri, 21 Jun 2019 12:18:10 +0200 Message-Id: <20190621101812.27300-7-avarab@gmail.com> X-Mailer: git-send-email 2.22.0.455.g172b71a6c5 In-Reply-To: <20190620210915.11297-1-avarab@gmail.com> References: <20190620210915.11297-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 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 Fri Jun 21 10:18:11 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: 11009693 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 7BEEE6C5 for ; Fri, 21 Jun 2019 10:18:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6AEFF289D0 for ; Fri, 21 Jun 2019 10:18:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5F224289EC; Fri, 21 Jun 2019 10:18: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 A6573289D0 for ; Fri, 21 Jun 2019 10:18:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726587AbfFUKSi (ORCPT ); Fri, 21 Jun 2019 06:18:38 -0400 Received: from mail-wr1-f44.google.com ([209.85.221.44]:33281 "EHLO mail-wr1-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726439AbfFUKSg (ORCPT ); Fri, 21 Jun 2019 06:18:36 -0400 Received: by mail-wr1-f44.google.com with SMTP id n9so6066396wru.0 for ; Fri, 21 Jun 2019 03:18:34 -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=0p1RCFjT87l9dgkXZ1aNcukicWmd8g+qnh5wDdPky9I=; b=PEjRP63xCsLYYUIkaQn8qvWJBVo4xIOQIcXS9/T9KWMlM6KtyN7WpflhMqWOBiauaa 5lJXOvrqIpcNhRudwKePBW/xWpiX861jsciv8jE+GkxgDJulnxYHmkFdn9u4WlrrMi91 IBWCt38LsttYHjxJ6iq2kTKYmmqsto6UlT+J47Yy5pwzCWsAtror6uEJeyIAksswFQ0T Yn1okylaxm/Ep/rkx2g/7YsLIR0haAf/73NMYB19qkETjECqQuSOWKvhUAr/VuYAtX5n i01wAjMrag2NQ6ebEAI45HBw8AidzrI8agq+PXOCfVvTr4VLIgQ0s8MMBVHhWvEWy2nO wiuA== 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=0p1RCFjT87l9dgkXZ1aNcukicWmd8g+qnh5wDdPky9I=; b=eZAmzxD/zJeC7gFXVksy0UKRoJn7QeomA1sEmmCN8xG8U7K9F0rLSDDzKQegt1EhbX O9Iw9o5nFkhzDEyYEbTWgSdEC65XdVwnkh8KqcPghZHNqvQtxzEtR0s3/dP2/guiliDm 4ImBNvkrhyMbZYXVq+gbJ59LiBsb2VXSLXYd+nMkgS5oCVpNT81XJ61m+0jJLqOOACWE OZkH6HOL5Caf/xzhmYAoc71dpDlaQKLOgiNHOlvmgNmkvCD7Goo3qNhsaaiYvXFiDM2q Dmaldzyu4ll/0QBZMRBZuhB4NwCSbe3DsmnwLhiOy1n3uLL9+MZzgTi6eNtRGUcN1SJr tBHQ== X-Gm-Message-State: APjAAAXRoyW1O/o2QIV4m6Ycq5EbdbK60ypUHxhRTWevnGUKLyYamlUS XjRpEcyE8FrAouVxRT4g6tS4byqYSwY= X-Google-Smtp-Source: APXvYqzs3vViI6TIMoQIWdZdgrVNTdweX7lx//IIpvRN3sxfDTz7ImV3NT9eMuEnQcBdiOpNO7hdMA== X-Received: by 2002:a5d:4703:: with SMTP id y3mr37767537wrq.35.1561112313781; Fri, 21 Jun 2019 03:18:33 -0700 (PDT) Received: from vm.nix.is ([2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id y184sm1878193wmg.14.2019.06.21.03.18.32 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 21 Jun 2019 03:18:32 -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 v3 7/8] tests: replace test_tristate with "git env--helper" Date: Fri, 21 Jun 2019 12:18:11 +0200 Message-Id: <20190621101812.27300-8-avarab@gmail.com> X-Mailer: git-send-email 2.22.0.455.g172b71a6c5 In-Reply-To: <20190620210915.11297-1-avarab@gmail.com> References: <20190620210915.11297-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..fb8f887080 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 --type=bool --default=true --exit-code GIT_TEST_GIT_DAEMON 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..5d4ae629e1 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 --type=bool --default=false --exit-code GIT_TEST_HTTPD + 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 --type=bool --default=false --exit-code GIT_TEST_SVNSERVE 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..0d985758c6 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 --type=bool --default=true --exit-code GIT_TEST_HTTPD 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..43e1d8d4d2 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 --type=bool --default=true --exit-code GIT_TEST_GIT_DAEMON ' # 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 Fri Jun 21 10:18:12 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: 11009695 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 091D5112C for ; Fri, 21 Jun 2019 10:18:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ED2F2289D0 for ; Fri, 21 Jun 2019 10:18:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E1E2A289EC; Fri, 21 Jun 2019 10:18:40 +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 62532289D0 for ; Fri, 21 Jun 2019 10:18:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726594AbfFUKSj (ORCPT ); Fri, 21 Jun 2019 06:18:39 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:38749 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726250AbfFUKSh (ORCPT ); Fri, 21 Jun 2019 06:18:37 -0400 Received: by mail-wr1-f65.google.com with SMTP id d18so6021312wrs.5 for ; Fri, 21 Jun 2019 03:18: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=EwCKMWeGYi+hfuT9Va6dVFeQR5sW6MhAbAfQxovpIEE=; b=izDb9gfzV+gUq+bVDk0zYJCNT8a8eh5nB1hxcGF6hcOoZ9+xVRbWfxsBoLQb/HPp81 UY9M8+n2E5w7ga7u2ggRw96D1s/HX5gb2rlz0c6hgapDLu3TV50XQHlLz5fVgl3w1JMI HX5h4YfMRLHVPC1MydGyJuInncBHxBfA+Q39x+sjvfuuNmqf4ZwEVYEzOAmVH/k3eEVs z578vPZlLIRAay21SE3Q3kbDlxZXxeAl53p8HAtpI+9kYQEL1fJoDwdfEJSW5Br8CtT+ HUijFylwUwNsbzT1aY7rAB1258suZrXU+LWZhBNXi4qOThzcJ6pJpSPKtpDI73AEaHM2 RRxQ== 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=EwCKMWeGYi+hfuT9Va6dVFeQR5sW6MhAbAfQxovpIEE=; b=Xuge3YUBiFRSSjIn7rEjSw62/yxsGYidakD/shpiEvIDNSRKHFJvDx36WDoO2U52lJ mwbV6nl8X01Gk7ab44zycMEwtU5GBWMGTEMNrYr7zzFcI2wL9TzQYaU7ZGu1NzHP0KyO f6RKcAyPsxI+QgdHsf+2pQh6CHws+O1jClMt8ZjYCHPG4yf892490e6rPsd7CVW1xrcM nAKbT66cGBw/Z/Xl9s5UHl3K/oEo30eNlHIX9Tj4KPsSeTt5TSaZ20El3p+oPVpZ2SXU WMdWQYhBFWvu/BrahGcQvMXpk7qzkGaEzRI5q887N5MoouhQygWgMWrGf7dLQalVd86P Za7Q== X-Gm-Message-State: APjAAAVA7hCpWzYvQFG3hvwNb7C3WWGTnLgLQ13UvG0wfoIpRXGCJHa7 HzMKwEPV4ZYppFGf6HW/J6Wg8OFvtlE= X-Google-Smtp-Source: APXvYqx3H5kBZmKwmA7z7RiW0xgJHR1OegxW8PDUWTGDX1ue4RTKppj7Rpr+b852do5IDXfHCZKG+g== X-Received: by 2002:adf:db81:: with SMTP id u1mr93337882wri.296.1561112314894; Fri, 21 Jun 2019 03:18:34 -0700 (PDT) Received: from vm.nix.is ([2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id y184sm1878193wmg.14.2019.06.21.03.18.33 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 21 Jun 2019 03:18: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 v3 8/8] tests: make GIT_TEST_FAIL_PREREQS a boolean Date: Fri, 21 Jun 2019 12:18:12 +0200 Message-Id: <20190621101812.27300-9-avarab@gmail.com> X-Mailer: git-send-email 2.22.0.455.g172b71a6c5 In-Reply-To: <20190620210915.11297-1-avarab@gmail.com> References: <20190620210915.11297-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 | 4 ++-- t/test-lib.sh | 23 +++++++++++++++++++---- 4 files changed, 27 insertions(+), 12 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..1cd0655f96 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 @@ -1043,7 +1043,7 @@ perl () { # The error/skip message should be given by $2. # test_skip_or_die () { - if ! git env--helper --mode-bool --variable=$1 --default=0 --exit-code --quiet + if ! git env--helper --type=bool --default=false --exit-code $1 then skip_all=$2 test_done diff --git a/t/test-lib.sh b/t/test-lib.sh index ed5d69dfe5..1af4e50653 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -1389,6 +1389,25 @@ 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 --type=bool --default=0 --exit-code GIT_TEST_FAIL_PREREQS + then + GIT_TEST_FAIL_PREREQS_INTERNAL=true + test_set_prereq FAIL_PREREQS + fi +else + test_lazy_prereq FAIL_PREREQS ' + git env--helper --type=bool --default=0 --exit-code GIT_TEST_FAIL_PREREQS + ' +fi + # Fix some commands on Windows uname_s=$(uname -s) case $uname_s in @@ -1605,7 +1624,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" -'