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 <wchargin@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

William Chargin committed Aug 6, 2018 at 11:35 UTC 6ec633059ad0b17850ad18c7325678d6c845b74c
5 files changed +26 -25
t/t3600-rm.sh
+3 -5
@@ -14,15 +14,13 @@ test_expect_success \
14 git add -- foo bar baz 'space embedded' -q &&
15 git commit -m 'add normal files'"
16
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
18 say 'Your filesystem does not allow tabs in filenames.'
19 fi
20
21 test_expect_success FUNNYNAMES 'add files with funny names' "
22 + touch -- 'tab embedded' 'newline
23 +embedded' &&
24 git add -- 'tab embedded' 'newline
25 embedded' &&
26 git commit -m 'add files with tabs and newlines'
t/t4135-apply-weird-filenames.sh
+1 -9
@@ -15,15 +15,7 @@ test_expect_success 'setup' '
15 git checkout -f preimage^0 &&
16 git read-tree -u --reset HEAD &&
17 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 + }
19 '
20
21 try_filename() {
t/t9902-completion.sh
+3 -3
@@ -1242,7 +1242,7 @@ test_expect_success 'setup for path completion tests' '
1242 touch BS\\dir/DQ\"file \
1243 '$'separators\034in\035dir/sep\036in\037file''
1244 then
1245 - test_set_prereq FUNNYNAMES
1245 + test_set_prereq FUNNIERNAMES
1246 else
1247 rm -rf BS\\dir '$'separators\034in\035dir''
1248 fi
@@ -1284,7 +1284,7 @@ test_expect_success '__git_complete_index_file - UTF-8 in ls-files output' '
1284 test_path_completion árvíztűrő/С "árvíztűrő/Сайн яваарай"
1285 '
1286
1287 -test_expect_success FUNNYNAMES \
1287 +test_expect_success FUNNIERNAMES \
1288 '__git_complete_index_file - C-style escapes in ls-files output' '
1289 test_path_completion BS \
1290 BS\\dir &&
@@ -1296,7 +1296,7 @@ test_expect_success FUNNYNAMES \
1296 BS\\dir/DQ\"file
1297 '
1298
1299 -test_expect_success FUNNYNAMES \
1299 +test_expect_success FUNNIERNAMES \
1300 '__git_complete_index_file - \nnn-escaped characters in ls-files output' '
1301 test_path_completion sep '$'separators\034in\035dir'' &&
1302 test_path_completion '$'separators\034i'' \
t/t9903-bash-prompt.sh
+5 -8
@@ -63,18 +63,15 @@ test_expect_success 'prompt - unborn branch' '
63 test_cmp expected "$actual"
64 '
65
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
67 say 'Your filesystem does not allow newlines in filenames.'
68 fi
69
70 test_expect_success FUNNYNAMES 'prompt - with newline in path' '
71 + repo_with_newline="repo
72 +with
73 +newline" &&
74 + mkdir "$repo_with_newline" &&
75 printf " (master)" >expected &&
76 git init "$repo_with_newline" &&
77 test_when_finished "rm -rf \"$repo_with_newline\"" &&
t/test-lib.sh
+14
@@ -1103,6 +1103,20 @@ test_lazy_prereq CASE_INSENSITIVE_FS '
1103 test "$(cat CamelCase)" != good
1104 '
1105
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 +
1120 test_lazy_prereq UTF8_NFD_TO_NFC '
1121 # check whether FS converts nfd unicode to nfc
1122 auml=$(printf "\303\244")