Skip to content

Commit 9bda8a8

Browse files
committed
Merge branch 'ss/t7004-unhide-git-failures' into seen
Test clean-up. * ss/t7004-unhide-git-failures: t7004: avoid subshells to capture git exit codes t7004: dynamically grab expected state in tests t7004: drop hardcoded tag count in invalid name test
2 parents 5af82f7 + 46106a4 commit 9bda8a8

File tree

1 file changed

+21
-22
lines changed

1 file changed

+21
-22
lines changed

t/t7004-tag.sh

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,7 @@ test_expect_success 'listing all tags if one exists should succeed' '
145145
'
146146

147147
test_expect_success 'Multiple -l or --list options are equivalent to one -l option' '
148-
cat >expect <<-\EOF &&
149-
mytag
150-
EOF
148+
git tag -l >expect &&
151149
git tag -l -l >actual &&
152150
test_cmp expect actual &&
153151
git tag --list --list >actual &&
@@ -157,8 +155,10 @@ test_expect_success 'Multiple -l or --list options are equivalent to one -l opti
157155
'
158156

159157
test_expect_success 'listing all tags if one exists should output that tag' '
160-
test $(git tag -l) = mytag &&
161-
test $(git tag) = mytag
158+
git tag -l >actual &&
159+
test_grep "^mytag$" actual &&
160+
git tag >actual &&
161+
test_grep "^mytag$" actual
162162
'
163163

164164
# pattern matching:
@@ -168,11 +168,15 @@ test_expect_success 'listing a tag using a matching pattern should succeed' '
168168
'
169169

170170
test_expect_success 'listing a tag with --ignore-case' '
171-
test $(git tag -l --ignore-case MYTAG) = mytag
171+
echo mytag >expect &&
172+
git tag -l --ignore-case MYTAG >actual &&
173+
test_cmp expect actual
172174
'
173175

174176
test_expect_success 'listing a tag using a matching pattern should output that tag' '
175-
test $(git tag -l mytag) = mytag
177+
echo mytag >expect &&
178+
git tag -l mytag >actual &&
179+
test_cmp expect actual
176180
'
177181

178182
test_expect_success 'listing tags using a non-matching pattern should succeed' '
@@ -191,15 +195,11 @@ test_expect_success 'trying to create a tag with the name of one existing should
191195
'
192196

193197
test_expect_success 'trying to create a tag with a non-valid name should fail' '
194-
git tag -l >actual &&
195-
test_line_count = 1 actual &&
196198
test_must_fail git tag "" &&
197199
test_must_fail git tag .othertag &&
198200
test_must_fail git tag "other tag" &&
199201
test_must_fail git tag "othertag^" &&
200-
test_must_fail git tag "other~tag" &&
201-
git tag -l >actual &&
202-
test_line_count = 1 actual
202+
test_must_fail git tag "other~tag"
203203
'
204204

205205
test_expect_success 'creating a tag using HEAD directly should succeed' '
@@ -227,12 +227,7 @@ test_expect_success 'trying to delete an unknown tag should fail' '
227227
'
228228

229229
test_expect_success 'trying to delete tags without params should succeed and do nothing' '
230-
cat >expect <<-\EOF &&
231-
myhead
232-
mytag
233-
EOF
234-
git tag -l >actual &&
235-
test_cmp expect actual &&
230+
git tag -l >expect &&
236231
git tag -d &&
237232
git tag -l >actual &&
238233
test_cmp expect actual
@@ -438,8 +433,12 @@ test_expect_success 'listing tags -n in column with column.ui ignored' '
438433

439434
test_expect_success 'a non-annotated tag created without parameters should point to HEAD' '
440435
git tag non-annotated-tag &&
441-
test $(git cat-file -t non-annotated-tag) = commit &&
442-
test $(git rev-parse non-annotated-tag) = $(git rev-parse HEAD)
436+
echo commit >expect &&
437+
git cat-file -t non-annotated-tag >actual &&
438+
test_cmp expect actual &&
439+
git rev-parse HEAD >expect &&
440+
git rev-parse non-annotated-tag >actual &&
441+
test_cmp expect actual
443442
'
444443

445444
test_expect_success 'trying to verify an unknown tag should fail' '
@@ -1528,11 +1527,11 @@ test_expect_success GPG 'verify signed tag fails when public key is not present'
15281527
'
15291528

15301529
test_expect_success 'git tag -a fails if tag annotation is empty' '
1531-
! (GIT_EDITOR=cat git tag -a initial-comment)
1530+
test_must_fail env GIT_EDITOR=cat git tag -a initial-comment
15321531
'
15331532

15341533
test_expect_success 'message in editor has initial comment' '
1535-
! (GIT_EDITOR=cat git tag -a initial-comment >actual)
1534+
test_must_fail env GIT_EDITOR=cat git tag -a initial-comment >actual
15361535
'
15371536

15381537
test_expect_success 'message in editor has initial comment: first line' '

0 commit comments

Comments
 (0)