git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: git@vger.kernel.org
Cc: "Junio C Hamano" <gitster@pobox.com>,
	"René Scharfe" <l.s.r@web.de>,
	"Eric Sunshine" <sunshine@sunshineco.com>,
	"Torsten Bögershausen" <tboegi@web.de>,
	"Phillip Wood" <phillip.wood123@gmail.com>,
	"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Subject: [PATCH v5 0/6] tests: fix ignored & hidden exit codes
Date: Mon,  6 Feb 2023 23:44:27 +0100	[thread overview]
Message-ID: <cover-v5-0.6-00000000000-20230206T224200Z-avarab@gmail.com> (raw)
In-Reply-To: <cover-v4-0.6-00000000000-20221219T101240Z-avarab@gmail.com>

Various fixes for "git" on the LHS of a pipe, but mostly when in
"test" expressions like:

       test str = "$(git some-command)" &&

Changes since v4[1]:

 * Tried to address all outstanding concernse, some with commit
   message clarifications, others with code changes.
 * The main code change here is to avoid converting code adjacent to
   the fixed "test" code away from sub-shell use, per Junio's request.

Branch & CI for this at:
https://github.com/avar/git/tree/avar/fix-even-more-broken-test-code-hiding-failures-5

1. https://lore.kernel.org/git/cover-v4-0.6-00000000000-20221219T101240Z-avarab@gmail.com/

Ævar Arnfjörð Bjarmason (6):
  auto-crlf tests: don't lose exit code in loops and outside tests
  t/lib-patch-mode.sh: fix ignored exit codes
  tests: don't lose exit status with "(cd ...; test <op> $(git ...))"
  tests: don't lose exit status with "test <op> $(git ...)"
  tests: don't lose "git" exit codes in "! ( git ... | grep )"
  tests: don't lose misc "git" exit codes

 t/lib-httpd.sh                     |   8 ++-
 t/lib-patch-mode.sh                |  11 ++-
 t/lib-submodule-update.sh          |  26 ++++---
 t/t0001-init.sh                    |   9 ++-
 t/t0002-gitfile.sh                 |   4 +-
 t/t0027-auto-crlf.sh               |  66 ++++++++++--------
 t/t0055-beyond-symlinks.sh         |  14 +++-
 t/t0060-path-utils.sh              | 108 +++++++++++++++++++++--------
 t/t0100-previous.sh                |   8 ++-
 t/t1401-symbolic-ref.sh            |   3 +-
 t/t1504-ceiling-dirs.sh            |   8 ++-
 t/t2005-checkout-index-symlinks.sh |   8 ++-
 t/t3200-branch.sh                  |   8 ++-
 t/t3700-add.sh                     |  18 +++--
 t/t3701-add-interactive.sh         |   8 ++-
 t/t5522-pull-symlink.sh            |   4 +-
 t/t5605-clone-local.sh             |  12 +++-
 t/t7402-submodule-rebase.sh        |  23 ++++--
 t/t7504-commit-msg-hook.sh         |   4 +-
 t/t7516-commit-races.sh            |   3 +-
 t/t7810-grep.sh                    |   4 +-
 21 files changed, 245 insertions(+), 112 deletions(-)

Range-diff against v4:
1:  68d276dd421 ! 1:  66d0f91e6aa auto-crlf tests: don't lose exit code in loops and outside tests
    @@ Commit message
         this failure under SANITIZE=leak when these invocations had errored
         out, even under "--immediate".
     
    +    For checkout_files() we could run one test_expect_success() instead of
    +    the 5 we run now in a loop.
    +
    +    But as this function added in [1] is already taking pains to split up
    +    its setup into phases (there are 5 more "test_expect_success()" at the
    +    end of it already, see [1]), let's follow that existing convention.
    +
    +    1. 343151dcbdf (t0027: combinations of core.autocrlf, core.eol and text, 2014-06-29)
    +
         Helped-by: René Scharfe <l.s.r@web.de>
         Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
     
2:  d351075f0ab ! 2:  97f8b6a7b86 t/lib-patch-mode.sh: fix ignored exit codes
    @@ Commit message
         SANITIZE=leak, this code doesn't leak now as far as I can tell, but I
         discovered it while looking at leaks in related code.
     
    +    For "verify_saved_head()" we could make use of "test_cmp_rev" with
    +    some changes, but it uses "git rev-parse --verify", and this existing
    +    test does not. I think it could safely use it, but let's avoid the
    +    while-at-it change, and narrowly fix the exit code problem.
    +
         Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
     
      ## t/lib-patch-mode.sh ##
