Skip to content

Commit 4454015

Browse files
avargitster
authored andcommitted
hook tests: use a modern style for "pre-push" tests
Indent the here-docs and use "test_cmp" instead of "diff" in tests added in ec55559 (push: Add support for pre-push hooks, 2013-01-13). Let's also use the more typical "expect" instead of "expected" to be consistent with the rest of the test file. Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent bbd837f commit 4454015

File tree

1 file changed

+35
-36
lines changed

1 file changed

+35
-36
lines changed

t/t5571-pre-push-hook.sh

Lines changed: 35 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,15 @@ echo "$2" >>actual
6161
cat >>actual
6262
EOF
6363

64-
cat >expected <<EOF
65-
parent1
66-
repo1
67-
refs/heads/main $COMMIT2 refs/heads/foreign $COMMIT1
68-
EOF
69-
7064
test_expect_success 'push with hook' '
65+
cat >expect <<-EOF &&
66+
parent1
67+
repo1
68+
refs/heads/main $COMMIT2 refs/heads/foreign $COMMIT1
69+
EOF
70+
7171
git push parent1 main:foreign &&
72-
diff expected actual
72+
test_cmp expect actual
7373
'
7474

7575
test_expect_success 'add a branch' '
@@ -80,49 +80,48 @@ test_expect_success 'add a branch' '
8080
COMMIT3="$(git rev-parse HEAD)"
8181
export COMMIT3
8282

83-
cat >expected <<EOF
84-
parent1
85-
repo1
86-
refs/heads/other $COMMIT3 refs/heads/foreign $COMMIT2
87-
EOF
88-
8983
test_expect_success 'push to default' '
84+
cat >expect <<-EOF &&
85+
parent1
86+
repo1
87+
refs/heads/other $COMMIT3 refs/heads/foreign $COMMIT2
88+
EOF
9089
git push &&
91-
diff expected actual
90+
test_cmp expect actual
9291
'
9392

94-
cat >expected <<EOF
95-
parent1
96-
repo1
97-
refs/tags/one $COMMIT1 refs/tags/tag1 $ZERO_OID
98-
HEAD~ $COMMIT2 refs/heads/prev $ZERO_OID
99-
EOF
100-
10193
test_expect_success 'push non-branches' '
94+
cat >expect <<-EOF &&
95+
parent1
96+
repo1
97+
refs/tags/one $COMMIT1 refs/tags/tag1 $ZERO_OID
98+
HEAD~ $COMMIT2 refs/heads/prev $ZERO_OID
99+
EOF
100+
102101
git push parent1 one:tag1 HEAD~:refs/heads/prev &&
103-
diff expected actual
102+
test_cmp expect actual
104103
'
105104

106-
cat >expected <<EOF
107-
parent1
108-
repo1
109-
(delete) $ZERO_OID refs/heads/prev $COMMIT2
110-
EOF
111-
112105
test_expect_success 'push delete' '
106+
cat >expect <<-EOF &&
107+
parent1
108+
repo1
109+
(delete) $ZERO_OID refs/heads/prev $COMMIT2
110+
EOF
111+
113112
git push parent1 :prev &&
114-
diff expected actual
113+
test_cmp expect actual
115114
'
116115

117-
cat >expected <<EOF
118-
repo1
119-
repo1
120-
HEAD $COMMIT3 refs/heads/other $ZERO_OID
121-
EOF
122-
123116
test_expect_success 'push to URL' '
117+
cat >expect <<-EOF &&
118+
repo1
119+
repo1
120+
HEAD $COMMIT3 refs/heads/other $ZERO_OID
121+
EOF
122+
124123
git push repo1 HEAD &&
125-
diff expected actual
124+
test_cmp expect actual
126125
'
127126

128127
test_expect_success 'set up many-ref tests' '

0 commit comments

Comments
 (0)