{"thread":{"id":"49050","subject":"[PATCH] t: factor out FUNNYNAMES as shared lazy prereq","startedAt":"2018-08-06T18:35:29Z","lastAt":"2018-08-06T18:35:29Z","messageCount":1,"participants":["William Chargin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"354665","messageId":"20180806183508.15711-1-wchargin@gmail.com","threadId":"49050","inReplyTo":null,"subject":"[PATCH] t: factor out FUNNYNAMES as shared lazy prereq","fromName":"William Chargin","fromEmail":"wchargin@gmail.com","sentAt":"2018-08-06T18:35:08Z","receivedAt":"2018-08-06T18:35:29Z","isPatch":true,"sender":{"key":"wchargin@gmail.com","avatar":"https://avatars.githubusercontent.com/u/4317806?v=4"},"body":"A fair number of tests need to check that the filesystem supports file\nnames including \"funny\" characters, like newline, tab, and double-quote.\nJonathan Nieder suggested that this be extracted into a lazy prereq in\nthe top-level `test-lib.sh`. This patch effects that change.\n\nThe FUNNYNAMES prereq now uniformly requires support for newlines, tabs,\nand double-quotes in filenames. This very slightly decreases the power\nof some tests, which might have run previously on a system that supports\n(e.g.) newlines and tabs but not double-quotes, but now will not. This\nseems to me like an acceptable tradeoff for consistency.\n\nOne test (`t/t9902-completion.sh`) defined FUNNYNAMES to further require\nthe separators \\034 through \\037, the test for which was implemented\nusing the Bash-specific $'\\034' syntax. I've elected to leave this one\nas is, renaming it to FUNNIERNAMES.\n\nAfter this patch, `git grep 'test_\\(set\\|lazy\\)_prereq.*FUNNYNAMES'` has\nonly one result.\n\nSigned-off-by: William Chargin <wchargin@gmail.com>\n---\nNote: I've tested this only on an Ubuntu-like system, where FUNNYNAMES\nand FUNNIERNAMES are both naturally satisfied. I've verified that the\ntests correctly skip when the prereqs are stubbed out to fail by\nprepending `false &&`, but I haven't verified that the actual logic for\ntesting the prereq has the correct behavior on non-FUNNYNAMES systems.\n\n t/t3600-rm.sh                    |  8 +++-----\n t/t4135-apply-weird-filenames.sh | 10 +---------\n t/t9902-completion.sh            |  6 +++---\n t/t9903-bash-prompt.sh           | 13 +++++--------\n t/test-lib.sh                    | 14 ++++++++++++++\n 5 files changed, 26 insertions(+), 25 deletions(-)\n\ndiff --git a/t/t3600-rm.sh b/t/t3600-rm.sh\nindex b8fbdefcd..5829dfd12 100755\n--- a/t/t3600-rm.sh\n+++ b/t/t3600-rm.sh\n@@ -14,15 +14,13 @@ test_expect_success \\\n      git add -- foo bar baz 'space embedded' -q &&\n      git commit -m 'add normal files'\"\n \n-if test_have_prereq !MINGW && touch -- 'tab\tembedded' 'newline\n-embedded' 2>/dev/null\n-then\n-\ttest_set_prereq FUNNYNAMES\n-else\n+if test_have_prereq !FUNNYNAMES; then\n \tsay 'Your filesystem does not allow tabs in filenames.'\n fi\n \n test_expect_success FUNNYNAMES 'add files with funny names' \"\n+     touch -- 'tab\tembedded' 'newline\n+embedded' &&\n      git add -- 'tab\tembedded' 'newline\n embedded' &&\n      git commit -m 'add files with tabs and newlines'\ndiff --git a/t/t4135-apply-weird-filenames.sh b/t/t4135-apply-weird-filenames.sh\nindex c7c688fcc..6bc3fb97a 100755\n--- a/t/t4135-apply-weird-filenames.sh\n+++ b/t/t4135-apply-weird-filenames.sh\n@@ -15,15 +15,7 @@ test_expect_success 'setup' '\n \t\tgit checkout -f preimage^0 &&\n \t\tgit read-tree -u --reset HEAD &&\n \t\tgit update-index --refresh\n-\t} &&\n-\n-\ttest_when_finished \"rm -f \\\"tab\tembedded.txt\\\"\" &&\n-\ttest_when_finished \"rm -f '\\''\\\"quoteembedded\\\".txt'\\''\" &&\n-\tif test_have_prereq !MINGW &&\n-\t\ttouch -- \"tab\tembedded.txt\" '\\''\"quoteembedded\".txt'\\''\n-\tthen\n-\t\ttest_set_prereq FUNNYNAMES\n-\tfi\n+\t}\n '\n \n try_filename() {\ndiff --git a/t/t9902-completion.sh b/t/t9902-completion.sh\nindex 5ff43b9cb..175f83d70 100755\n--- a/t/t9902-completion.sh\n+++ b/t/t9902-completion.sh\n@@ -1278,7 +1278,7 @@ test_expect_success 'setup for path completion tests' '\n \t   touch BS\\\\dir/DQ\\\"file \\\n \t\t '$'separators\\034in\\035dir/sep\\036in\\037file''\n \tthen\n-\t\ttest_set_prereq FUNNYNAMES\n+\t\ttest_set_prereq FUNNIERNAMES\n \telse\n \t\trm -rf BS\\\\dir '$'separators\\034in\\035dir''\n \tfi\n@@ -1320,7 +1320,7 @@ test_expect_success '__git_complete_index_file - UTF-8 in ls-files output' '\n \ttest_path_completion árvíztűrő/С \"árvíztűrő/Сайн яваарай\"\n '\n \n-test_expect_success FUNNYNAMES \\\n+test_expect_success FUNNIERNAMES \\\n     '__git_complete_index_file - C-style escapes in ls-files output' '\n \ttest_path_completion BS \\\n \t\t\t     BS\\\\dir &&\n@@ -1332,7 +1332,7 @@ test_expect_success FUNNYNAMES \\\n \t\t\t     BS\\\\dir/DQ\\\"file\n '\n \n-test_expect_success FUNNYNAMES \\\n+test_expect_success FUNNIERNAMES \\\n     '__git_complete_index_file - \\nnn-escaped characters in ls-files output' '\n \ttest_path_completion sep '$'separators\\034in\\035dir'' &&\n \ttest_path_completion '$'separators\\034i'' \\\ndiff --git a/t/t9903-bash-prompt.sh b/t/t9903-bash-prompt.sh\nindex 04440685a..ab890d3d4 100755\n--- a/t/t9903-bash-prompt.sh\n+++ b/t/t9903-bash-prompt.sh\n@@ -63,18 +63,15 @@ test_expect_success 'prompt - unborn branch' '\n \ttest_cmp expected \"$actual\"\n '\n \n-repo_with_newline='repo\n-with\n-newline'\n-\n-if test_have_prereq !MINGW && mkdir \"$repo_with_newline\" 2>/dev/null\n-then\n-\ttest_set_prereq FUNNYNAMES\n-else\n+if test_have_prereq !FUNNYNAMES; then\n \tsay 'Your filesystem does not allow newlines in filenames.'\n fi\n \n test_expect_success FUNNYNAMES 'prompt - with newline in path' '\n+    repo_with_newline=\"repo\n+with\n+newline\" &&\n+\tmkdir \"$repo_with_newline\" &&\n \tprintf \" (master)\" >expected &&\n \tgit init \"$repo_with_newline\" &&\n \ttest_when_finished \"rm -rf \\\"$repo_with_newline\\\"\" &&\ndiff --git a/t/test-lib.sh b/t/test-lib.sh\nindex 78f709774..8bb0f4348 100644\n--- a/t/test-lib.sh\n+++ b/t/test-lib.sh\n@@ -1104,6 +1104,20 @@ test_lazy_prereq CASE_INSENSITIVE_FS '\n \ttest \"$(cat CamelCase)\" != good\n '\n \n+test_lazy_prereq FUNNYNAMES '\n+\ttest_have_prereq !MINGW &&\n+\ttouch -- \\\n+\t\t\"FUNNYNAMES tab\tembedded\" \\\n+\t\t\"FUNNYNAMES \\\"quote embedded\\\"\" \\\n+\t\t\"FUNNYNAMES newline\n+embedded\" 2>/dev/null &&\n+\trm -- \\\n+\t\t\"FUNNYNAMES tab\tembedded\" \\\n+\t\t\"FUNNYNAMES \\\"quote embedded\\\"\" \\\n+\t\t\"FUNNYNAMES newline\n+embedded\" 2>/dev/null\n+'\n+\n test_lazy_prereq UTF8_NFD_TO_NFC '\n \t# check whether FS converts nfd unicode to nfc\n \tauml=$(printf \"\\303\\244\")\n-- \n2.18.0.548.g101af7bd4\n\n"}]}