Skip to content

Commit 9291e63

Browse files
Denton-Lgitster
authored andcommitted
t1507: run commands within test_expect_success
The expected test style is to have all commands tested within a test_expect_success block. Move the generation of the 'expect' text into their corresponding blocks. While we're at it, insert a second `commit=$(git rev-parse HEAD)` into the next test case so that it's clear where $commit is coming from. The biggest advantage of doing this is that we now check the return code of `git rev-parse HEAD` so we can catch it in case it fails. This patch is best viewed with `--color-moved --ignore-all-space`. Signed-off-by: Denton Liu <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5236fce commit 9291e63

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

t/t1507-rev-parse-upstream.sh

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -225,32 +225,32 @@ test_expect_success '@{u} works when tracking a local branch' '
225225
test_cmp expect actual
226226
'
227227

228-
commit=$(git rev-parse HEAD)
229-
cat >expect <<EOF
230-
commit $commit
231-
Reflog: master@{0} (C O Mitter <[email protected]>)
232-
Reflog message: branch: Created from HEAD
233-
Author: A U Thor <[email protected]>
234-
Date: Thu Apr 7 15:15:13 2005 -0700
235-
236-
3
237-
EOF
238228
test_expect_success 'log -g other@{u}' '
229+
commit=$(git rev-parse HEAD) &&
230+
cat >expect <<-EOF &&
231+
commit $commit
232+
Reflog: master@{0} (C O Mitter <[email protected]>)
233+
Reflog message: branch: Created from HEAD
234+
Author: A U Thor <[email protected]>
235+
Date: Thu Apr 7 15:15:13 2005 -0700
236+
237+
3
238+
EOF
239239
git log -1 -g other@{u} >actual &&
240240
test_cmp expect actual
241241
'
242242

243-
cat >expect <<EOF
244-
commit $commit
245-
Reflog: master@{Thu Apr 7 15:17:13 2005 -0700} (C O Mitter <[email protected]>)
246-
Reflog message: branch: Created from HEAD
247-
Author: A U Thor <[email protected]>
248-
Date: Thu Apr 7 15:15:13 2005 -0700
249-
250-
3
251-
EOF
252-
253243
test_expect_success 'log -g other@{u}@{now}' '
244+
commit=$(git rev-parse HEAD) &&
245+
cat >expect <<-EOF &&
246+
commit $commit
247+
Reflog: master@{Thu Apr 7 15:17:13 2005 -0700} (C O Mitter <[email protected]>)
248+
Reflog message: branch: Created from HEAD
249+
Author: A U Thor <[email protected]>
250+
Date: Thu Apr 7 15:15:13 2005 -0700
251+
252+
3
253+
EOF
254254
git log -1 -g other@{u}@{now} >actual &&
255255
test_cmp expect actual
256256
'

0 commit comments

Comments
 (0)