t3600: Use test prerequisite tags
There are two prerequisites: - The filesystem supports names with tabs or new-lines. - Files cannot be removed if their containing directory is read-only. Previously, whether these preconditions are satisified was tested inside test_expect_success. We move these tests outside because, strictly speaking, they are not part of the tests. Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Johannes Sixt committed
Feb 26, 2009 at 23:09 UTC
56e78bfb299207213ff170238c34a1dc8fa67c09
1 file changed
+30
-28
t/t3600-rm.sh
+30
-28
@@ -12,31 +12,37 @@ test_expect_success \
12
'Initialize test directory' \
13
"touch -- foo bar baz 'space embedded' -q &&
14
git add -- foo bar baz 'space embedded' -q &&
15
- git commit -m 'add normal files' &&
16
- test_tabs=y &&
17
- if touch -- 'tab embedded' 'newline
18
-embedded'
19
- then
15
+ git commit -m 'add normal files'"
16
+
17
+if touch -- 'tab embedded' 'newline
18
+embedded' 2>/dev/null
19
+then
20
+ test_set_prereq FUNNYNAMES
21
+else
22
+ say 'Your filesystem does not allow tabs in filenames.'
23
+fi
24
+
25
+test_expect_success FUNNYNAMES 'add files with funny names' "
26
git add -- 'tab embedded' 'newline
27
embedded' &&
28
git commit -m 'add files with tabs and newlines'
23
- else
24
- test_tabs=n
25
- fi"
26
-
27
-test "$test_tabs" = n && say 'Your filesystem does not allow tabs in filenames.'
29
+"
30
31
+# Determine rm behavior
32
# Later we will try removing an unremovable path to make sure
33
# git rm barfs, but if the test is run as root that cannot be
34
# arranged.
32
-test_expect_success \
33
- 'Determine rm behavior' \
34
- ': >test-file
35
- chmod a-w .
36
- rm -f test-file
37
- test -f test-file && test_failed_remove=y
38
- chmod 775 .
39
- rm -f test-file'
35
+: >test-file
36
+chmod a-w .
37
+rm -f test-file 2>/dev/null
38
+if test -f test-file
39
+then
40
+ test_set_prereq RO_DIR
41
+else
42
+ say 'skipping removal failure test (perhaps running as root?)'
43
+fi
44
+chmod 775 .
45
+rm -f test-file
46
47
test_expect_success \
48
'Pre-check that foo exists and is in index before git rm foo' \
@@ -101,20 +107,16 @@ test_expect_success \
107
'Test that "git rm -- -q" succeeds (remove a file that looks like an option)' \
108
'git rm -- -q'
109
104
-test "$test_tabs" = y && test_expect_success \
110
+test_expect_success FUNNYNAMES \
111
"Test that \"git rm -f\" succeeds with embedded space, tab, or newline characters." \
112
"git rm -f 'space embedded' 'tab embedded' 'newline
113
embedded'"
114
109
-if test "$test_failed_remove" = y; then
110
-chmod a-w .
111
-test_expect_success \
112
- 'Test that "git rm -f" fails if its rm fails' \
113
- 'test_must_fail git rm -f baz'
114
-chmod 775 .
115
-else
116
- say 'skipping removal failure test (perhaps running as root?)'
117
-fi
115
+test_expect_success RO_DIR 'Test that "git rm -f" fails if its rm fails' '
116
+ chmod a-w . &&
117
+ test_must_fail git rm -f baz &&
118
+ chmod 775 .
119
+'
120
121
test_expect_success \
122
'When the rm in "git rm -f" fails, it should not remove the file from the index' \