reset test: modernize style

Avoid command substitution and pipes to ensure that the exit status from each git command is tested (and in particular that any segfaults are caught). Maintain the test setup (no commits, one file named "a", another named "b") even after the last test, to make it easier to rearrange tests or add new tests after the last in the future. Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jonathan Nieder committed Aug 24, 2013 at 13:34 UTC 95728f74b100a4feabb5c70c0e6d8bed9dc29451
1 file changed +24 -7
t/t7106-reset-unborn-branch.sh
+24 -7
@@ -11,7 +11,10 @@ test_expect_success 'setup' '
11 test_expect_success 'reset' '
12 git add a b &&
13 git reset &&
14 - test "$(git ls-files)" = ""
14 +
15 + >expect &&
16 + git ls-files >actual &&
17 + test_cmp expect actual
18 '
19
20 test_expect_success 'reset HEAD' '
@@ -24,28 +27,42 @@ test_expect_success 'reset $file' '
27 rm .git/index &&
28 git add a b &&
29 git reset a &&
27 - test "$(git ls-files)" = "b"
30 +
31 + echo b >expect &&
32 + git ls-files >actual &&
33 + test_cmp expect actual
34 '
35
36 test_expect_success PERL 'reset -p' '
37 rm .git/index &&
38 git add a &&
33 - echo y | git reset -p &&
34 - test "$(git ls-files)" = ""
39 + echo y >yes &&
40 + git reset -p <yes &&
41 +
42 + >expect &&
43 + git ls-files >actual &&
44 + test_cmp expect actual
45 '
46
47 test_expect_success 'reset --soft is a no-op' '
48 rm .git/index &&
49 git add a &&
40 - git reset --soft
41 - test "$(git ls-files)" = "a"
50 + git reset --soft &&
51 +
52 + echo a >expect &&
53 + git ls-files >actual &&
54 + test_cmp expect actual
55 '
56
57 test_expect_success 'reset --hard' '
58 rm .git/index &&
59 git add a &&
60 + test_when_finished "echo a >a" &&
61 git reset --hard &&
48 - test "$(git ls-files)" = "" &&
62 +
63 + >expect &&
64 + git ls-files >actual &&
65 + test_cmp expect actual &&
66 test_path_is_missing a
67 '
68