From patchwork Mon Apr 12 11:08:50 2021 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: 12197623 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D004CC43460 for ; Mon, 12 Apr 2021 11:09:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A8CEC61288 for ; Mon, 12 Apr 2021 11:09:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240007AbhDLLJe (ORCPT ); Mon, 12 Apr 2021 07:09:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239914AbhDLLJb (ORCPT ); Mon, 12 Apr 2021 07:09:31 -0400 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3FC9C061574 for ; Mon, 12 Apr 2021 04:09:12 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id p6so5759575wrn.9 for ; Mon, 12 Apr 2021 04:09:12 -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=y1sXkxLV2EdPFJeNxmJyl70xhIZRRljSRYA56qbNzfM=; b=U2eC75D+eihKErKlo+RFlD+/zBw1iqnygJCirDQSITLR6iYvrRC5g1sD09CXrelWX+ dNeLyKFJDYkM1R35UXBnrPiI9pGZFYb6le8omy96PK457FFMPoCHQwn77q3v4SuGsdTJ a+O5kvakD//XJ38uxa/ZDvk1cD3Kr5hHv3zyqULPeSLjCeuFNg79uQ85yVxgELVrH++G ijgi5X8iNoi+/sJpZkvF+iWnPTmSHsgoW/hE3VVBhpQ8m1YPnU4jjFUEYftCZbkSQc4T Iv6T3/3c9VN/1wHrT0mKOCGND/pJYk1JZp9uZSHg6EPYJ+nhHbVKsSYyJEL7LQyhiABd Bdug== 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=y1sXkxLV2EdPFJeNxmJyl70xhIZRRljSRYA56qbNzfM=; b=L5ywMoc6puA5zFeop/2k3WurYFSvjCyyfHDjek3K26PnVkBTVBGIrsTb6tBMYyi+dK 3K/0WhSTBzo6WenV+ZBhhksv44s59BfvF5k7IvQxT3at69TNadR5uYmYcF/4/6WlYuC1 uJYA7sVV87+pLAGmf81/O5wgNspLC9FqZ3twRlMRsaH7DxepEuTs/DqGkrurmAi2NZOr agJ+CUwCrgF36eSUcAnUbioTc3hxWLqNHli7qra+jSUxLs/YoRL4kKntgTvy3lr0yjWp WvyYA9AMkqa1XyEwO31w/GyNz3/PK3DLqOZEVZ8BSqc+oKGQL/bsFGf1gc3jfE/W2Ywo /RZA== X-Gm-Message-State: AOAM532zUaWugLHgbk3d2H3QBnY9wi5/vta2U/uefEymJj52Y+ensVBj gqIE/UKaeneJY18YbPeqP/88OGGidtgW7g== X-Google-Smtp-Source: ABdhPJxdtz0qD4oKv2wcCgFrSzsbjryur+ImlI0GjpMz81FCVtfs0yDcmrS92xt+93stOiuRmlm+jg== X-Received: by 2002:adf:f00e:: with SMTP id j14mr6551783wro.180.1618225751402; Mon, 12 Apr 2021 04:09:11 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id a8sm18158744wrh.91.2021.04.12.04.09.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Apr 2021 04:09:10 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Matthieu Moy , Johannes Schindelin , =?utf-8?b?w4Z2YXIgQXJu?= =?utf-8?b?ZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH 01/16] check-non-portable-shell: complain about "test" a/-o instead of &&/|| Date: Mon, 12 Apr 2021 13:08:50 +0200 Message-Id: X-Mailer: git-send-email 2.31.1.634.gb41287a30b0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Expand the t/check-non-portable-shell.pl checks to complain about the use of "-a" and "-o" to the "test" shell built-in to to mean "and" and "or", as opposed to using two "test" invocations with "&&" or "||". There aren't any portability issues with using that construct that I know of, but since Junio expressed a dislike of it in [1] and we've currently got no such constructs let's add it to the lint checking. I had various in-flight and WIP patches that used this construct. 1. https://lore.kernel.org/git/xmqqa6qkb5fi.fsf@gitster.g/ Signed-off-by: Ævar Arnfjörð Bjarmason --- t/check-non-portable-shell.pl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/t/check-non-portable-shell.pl b/t/check-non-portable-shell.pl index fd3303552be..a5367346255 100755 --- a/t/check-non-portable-shell.pl +++ b/t/check-non-portable-shell.pl @@ -35,6 +35,7 @@ sub err { next if $line =~ s/\\$//; $_ = $line; + # Portability issues /\bcp\s+-a/ and err 'cp -a is not portable'; /\bsed\s+-[^efn]\s+/ and err 'sed option not portable (use only -n, -e, -f)'; /\becho\s+-[neE]/ and err 'echo with option is not portable (use printf)'; @@ -48,6 +49,9 @@ sub err { /\bexport\s+[A-Za-z0-9_]*=/ and err '"export FOO=bar" is not portable (use FOO=bar && export FOO)'; /^\s*([A-Z0-9_]+=(\w*|(["']).*?\3)\s+)+(\w+)/ and exists($func{$4}) and err '"FOO=bar shell_func" assignment extends beyond "shell_func"'; + # Coding style preferences + /\btest\s+-[a-z]\s+.*?\s+-a\s+/ and err '"test A && test B" preferred to "test A -a B"'; + /\btest\s+-[a-z]\s+.*?\s+-o\s+/ and err '"test A || test B" preferred to "test A -o B"'; $line = ''; # this resets our $. for each file close ARGV if eof; From patchwork Mon Apr 12 11:08:51 2021 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: 12197625 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 80B0FC43461 for ; Mon, 12 Apr 2021 11:09:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 58B9C61244 for ; Mon, 12 Apr 2021 11:09:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239986AbhDLLJf (ORCPT ); Mon, 12 Apr 2021 07:09:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239953AbhDLLJb (ORCPT ); Mon, 12 Apr 2021 07:09:31 -0400 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D10CC06174A for ; Mon, 12 Apr 2021 04:09:13 -0700 (PDT) Received: by mail-wr1-x436.google.com with SMTP id j5so11512177wrn.4 for ; Mon, 12 Apr 2021 04:09:13 -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=vHYA0D1toPavqtolWM0ZcBl7gQYmkYwp53GiQbfFnq8=; b=NVSrIkZttkD4wXu81po+9/Ahkb2eVCIPLaE0c08nhPo5f91kFGSp/ofxiPkF1ZMEA0 KbLq4Nqm8HvlhxZE6QP5iiB55fVJyoF5rVNWmYHbEmUgT2lwt45kef6Si6VNi2klH+lh xGvRBLSFsuzG9RQAB4ExHhjJmLteONCoYvedFXRzP9TrwI0mbOyZMp+mytYRIrQf/OUI na7tWupCHPe3BC5Wqe5EubPHwpBVUmyK+QUBxKQ2r0ZjbJr+dL7spNijbZniA42uwtbg vtWdR8zZQvOpznsCbftgtrw/DTrfEGoaGx9fpy9nRgxnfqrdlI2RcZ1NXLs9BkcT6Px8 WVrw== 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=vHYA0D1toPavqtolWM0ZcBl7gQYmkYwp53GiQbfFnq8=; b=mmfyasVgzvXZoYQJJMjYaUCs4dS0NMmU9WRN0mAPK3tNw6u74oM7t2oQF4JlRs4nBG LQ5fKMqcUd699+ZIIJeNro+EdGpmxBJLhz7y0HyDBn9M+teE4RrcfBDT9KE7/I4iNX8Q kVGSywSf4HUMBe5RA33lO0OmY8MaLP533Pi5yZAudK0N0zLYf8IyOL8gnSOhN2m4YPYg GUHILZRcFTLcIVw2rUSe8U2THmScKvGJdOArKb2cXqWh9gOSQDgs9evYaHEf3aPMmPCP n2h1/EewWxp7OL2BjIpV6eLJxkacGYcd8YArzETpLjEtAiQurLSn9oBq8qyrwWd6Q+3F rVkw== X-Gm-Message-State: AOAM531W9Qd5ZCRDbxgShGydYowq+utUcEdDAwfGEag0bhpbrvCMv0rp WhqHDCT50TLGMGZWeENMlwnriqkV7wYDbw== X-Google-Smtp-Source: ABdhPJwFo0D83XuYbxp4dZVBE6KGI/wCLEomcaTSJr5B47rFU0n/DGp79UpTibzpoiavGhHNYGADQg== X-Received: by 2002:a05:6000:22d:: with SMTP id l13mr21586712wrz.26.1618225752141; Mon, 12 Apr 2021 04:09:12 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id a8sm18158744wrh.91.2021.04.12.04.09.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Apr 2021 04:09:11 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Matthieu Moy , Johannes Schindelin , =?utf-8?b?w4Z2YXIgQXJu?= =?utf-8?b?ZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH 02/16] test-lib: bring $remove_trash out of retirement Date: Mon, 12 Apr 2021 13:08:51 +0200 Message-Id: X-Mailer: git-send-email 2.31.1.634.gb41287a30b0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org There's no point in creating a repository or directory only to decide right afterwards that we're skipping all the tests. So let's partially revert 06478dab4c (test-lib: retire $remove_trash variable, 2017-04-23) and move the decision about whether to skip all tests earlier. I tested this with --debug, see 4d0912a206 (test-lib.sh: do not barf under --debug at the end of the test, 2017-04-24) for a bug we don't want to re-introduce. While I'm at it let's move the HOME assignment to just before test_create_repo, it could be lower, but it seems better to set it before calling anything in test-lib-functions.sh Signed-off-by: Ævar Arnfjörð Bjarmason --- t/test-lib.sh | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/t/test-lib.sh b/t/test-lib.sh index d3f6af6a654..a8869eee58f 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -1167,7 +1167,7 @@ test_done () { esac fi - if test -z "$debug" + if test -z "$debug" && test -n "$remove_trash" then test -d "$TRASH_DIRECTORY" || error "Tests passed but trash directory already removed before test cleanup; aborting" @@ -1332,6 +1332,21 @@ then exit 1 fi +# Are we running this test at all? +this_test=${0##*/} +this_test=${this_test%%-*} +if match_pattern_list "$this_test" $GIT_SKIP_TESTS +then + say_color info >&3 "skipping test $this_test altogether" + skip_all="skip all tests in $this_test" + test_done +fi + +# Last-minute variable setup +HOME="$TRASH_DIRECTORY" +GNUPGHOME="$HOME/gnupg-home-not-used" +export HOME GNUPGHOME + # Test repository rm -fr "$TRASH_DIRECTORY" || { GIT_EXIT_OK=t @@ -1339,10 +1354,7 @@ rm -fr "$TRASH_DIRECTORY" || { exit 1 } -HOME="$TRASH_DIRECTORY" -GNUPGHOME="$HOME/gnupg-home-not-used" -export HOME GNUPGHOME - +remove_trash=t if test -z "$TEST_NO_CREATE_REPO" then test_create_repo "$TRASH_DIRECTORY" @@ -1354,15 +1366,6 @@ fi # in subprocesses like git equals our $PWD (for pathname comparisons). cd -P "$TRASH_DIRECTORY" || exit 1 -this_test=${0##*/} -this_test=${this_test%%-*} -if match_pattern_list "$this_test" $GIT_SKIP_TESTS -then - say_color info >&3 "skipping test $this_test altogether" - skip_all="skip all tests in $this_test" - test_done -fi - if test -n "$write_junit_xml" then junit_xml_dir="$TEST_OUTPUT_DIRECTORY/out" From patchwork Mon Apr 12 11:08:52 2021 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: 12197629 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 986F0C43460 for ; Mon, 12 Apr 2021 11:09:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 79A2A61249 for ; Mon, 12 Apr 2021 11:09:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240027AbhDLLJg (ORCPT ); Mon, 12 Apr 2021 07:09:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239969AbhDLLJc (ORCPT ); Mon, 12 Apr 2021 07:09:32 -0400 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69812C06138C for ; Mon, 12 Apr 2021 04:09:14 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id f12so12520679wro.0 for ; Mon, 12 Apr 2021 04:09:14 -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=nKj6+4mXMs95f/EB7TGBgYMSs41twH9ljnu5PXsWqyc=; b=IY0WJsQJhlxPoqNa9imPufKn6/hLYgNokjIvT2chitUCAFUfxLRUUjpxFR4N/6p82A GW8bL5PzhNFTthEVdsKs5IfWI4JPUZCNKm6HjFCBjuqfufJluVEK/68lvEZVeNTbrRIS Z7LubMKkd+6okZ4GmgjjFgnhs1bBqpDKWtdxDlEi4SyvvbcaA9fb4DMLN759ml5Soc4P sjvETbZMhD8eBZ6daIth/GRpYaw3WCUnz6olrsBytOWlWpuOFvlAapiejE4KEsAf9oRm 2OBpiXqtFu36j2GZO+Ee0wd310ZiK5MeRGMEtFbn9DsDBKyh2IgOFkrwVUGUkrDR+2mz jDTw== 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=nKj6+4mXMs95f/EB7TGBgYMSs41twH9ljnu5PXsWqyc=; b=ohukkFKPhAaHylSQiPYA1YTjgdi2cWxM0g+mVtnzlbYv714cHRx5ZkYhY75tn4Tx0J nMBR141CnP96fuw3zhhd0RtrN7opCsZoqafskDuJwSRQmkw+vxa9IpunpvvbvRYWfpC7 Xc6vCSU2h+S/rCK+aMXHZKHl2zzqt1I4RLPPbELQIwj4imvNIiKeBJ35wvkMGKWzipv0 Wn4tz2Y98fUQUKGKwQddigIKvEmrQ6bIOWZNkIWuzGBqXfXxb7fxX3Cbgmi3wPxhPGO+ KUJEHmCMmwBl29XGgIEU9zNO7JssTQeAFD2vSP6RmaYxAKDzpo0wKHh7rprZJCqftWq3 bdVA== X-Gm-Message-State: AOAM530ZHKrofBjj0BCJqzOhCXN+w1Q9MDF+UOr91W5o0TbCzXO2K+xl EGRgYb88ue42XmwyHtseQiLcyH69tduQfA== X-Google-Smtp-Source: ABdhPJyRELbWU/kRtBo0BV2BmyRcY23w9HvyYXLZODn+kcKRPc80RHWU0iR/m0FVDaeufeelm6bjXA== X-Received: by 2002:a05:6000:1549:: with SMTP id 9mr31140949wry.192.1618225752890; Mon, 12 Apr 2021 04:09:12 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id a8sm18158744wrh.91.2021.04.12.04.09.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Apr 2021 04:09:12 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Matthieu Moy , Johannes Schindelin , =?utf-8?b?w4Z2YXIgQXJu?= =?utf-8?b?ZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH 03/16] test-lib tests: remove dead GIT_TEST_FRAMEWORK_SELFTEST variable Date: Mon, 12 Apr 2021 13:08:52 +0200 Message-Id: X-Mailer: git-send-email 2.31.1.634.gb41287a30b0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Stop setting the GIT_TEST_FRAMEWORK_SELFTEST variable. This was originally needed back in 4231d1ba99 (t0000: do not get self-test disrupted by environment warnings, 2018-09-20). It hasn't been needed since I deleted the relevant code in test-lib.sh in c0eedbc009 (test-lib: remove check_var_migration, 2021-02-09), I just didn't notice that it was set here. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/t0000-basic.sh | 4 ---- 1 file changed, 4 deletions(-) diff --git a/t/t0000-basic.sh b/t/t0000-basic.sh index 705d62cc27a..2c6e34b9478 100755 --- a/t/t0000-basic.sh +++ b/t/t0000-basic.sh @@ -84,10 +84,6 @@ _run_sub_test_lib_test_common () { passing metrics ' - # Tell the framework that we are self-testing to make sure - # it yields a stable result. - GIT_TEST_FRAMEWORK_SELFTEST=t && - # Point to the t/test-lib.sh, which isn't in ../ as usual . "\$TEST_DIRECTORY"/test-lib.sh EOF From patchwork Mon Apr 12 11:08:53 2021 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: 12197627 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6385BC433B4 for ; Mon, 12 Apr 2021 11:09:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3FE6361249 for ; Mon, 12 Apr 2021 11:09:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240020AbhDLLJg (ORCPT ); Mon, 12 Apr 2021 07:09:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38824 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239971AbhDLLJd (ORCPT ); Mon, 12 Apr 2021 07:09:33 -0400 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 287B7C06138D for ; Mon, 12 Apr 2021 04:09:15 -0700 (PDT) Received: by mail-wr1-x435.google.com with SMTP id p6so5759679wrn.9 for ; Mon, 12 Apr 2021 04:09:15 -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=p/hvGIzGPDCKVC/OKdQxESjHYzzNU9xdyNR3xIBKbkA=; b=QOXfTUHpchVZSEFVVw1yzeRP3rutPSSsNiWj0T8L9ybel8EvZNylG/gFmHwBXT/DDf P65il2J1ffjVe9+djhHpL8nP8DlaygRaAS2AFt0ocGk8X7RXCa+tGPda/nCYbKWZT7Jl yTwnz5GQyeMeuKnt/F/6aKtr8T3O3+qhtZ6EdgBgDkbGcUS+r9xaur+Jh42oOvSP99Gu AnNwaiCRKjz4oMd38r5bFRGcPrZ16xqG/8HzR+ZWoQqZjcyx3HTgjUo4cFHzNSZs2SLD ogo5FWyROrsX0yK1be5cvGOY9wa6e0rXpXMtmyGKgpZlg9a8uEsftLu9KxDj1lm8SphH k4og== 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=p/hvGIzGPDCKVC/OKdQxESjHYzzNU9xdyNR3xIBKbkA=; b=P7NB5RFfHVVcjrJbMawYQrRj150oa+Fl5GUsSHJBLe00hxmI6fy4mFTtAopiY2RzpV uuw9HhPukt05Zp6Po2rPAIv5j4tS9a2zkMKidClxXOPdDF4b2Po+jwRrrYz81c1YQtPU eLNGGIqlx+iMSSP4W2HILzHmYCcrrhZO5balwO9LaWZYFsDafbCzx5lsxtdRnmUjVeaZ Z45UKAL/H4A7ypz3rW4DhxceB7KKZddMc4x9niphtwzfaUbi/i4GARc8NvCr8iqlOg/0 jZaSSBchTd75F3eXFAyQb63qSswNxM1LSSS40s22vmeedpvbeuguDMYuZWSqe3uga01k yKYQ== X-Gm-Message-State: AOAM530R4M037Y7+3hfcUXwO7GnF6ghQ7hR/u7MlRZVa+bHVPVpcJCou 2q0nMo9cqbqr4XHIlgR6nQ01Ut/a4+0+ew== X-Google-Smtp-Source: ABdhPJwkyyCbvYhEjtB9K3pRXW2D2DjnTX6Mvf4dLuostVJfbKFxL4J9PT95H2qDleYC7ExJXkIDaA== X-Received: by 2002:adf:fdcd:: with SMTP id i13mr16232843wrs.185.1618225753685; Mon, 12 Apr 2021 04:09:13 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id a8sm18158744wrh.91.2021.04.12.04.09.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Apr 2021 04:09:13 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Matthieu Moy , Johannes Schindelin , =?utf-8?b?w4Z2YXIgQXJu?= =?utf-8?b?ZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH 04/16] test-lib-functions: reword "test_commit --append" docs Date: Mon, 12 Apr 2021 13:08:53 +0200 Message-Id: X-Mailer: git-send-email 2.31.1.634.gb41287a30b0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Reword the documentation for "test_commit --append" added in my 3373518cc8 (test-lib functions: add an --append option to test_commit, 2021-01-12). A follow-up commit will make the "echo" part of this configurable, and in any case saying "echo >>" rather than ">>" was redundant. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/test-lib-functions.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh index 6348e8d7339..d169fb2f597 100644 --- a/t/test-lib-functions.sh +++ b/t/test-lib-functions.sh @@ -172,8 +172,7 @@ debug () { # --notick # Do not call test_tick before making a commit # --append -# Use "echo >>" instead of "echo >" when writing "" to -# "" +# Use ">>" instead of ">" when writing "" to "" # --signoff # Invoke "git commit" with --signoff # --author From patchwork Mon Apr 12 11:08:54 2021 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: 12197631 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 070A3C433ED for ; Mon, 12 Apr 2021 11:09:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DCCBD61249 for ; Mon, 12 Apr 2021 11:09:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240029AbhDLLJi (ORCPT ); Mon, 12 Apr 2021 07:09:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239975AbhDLLJd (ORCPT ); Mon, 12 Apr 2021 07:09:33 -0400 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF129C06138E for ; Mon, 12 Apr 2021 04:09:15 -0700 (PDT) Received: by mail-wr1-x436.google.com with SMTP id x7so12463385wrw.10 for ; Mon, 12 Apr 2021 04:09:15 -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=wtCLBXVFgxGD5dMcuTCE7t2GK4E6j0uhLdgKnW/lAfI=; b=R5AEvwunI7xNip3w7uOcyAAeWuLb9phwpRyQUKIDqh1H2/x0omaVaNoALFeeORyiLW 4FZU/P+ffQZzO3rQMmhrT2RdIMZ9UVaetnfA33sDFRaem3waC9/U6OQyibKnP4f/YCvX GN7Hz64RsyN8T8HIpb1UdMoOK4tTGFB0GuKVDDkG3xvA33r97lTyjUh7gjV81EIV0AcU EX4rdoP56phDyD4iXDYUNJ/eSx/7DqiOuoZhkiVcGUwIZdXmu5tf3n9fL2d1fbKW1pTG h9w8k9GGL7sPIGN9fYCFRwtB1rIVbo0bPk5rkLUCja6VEWJ3VDQqHo8gCKX5M8KBUevC S5tA== 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=wtCLBXVFgxGD5dMcuTCE7t2GK4E6j0uhLdgKnW/lAfI=; b=dpRF5LHHm2+pW3fzOry7PaGMg/cXtlc0emhH005cp2L26CMcxUQllh7Fn6FLW38GZo XMQTyiMwWSydhvGlVpSUR38lkrVKH90R+67HQ1WLr2t+pCyzYFsUci9YFvcTPC84Fzbw X1Ta8vMmywPUyjcyZn0EwrYfeo2A4cyisEDVec4VLEg0yedxU9Qs0X3j12qGIyyJi1Mc L54mZi6mXDiuIfPMiAAepkOZcS2axAn2ijoghlSY/TX46ZmM+imybp3OH8teSehscTxf 2xEv5w70FHg3q/kbu3cd+CFN7AAf/GegQD4z90Rhsx9IIaGE3VmGVT+usKE0AzzcUeKk vRHQ== X-Gm-Message-State: AOAM532ZdWeWU0pNv0t2VByh6up5Ez6lcs053D8kK9OwdhDTHauqzB/u 5sfN5Dnn6rzrRWY+rAnCygUowbUl/etLlw== X-Google-Smtp-Source: ABdhPJyp/AB+71mm2lTrlLlUmx6UVpOBNcTvrF/gPWMzS50ROT3zgXLn+moAtV+iY5bYAxs3itAD9w== X-Received: by 2002:adf:e843:: with SMTP id d3mr31312018wrn.56.1618225754356; Mon, 12 Apr 2021 04:09:14 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id a8sm18158744wrh.91.2021.04.12.04.09.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Apr 2021 04:09:13 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Matthieu Moy , Johannes Schindelin , =?utf-8?b?w4Z2YXIgQXJu?= =?utf-8?b?ZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH 05/16] test-lib-functions: document test_commit --no-tag Date: Mon, 12 Apr 2021 13:08:54 +0200 Message-Id: X-Mailer: git-send-email 2.31.1.634.gb41287a30b0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org In 76b8b8d05c (test-lib functions: document arguments to test_commit, 2021-01-12) I added missing documentation to test_commit, but in less than a month later in 3803a3a099 (t: add --no-tag option to test_commit, 2021-02-09) we got another undocumented option. Let's fix that. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/test-lib-functions.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh index d169fb2f597..fa3e3e975fd 100644 --- a/t/test-lib-functions.sh +++ b/t/test-lib-functions.sh @@ -177,6 +177,9 @@ debug () { # Invoke "git commit" with --signoff # --author # Invoke "git commit" with --author +# --no-tag +# Do not tag the resulting commit, if supplied giving the +# optional "" argument is an error. # # This will commit a file with the given contents and the given commit # message, and tag the resulting commit with the given tag name. From patchwork Mon Apr 12 11:08:55 2021 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: 12197633 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6F902C433B4 for ; Mon, 12 Apr 2021 11:09:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 315EE6134F for ; Mon, 12 Apr 2021 11:09:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240040AbhDLLJj (ORCPT ); Mon, 12 Apr 2021 07:09:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38834 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239983AbhDLLJe (ORCPT ); Mon, 12 Apr 2021 07:09:34 -0400 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 863A5C06138F for ; Mon, 12 Apr 2021 04:09:16 -0700 (PDT) Received: by mail-wr1-x42c.google.com with SMTP id x15so12496312wrq.3 for ; Mon, 12 Apr 2021 04:09:16 -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=gkj/RqucwxRWIB1UtAk33REd9QSuCQEKy+Zm0v5G4jM=; b=XrTd5BSYxcKGUZXLawdI5mCY9aFKD4V1SF238dCIqNczdjnsCgjT2pEDxCsK8Qj3wJ 7DUdnO60viuH4wxheOXFdwQPIxySma14X8OvCXbSo8j6X0aqrXieDgFKcOKm9WxqRaCD /AxrDaW33bOvSPVAYhEKAlXoQZKEcJOYUs7qNey8ASsQi/wCyejvHYwZPPbVx7VNeEXg tX7OVWzqeWgX4ctos79TMaDXJCHmlrpmw4Nez6i6btwz/64en2vhF54iCCXuPd6XrrU1 7RuuISXqHE0ARGHDz8bkPXsiqoBUnTk5JWGKRliHigzxFJrBIsvCrBVIRZJnNHm+9ORk MWHw== 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=gkj/RqucwxRWIB1UtAk33REd9QSuCQEKy+Zm0v5G4jM=; b=dYXDQ1oavvVWN4Py1af0+xTkH8kXZ4nWpx41IxXziYDplY1MNsYyMojTVtDzDOOJHS 9ugelMymzS5LhqHQ7+nV1q7ptYSWvxRB2/r9S9cgXL/hBWPxM/wRHf2kfwImUONRHMxD 85M/pmsPYc1bI8qJS6JgVi7L0Roo0B/T3xsDlVNJy1FxyA164P2rPH1QqkiRbWETAKj7 xs0BhU0XXpL5KBhvlNx8/jGFFXw22USgyJcrHNMjJTWccFvuxOCWdUBE0fSTaMQVRT42 Ex3uR7TGnVbVWdnBcyCu8Z0NdkZ3OGndu+/XpkPLSZXttOL/PXa/SmAyriBKwkQUVTaH Mxqg== X-Gm-Message-State: AOAM530PQHKxztQ9MwEx9yBz0gkpMxFrxY8BubtOeBaSJFj/mHDwTXQT G7elGpSLeGeckSV0zdsaaCrsQ/o8YaXthA== X-Google-Smtp-Source: ABdhPJxha4ZVlSsqLZj4+XO3nfuXg5BbP5uOl8da5rhwgbnWfbhaT3vWXNCBMi+jf88FiCvVsfSKnQ== X-Received: by 2002:adf:fdc7:: with SMTP id i7mr14774970wrs.350.1618225755045; Mon, 12 Apr 2021 04:09:15 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id a8sm18158744wrh.91.2021.04.12.04.09.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Apr 2021 04:09:14 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Matthieu Moy , Johannes Schindelin , =?utf-8?b?w4Z2YXIgQXJu?= =?utf-8?b?ZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH 06/16] test-lib functions: add an --annotated-tag option to "test_commit" Date: Mon, 12 Apr 2021 13:08:55 +0200 Message-Id: X-Mailer: git-send-email 2.31.1.634.gb41287a30b0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Add an --annotated-tag option to test_commit. The tag will share the same message as the commit, and we'll call test_tick before creating it (unless --notick) is provided. There's quite a few tests that could be simplified with this construct. I've picked one to convert in this change as a demonstration. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/t1403-show-ref.sh | 6 ++---- t/test-lib-functions.sh | 27 ++++++++++++++++++++++----- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/t/t1403-show-ref.sh b/t/t1403-show-ref.sh index 6ce62f878c3..17d3cc14050 100755 --- a/t/t1403-show-ref.sh +++ b/t/t1403-show-ref.sh @@ -7,11 +7,9 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME . ./test-lib.sh test_expect_success setup ' - test_commit A && - git tag -f -a -m "annotated A" A && + test_commit --annotate A && git checkout -b side && - test_commit B && - git tag -f -a -m "annotated B" B && + test_commit --annotate B && git checkout main && test_commit C && git branch B A^0 diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh index fa3e3e975fd..a0fcc383d0b 100644 --- a/t/test-lib-functions.sh +++ b/t/test-lib-functions.sh @@ -180,6 +180,10 @@ debug () { # --no-tag # Do not tag the resulting commit, if supplied giving the # optional "" argument is an error. +# --annotate +# Create an annotated tag with "--annotate -m ". Calls +# test_tick between making the commit and tag unless --notick is +# given. # # This will commit a file with the given contents and the given commit # message, and tag the resulting commit with the given tag name. @@ -192,7 +196,7 @@ test_commit () { author= && signoff= && indir= && - no_tag= && + tag=light && while test $# != 0 do case "$1" in @@ -220,7 +224,10 @@ test_commit () { shift ;; --no-tag) - no_tag=yes + tag=none + ;; + --annotate) + tag=annotate ;; *) break @@ -244,10 +251,20 @@ test_commit () { git ${indir:+ -C "$indir"} commit \ ${author:+ --author "$author"} \ $signoff -m "$1" && - if test -z "$no_tag" - then + case "$tag" in + none) + ;; + light) git ${indir:+ -C "$indir"} tag "${4:-$1}" - fi + ;; + annotate) + if test "$tag$notick" = "annotate" + then + test_tick + fi && + git ${indir:+ -C "$indir"} tag -a -m "$1" "${4:-$1}" + ;; + esac } # Call test_merge with the arguments " ", where From patchwork Mon Apr 12 11:08:56 2021 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: 12197635 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6BDCCC43460 for ; Mon, 12 Apr 2021 11:09:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 33BA761249 for ; Mon, 12 Apr 2021 11:09:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240053AbhDLLJk (ORCPT ); Mon, 12 Apr 2021 07:09:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38834 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240017AbhDLLJf (ORCPT ); Mon, 12 Apr 2021 07:09:35 -0400 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 40D17C061574 for ; Mon, 12 Apr 2021 04:09:17 -0700 (PDT) Received: by mail-wr1-x434.google.com with SMTP id c15so3525737wro.13 for ; Mon, 12 Apr 2021 04:09:17 -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=uTxmY/erkaUGs0q9PprtI8ErQl0/SxKCaUdgamir83s=; b=gEFdlMlIWIuXTueTixDTMCPPwDGPcgNHrH1m7fjsa2iFgv6Ik8VS2aGTQE3bXEA7GL 8ZyFsld6AVZlGJNzzgqrasbh8W/57W6XySqPUF/xhJbyDEIB2L2RJcZyQ6cWG+LIGVxY BGT+WT4DVUatcUGiBt0j+FI234GGw+ofDx3CFu1mQuxibHHPFibmOKVqJ+ppJ48raLt7 +u+9GcTv5vwc7LO7QhtXqX9XUfa357qAMhTr1jN4rrca091gThq5k+kqb22R2KX/kVi5 iD8A519ZTMqZjq/ED3bYVYpRcZQZ/EY82GWRyfmEF4sT2tDf6zlW2XoRtdNLJgLKCyJ+ WtKA== 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=uTxmY/erkaUGs0q9PprtI8ErQl0/SxKCaUdgamir83s=; b=Z46iuhndC6GF4ztj90M+Up5DQH6GCTmY6y/EZjj2kAygv21dxpNGb8LG/Hn3wTE3OC wLJo/rv6N1A5DdpFVUyVDxRfrM2Z9Gx2fMsNU0B2QQRFvMeVo3KP5hDeBQdz0Gqi53Np 0Z7ENv8eKHdAajp/GktP+KzVA4J17bsCHui8kUexuUMBoLB4tQyv6VHPMyXDTzqj+pGY nYgEXBhEyGYySHYVshs/Is/yQg+NyYQTMSDJwJkaTwtjdTjFKZeskLUMtYur+fgO1mRs IiziWbr1bLJtiXPq4YPlGjFc3KklQEnGQm4jg4Eej7UO2YDbUfXLYgYaTeDRgV5A5tYe TRCA== X-Gm-Message-State: AOAM532L8rA0DPC37qBDleXP2aMnuAUnjkZWwPyd78eBhz8912n5+L00 24emx4SKWYCO03XpohODHN3AcxJrRVxv4w== X-Google-Smtp-Source: ABdhPJzfeiNB4Da68YZGk556AL8GHobQVGzqqJzckqjUuosqtLh0pcGjiiuRhQTIStX7KXBbdaEGwA== X-Received: by 2002:adf:fb0b:: with SMTP id c11mr31223969wrr.425.1618225755797; Mon, 12 Apr 2021 04:09:15 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id a8sm18158744wrh.91.2021.04.12.04.09.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Apr 2021 04:09:15 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Matthieu Moy , Johannes Schindelin , =?utf-8?b?w4Z2YXIgQXJu?= =?utf-8?b?ZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH 07/16] describe tests: convert setup to use test_commit Date: Mon, 12 Apr 2021 13:08:56 +0200 Message-Id: X-Mailer: git-send-email 2.31.1.634.gb41287a30b0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Convert the setup of the describe tests to use test_commit when possible. This makes use of the new --annotated-tag option to test_commit. Some of the setup here could simply be removed since the data being created wasn't important to any of the subsequent tests, so I've done so. E.g. assigning to the "one" variable was always useless, and just checking that we can describe HEAD after the first commit wasn't useful. In the case of the "two" variable we could instead use the tag we just created. See 5312ab11fbf (Add describe test., 2007-01-13) for the initial version of this code. There's other cases here like redundant "test_tick" invocations, or the simplification of not echoing "X" to a file we're about to tag as "x", now we just use "x" in both cases. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/t6120-describe.sh | 58 ++++++++++----------------------------------- 1 file changed, 13 insertions(+), 45 deletions(-) diff --git a/t/t6120-describe.sh b/t/t6120-describe.sh index e89b6747bee..88fddc91424 100755 --- a/t/t6120-describe.sh +++ b/t/t6120-describe.sh @@ -31,64 +31,32 @@ check_describe () { } test_expect_success setup ' + test_commit initial file one && + test_commit second file two && + test_commit third file three && + test_commit --annotate A file A && + test_commit c file c && - test_tick && - echo one >file && git add file && git commit -m initial && - one=$(git rev-parse HEAD) && - - git describe --always HEAD && - - test_tick && - echo two >file && git add file && git commit -m second && - two=$(git rev-parse HEAD) && - - test_tick && - echo three >file && git add file && git commit -m third && - - test_tick && - echo A >file && git add file && git commit -m A && - test_tick && - git tag -a -m A A && - - test_tick && - echo c >file && git add file && git commit -m c && - test_tick && - git tag c && - - git reset --hard $two && - test_tick && - echo B >side && git add side && git commit -m B && - test_tick && - git tag -a -m B B && + git reset --hard second && + test_commit --annotate B side B && test_tick && git merge -m Merged c && merged=$(git rev-parse HEAD) && - git reset --hard $two && - test_tick && - echo D >another && git add another && git commit -m D && - test_tick && - git tag -a -m D D && - test_tick && - git tag -a -m R R && - - test_tick && - echo DD >another && git commit -a -m another && + git reset --hard second && + test_commit --no-tag D another D && test_tick && - git tag e && + git tag -a -m R R && - test_tick && - echo DDD >another && git commit -a -m "yet another" && + test_commit e another DD && + test_commit --no-tag "yet another" another DDD && test_tick && git merge -m Merged $merged && - test_tick && - echo X >file && echo X >side && git add file side && - git commit -m x - + test_commit --no-tag x file ' check_describe A-* HEAD From patchwork Mon Apr 12 11:08:57 2021 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: 12197637 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A9AEEC433ED for ; Mon, 12 Apr 2021 11:09:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8A5D46134F for ; Mon, 12 Apr 2021 11:09:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240055AbhDLLJl (ORCPT ); Mon, 12 Apr 2021 07:09:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240021AbhDLLJf (ORCPT ); Mon, 12 Apr 2021 07:09:35 -0400 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24B1CC06138C for ; Mon, 12 Apr 2021 04:09:18 -0700 (PDT) Received: by mail-wr1-x435.google.com with SMTP id s7so12367264wru.6 for ; Mon, 12 Apr 2021 04:09:18 -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=30Kk+2RZYtpARiUZ32rbRmXO8KXIXAGMfTzcA63gHLk=; b=GCEGpMVIF5ZTAbVKBk5ZJH1yJgsCQAT2aWUOdCMWDO9a/Z5oxJAH3UiajkzBHBR0Zv 6IA11DrfYe5pFpw3cCatWvA4Wh8vy/d4NVyxcPmKAttG57RJe7479UpMOggvoRexo2Qc 77/dekrFcnTtXDY6Fa3oBeelTRxSqXiIbDRHsUPrBCcZhBqtI+vONkDaR1GS+kKLS/e6 /kGMczarkhPH8a6fkwfR2xDfED+kkDpC3P8UEIAy2bo+g7MRoECkvOaZrnYRuXuvgGex c6GLPTS5zOVK5Kc9dEW9DI7UH2mEcMBmJxbEOMORtUdxuC0Yo5H1ErOYugrOK7BVgLd+ gA7A== 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=30Kk+2RZYtpARiUZ32rbRmXO8KXIXAGMfTzcA63gHLk=; b=RWEIYNgJOztdF8FLG8hTIgRvQFUwF1z23WjhqLtc6vB+UsUztH1xICUMGiVLP1ifQj JtW6wM5AZKJFIesIr8NwRNMLUCS0ffspAxsX9sLPqwMpuadIq5pwGGSZf3Yusk1sexOf pVyU0e9w/S16X3v9E5WoYXeKJ624FCQS7y6dXkeORgtM0RBZwgTaRez76wm5qFpOwsjx nx3L8KonibHKFH+us4HtzbH2FNvssv0gYOYb6TPCsIBYJQPsF/Vx2aYV6Qxrn7itMDBj uMvkZ6ApJROyG4r6Ux6y/rw3Q68/0sQWGkNMWO9Awy6m6mW3RXyrapdNV5wEavXqsU4g 7H1w== X-Gm-Message-State: AOAM531RGZzjWBy4XOvCCCs9AltQHpccDt7eB3gpPLAHZGI6vnjYa1o/ z3s4he7KfngEko3FeklzmwsUMzL24KNIzw== X-Google-Smtp-Source: ABdhPJy7GPGNhNHnpLumlKdyGmDzofJ1o1SOKyTLZW1eWNlhtM6Zicuq13KW1hl4ul1Ejmp0deB4Ew== X-Received: by 2002:adf:e650:: with SMTP id b16mr10797772wrn.273.1618225756630; Mon, 12 Apr 2021 04:09:16 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id a8sm18158744wrh.91.2021.04.12.04.09.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Apr 2021 04:09:16 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Matthieu Moy , Johannes Schindelin , =?utf-8?b?w4Z2YXIgQXJu?= =?utf-8?b?ZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH 08/16] test-lib functions: add --printf option to test_commit Date: Mon, 12 Apr 2021 13:08:57 +0200 Message-Id: X-Mailer: git-send-email 2.31.1.634.gb41287a30b0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Add a --printf option to test_commit to allow writing to the file with "printf" instead of "echo". This is useful for writing "\n", "\0" etc., in particular in combination with the --append option added in 3373518cc8 (test-lib functions: add an --append option to test_commit, 2021-01-12). I'm converting a few tests to use the new option rather than a manual printf/add/commit combination to demonstrate its usefulness. While I'm at it use "test_create_repo" where appropriate, and give the first/second commit a meaningful/more conventional log message in cases where no test cared about that message. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/t1307-config-blob.sh | 4 +--- t/t2030-unresolve-info.sh | 3 +-- t/t4006-diff-mode.sh | 6 ++---- t/t4030-diff-textconv.sh | 8 ++------ t/t5520-pull.sh | 10 ++-------- t/test-lib-functions.sh | 12 ++++++++++-- 6 files changed, 18 insertions(+), 25 deletions(-) diff --git a/t/t1307-config-blob.sh b/t/t1307-config-blob.sh index 002e6d3388e..930dce06f0f 100755 --- a/t/t1307-config-blob.sh +++ b/t/t1307-config-blob.sh @@ -65,9 +65,7 @@ test_expect_success 'parse errors in blobs are properly attributed' ' ' test_expect_success 'can parse blob ending with CR' ' - printf "[some]key = value\\r" >config && - git add config && - git commit -m CR && + test_commit --printf CR config "[some]key = value\\r" && echo value >expect && git config --blob=HEAD:config some.key >actual && test_cmp expect actual diff --git a/t/t2030-unresolve-info.sh b/t/t2030-unresolve-info.sh index be6c84c52a2..f691e6d9032 100755 --- a/t/t2030-unresolve-info.sh +++ b/t/t2030-unresolve-info.sh @@ -179,8 +179,7 @@ test_expect_success 'rerere and rerere forget (subdirectory)' ' test_expect_success 'rerere forget (binary)' ' git checkout -f side && - printf "a\0c" >binary && - git commit -a -m binary && + test_commit --printf binary binary "a\0c" && test_must_fail git merge second && git rerere forget binary ' diff --git a/t/t4006-diff-mode.sh b/t/t4006-diff-mode.sh index 275ce5fa15b..6cdee2a2164 100755 --- a/t/t4006-diff-mode.sh +++ b/t/t4006-diff-mode.sh @@ -26,10 +26,8 @@ test_expect_success 'chmod' ' ' test_expect_success 'prepare binary file' ' - git commit -m rezrov && - printf "\00\01\02\03\04\05\06" >binbin && - git add binbin && - git commit -m binbin + git commit -m one && + test_commit --printf two binbin "\00\01\02\03\04\05\06" ' test_expect_success '--stat output after text chmod' ' diff --git a/t/t4030-diff-textconv.sh b/t/t4030-diff-textconv.sh index c906320b60d..a39a626664d 100755 --- a/t/t4030-diff-textconv.sh +++ b/t/t4030-diff-textconv.sh @@ -26,12 +26,8 @@ EOF chmod +x hexdump test_expect_success 'setup binary file with history' ' - printf "\\0\\n" >file && - git add file && - git commit -m one && - printf "\\01\\n" >>file && - git add file && - git commit -m two + test_commit --printf one file "\\0\\n" && + test_commit --printf --append two file "\\01\\n" ' test_expect_success 'file is considered binary by porcelain' ' diff --git a/t/t5520-pull.sh b/t/t5520-pull.sh index a09411327f9..e2c0c510222 100755 --- a/t/t5520-pull.sh +++ b/t/t5520-pull.sh @@ -746,14 +746,8 @@ test_expect_success 'pull --rebase fails on corrupt HEAD' ' ' test_expect_success 'setup for detecting upstreamed changes' ' - mkdir src && - ( - cd src && - git init && - printf "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n" > stuff && - git add stuff && - git commit -m "Initial revision" - ) && + test_create_repo src && + test_commit -C src --printf one stuff "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n" && git clone src dst && ( cd src && diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh index a0fcc383d0b..a90a6b2cc27 100644 --- a/t/test-lib-functions.sh +++ b/t/test-lib-functions.sh @@ -173,6 +173,10 @@ debug () { # Do not call test_tick before making a commit # --append # Use ">>" instead of ">" when writing "" to "" +# --printf +# Use "printf" instead of "echo" when writing "" to +# "". You will need to provide your own trailing "\n". You +# can only supply the FORMAT for the printf(1), not its ARGUMENT(s). # --signoff # Invoke "git commit" with --signoff # --author @@ -192,6 +196,7 @@ debug () { test_commit () { notick= && + echo=echo && append= && author= && signoff= && @@ -203,6 +208,9 @@ test_commit () { --notick) notick=yes ;; + --printf) + echo=printf + ;; --append) append=yes ;; @@ -239,9 +247,9 @@ test_commit () { file=${2:-"$1.t"} && if test -n "$append" then - echo "${3-$1}" >>"$indir$file" + $echo "${3-$1}" >>"$indir$file" else - echo "${3-$1}" >"$indir$file" + $echo "${3-$1}" >"$indir$file" fi && git ${indir:+ -C "$indir"} add "$file" && if test -z "$notick" From patchwork Mon Apr 12 11:08:58 2021 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: 12197639 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F14D5C433B4 for ; Mon, 12 Apr 2021 11:09:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C46A661352 for ; Mon, 12 Apr 2021 11:09:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240062AbhDLLJn (ORCPT ); Mon, 12 Apr 2021 07:09:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240016AbhDLLJg (ORCPT ); Mon, 12 Apr 2021 07:09:36 -0400 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D1DCFC061574 for ; Mon, 12 Apr 2021 04:09:18 -0700 (PDT) Received: by mail-wr1-x433.google.com with SMTP id w4so8740665wrt.5 for ; Mon, 12 Apr 2021 04:09:18 -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=UAJszAaQO87MJV7zOk0rTBrz8wCQ47q4yvccsO6MsD8=; b=QaTIg4MhBISqFYa6dpD0q7bXl5I3EaztU+iKY9FfvLIv5KYH5vFwOeUhkUpTEeXfYb LqPAnSVHU/pY39yI84bsHKwhdpRwGI8QF/6ws98RiO8jx1GPlx6+svHhBMhk3tAm5yi8 r97/OLBnqr0VK/C5wNQbxsDIhD7YpcOKySyCpi+2KRDpOWjOnLSFMorycTkoeSIwz4x9 y29zrlvL1+UfweCrPdqMIKoIUlm4p0Y8dnKMlz4QX0yMdQgyjfa4bVTCR7k7YT/E/h7/ sQm0QM5uP+cQVsqRxTsQ1KYsaPDpv/PK9/PnrzEvkto/9Hbpm1JhWQR85I5CO9CHY1CF wO6A== 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=UAJszAaQO87MJV7zOk0rTBrz8wCQ47q4yvccsO6MsD8=; b=jXWIFutcgbG9QEh8t1l7VTNrUVnFQPONORyqFuJd51IJtqACxBu9EvNcCzGw6dr6ts q9MYKySKgZ4LnDEHhosAh3lmtNkjFOSmGEoCse4Reofh6pHcg2uP6Qk+hx8+oZsSsFLf BIKfFlW5/l+if8fxCQT6gk/xDmiCV7GBUh5eN2FbUeDiwvGjS32WtLPDVLPMvEydzehM kUqCKuJMkx/EOttzWdhrmUy87p0o8mXqmS8cLkebV/edXCyjd/1sXWg/OlUKiVSxNQhp Hr94aMEH9NzB8TCpWbDNozPGAxsRqh4/b1iG7f3vqZi3CGhfItY2Q/ovWDtKUrGukWIA l5kA== X-Gm-Message-State: AOAM5310ZoniFBWEBwUcZb/4qBM1fzsczIPcPQUV7BTdQZD4hC1AzHJu 7St8HcxglSSzTVZRCb6Md2OO6AnGjYXwmA== X-Google-Smtp-Source: ABdhPJwoyyqC4q4n4FMfr6vKREqL/HROD9vWnXCvvhwfPGh9EVV1u7RVZRRAgtGgOcmFsLOwj48FdQ== X-Received: by 2002:adf:e0c8:: with SMTP id m8mr31523867wri.349.1618225757364; Mon, 12 Apr 2021 04:09:17 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id a8sm18158744wrh.91.2021.04.12.04.09.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Apr 2021 04:09:16 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Matthieu Moy , Johannes Schindelin , =?utf-8?b?w4Z2YXIgQXJu?= =?utf-8?b?ZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH 09/16] submodule tests: use symbolic-ref --short to discover branch name Date: Mon, 12 Apr 2021 13:08:58 +0200 Message-Id: X-Mailer: git-send-email 2.31.1.634.gb41287a30b0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Change a use of $GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME added in 704fed9ea22 (tests: start moving to a different default main branch name, 2020-10-23) to simply discover the initial branch name of a repository set up in this function with "symbolic-ref --short". That's something done in another test in 704fed9ea22, so doing it like this seems like an omission, or rather an overly eager search/replacement instead of fixing the test logic. There are only three uses of the GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME variable in the test suite, this gets rid of one of those. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/lib-submodule-update.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/t/lib-submodule-update.sh b/t/lib-submodule-update.sh index 4b714e93083..f7c7df0ca42 100644 --- a/t/lib-submodule-update.sh +++ b/t/lib-submodule-update.sh @@ -63,6 +63,7 @@ create_lib_submodule_repo () { git init submodule_update_repo && ( cd submodule_update_repo && + branch=$(git symbolic-ref --short HEAD) && echo "expect" >>.gitignore && echo "actual" >>.gitignore && echo "x" >file1 && @@ -144,7 +145,7 @@ create_lib_submodule_repo () { git checkout -b valid_sub1 && git revert HEAD && - git checkout "${GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME-master}" + git checkout "$branch" ) } From patchwork Mon Apr 12 11:08:59 2021 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: 12197641 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E0709C433ED for ; Mon, 12 Apr 2021 11:09:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BB9276134F for ; Mon, 12 Apr 2021 11:09:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240074AbhDLLJo (ORCPT ); Mon, 12 Apr 2021 07:09:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240024AbhDLLJh (ORCPT ); Mon, 12 Apr 2021 07:09:37 -0400 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8CE72C06174A for ; Mon, 12 Apr 2021 04:09:19 -0700 (PDT) Received: by mail-wr1-x434.google.com with SMTP id p6so5759922wrn.9 for ; Mon, 12 Apr 2021 04:09:19 -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=rUVrMUDo9yDe6nCWrB6hmxvw6riSKT5gYrc2KiZY3kA=; b=AZEjhRY4xGyc9o7WVOE5gM5r4Z+GcyzsZpXbc9RBVNMr3vc12sTKb3EvyH0/cO5v3l ecDS5/t8C5JZXA5Tf8ELQYz//0pL+X2lPoiVGEUaBY0vK2Gis/WgvUhvNZqDDSWIzL6B 1Q7dIkBLCW2+IK6x+nKEDHDAfutK4XYjw3EYdBpioD7HzGsDspdruGF2olouZafJTVKB cq64i3eZbGlDJ9k25d9kZOTh0bv5vZFsleOXAfo5Ztn85jSIXHPN5IaLsOEmFnJ2QGtN HIDa+blIxi7VM16Tnk3/9L/TqOH/rAxgqDojwTbkRyxRH16rzS77yQHPJW2ltKXVBIlx uV0A== 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=rUVrMUDo9yDe6nCWrB6hmxvw6riSKT5gYrc2KiZY3kA=; b=b1QG/3KkcAZbtAJApLm6QTGh5hZYepNilHO/lBkvaSX0L/aP40Jdd8O5Wb24OLg7O0 +khHASirr/OoqynZrJcKRQj8K409xGuf3M35ZK80LUiu3GKagKB3g/w3AvwPkjXtaj1e 0SFEDm1I9S0amPDKzYlD4wwq4OWxUpO3UOlrzJwTEAVKTmlmELa4SI3CaNSsxxRYTkdV 5Q0PvaOJasagmyr/BhlETC2kqZd2HU8D3zACl+mVPB7Gc4Ee39ZvzFwxGtgrXAsKbrDe aght4rf2ULRTwwKggQnP+FnYjSmajqCeguwDznJn42zrlO2+dU+PrD6nlc5VmfV2AYLJ hypw== X-Gm-Message-State: AOAM532ZneDuUVRlFDSW0+qzMWQ/khdjRkRpMJazfcMZ+iN2sC7CSGNZ lP3CpE2uFa7Jo8mSZugilWqdjijVO1qqGw== X-Google-Smtp-Source: ABdhPJzMfrwnDjFZ6VQkt0iVydHsBzMjLd7+WykcEl0Iq6o7bvUrHxIPJ5lQueDR8b16c2yaLhdn+Q== X-Received: by 2002:adf:cd8c:: with SMTP id q12mr7322141wrj.328.1618225758099; Mon, 12 Apr 2021 04:09:18 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id a8sm18158744wrh.91.2021.04.12.04.09.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Apr 2021 04:09:17 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Matthieu Moy , Johannes Schindelin , =?utf-8?b?w4Z2YXIgQXJu?= =?utf-8?b?ZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH 10/16] test-lib: reformat argument list in test_create_repo() Date: Mon, 12 Apr 2021 13:08:59 +0200 Message-Id: X-Mailer: git-send-email 2.31.1.634.gb41287a30b0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Reformat an argument list changed in 675704c74dd (init: provide useful advice about init.defaultBranch, 2020-12-11) to have the "-c" on the same line as the argument it sets. This whitespace-only change makes it easier to review a subsequent commit. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/test-lib-functions.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh index a90a6b2cc27..674b865a20d 100644 --- a/t/test-lib-functions.sh +++ b/t/test-lib-functions.sh @@ -1258,8 +1258,8 @@ test_create_repo () { mkdir -p "$repo" ( cd "$repo" || error "Cannot setup test environment" - "${GIT_TEST_INSTALLED:-$GIT_EXEC_PATH}/git$X" -c \ - init.defaultBranch="${GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME-master}" \ + "${GIT_TEST_INSTALLED:-$GIT_EXEC_PATH}/git$X" \ + -c init.defaultBranch="${GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME-master}" \ init \ "--template=$GIT_BUILD_DIR/templates/blt/" >&3 2>&4 || error "cannot run git init -- have you built things yet?" From patchwork Mon Apr 12 11:09:00 2021 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: 12197643 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CD318C433B4 for ; Mon, 12 Apr 2021 11:09:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 97B856134F for ; Mon, 12 Apr 2021 11:09:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240097AbhDLLJq (ORCPT ); Mon, 12 Apr 2021 07:09:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240031AbhDLLJi (ORCPT ); Mon, 12 Apr 2021 07:09:38 -0400 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6AE3CC06138C for ; Mon, 12 Apr 2021 04:09:20 -0700 (PDT) Received: by mail-wr1-x435.google.com with SMTP id h4so3449391wrt.12 for ; Mon, 12 Apr 2021 04:09:20 -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=0nXQnEeqyKsUjE0RUMn+hQlwSRfV4F+S9KtwaPGs2KU=; b=lAGFdGOvUCa0MQwrZXdMwX4RQkPaXs61DzH7fD0iJ8A7KJebeND1fpZrpfjX2PqNK3 IjWTvYiYpGAycumw2YBZR7iGlvkPMB8fE/soPFtlyL05tM/zPPKlOzmgi76YCT+d2iLa D08IMDthHTQozyj2ClUgbFlx+zplnl7vmKMEO7nzAzouRB4I5zbEj7fSkbK8sDFkW2E9 QUorL2kU2cR/GvialV4BKT6YDKyZIiGjXq3Eedk29XY18y1AwgQfyD5VQTD9vq/gzVhL Z97N//f9wsO5yKF4kF9THt8YpSJMdbD70/52152XqykDMBAX9q3q4a1BXdgN00QIg3It O6DA== 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=0nXQnEeqyKsUjE0RUMn+hQlwSRfV4F+S9KtwaPGs2KU=; b=fCj5jyL1/fSUQcrpTM/ScviuHS3c+oBVnTvZrvk1aDpC4fM1/QYyUEqiPMweGMPp5W ZBq3y+my8DviHXRPD8Yze1DWogjfsL8OtlA2YFMgEIxodfq/xrW7wUPDo5lZjnrVdiJl 86Z8IcmjgPEFlJ3es/tKdQdpeul9gCNP8JmrCbAPQ9LiismiuZJi1i13btKfH1rHof+n 0MgpMzhW1mg5xqtucLkPa+e/gmXftjfmdTb0USs5YYKGWm0gP7/XLETauBzLoR2Sshrg Eeo6A7f50JJkOCQMamxcQ2/pgaeXUfvhIdMGo+Q7wMg6sHIZtgTwGZdmPQYzA3c29Ya5 3X+g== X-Gm-Message-State: AOAM533aV915vVOZHXPFqD32Dz81ZjFMqMguv9c7LqelGXFweBFu3jgo swCGefZF1Mtjuaq4LjUTYIX/bewiPWemzQ== X-Google-Smtp-Source: ABdhPJxfijPQ7DkbqsFjgF8srMhW3u5deKwhTTQ1txtEcZ6EteDZzk5p2qb8hTxRg7+bz9gdCthq1Q== X-Received: by 2002:adf:dc4b:: with SMTP id m11mr31614863wrj.145.1618225758974; Mon, 12 Apr 2021 04:09:18 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id a8sm18158744wrh.91.2021.04.12.04.09.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Apr 2021 04:09:18 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Matthieu Moy , Johannes Schindelin , =?utf-8?b?w4Z2YXIgQXJu?= =?utf-8?b?ZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH 11/16] test-lib: do not show advice about init.defaultBranch under --verbose Date: Mon, 12 Apr 2021 13:09:00 +0200 Message-Id: X-Mailer: git-send-email 2.31.1.634.gb41287a30b0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Arrange for the advice about naming the initial branch not to be shown in the --verbose output of the test suite. Since 675704c74dd (init: provide useful advice about init.defaultBranch, 2020-12-11) some tests have been very chatty with repeated occurrences of this multi-line advice. Having it be this verbose isn't helpful for anyone in the context of git's own test suite, and it makes debugging tests that use their own "git init" invocations needlessly distracting. By setting the GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME variable early in test-lib.sh itself we'll squash the warning not only for test_create_repo(), as 675704c74dd explicitly intended, but also for other "git init" invocations. And once we'd like to have this configuration set for all "git init" invocations in the test suite we can get rid of the init.defaultBranch configuration setting in test_create_repo(), as repo_default_branch_name() in refs.c will take the GIT_TEST_* variable over it being set. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/test-lib-functions.sh | 1 - t/test-lib.sh | 5 +++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh index 674b865a20d..c81726acb9e 100644 --- a/t/test-lib-functions.sh +++ b/t/test-lib-functions.sh @@ -1259,7 +1259,6 @@ test_create_repo () { ( cd "$repo" || error "Cannot setup test environment" "${GIT_TEST_INSTALLED:-$GIT_EXEC_PATH}/git$X" \ - -c init.defaultBranch="${GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME-master}" \ init \ "--template=$GIT_BUILD_DIR/templates/blt/" >&3 2>&4 || error "cannot run git init -- have you built things yet?" diff --git a/t/test-lib.sh b/t/test-lib.sh index a8869eee58f..0057dfa69d0 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -64,6 +64,11 @@ then export GIT_TEST_DISALLOW_ABBREVIATED_OPTIONS fi +# Explicitly set the default branch name for testing, to avoid the +# transitory "git init" warning under --verbose. +: ${GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME:=master} +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + ################################################################ # It appears that people try to run tests without building... "${GIT_TEST_INSTALLED:-$GIT_BUILD_DIR}/git$X" >/dev/null From patchwork Mon Apr 12 11:09:01 2021 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: 12197645 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F1F0CC43461 for ; Mon, 12 Apr 2021 11:09:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D3D1A61241 for ; Mon, 12 Apr 2021 11:09:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240106AbhDLLJr (ORCPT ); Mon, 12 Apr 2021 07:09:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240034AbhDLLJj (ORCPT ); Mon, 12 Apr 2021 07:09:39 -0400 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4049EC06138D for ; Mon, 12 Apr 2021 04:09:21 -0700 (PDT) Received: by mail-wm1-x32a.google.com with SMTP id t5-20020a1c77050000b029010e62cea9deso6651268wmi.0 for ; Mon, 12 Apr 2021 04:09:21 -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=rPHwDC58iYFxN7sMvoKI/ERAJbHI3mRXaODvcOSrqTc=; b=ULGJh1cq4/tDf2VviyCI9V80j844du8vsYyxzhtWkOq5R6H1wZAB4yXuH3OiMtOrse u1z2J/1V6q2rQwfEgUlWLyRRo2aOepg2xn+dO/8clgaO5q6uXxs37yhflbO+oFdThEAi YctflO6JUlGmXyxWKBr2S0TZwwtT7RiyoQ5rJhd7c92etHIpgz/C8bNvRrrz7R+vTrKY EWL3DdM23/Kz8CqZIXJZ/PSNYCbWmt0Pch8ndbqv6eqNgCLtMLgHj7HqtQbYEX306jfj bA/yGz5cgKIKWh+Bz0Ja5uWXHjuW49QsSxtD12Wx/TQdOINWO8OexSOPKEWvzLyEjxrH eKlw== 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=rPHwDC58iYFxN7sMvoKI/ERAJbHI3mRXaODvcOSrqTc=; b=LzPqLozRG4rnv2/4X77763R5bZcnD1a5ytDGyOgpawgATrSIQHxdx19SsQyCcnZVwe u+AeHDpmfJ/NUFKiwUYgp97V4WfKmVlyfFV/cxyIJtYffcMMN88lKW30q9Iql1ACLpDm KSO1HrxGCBzB90q/+FB8Bw14sZ4Z/dbzd3bhtRTnSY3nSke1PcCTXwHj42lgssIZ3qOO K2NigsPhycuthIOk7H47Yaxe4sIyfcK1Hkcig1FuwDo4MLCP7WJtFyQsI4C3tUUjUMNA 9vinmhgsyI2f2/rUlPIe59tGNvDfiRU0EAq38TnqBTxNgl7quOHTfR4w74cYVyM/FnXE itqg== X-Gm-Message-State: AOAM532dnsxWCmgGAf4EYSSlz+LWXO854Nt+BCAkKGBmHYyO9O/sit6f OfR3Ceqx4PlH03hdUvdxDKTAxSJLVP7MDw== X-Google-Smtp-Source: ABdhPJwvKNOV9SxOyNAALplLVRrOfUyNmbCwtP8aRuipqJ5nzH9Rx3meQNiMLdiMzHG+q3++PdRpcg== X-Received: by 2002:a05:600c:17c3:: with SMTP id y3mr7706885wmo.185.1618225759692; Mon, 12 Apr 2021 04:09:19 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id a8sm18158744wrh.91.2021.04.12.04.09.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Apr 2021 04:09:19 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Matthieu Moy , Johannes Schindelin , =?utf-8?b?w4Z2YXIgQXJu?= =?utf-8?b?ZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH 12/16] test-lib: modernize test_create_repo() function Date: Mon, 12 Apr 2021 13:09:01 +0200 Message-Id: X-Mailer: git-send-email 2.31.1.634.gb41287a30b0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Remove redundant "mkdir -p", argument number checking', test environment sanity checking, and disabling of hooks from test_create_repo(). As we'll see below these were all either redundant to other test other framework code, or to changes in git itself. Respectively: 1. "mkdir -p" isn't needed because "git init" itself will create leading directories if needed. 2. We don't need to check the number of arguments anymore, instead we'll feed "git init" with "$@". It will die if given too many arguments. 3. We won't ever hit that "Cannot setup test environment" error. Checking the test environment sanity when doing "git init" dates back to eea420693be (t0000: catch trivial pilot errors., 2005-12-10) and 2ccd2027b01 (trivial: check, if t/trash directory was successfully created, 2006-01-05). We can also see it in another form a bit later in my own 0d314ce834d (test-lib: use subshell instead of cd $new && .. && cd $old, 2010-08-30). But since 2006f0adaee (t/test-lib: make sure Git has already been built, 2012-09-17) we already check if we have a built git earlier. The one thing this was testing after that 2012 change was that we'd just built "git", but not "git-init", but since 3af4c7156c4 (tests: respect GIT_TEST_INSTALLED when initializing repositories, 2018-11-12) we invoke "git", not "git-init". So all of that's been checked already, and we don't need to re-check it here. 4. We don't need to move .git/hooks out of the way. That dates back to c09a69a83e3 (Disable hooks during tests., 2005-10-16), since then hooks became disabled by default in f98f8cbac01 (Ship sample hooks with .sample suffix, 2008-06-24). So the hooks were already disabled by default, but as can be seen from "mkdir .git/hooks" changes various tests needed to re-setup that directory. Now they no longer do. 5. Since we don't need to move the .git/hooks directory we don't need the subshell here either. In the end it turns out that all we needed was a plain "git init" invocation with a custom --template directory. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/t5406-remote-rejects.sh | 1 - t/t5407-post-rewrite-hook.sh | 2 -- t/t5409-colorize-remote-messages.sh | 1 - t/test-lib-functions.sh | 15 +++------------ 4 files changed, 3 insertions(+), 16 deletions(-) diff --git a/t/t5406-remote-rejects.sh b/t/t5406-remote-rejects.sh index ff06f99649e..5c509db6fc3 100755 --- a/t/t5406-remote-rejects.sh +++ b/t/t5406-remote-rejects.sh @@ -5,7 +5,6 @@ test_description='remote push rejects are reported by client' . ./test-lib.sh test_expect_success 'setup' ' - mkdir .git/hooks && write_script .git/hooks/update <<-\EOF && exit 1 EOF diff --git a/t/t5407-post-rewrite-hook.sh b/t/t5407-post-rewrite-hook.sh index 5bb23cc3a4e..6da8d760e28 100755 --- a/t/t5407-post-rewrite-hook.sh +++ b/t/t5407-post-rewrite-hook.sh @@ -20,8 +20,6 @@ test_expect_success 'setup' ' git checkout main ' -mkdir .git/hooks - cat >.git/hooks/post-rewrite < "$TRASH_DIRECTORY"/post-rewrite.args diff --git a/t/t5409-colorize-remote-messages.sh b/t/t5409-colorize-remote-messages.sh index 5d8f401d8ec..9f1a483f426 100755 --- a/t/t5409-colorize-remote-messages.sh +++ b/t/t5409-colorize-remote-messages.sh @@ -5,7 +5,6 @@ test_description='remote messages are colorized on the client' . ./test-lib.sh test_expect_success 'setup' ' - mkdir .git/hooks && write_script .git/hooks/update <<-\EOF && echo error: error echo ERROR: also highlighted diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh index c81726acb9e..1258329fdd8 100644 --- a/t/test-lib-functions.sh +++ b/t/test-lib-functions.sh @@ -1252,18 +1252,9 @@ test_atexit () { # Most tests can use the created repository, but some may need to create more. # Usage: test_create_repo test_create_repo () { - test "$#" = 1 || - BUG "not 1 parameter to test-create-repo" - repo="$1" - mkdir -p "$repo" - ( - cd "$repo" || error "Cannot setup test environment" - "${GIT_TEST_INSTALLED:-$GIT_EXEC_PATH}/git$X" \ - init \ - "--template=$GIT_BUILD_DIR/templates/blt/" >&3 2>&4 || - error "cannot run git init -- have you built things yet?" - mv .git/hooks .git/hooks-disabled - ) || exit + "${GIT_TEST_INSTALLED:-$GIT_EXEC_PATH}/git$X" \ + init \ + "--template=$GIT_BUILD_DIR/templates/blt/" "$@" >&3 2>&4 } # This function helps on symlink challenged file systems when it is not From patchwork Mon Apr 12 11:09:02 2021 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: 12197647 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7FC5CC433B4 for ; Mon, 12 Apr 2021 11:09:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5678161249 for ; Mon, 12 Apr 2021 11:09:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238720AbhDLLJy (ORCPT ); Mon, 12 Apr 2021 07:09:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240014AbhDLLJk (ORCPT ); Mon, 12 Apr 2021 07:09:40 -0400 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B0FAC06138E for ; Mon, 12 Apr 2021 04:09:22 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id c15so3526032wro.13 for ; Mon, 12 Apr 2021 04:09:22 -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=9yRM16telXossWOvLEumw2ekaxhD50TlwIrN6qhLl0s=; b=mPw0NJ3qdYOEJl+Y1Z+tZMBlcdFD45hVZJLi/O0FnDUa2EQAXXmN2guVZpB6+U5Ow0 /A7l6qvJ3KbEoXKndRe7ZFEhsabCL3qSQJNKo8CHR9vLE47iSSzbJ84kHtG8cVZmdWfp i22IDWI4aXJPGNe6rP+xFGQ9YDVpfXjAO1JQE31HbFEz0Ul1LqxV5hWIqWhBD2cr+8RZ TnTFgL8C414oe9pjwZ31Rg6l8LddPTEiBiiUnm9bMpkhCI1fuNnnfKEsEA4PZXpH9/LC dW0U093pUKUJqdknFzseqYO8EWj0eb/oiAkAG8b+zU+/wWgYPgxP4NQSwMvzIzawPKCM WOcg== 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=9yRM16telXossWOvLEumw2ekaxhD50TlwIrN6qhLl0s=; b=um8pCGG8VKcxiyDp+ulq5HEd3t1JwJ1rzusn78dYorplpSh8/DCnDxac7eewP0C1U7 YCi+5CCJkcj2Si33yBCXBNsWQ3hHSdsyNRW0Hs+YxiF0NL8H6aZoK6H/q1RpvRqZMASb Q0xvu+MCi0KIh7LfbIZihv73D7a/P5jeJL/EZ2DUm907RWPLlZUUTMnWgq1pJ1ze1+/Q lxOoJ66KXyQ5pt7XwoSf39N2flvL9XezsLwckXAb+6eO9y2n+btvYJ4bE0jFeAY9/Q/+ QiVCO306S0AD9eTuTL15ESEBIGlmwZO6oYqYEAEH/fq0/DCiXITo9wO8xiYPAmIEEX9s iGzw== X-Gm-Message-State: AOAM532Heaj+czjEmTTYB+sdlLwOpcTwawC/oF7pZYgUpJubsPHpz1Yy 7WU659s7ehKZIQ8oT0yWhO4C9tspsJq8YA== X-Google-Smtp-Source: ABdhPJzQQh45fhP4PCHiUfpbDfWn3lLoew3vyrdQKl3zKaVJ3Fh20W5/1YmNm+x/cngdzVDzw/ULRA== X-Received: by 2002:a5d:4691:: with SMTP id u17mr12673201wrq.22.1618225760650; Mon, 12 Apr 2021 04:09:20 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id a8sm18158744wrh.91.2021.04.12.04.09.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Apr 2021 04:09:19 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Matthieu Moy , Johannes Schindelin , =?utf-8?b?w4Z2YXIgQXJu?= =?utf-8?b?ZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH 13/16] test-lib-functions: normalize test_path_is_missing() debugging Date: Mon, 12 Apr 2021 13:09:02 +0200 Message-Id: X-Mailer: git-send-email 2.31.1.634.gb41287a30b0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Change the test_path_is_missing() to be consistent with related functions. Since 2caf20c52b7 (test-lib: user-friendly alternatives to test [-d|-f|-e], 2010-08-10) we've been ls -ld-ing the bad path and echo-ing $* if it exists. Let's just say that it exists instead. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/test-lib-functions.sh | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh index 1258329fdd8..2518a9b8274 100644 --- a/t/test-lib-functions.sh +++ b/t/test-lib-functions.sh @@ -811,12 +811,7 @@ test_path_is_missing () { test "$#" -ne 1 && BUG "1 param" if test -e "$1" then - echo "Path exists:" - ls -ld "$1" - if test $# -ge 1 - then - echo "$*" - fi + echo "Path $1 exists!" false fi } From patchwork Mon Apr 12 11:09:03 2021 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: 12197649 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 305DEC433ED for ; Mon, 12 Apr 2021 11:09:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0398561241 for ; Mon, 12 Apr 2021 11:09:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240126AbhDLLJ5 (ORCPT ); Mon, 12 Apr 2021 07:09:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240052AbhDLLJk (ORCPT ); Mon, 12 Apr 2021 07:09:40 -0400 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DFD7FC06138F for ; Mon, 12 Apr 2021 04:09:22 -0700 (PDT) Received: by mail-wm1-x32e.google.com with SMTP id w186so2029462wmg.3 for ; Mon, 12 Apr 2021 04:09:22 -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=swSie5ck3VhtKLBfrJHlPXMiVBO9s/osIov1znO1B6g=; b=d+QGOkxgSimREhMqVkaweQ1YUodHHlWKIAIR61lMOFfX8mfmwBBCCydHnItLGP8dzS uhcNTvP+JS4qBVWUanMMrDk9kIkjNBQEFpE45447vU1bx08cLzgEQbJC35G954z7B56O pDQcPsIPLSm1DVGl8S0e0u3//8FPIbCu4/P0zv9i++U4MFWYbRgZ4P59SIeuT3N/s4UL v7pOnkuAOB3K8907LN3azn1W306TXhTyiEJ3S5PY+aPd+d+yPiJCtt2oBrGdyOVmZoZr QrWLiqc5Abc0A8b6j690rqbqTq0sBCpZDE1/4GXlU5lp3JiFQ/IY4T8f0SHOV+uPAb/j r1LQ== 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=swSie5ck3VhtKLBfrJHlPXMiVBO9s/osIov1znO1B6g=; b=V2SaKxwD6XsZNKjbieERog7ugRnRTRBp++jmKE4WfeyObhcc2Cnh0SzQcvSUFZKgJN yXuJZhU/i2BiWCCKZAFiWXQbzqBSL/WPksA+6G2AkGeQjEoUZtfUZ7Tz090sgUNqkPKO /vZmHpBwGRYACtBNV0U039iBix+3iZc6Q+/ppMN16EzSFfMSIPqqWxpNDXJ8vyln2G5u BbBhZsTlCE3AqLTZ/fkn3JchEpzayspLda4N5evbePZ0iCOQH3i4xm5nqZAi7VmLPCox sEoA5kTGzIV52LFpZK7jQNAxZ9v/3bnrgRMVsIp1D3h+cXrPHmDk6VNqAQLhraq7EtXx Y99Q== X-Gm-Message-State: AOAM533qVFUZ4dFVcUYCzKmLUJEKpi4lLdYE3Rg9uDLgup+L5Jf1+QdA bRtYjqrpQKxU9Mwsg5+sMtuHyl2pi5BgIA== X-Google-Smtp-Source: ABdhPJy/HrceZWuNvZ0ZiKD2Y57uQPcbikCw6TyhEovIGYvV/0P7+snUh6aB/M4jt4VHhU9FA2f7zA== X-Received: by 2002:a1c:2587:: with SMTP id l129mr25944124wml.135.1618225761429; Mon, 12 Apr 2021 04:09:21 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id a8sm18158744wrh.91.2021.04.12.04.09.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Apr 2021 04:09:20 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Matthieu Moy , Johannes Schindelin , =?utf-8?b?w4Z2YXIgQXJu?= =?utf-8?b?ZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH 14/16] test-lib-functions: use "return 1" instead of "false" Date: Mon, 12 Apr 2021 13:09:03 +0200 Message-Id: X-Mailer: git-send-email 2.31.1.634.gb41287a30b0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Change a few functions that relied on a "false" being the last statement in the function to use an explicit "return 1" like the other functions in this file. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/test-lib-functions.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh index 2518a9b8274..c46bf0ff09c 100644 --- a/t/test-lib-functions.sh +++ b/t/test-lib-functions.sh @@ -763,7 +763,7 @@ test_path_is_file () { if ! test -f "$1" then echo "File $1 doesn't exist" - false + return 1 fi } @@ -772,7 +772,7 @@ test_path_is_dir () { if ! test -d "$1" then echo "Directory $1 doesn't exist" - false + return 1 fi } @@ -781,7 +781,7 @@ test_path_exists () { if ! test -e "$1" then echo "Path $1 doesn't exist" - false + return 1 fi } @@ -803,7 +803,7 @@ test_file_not_empty () { if ! test -s "$1" then echo "'$1' is not a non-empty file." - false + return 1 fi } From patchwork Mon Apr 12 11:09:04 2021 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: 12197653 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9333EC43461 for ; Mon, 12 Apr 2021 11:09:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7326661249 for ; Mon, 12 Apr 2021 11:09:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240016AbhDLLJ6 (ORCPT ); Mon, 12 Apr 2021 07:09:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240028AbhDLLJl (ORCPT ); Mon, 12 Apr 2021 07:09:41 -0400 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B488BC061574 for ; Mon, 12 Apr 2021 04:09:23 -0700 (PDT) Received: by mail-wm1-x335.google.com with SMTP id 12so6548168wmf.5 for ; Mon, 12 Apr 2021 04:09:23 -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=qfGCBhAgfn+A1wCEWJ9Q6Q2IIWnpaL3kO8sl+AHLD2s=; b=c3ACsWFTpYAnuyJl10U7Ts9yUW/DUey9oQF3ih4MfB/bL/mZXJTuQK4zrL5z+JCO8X tuIVeXdD7SxyjasbDiPwqaIwUNUZDbBnGQnGkF4qe41HULwgeqZFMMEwSf1aKDzrsQSL ZTAZu7976B24Rk+SDmgjp6hMVLaBDjV59LV5GSUEB4SekIaLW1Iw4XsSevmK5ACZTDcC aCPPxVGZAQXD8P/pDOnMV4OhaYgnQ98uXW/1u+0byUvk2GXSuw3LUwwgIzegvP9sgU30 hDcg7OlxcAKt2h23GJ2z57c8thiL2P3JWHXguENhtWiLxdqWN/AY/CBOGFqfwPBr7d5m BIqw== 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=qfGCBhAgfn+A1wCEWJ9Q6Q2IIWnpaL3kO8sl+AHLD2s=; b=gZHsjVDCrA3/Frr6jfh5VasshX/Z5pVylAKbqW5/BNpg4vVDihjzdCsaBPb/POWTx0 V+yYavx6sQ/qbWTLvGEESnQjUefTuzynV+MjtQUSL2Ii0+LOVIE5uQJl3WZewMAJPwEw UAjqrcmRHytKHp1XuxmC+eimU1mY92RO35k3RW5XNzGJbiWznwOTTN0bTvx5LZ6q78tu dQjI4D100QNghkDelnmjMsJx2h3LydnBh4Ibf5aUfPLFHWbYtWDsRlVAYtWEiqUodBvo 5uocwrdBiyJTeFjwy9kY2bJCf0F+JqFPfZOL9yx/CJjRQkf5C2s6g7LRvZS4cveqaBUb jJGw== X-Gm-Message-State: AOAM531s/i7QY+F3reDNTLETGIzJ+J5PLYB3yuVSUvjxX8yY1XCqbO+G jrfcfiNm6KKizo0ptJBRDhoecBwRr9eO2A== X-Google-Smtp-Source: ABdhPJxBxzWV41KXqQ8GT8aATkPKPMw5CIjTqPK2nWZjLJuxm2G1AzBmO+aiFJfLNvHgXDfoWwtaRg== X-Received: by 2002:a1c:6489:: with SMTP id y131mr13377807wmb.0.1618225762104; Mon, 12 Apr 2021 04:09:22 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id a8sm18158744wrh.91.2021.04.12.04.09.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Apr 2021 04:09:21 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Matthieu Moy , Johannes Schindelin , =?utf-8?b?w4Z2YXIgQXJu?= =?utf-8?b?ZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH 15/16] Revert and amend "test-lib-functions: assert correct parameter count" Date: Mon, 12 Apr 2021 13:09:04 +0200 Message-Id: X-Mailer: git-send-email 2.31.1.634.gb41287a30b0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org This reverts and amends my my own e7884b353b7 (test-lib-functions: assert correct parameter count, 2021-02-12) in order to improve the -x output. When I added these BUG assertions in e7884b353b7 I missed that this made the -x output much more verbose. E.g. for each test_cmp invocation we'd now emit: + test_cmp expect actual + test 2 -ne 2 + eval diff -u "$@" + diff -u expect actual That "test 2 -ne 2" line is new in e7884b353b7. As noted in 45a2686441b (test-lib-functions: remove bug-inducing "diagnostics" helper param, 2021-02-12) we had buggy invocations of some of these functions with too many parameters. Let's instead use "$@" instead of "$1" to achieve the same ends with no extra -x output verbosity. The "test" operator will die with an error if given more than one argument in these contexts, so using "$@" achieves the same goal. The same goes for "cmp" and "diff -u" (which we typically use for test_cmp). Signed-off-by: Ævar Arnfjörð Bjarmason --- t/test-lib-functions.sh | 41 ++++++++++++++++------------------------- 1 file changed, 16 insertions(+), 25 deletions(-) diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh index c46bf0ff09c..2cf72b56851 100644 --- a/t/test-lib-functions.sh +++ b/t/test-lib-functions.sh @@ -759,39 +759,35 @@ test_external_without_stderr () { # debugging-friendly alternatives to "test [-f|-d|-e]" # The commands test the existence or non-existence of $1 test_path_is_file () { - test "$#" -ne 1 && BUG "1 param" - if ! test -f "$1" + if ! test -f "$@" then - echo "File $1 doesn't exist" + echo "File $@ doesn't exist" return 1 fi } test_path_is_dir () { - test "$#" -ne 1 && BUG "1 param" - if ! test -d "$1" + if ! test -d "$@" then - echo "Directory $1 doesn't exist" + echo "Directory $@ doesn't exist" return 1 fi } test_path_exists () { - test "$#" -ne 1 && BUG "1 param" - if ! test -e "$1" + if ! test -e "$@" then - echo "Path $1 doesn't exist" + echo "Path $@ doesn't exist" return 1 fi } # Check if the directory exists and is empty as expected, barf otherwise. test_dir_is_empty () { - test "$#" -ne 1 && BUG "1 param" - test_path_is_dir "$1" && - if test -n "$(ls -a1 "$1" | egrep -v '^\.\.?$')" + test_path_is_dir "$@" && + if test -n "$(ls -a1 "$@" | egrep -v '^\.\.?$')" then - echo "Directory '$1' is not empty, it contains:" + echo "Directory '$@' is not empty, it contains:" ls -la "$1" return 1 fi @@ -799,17 +795,15 @@ test_dir_is_empty () { # Check if the file exists and has a size greater than zero test_file_not_empty () { - test "$#" = 2 && BUG "2 param" - if ! test -s "$1" + if ! test -s "$@" then - echo "'$1' is not a non-empty file." + echo "'$@' is not a non-empty file." return 1 fi } test_path_is_missing () { - test "$#" -ne 1 && BUG "1 param" - if test -e "$1" + if test -e "$@" then echo "Path $1 exists!" false @@ -1013,7 +1007,6 @@ test_expect_code () { # - not all diff versions understand "-u" test_cmp () { - test "$#" -ne 2 && BUG "2 param" eval "$GIT_TEST_CMP" '"$@"' } @@ -1043,7 +1036,6 @@ test_cmp_config () { # test_cmp_bin - helper to compare binary files test_cmp_bin () { - test "$#" -ne 2 && BUG "2 param" cmp "$@" } @@ -1104,12 +1096,11 @@ verbose () { # otherwise. test_must_be_empty () { - test "$#" -ne 1 && BUG "1 param" - test_path_is_file "$1" && - if test -s "$1" + test_path_is_file "$@" && + if test -s "$@" then - echo "'$1' is not empty, it contains:" - cat "$1" + echo "'$@' is not empty, it contains:" + cat "$@" return 1 fi } From patchwork Mon Apr 12 11:09:05 2021 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: 12197651 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7D327C43460 for ; Mon, 12 Apr 2021 11:09:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 535C161241 for ; Mon, 12 Apr 2021 11:09:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240068AbhDLLJ7 (ORCPT ); Mon, 12 Apr 2021 07:09:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240061AbhDLLJn (ORCPT ); Mon, 12 Apr 2021 07:09:43 -0400 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B5D8C061342 for ; Mon, 12 Apr 2021 04:09:24 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id 12so12490534wrz.7 for ; Mon, 12 Apr 2021 04:09:24 -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=hpFibl7BhOy4Lfslv7gEMw1HEtvWSoGoavwYSZVNh9M=; b=ER7uXR94GW5rGWLS6PoQUtHowHkVdaht/JUM7+pprwjR5ymkIsVm8bfSumxD3Y7cZm RSN9ZL0LSwl3bq0T5/Uz5eAl36dJYL//nT3wQTSHlNOQ9/SDeUMmIomrKcmo6D+LnLUn Rsg4kBa5CNPydcNiB2QNm5QvyDobzQM0C7cqaZTOOmqRjeU4DzWmuDoizg0/yGSCakaO mnBF4UGvyhLUo4vR1trWppFngK/EU+x+53q0OPfeqdJ19ARY3eopjf1XU6rSEls4+ck6 PzBVghbT71rK2KpIcZ3vht3ghFEWWTBYRRqFdDQG8rOoh6B3WsOeRgzoacdHVO/DCTof UqXA== 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=hpFibl7BhOy4Lfslv7gEMw1HEtvWSoGoavwYSZVNh9M=; b=RNr27mHQ7o40GwwpDLEowG0Wu4FwqzPFcfH70hFS4oMYiLZkD5UlZuwVU6XaLlAYO5 xFKySJp7JVRfAolqixeYPyI23bBoVZ9AfST7Yfs69gP/II4Xi0ldgIIR2+Khpztbwg7I rIQRYxSt9F3cjWHMhNZgJ8iq1T9QquszQ1gcPMZu7RH1vTW56ydvyjh/hozYEZVamfdI +PBwFxdRDwwXR1h77ECnPCUf0Vj9BPfz/AT7Tj48h9aXw9MBNtC1F0ZkvBc4jqr4h3Mr tEBPFFLMCWG0NwCNQHamVeJIK+m4xNiBA97vaebMKY8oYTFcCjLX514qOW9DNF7dxIGq kkXg== X-Gm-Message-State: AOAM530jWyuNTZtWN8+0mFzHBPtWqxuOid0KGlG9I1dIfvk6omDeR7be Gk9Ofz/HxdrnnM1y931RSKqUmx+5bMCUjA== X-Google-Smtp-Source: ABdhPJyRMiJEuHYAgczqxKgRZSFQY8eJASx7VNFqvsSV4ZgNugI9XbwwmTulCHR85a5vRsBaDIC2vQ== X-Received: by 2002:adf:fdc7:: with SMTP id i7mr14775587wrs.350.1618225763044; Mon, 12 Apr 2021 04:09:23 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id a8sm18158744wrh.91.2021.04.12.04.09.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Apr 2021 04:09:22 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Matthieu Moy , Johannes Schindelin , =?utf-8?b?w4Z2YXIgQXJu?= =?utf-8?b?ZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH 16/16] test-lib-functions: remove last two parameter count assertions Date: Mon, 12 Apr 2021 13:09:05 +0200 Message-Id: X-Mailer: git-send-email 2.31.1.634.gb41287a30b0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Remove a couple of parameter count assertions where we'll now silently do the wrong thing if given too many parameters, unlike the "$@" cases in the preceding commit where "test" etc. handle the check for usi. In the case of "test_file_size", the "test-tool" we're invoking is happy to accept N parameters (it'll print out all N sizes). Let's just use "$@" in that case anyway, there's only a few callers, and eventually those should probably be moved to use the test-tool directly. That only leaves test_line_count, I suppose I could leave that one alone, but since it's the only common function left that does this assertion let's remove it for the brevity of the -x output and consistency with other functions. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/test-lib-functions.sh | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh index 2cf72b56851..32d6b98b972 100644 --- a/t/test-lib-functions.sh +++ b/t/test-lib-functions.sh @@ -822,10 +822,7 @@ test_path_is_missing () { # output through when the number of lines is wrong. test_line_count () { - if test $# != 3 - then - BUG "not 3 parameters to test_line_count" - elif ! test $(wc -l <"$3") "$1" "$2" + if ! test $(wc -l <"$3") "$1" "$2" then echo "test_line_count: line count for $3 !$1 $2" cat "$3" @@ -834,8 +831,7 @@ test_line_count () { } test_file_size () { - test "$#" -ne 1 && BUG "1 param" - test-tool path-utils file-size "$1" + test-tool path-utils file-size "$@" } # Returns success if a comma separated string of keywords ($1) contains a