@matheusbsbs / matheus-bagliano / commits / cf7e147cce
Fork 0

Style fixes for pre-commit hook tests

As pointed out by Junio on the mailing list, surrounding tests in double quotes can lead to bugs wherein variables get substituted away, so this isn't just style churn but important to prevent others from looking at these tests in the future and thinking that this is "the way" that Git tests should be written. Signed-off-by: Wincent Colaiuta <win@wincent.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Wincent Colaiuta committed Dec 10, 2007 at 08:42 UTC cf7e147cce9248e34b2e926d813c975c539aeaa6
1 file changed +57 -33
t/t7503-pre-commit-hook.sh
+57 -33
@@ -4,15 +4,21 @@ test_description='pre-commit hook'
4
5 . ./test-lib.sh
6
7 -test_expect_success "with no hook" \
8 - "echo 'foo' > file &&
9 - git add file &&
10 - git commit -m 'first'"
7 +test_expect_success 'with no hook' '
8
12 -test_expect_success "--no-verify with no hook" \
13 - "echo 'bar' > file &&
14 - git add file &&
15 - git commit --no-verify -m 'bar'"
9 + echo "foo" > file &&
10 + git add file &&
11 + git commit -m "first"
12 +
13 +'
14 +
15 +test_expect_success '--no-verify with no hook' '
16 +
17 + echo "bar" > file &&
18 + git add file &&
19 + git commit --no-verify -m "bar"
20 +
21 +'
22
23 # now install hook that always succeeds
24 HOOKDIR="$(git rev-parse --git-dir)/hooks"
@@ -24,15 +30,21 @@ exit 0
30 EOF
31 chmod +x "$HOOK"
32
27 -test_expect_success "with succeeding hook" \
28 - "echo 'more' >> file &&
29 - git add file &&
30 - git commit -m 'more'"
33 +test_expect_success 'with succeeding hook' '
34 +
35 + echo "more" >> file &&
36 + git add file &&
37 + git commit -m "more"
38
32 -test_expect_success "--no-verify with succeeding hook" \
33 - "echo 'even more' >> file &&
34 - git add file &&
35 - git commit --no-verify -m 'even more'"
39 +'
40 +
41 +test_expect_success '--no-verify with succeeding hook' '
42 +
43 + echo "even more" >> file &&
44 + git add file &&
45 + git commit --no-verify -m "even more"
46 +
47 +'
48
49 # now a hook that fails
50 cat > "$HOOK" <<EOF
@@ -40,25 +52,37 @@ cat > "$HOOK" <<EOF
52 exit 1
53 EOF
54
43 -test_expect_failure "with failing hook" \
44 - "echo 'another' >> file &&
45 - git add file &&
46 - git commit -m 'another'"
55 +test_expect_failure 'with failing hook' '
56 +
57 + echo "another" >> file &&
58 + git add file &&
59 + git commit -m "another"
60
48 -test_expect_success "--no-verify with failing hook" \
49 - "echo 'stuff' >> file &&
50 - git add file &&
51 - git commit --no-verify -m 'stuff'"
61 +'
62 +
63 +test_expect_success '--no-verify with failing hook' '
64 +
65 + echo "stuff" >> file &&
66 + git add file &&
67 + git commit --no-verify -m "stuff"
68 +
69 +'
70
71 chmod -x "$HOOK"
54 -test_expect_success "with non-executable hook" \
55 - "echo 'content' >> file &&
56 - git add file &&
57 - git commit -m 'content'"
58 -
59 -test_expect_success "--no-verify with non-executable hook" \
60 - "echo 'more content' >> file &&
61 - git add file &&
62 - git commit --no-verify -m 'more content'"
72 +test_expect_success 'with non-executable hook' '
73 +
74 + echo "content" >> file &&
75 + git add file &&
76 + git commit -m "content"
77 +
78 +'
79 +
80 +test_expect_success '--no-verify with non-executable hook' '
81 +
82 + echo "more content" >> file &&
83 + git add file &&
84 + git commit --no-verify -m "more content"
85 +
86 +'
87
88 test_done