Skip to content

Commit 6ec6330

Browse files
wchargingitster
authored andcommitted
t: factor out FUNNYNAMES as shared lazy prereq
A fair number of tests need to check that the filesystem supports file names including "funny" characters, like newline, tab, and double-quote. Jonathan Nieder suggested that this be extracted into a lazy prereq in the top-level `test-lib.sh`. This patch effects that change. The FUNNYNAMES prereq now uniformly requires support for newlines, tabs, and double-quotes in filenames. This very slightly decreases the power of some tests, which might have run previously on a system that supports (e.g.) newlines and tabs but not double-quotes, but now will not. This seems to me like an acceptable tradeoff for consistency. One test (`t/t9902-completion.sh`) defined FUNNYNAMES to further require the separators \034 through \037, the test for which was implemented using the Bash-specific $'\034' syntax. I've elected to leave this one as is, renaming it to FUNNIERNAMES. After this patch, `git grep 'test_\(set\|lazy\)_prereq.*FUNNYNAMES'` has only one result. Signed-off-by: William Chargin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 53f9a3e commit 6ec6330

File tree

5 files changed

+26
-25
lines changed

5 files changed

+26
-25
lines changed

t/t3600-rm.sh

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,13 @@ test_expect_success \
1414
git add -- foo bar baz 'space embedded' -q &&
1515
git commit -m 'add normal files'"
1616

17-
if test_have_prereq !MINGW && touch -- 'tab embedded' 'newline
18-
embedded' 2>/dev/null
19-
then
20-
test_set_prereq FUNNYNAMES
21-
else
17+
if test_have_prereq !FUNNYNAMES; then
2218
say 'Your filesystem does not allow tabs in filenames.'
2319
fi
2420

2521
test_expect_success FUNNYNAMES 'add files with funny names' "
22+
touch -- 'tab embedded' 'newline
23+
embedded' &&
2624
git add -- 'tab embedded' 'newline
2725
embedded' &&
2826
git commit -m 'add files with tabs and newlines'

t/t4135-apply-weird-filenames.sh

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,7 @@ test_expect_success 'setup' '
1515
git checkout -f preimage^0 &&
1616
git read-tree -u --reset HEAD &&
1717
git update-index --refresh
18-
} &&
19-
20-
test_when_finished "rm -f \"tab embedded.txt\"" &&
21-
test_when_finished "rm -f '\''\"quoteembedded\".txt'\''" &&
22-
if test_have_prereq !MINGW &&
23-
touch -- "tab embedded.txt" '\''"quoteembedded".txt'\''
24-
then
25-
test_set_prereq FUNNYNAMES
26-
fi
18+
}
2719
'
2820

2921
try_filename() {

t/t9902-completion.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1242,7 +1242,7 @@ test_expect_success 'setup for path completion tests' '
12421242
touch BS\\dir/DQ\"file \
12431243
'$'separators\034in\035dir/sep\036in\037file''
12441244
then
1245-
test_set_prereq FUNNYNAMES
1245+
test_set_prereq FUNNIERNAMES
12461246
else
12471247
rm -rf BS\\dir '$'separators\034in\035dir''
12481248
fi
@@ -1284,7 +1284,7 @@ test_expect_success '__git_complete_index_file - UTF-8 in ls-files output' '
12841284
test_path_completion árvíztűrő/С "árvíztűrő/Сайн яваарай"
12851285
'
12861286

1287-
test_expect_success FUNNYNAMES \
1287+
test_expect_success FUNNIERNAMES \
12881288
'__git_complete_index_file - C-style escapes in ls-files output' '
12891289
test_path_completion BS \
12901290
BS\\dir &&
@@ -1296,7 +1296,7 @@ test_expect_success FUNNYNAMES \
12961296
BS\\dir/DQ\"file
12971297
'
12981298

1299-
test_expect_success FUNNYNAMES \
1299+
test_expect_success FUNNIERNAMES \
13001300
'__git_complete_index_file - \nnn-escaped characters in ls-files output' '
13011301
test_path_completion sep '$'separators\034in\035dir'' &&
13021302
test_path_completion '$'separators\034i'' \

t/t9903-bash-prompt.sh

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,18 +63,15 @@ test_expect_success 'prompt - unborn branch' '
6363
test_cmp expected "$actual"
6464
'
6565

66-
repo_with_newline='repo
67-
with
68-
newline'
69-
70-
if test_have_prereq !MINGW && mkdir "$repo_with_newline" 2>/dev/null
71-
then
72-
test_set_prereq FUNNYNAMES
73-
else
66+
if test_have_prereq !FUNNYNAMES; then
7467
say 'Your filesystem does not allow newlines in filenames.'
7568
fi
7669

7770
test_expect_success FUNNYNAMES 'prompt - with newline in path' '
71+
repo_with_newline="repo
72+
with
73+
newline" &&
74+
mkdir "$repo_with_newline" &&
7875
printf " (master)" >expected &&
7976
git init "$repo_with_newline" &&
8077
test_when_finished "rm -rf \"$repo_with_newline\"" &&

t/test-lib.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,6 +1103,20 @@ test_lazy_prereq CASE_INSENSITIVE_FS '
11031103
test "$(cat CamelCase)" != good
11041104
'
11051105

1106+
test_lazy_prereq FUNNYNAMES '
1107+
test_have_prereq !MINGW &&
1108+
touch -- \
1109+
"FUNNYNAMES tab embedded" \
1110+
"FUNNYNAMES \"quote embedded\"" \
1111+
"FUNNYNAMES newline
1112+
embedded" 2>/dev/null &&
1113+
rm -- \
1114+
"FUNNYNAMES tab embedded" \
1115+
"FUNNYNAMES \"quote embedded\"" \
1116+
"FUNNYNAMES newline
1117+
embedded" 2>/dev/null
1118+
'
1119+
11061120
test_lazy_prereq UTF8_NFD_TO_NFC '
11071121
# check whether FS converts nfd unicode to nfc
11081122
auml=$(printf "\303\244")

0 commit comments

Comments
 (0)