3:  f5b2489609c ! 3:  d8f4c4a6d9e tests: don't lose exit status with "(cd ...; test <op> $(git ...))"
    @@ Commit message
         exit status of "git" so that we notice the failing "git".
     
         Have them use modern patterns such as a "test_cmp" of the expected
    -    outputs instead, and avoid needlessly spawning sub-shell in favor of
    -    using "git -C <dir>".
    +    outputs instead.
     
         We'll fix more of these these in the subsequent commit, for now we're
         only converting the cases where this loss of exit code was combined
    -    with spawning a sub-shell. The one exception to that is the casein
    -    "t3200-branch.sh" where adjacent code didn't use a sub-shell, let's
    -    convert that here as it's within the same hunk.
    +    with spawning a sub-shell.
     
         Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
     
    @@ t/lib-httpd.sh: test_http_push_nonff () {
      		test_must_fail git push -v origin >output 2>&1 &&
     -		(cd "$REMOTE_REPO" &&
     -		 test $HEAD = $(git rev-parse --verify HEAD))
    -+		echo "$HEAD" >expect &&
    -+		git -C "$REMOTE_REPO" rev-parse --verify HEAD >actual &&
    -+		test_cmp expect actual
    ++		(
    ++			cd "$REMOTE_REPO" &&
    ++			echo "$HEAD" >expect &&
    ++			git rev-parse --verify HEAD >actual &&
    ++			test_cmp expect actual
    ++		)
      	'
      
      	test_expect_success 'non-fast-forward push show ref status' '
    @@ t/t0060-path-utils.sh: test_expect_success 'prefix_path rejects absolute path to
      	ln -s repo repolink &&
     -	test "a" = "$(cd repo && test-tool path-utils prefix_path prefix "$(pwd)/../repolink/a")"
     +	echo "a" >expect &&
    -+	test-tool -C repo path-utils prefix_path prefix "$(cd repo && pwd)/../repolink/a" >actual &&
    ++	repo_path="$(cd repo && pwd)" &&
    ++	test-tool -C repo path-utils prefix_path prefix "$repo_path/../repolink/a" >actual &&
     +	test_cmp expect actual
      '
      
      relative_path /foo/a/b/c/	/foo/a/b/	c/
     
      ## t/t3200-branch.sh ##
    -@@ t/t3200-branch.sh: test_expect_success 'git branch -M baz bam should succeed when baz is checked ou
    - test_expect_success 'git branch -M baz bam should succeed within a worktree in which baz is checked out' '
    - 	git checkout -b baz &&
    - 	git worktree add -f bazdir baz &&
    --	(
    --		cd bazdir &&
    --		git branch -M baz bam &&
    +@@ t/t3200-branch.sh: test_expect_success 'git branch -M baz bam should succeed within a worktree in w
    + 	(
    + 		cd bazdir &&
    + 		git branch -M baz bam &&
     -		test $(git rev-parse --abbrev-ref HEAD) = bam
    --	) &&
    ++		echo bam >expect &&
    ++		git rev-parse --abbrev-ref HEAD >actual &&
    ++		test_cmp expect actual
    + 	) &&
     -	test $(git rev-parse --abbrev-ref HEAD) = bam &&
    -+	git -C "$bazdir" branch -M baz bam &&
    -+	echo "bam" >expect &&
    -+	git -C "$bazdir" rev-parse --abbrev-ref HEAD >actual &&
    -+	test_cmp expect actual &&
    -+	echo "bam" >expect &&
    ++	echo bam >expect &&
     +	git rev-parse --abbrev-ref HEAD >actual &&
     +	test_cmp expect actual &&
      	rm -r bazdir &&
    @@ t/t5605-clone-local.sh: test_expect_success 'preparing origin repository' '
      	git bundle create b2.bundle main &&
      	mkdir dir &&
     @@ t/t5605-clone-local.sh: test_expect_success 'preparing origin repository' '
    - 
      test_expect_success 'local clone without .git suffix' '
      	git clone -l -s a b &&
    --	(cd b &&
    + 	(cd b &&
     -	test "$(git config --bool core.bare)" = false &&
    --	git fetch)
     +	echo false >expect &&
    -+	git -C b config --bool core.bare >actual &&
    ++	git config --bool core.bare >actual &&
     +	test_cmp expect actual &&
    -+	git -C b fetch
    + 	git fetch)
      '
      
    - test_expect_success 'local clone with .git suffix' '
     
      ## t/t7402-submodule-rebase.sh ##
     @@ t/t7402-submodule-rebase.sh: test_expect_success 'stash with a dirty submodule' '
4:  da66e5bf1c1 = 4:  e6f56478b65 tests: don't lose exit status with "test <op> $(git ...)"
5:  9596702978e = 5:  55abdbef49f tests: don't lose "git" exit codes in "! ( git ... | grep )"
6:  94df7a1764e = 6:  e7f10c0641a tests: don't lose misc "git" exit codes
-- 
2.39.1.1425.gac85d95d48c


  parent reply	other threads:[~2023-02-06 22:44 UTC|newest]

Thread overview: 83+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-21  6:51 [PATCH 0/6] tests: fix ignored & hidden exit codes Ævar Arnfjörð Bjarmason
2022-07-21  6:51 ` [PATCH 1/6] diff tests: fix ignored exit codes in t4023 Ævar Arnfjörð Bjarmason
2022-07-21  6:51 ` [PATCH 2/6] t/lib-patch-mode.sh: fix ignored "git" exit codes Ævar Arnfjörð Bjarmason
2022-07-21  6:51 ` [PATCH 3/6] auto-crlf tests: check "git checkout" exit code Ævar Arnfjörð Bjarmason
2022-07-21  6:51 ` [PATCH 4/6] test-lib-functions: add and use test_cmp_cmd Ævar Arnfjörð Bjarmason
2022-07-21  6:51 ` [PATCH 5/6] merge tests: don't ignore "rev-parse" exit code in helper Ævar Arnfjörð Bjarmason
2022-07-21  6:51 ` [PATCH 6/6] log tests: don't use "exit 1" outside a sub-shell Ævar Arnfjörð Bjarmason
2022-12-02  0:06 ` [PATCH v2 0/8] tests: fix ignored & hidden exit codes Ævar Arnfjörð Bjarmason
2022-12-02  0:06   ` [PATCH v2 1/8] log tests: don't use "exit 1" outside a sub-shell Ævar Arnfjörð Bjarmason
2022-12-02  1:02     ` Eric Sunshine
2022-12-02  1:48       ` Junio C Hamano
2022-12-02  2:45         ` Ævar Arnfjörð Bjarmason
2022-12-02  9:03           ` Eric Sunshine
2022-12-02 10:02             ` Ævar Arnfjörð Bjarmason
2022-12-07  6:09               ` Eric Sunshine
2022-12-02  3:24       ` Junio C Hamano
2022-12-02  0:06   ` [PATCH v2 2/8] auto-crlf tests: check "git checkout" exit code Ævar Arnfjörð Bjarmason
2022-12-02  1:02     ` René Scharfe
2022-12-02  1:10       ` Eric Sunshine
2022-12-02  5:59       ` Torsten Bögershausen
2022-12-02  6:03         ` Eric Sunshine
2022-12-02  0:06   ` [PATCH v2 3/8] diff tests: fix ignored exit codes in t4023 Ævar Arnfjörð Bjarmason
2022-12-02  2:02     ` Junio C Hamano
2022-12-02  0:06   ` [PATCH v2 4/8] test-lib-functions: add and use test_cmp_cmd Ævar Arnfjörð Bjarmason
2022-12-02  1:30     ` René Scharfe
2022-12-02  1:33     ` Eric Sunshine
2022-12-02  1:45       ` Eric Sunshine
2022-12-02  1:52         ` Eric Sunshine
2022-12-02  3:41         ` Junio C Hamano
2022-12-02  0:06   ` [PATCH v2 5/8] t/lib-patch-mode.sh: fix ignored "git" exit codes Ævar Arnfjörð Bjarmason
2022-12-02  1:31     ` René Scharfe
2022-12-02  0:06   ` [PATCH v2 6/8] merge tests: don't ignore "rev-parse" exit code in helper Ævar Arnfjörð Bjarmason
2022-12-02  1:41     ` René Scharfe
2022-12-02  0:06   ` [PATCH v2 7/8] tests: use "test_cmp_cmd" instead of "test" in sub-shells Ævar Arnfjörð Bjarmason
2022-12-02  0:06   ` [PATCH v2 8/8] tests: use "test_cmp_cmd" in misc tests Ævar Arnfjörð Bjarmason
2022-12-02  2:19     ` Junio C Hamano
2022-12-02 11:52   ` [PATCH v3 0/8] tests: fix ignored & hidden exit codes Ævar Arnfjörð Bjarmason
2022-12-02 11:52     ` [PATCH v3 1/8] merge tests: don't ignore "rev-parse" exit code in helper Ævar Arnfjörð Bjarmason
2022-12-05  0:24       ` Junio C Hamano
2022-12-02 11:52     ` [PATCH v3 2/8] auto-crlf tests: don't lose exit code in loops and outside tests Ævar Arnfjörð Bjarmason
2022-12-02 15:59       ` René Scharfe
2022-12-02 11:52     ` [PATCH v3 3/8] diff tests: fix ignored exit codes in t4023 Ævar Arnfjörð Bjarmason
2022-12-05  0:26       ` Junio C Hamano
2022-12-02 11:52     ` [PATCH v3 4/8] t/lib-patch-mode.sh: fix ignored exit codes Ævar Arnfjörð Bjarmason
2022-12-02 15:59       ` René Scharfe
2022-12-04  0:45       ` Eric Sunshine
2022-12-02 11:52     ` [PATCH v3 5/8] tests: use "test_cmp" instead of "test" in sub-shells Ævar Arnfjörð Bjarmason
2022-12-05  0:39       ` Junio C Hamano
2022-12-02 11:52     ` [PATCH v3 6/8] tests: don't lose 'test <str> = $(cmd ...)"' exit code Ævar Arnfjörð Bjarmason
2022-12-02 11:52     ` [PATCH v3 7/8] tests: don't lose "git" exit codes in "! ( git ... | grep )" Ævar Arnfjörð Bjarmason
2022-12-02 18:31       ` René Scharfe
2022-12-02 11:52     ` [PATCH v3 8/8] tests: don't lose mist "git" exit codes Ævar Arnfjörð Bjarmason
2022-12-04  0:40       ` Eric Sunshine
2022-12-05  0:45         ` Junio C Hamano
2022-12-19 10:19     ` [PATCH v4 0/6] tests: fix ignored & hidden " Ævar Arnfjörð Bjarmason
2022-12-19 10:19       ` [PATCH v4 1/6] auto-crlf tests: don't lose exit code in loops and outside tests Ævar Arnfjörð Bjarmason
2022-12-19 12:07         ` René Scharfe
2022-12-19 10:19       ` [PATCH v4 2/6] t/lib-patch-mode.sh: fix ignored exit codes Ævar Arnfjörð Bjarmason
2022-12-20  0:09         ` Junio C Hamano
2022-12-27 16:40         ` Phillip Wood
2022-12-27 18:14           ` Ævar Arnfjörð Bjarmason
2022-12-19 10:19       ` [PATCH v4 3/6] tests: don't lose exit status with "(cd ...; test <op> $(git ...))" Ævar Arnfjörð Bjarmason
2022-12-20  0:20         ` Junio C Hamano
2022-12-19 10:19       ` [PATCH v4 4/6] tests: don't lose exit status with "test <op> $(git ...)" Ævar Arnfjörð Bjarmason
2022-12-26  1:14         ` Junio C Hamano
2022-12-19 10:19       ` [PATCH v4 5/6] tests: don't lose "git" exit codes in "! ( git ... | grep )" Ævar Arnfjörð Bjarmason
2022-12-26  1:18         ` Junio C Hamano
2022-12-27 16:44         ` Phillip Wood
2022-12-27 17:13           ` Phillip Wood
2022-12-27 23:16           ` Junio C Hamano
2022-12-19 10:19       ` [PATCH v4 6/6] tests: don't lose misc "git" exit codes Ævar Arnfjörð Bjarmason
2022-12-27 16:46         ` Phillip Wood
2022-12-27 18:18           ` Ævar Arnfjörð Bjarmason
2022-12-27 23:17           ` Junio C Hamano
2022-12-20  0:06       ` [PATCH v4 0/6] tests: fix ignored & hidden " Junio C Hamano
2023-02-06 22:44       ` Ævar Arnfjörð Bjarmason [this message]
2023-02-06 22:44         ` [PATCH v5 1/6] auto-crlf tests: don't lose exit code in loops and outside tests Ævar Arnfjörð Bjarmason
2023-02-06 22:44         ` [PATCH v5 2/6] t/lib-patch-mode.sh: fix ignored exit codes Ævar Arnfjörð Bjarmason
2023-02-06 22:44         ` [PATCH v5 3/6] tests: don't lose exit status with "(cd ...; test <op> $(git ...))" Ævar Arnfjörð Bjarmason
2023-02-06 22:44         ` [PATCH v5 4/6] tests: don't lose exit status with "test <op> $(git ...)" Ævar Arnfjörð Bjarmason
2023-02-06 22:44         ` [PATCH v5 5/6] tests: don't lose "git" exit codes in "! ( git ... | grep )" Ævar Arnfjörð Bjarmason
2023-02-06 22:44         ` [PATCH v5 6/6] tests: don't lose misc "git" exit codes Ævar Arnfjörð Bjarmason
2023-02-06 23:33         ` [PATCH v5 0/6] tests: fix ignored & hidden " Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cover-v5-0.6-00000000000-20230206T224200Z-avarab@gmail.com \
    --to=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=l.s.r@web.de \
    --cc=phillip.wood123@gmail.com \
    --cc=sunshine@sunshineco.com \
    --cc=tboegi@web.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).