Skip to content

Commit 8486b84

Browse files
peffgitster
authored andcommitted
t5600: modernize style
This is an old script which could use some updating before we add to it: - use the standard line-breaking: test_expect_success 'title' ' body ' - run all code inside test_expect blocks to catch unexpected failures in setup steps - use "test_commit -C" instead of manually entering sub-repo - use test_when_finished for cleanup steps - test_path_is_* as appropriate Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a4c4efd commit 8486b84

File tree

1 file changed

+25
-23
lines changed

1 file changed

+25
-23
lines changed

t/t5600-clone-fail-cleanup.sh

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,42 +11,44 @@ remove the directory before attempting a clone again.'
1111

1212
. ./test-lib.sh
1313

14-
test_expect_success \
15-
'clone of non-existent source should fail' \
16-
'test_must_fail git clone foo bar'
14+
test_expect_success 'clone of non-existent source should fail' '
15+
test_must_fail git clone foo bar
16+
'
1717

18-
test_expect_success \
19-
'failed clone should not leave a directory' \
20-
'! test -d bar'
18+
test_expect_success 'failed clone should not leave a directory' '
19+
test_path_is_missing bar
20+
'
2121

22-
# Need a repo to clone
23-
test_create_repo foo
22+
test_expect_success 'create a repo to clone' '
23+
test_create_repo foo
24+
'
2425

25-
# create some objects so that we can corrupt the repo later
26-
(cd foo && touch file && git add file && git commit -m 'add file' >/dev/null 2>&1)
26+
test_expect_success 'create objects in repo for later corruption' '
27+
test_commit -C foo file
28+
'
2729

2830
# source repository given to git clone should be relative to the
2931
# current path not to the target dir
30-
test_expect_success \
31-
'clone of non-existent (relative to $PWD) source should fail' \
32-
'test_must_fail git clone ../foo baz'
32+
test_expect_success 'clone of non-existent (relative to $PWD) source should fail' '
33+
test_must_fail git clone ../foo baz
34+
'
3335

34-
test_expect_success \
35-
'clone should work now that source exists' \
36-
'git clone foo bar'
36+
test_expect_success 'clone should work now that source exists' '
37+
git clone foo bar
38+
'
3739

38-
test_expect_success \
39-
'successful clone must leave the directory' \
40-
'test -d bar'
40+
test_expect_success 'successful clone must leave the directory' '
41+
test_path_is_dir bar
42+
'
4143

4244
test_expect_success 'failed clone --separate-git-dir should not leave any directories' '
45+
test_when_finished "rmdir foo/.git/objects.bak" &&
4346
mkdir foo/.git/objects.bak/ &&
47+
test_when_finished "mv foo/.git/objects.bak/* foo/.git/objects/" &&
4448
mv foo/.git/objects/* foo/.git/objects.bak/ &&
4549
test_must_fail git clone --separate-git-dir gitdir foo worktree &&
46-
test_must_fail test -e gitdir &&
47-
test_must_fail test -e worktree &&
48-
mv foo/.git/objects.bak/* foo/.git/objects/ &&
49-
rmdir foo/.git/objects.bak
50+
test_path_is_missing gitdir &&
51+
test_path_is_missing worktree
5052
'
5153

5254
test_done

0 commit comments

Comments
 (0)