Skip to content

Commit 9fdc79e

Browse files
avargitster
authored andcommitted
tests: don't lose misc "git" exit codes
Fix a few miscellaneous cases where: - We lost the "git" exit code via "git ... | grep" - Likewise by having a $(git) argument to git itself - Used "test -z" to check that a command emitted no output, we can use "test_must_be_empty" and &&-chaining instead. Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4bd0785 commit 9fdc79e

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

t/t1401-symbolic-ref.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ test_expect_success 'symbolic-ref refuses non-ref for HEAD' '
3333
reset_to_sane
3434

3535
test_expect_success 'symbolic-ref refuses bare sha1' '
36-
test_must_fail git symbolic-ref HEAD $(git rev-parse HEAD)
36+
rev=$(git rev-parse HEAD) &&
37+
test_must_fail git symbolic-ref HEAD "$rev"
3738
'
3839

3940
reset_to_sane

t/t3701-add-interactive.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,9 +296,11 @@ test_expect_success FILEMODE 'stage mode and hunk' '
296296
echo content >>file &&
297297
chmod +x file &&
298298
printf "y\\ny\\n" | git add -p &&
299-
git diff --cached file | grep "new mode" &&
300-
git diff --cached file | grep "+content" &&
301-
test -z "$(git diff file)"
299+
git diff --cached file >out &&
300+
grep "new mode" out &&
301+
grep "+content" out &&
302+
git diff file >out &&
303+
test_must_be_empty out
302304
'
303305

304306
# end of tests disabled when filemode is not usable

t/t7516-commit-races.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ test_expect_success 'race to create orphan commit' '
1010
test_must_fail env EDITOR=./hare-editor git commit --allow-empty -m tortoise -e &&
1111
git show -s --pretty=format:%s >subject &&
1212
grep hare subject &&
13-
test -z "$(git show -s --pretty=format:%P)"
13+
git show -s --pretty=format:%P >out &&
14+
test_must_be_empty out
1415
'
1516

1617
test_expect_success 'race to create non-orphan commit' '

0 commit comments

Comments
 (0)