@matheusbsbs / matheus-bagliano / commits / 8fe5aeddcb
Fork 0

t1302 (core.repositoryversion): style tweaks

This test is from 2007, which is late enough for the style to be recognizably modern but still a while ago. Freshen it up to follow new best practices: - guard setup commands with test_expect_setup, so errors at that stage can be caught; - use <<\EOF in preference to <<EOF, to save reviewers the trouble of looking for variable interpolations; - use test_cmp instead of test "$foo" = "$bar", for better output with -v on failure; - indent commands in subshells and let them span multiple lines; - combine the two "gitdir required mode" tests that do not make as much sense alone. Cc: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jonathan Nieder committed Sep 6, 2010 at 20:52 UTC 8fe5aeddcbeb194ea0f6e23e1f7b4ac38809921b
1 file changed +40 -24
t/t1302-repo-version.sh
+40 -24
@@ -7,29 +7,41 @@ test_description='Test repository version check'
7
8 . ./test-lib.sh
9
10 -cat >test.patch <<EOF
11 -diff --git a/test.txt b/test.txt
12 -new file mode 100644
13 ---- /dev/null
14 -+++ b/test.txt
15 -@@ -0,0 +1 @@
16 -+123
17 -EOF
10 +test_expect_success 'setup' '
11 + cat >test.patch <<-\EOF &&
12 + diff --git a/test.txt b/test.txt
13 + new file mode 100644
14 + --- /dev/null
15 + +++ b/test.txt
16 + @@ -0,0 +1 @@
17 + +123
18 + EOF
19
19 -test_create_repo "test"
20 -test_create_repo "test2"
21 -
22 -GIT_CONFIG=test2/.git/config git config core.repositoryformatversion 99 || exit 1
20 + test_create_repo "test" &&
21 + test_create_repo "test2" &&
22 + GIT_CONFIG=test2/.git/config git config core.repositoryformatversion 99
23 +'
24
25 test_expect_success 'gitdir selection on normal repos' '
25 - (test "$(git config core.repositoryformatversion)" = 0 &&
26 - cd test &&
27 - test "$(git config core.repositoryformatversion)" = 0)'
26 + echo 0 >expect &&
27 + git config core.repositoryformatversion >actual &&
28 + (
29 + cd test &&
30 + git config core.repositoryformatversion >../actual2
31 + ) &&
32 + test_cmp expect actual &&
33 + test_cmp expect actual2
34 +'
35
29 -# Make sure it would stop at test2, not trash
36 test_expect_success 'gitdir selection on unsupported repo' '
31 - (cd test2 &&
32 - test "$(git config core.repositoryformatversion)" = 99)'
37 + # Make sure it would stop at test2, not trash
38 + echo 99 >expect &&
39 + (
40 + cd test2 &&
41 + git config core.repositoryformatversion >../actual
42 + )
43 + test_cmp expect actual
44 +'
45
46 test_expect_success 'gitdir not required mode' '
47 git apply --stat test.patch &&
@@ -43,12 +55,16 @@ test_expect_success 'gitdir not required mode' '
55 )
56 '
57
46 -test_expect_success 'gitdir required mode on normal repos' '
47 - (git apply --check --index test.patch &&
48 - cd test && git apply --check --index ../test.patch)'
49 -
50 -test_expect_success 'gitdir required mode on unsupported repo' '
51 - (cd test2 && test_must_fail git apply --check --index ../test.patch)
58 +test_expect_success 'gitdir required mode' '
59 + git apply --check --index test.patch &&
60 + (
61 + cd test &&
62 + git apply --check --index ../test.patch
63 + ) &&
64 + (
65 + cd test2 &&
66 + test_must_fail git apply --check --index ../test.patch
67 + )
68 '
69
70 test_done