Change a few miscellaneous tests to use "test_cmp_cmd" to avoid losing the exit code of "git". There's many offenders left that match patterns like: /test .*\$\((test-tool|git)/ What these all have in common is that they were the rare odd cases out in test files that were otherwise consistently checking the exit code. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx> --- t/t1401-symbolic-ref.sh | 3 ++- t/t2005-checkout-index-symlinks.sh | 2 +- t/t3701-add-interactive.sh | 9 ++++++--- t/t5522-pull-symlink.sh | 2 +- t/t7402-submodule-rebase.sh | 4 ++-- t/t7504-commit-msg-hook.sh | 2 +- t/t7516-commit-races.sh | 3 ++- t/t7810-grep.sh | 2 +- 8 files changed, 16 insertions(+), 11 deletions(-) diff --git a/t/t1401-symbolic-ref.sh b/t/t1401-symbolic-ref.sh index d708acdb819..5e36899d207 100755 --- a/t/t1401-symbolic-ref.sh +++ b/t/t1401-symbolic-ref.sh @@ -33,7 +33,8 @@ test_expect_success 'symbolic-ref refuses non-ref for HEAD' ' reset_to_sane test_expect_success 'symbolic-ref refuses bare sha1' ' - test_must_fail git symbolic-ref HEAD $(git rev-parse HEAD) + rev=$(git rev-parse HEAD) && + test_must_fail git symbolic-ref HEAD "$rev" ' reset_to_sane diff --git a/t/t2005-checkout-index-symlinks.sh b/t/t2005-checkout-index-symlinks.sh index 112682a45a1..aee80d39221 100755 --- a/t/t2005-checkout-index-symlinks.sh +++ b/t/t2005-checkout-index-symlinks.sh @@ -24,6 +24,6 @@ test -f symlink' test_expect_success \ 'the file must be the blob we added during the setup' ' -test "$(git hash-object -t blob symlink)" = $l' +test_cmp_cmd "$l" git hash-object -t blob symlink' test_done diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh index 5841f280fb2..3e59ffd18a0 100755 --- a/t/t3701-add-interactive.sh +++ b/t/t3701-add-interactive.sh @@ -296,9 +296,12 @@ test_expect_success FILEMODE 'stage mode and hunk' ' echo content >>file && chmod +x file && printf "y\\ny\\n" | git add -p && - git diff --cached file | grep "new mode" && - git diff --cached file | grep "+content" && - test -z "$(git diff file)" + git diff --cached file >out && + grep "new mode" <out && + git diff --cached file >out && + grep "+content" <out && + git diff file >out && + test_must_be_empty out ' # end of tests disabled when filemode is not usable diff --git a/t/t5522-pull-symlink.sh b/t/t5522-pull-symlink.sh index bcff460d0a2..b36dd40e34e 100755 --- a/t/t5522-pull-symlink.sh +++ b/t/t5522-pull-symlink.sh @@ -78,7 +78,7 @@ test_expect_success SYMLINKS 'pushing from symlinked subdir' ' git commit -m push ./file && git push ) && - test push = $(git show HEAD:subdir/file) + test_cmp_cmd push git show HEAD:subdir/file ' test_done diff --git a/t/t7402-submodule-rebase.sh b/t/t7402-submodule-rebase.sh index 277bb8ae520..b27d8da69ee 100755 --- a/t/t7402-submodule-rebase.sh +++ b/t/t7402-submodule-rebase.sh @@ -55,11 +55,11 @@ chmod a+x fake-editor.sh test_expect_success 'interactive rebase with a dirty submodule' ' - test submodule = $(git diff --name-only) && + test_cmp_cmd submodule git diff --name-only && HEAD=$(git rev-parse HEAD) && GIT_EDITOR="\"$(pwd)/fake-editor.sh\"" EDITOR_TEXT="pick $HEAD" \ git rebase -i HEAD^ && - test submodule = $(git diff --name-only) + test_cmp_cmd submodule git diff --name-only ' diff --git a/t/t7504-commit-msg-hook.sh b/t/t7504-commit-msg-hook.sh index a39de8c1126..2b94237f9d1 100755 --- a/t/t7504-commit-msg-hook.sh +++ b/t/t7504-commit-msg-hook.sh @@ -101,7 +101,7 @@ test_expect_success 'setup: commit-msg hook that always fails' ' ' commit_msg_is () { - test "$(git log --pretty=format:%s%b -1)" = "$1" + test_cmp_cmd "$1" git log --pretty=tformat:%s%b -1 } test_expect_success 'with failing hook' ' diff --git a/t/t7516-commit-races.sh b/t/t7516-commit-races.sh index f2ce14e9071..2d38a16480e 100755 --- a/t/t7516-commit-races.sh +++ b/t/t7516-commit-races.sh @@ -10,7 +10,8 @@ test_expect_success 'race to create orphan commit' ' test_must_fail env EDITOR=./hare-editor git commit --allow-empty -m tortoise -e && git show -s --pretty=format:%s >subject && grep hare subject && - test -z "$(git show -s --pretty=format:%P)" + git show -s --pretty=format:%P >out && + test_must_be_empty out ' test_expect_success 'race to create non-orphan commit' ' diff --git a/t/t7810-grep.sh b/t/t7810-grep.sh index 8eded6ab274..232b041b0cf 100755 --- a/t/t7810-grep.sh +++ b/t/t7810-grep.sh @@ -1001,7 +1001,7 @@ test_expect_success 'log --committer does not search in timestamp' ' test_expect_success 'grep with CE_VALID file' ' git update-index --assume-unchanged t/t && rm t/t && - test "$(git grep test)" = "t/t:test" && + test_cmp_cmd "t/t:test" git grep test && git update-index --no-assume-unchanged t/t && git checkout t/t ' -- 2.39.0.rc1.980.g92d3d4579ad