Skip to content

Commit 8fe5aed

Browse files
jrngitster
authored andcommitted
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 <[email protected]> Signed-off-by: Jonathan Nieder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 76bbcd4 commit 8fe5aed

File tree

1 file changed

+40
-24
lines changed

1 file changed

+40
-24
lines changed

t/t1302-repo-version.sh

Lines changed: 40 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,41 @@ test_description='Test repository version check'
77

88
. ./test-lib.sh
99

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
1819
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+
'
2324

2425
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+
'
2835

29-
# Make sure it would stop at test2, not trash
3036
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+
'
3345

3446
test_expect_success 'gitdir not required mode' '
3547
git apply --stat test.patch &&
@@ -43,12 +55,16 @@ test_expect_success 'gitdir not required mode' '
4355
)
4456
'
4557

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+
)
5268
'
5369

5470
test_done

0 commit comments

Comments
 (0)