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 <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King committed
Jan 2, 2018 at 16:09 UTC
8486b84f0ea4d7f943fdbe81050553d69d198742
1 file changed
+25
-23
t/t5600-clone-fail-cleanup.sh
+25
-23
@@ -11,42 +11,44 @@ remove the directory before attempting a clone again.'
11
12
. ./test-lib.sh
13
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
+'
17
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
+'
21
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
+'
25
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
+'
29
30
# source repository given to git clone should be relative to the
31
# 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
+'
35
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
+'
39
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
+'
43
44
test_expect_success 'failed clone --separate-git-dir should not leave any directories' '
45
+ test_when_finished "rmdir foo/.git/objects.bak" &&
46
mkdir foo/.git/objects.bak/ &&
47
+ test_when_finished "mv foo/.git/objects.bak/* foo/.git/objects/" &&
48
mv foo/.git/objects/* foo/.git/objects.bak/ &&
49
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
52
'
53
54
test_done