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>,
"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Subject: [PATCH v2 8/8] tests: use "test_cmp_cmd" in misc tests
Date: Fri, 2 Dec 2022 01:06:34 +0100 [thread overview]
Message-ID: <patch-v2-8.8-979a7f003f8-20221202T000227Z-avarab@gmail.com> (raw)
In-Reply-To: <cover-v2-0.8-00000000000-20221202T000227Z-avarab@gmail.com>
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@gmail.com>
---
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
next prev parent reply other threads:[~2022-12-02 0:08 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 ` Ævar Arnfjörð Bjarmason [this message]
2022-12-02 2:19 ` [PATCH v2 8/8] tests: use "test_cmp_cmd" in misc tests 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 ` [PATCH v5 " Ævar Arnfjörð Bjarmason
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=patch-v2-8.8-979a7f003f8-20221202T000227Z-avarab@gmail.com \
--to=avarab@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=l.s.r@web.de \
--cc=sunshine@sunshineco.com \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).