Skip to content

Commit 0238038

Browse files
artagnongitster
authored andcommitted
test: fix '&&' chaining
Breaks in a test assertion's && chain can potentially hide failures from earlier commands in the chain by adding " &&" at the end of line to the commands that need them. Signed-off-by: Ramkumar Ramachandra <[email protected]> Acked-by: Jonathan Nieder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2f13904 commit 0238038

10 files changed

+17
-17
lines changed

t/t1007-hash-object.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ for args in "-w --stdin-paths" "--stdin-paths -w"; do
189189
done
190190

191191
test_expect_success 'corrupt tree' '
192-
echo abc >malformed-tree
192+
echo abc >malformed-tree &&
193193
test_must_fail git hash-object -t tree malformed-tree
194194
'
195195

t/t1013-loose-object-format.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ assert_blob_equals() {
3434
}
3535

3636
test_expect_success setup '
37-
cp -R "$TEST_DIRECTORY/t1013/objects" .git/
37+
cp -R "$TEST_DIRECTORY/t1013/objects" .git/ &&
3838
git --version
3939
'
4040

t/t1300-repo-config.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ cat > expect << EOF
3838
WhatEver = Second
3939
EOF
4040
test_expect_success 'similar section' '
41-
git config Cores.WhatEver Second
41+
git config Cores.WhatEver Second &&
4242
test_cmp expect .git/config
4343
'
4444

t/t1412-reflog-loop.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ test_expect_success 'setup reflog with alternating commits' '
2020
'
2121

2222
test_expect_success 'reflog shows all entries' '
23-
cat >expect <<-\EOF
23+
cat >expect <<-\EOF &&
2424
topic@{0} reset: moving to two
2525
topic@{1} reset: moving to one
2626
topic@{2} reset: moving to two

t/t1510-repo-setup.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ test_expect_success '#22a: core.worktree = GIT_DIR = .git dir' '
603603
# like case #6.
604604
605605
setup_repo 22a "$here/22a/.git" "" unset &&
606-
setup_repo 22ab . "" unset
606+
setup_repo 22ab . "" unset &&
607607
mkdir -p 22a/.git/sub 22a/sub &&
608608
mkdir -p 22ab/.git/sub 22ab/sub &&
609609
try_case 22a/.git unset . \
@@ -742,7 +742,7 @@ test_expect_success '#28: core.worktree and core.bare conflict (gitfile case)' '
742742
# Case #29: GIT_WORK_TREE(+core.worktree) overrides core.bare (gitfile case).
743743
test_expect_success '#29: setup' '
744744
setup_repo 29 non-existent gitfile true &&
745-
mkdir -p 29/sub/sub 29/wt/sub
745+
mkdir -p 29/sub/sub 29/wt/sub &&
746746
(
747747
cd 29 &&
748748
GIT_WORK_TREE="$here/29" &&

t/t1511-rev-parse-caret.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ test_description='tests for ref^{stuff}'
66

77
test_expect_success 'setup' '
88
echo blob >a-blob &&
9-
git tag -a -m blob blob-tag `git hash-object -w a-blob`
9+
git tag -a -m blob blob-tag `git hash-object -w a-blob` &&
1010
mkdir a-tree &&
1111
echo moreblobs >a-tree/another-blob &&
1212
git add . &&

t/t3310-notes-merge-manual-resolve.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ test_expect_success 'abort notes merge' '
389389
test_must_fail ls .git/NOTES_MERGE_* >output 2>/dev/null &&
390390
test_cmp /dev/null output &&
391391
# m has not moved (still == y)
392-
test "$(git rev-parse refs/notes/m)" = "$(cat pre_merge_y)"
392+
test "$(git rev-parse refs/notes/m)" = "$(cat pre_merge_y)" &&
393393
# Verify that other notes refs has not changed (w, x, y and z)
394394
verify_notes w &&
395395
verify_notes x &&
@@ -525,9 +525,9 @@ EOF
525525
test -f .git/NOTES_MERGE_WORKTREE/$commit_sha3 &&
526526
test -f .git/NOTES_MERGE_WORKTREE/$commit_sha4 &&
527527
# Refs are unchanged
528-
test "$(git rev-parse refs/notes/m)" = "$(git rev-parse refs/notes/w)"
529-
test "$(git rev-parse refs/notes/y)" = "$(git rev-parse NOTES_MERGE_PARTIAL^1)"
530-
test "$(git rev-parse refs/notes/m)" != "$(git rev-parse NOTES_MERGE_PARTIAL^1)"
528+
test "$(git rev-parse refs/notes/m)" = "$(git rev-parse refs/notes/w)" &&
529+
test "$(git rev-parse refs/notes/y)" = "$(git rev-parse NOTES_MERGE_PARTIAL^1)" &&
530+
test "$(git rev-parse refs/notes/m)" != "$(git rev-parse NOTES_MERGE_PARTIAL^1)" &&
531531
# Mention refs/notes/m, and its current and expected value in output
532532
grep -q "refs/notes/m" output &&
533533
grep -q "$(git rev-parse refs/notes/m)" output &&
@@ -545,7 +545,7 @@ test_expect_success 'resolve situation by aborting the notes merge' '
545545
test_must_fail ls .git/NOTES_MERGE_* >output 2>/dev/null &&
546546
test_cmp /dev/null output &&
547547
# m has not moved (still == w)
548-
test "$(git rev-parse refs/notes/m)" = "$(git rev-parse refs/notes/w)"
548+
test "$(git rev-parse refs/notes/m)" = "$(git rev-parse refs/notes/w)" &&
549549
# Verify that other notes refs has not changed (w, x, y and z)
550550
verify_notes w &&
551551
verify_notes x &&

t/t3400-rebase.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,8 @@ test_expect_success 'fail when upstream arg is missing and not configured' '
172172

173173
test_expect_success 'default to @{upstream} when upstream arg is missing' '
174174
git checkout -b default topic &&
175-
git config branch.default.remote .
176-
git config branch.default.merge refs/heads/master
175+
git config branch.default.remote . &&
176+
git config branch.default.merge refs/heads/master &&
177177
git rebase &&
178178
test "$(git rev-parse default~1)" = "$(git rev-parse master)"
179179
'

t/t3418-rebase-continue.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ test_expect_success 'rebase --continue remembers merge strategy and options' '
5151
test_commit "commit-new-file-F3-on-topic-branch" F3 32 &&
5252
test_when_finished "rm -fr test-bin funny.was.run" &&
5353
mkdir test-bin &&
54-
cat >test-bin/git-merge-funny <<-EOF
54+
cat >test-bin/git-merge-funny <<-EOF &&
5555
#!$SHELL_PATH
5656
case "\$1" in --opt) ;; *) exit 2 ;; esac
5757
shift &&
@@ -77,7 +77,7 @@ test_expect_success 'rebase --continue remembers merge strategy and options' '
7777
test_expect_success 'rebase --continue remembers --rerere-autoupdate' '
7878
rm -fr .git/rebase-* &&
7979
git reset --hard commit-new-file-F3-on-topic-branch &&
80-
git checkout master
80+
git checkout master &&
8181
test_commit "commit-new-file-F3" F3 3 &&
8282
git config rerere.enabled true &&
8383
test_must_fail git rebase -m master topic &&

t/t3419-rebase-patch-id.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ run()
3939
}
4040

4141
test_expect_success 'setup' '
42-
git commit --allow-empty -m initial
42+
git commit --allow-empty -m initial &&
4343
git tag root
4444
'
4545

0 commit comments

Comments
 (0)