]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t: factor out FUNNYNAMES as shared lazy prereq
authorWilliam Chargin <wchargin@gmail.com>
Mon, 6 Aug 2018 18:35:08 +0000 (11:35 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 6 Aug 2018 20:35:15 +0000 (13:35 -0700)
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>
t/t3600-rm.sh
t/t4135-apply-weird-filenames.sh
t/t9902-completion.sh
t/t9903-bash-prompt.sh
t/test-lib.sh

index b8fbdefcdc34ffa6fb54fc1ad375a583a194fb38..5829dfd12cfdcbfe3061b7dcc7a91cd9799f4687 100755 (executable)
@@ -14,15 +14,13 @@ test_expect_success \
      git add -- foo bar baz 'space embedded' -q &&
      git commit -m 'add normal files'"
 
-if test_have_prereq !MINGW && touch -- 'tab    embedded' 'newline
-embedded' 2>/dev/null
-then
-       test_set_prereq FUNNYNAMES
-else
+if test_have_prereq !FUNNYNAMES; then
        say 'Your filesystem does not allow tabs in filenames.'
 fi
 
 test_expect_success FUNNYNAMES 'add files with funny names' "
+     touch -- 'tab     embedded' 'newline
+embedded' &&
      git add -- 'tab   embedded' 'newline
 embedded' &&
      git commit -m 'add files with tabs and newlines'
index c7c688fcc4bbdfe97a5c595fddc96e2590e021a2..6bc3fb97a754bf242f8baf1ba867aa9f7fa93d0d 100755 (executable)
@@ -15,15 +15,7 @@ test_expect_success 'setup' '
                git checkout -f preimage^0 &&
                git read-tree -u --reset HEAD &&
                git update-index --refresh
-       } &&
-
-       test_when_finished "rm -f \"tab embedded.txt\"" &&
-       test_when_finished "rm -f '\''\"quoteembedded\".txt'\''" &&
-       if test_have_prereq !MINGW &&
-               touch -- "tab   embedded.txt" '\''"quoteembedded".txt'\''
-       then
-               test_set_prereq FUNNYNAMES
-       fi
+       }
 '
 
 try_filename() {
index a28640ce1accd604bd32fdc95fd172119f6c3741..532df85c43855cbb90d6a329ec363c53cc0bd6ae 100755 (executable)
@@ -1242,7 +1242,7 @@ test_expect_success 'setup for path completion tests' '
           touch BS\\dir/DQ\"file \
                 '$'separators\034in\035dir/sep\036in\037file''
        then
-               test_set_prereq FUNNYNAMES
+               test_set_prereq FUNNIERNAMES
        else
                rm -rf BS\\dir '$'separators\034in\035dir''
        fi
@@ -1284,7 +1284,7 @@ test_expect_success '__git_complete_index_file - UTF-8 in ls-files output' '
        test_path_completion árvíztűrő/С "árvíztűrő/Сайн яваарай"
 '
 
-test_expect_success FUNNYNAMES \
+test_expect_success FUNNIERNAMES \
     '__git_complete_index_file - C-style escapes in ls-files output' '
        test_path_completion BS \
                             BS\\dir &&
@@ -1296,7 +1296,7 @@ test_expect_success FUNNYNAMES \
                             BS\\dir/DQ\"file
 '
 
-test_expect_success FUNNYNAMES \
+test_expect_success FUNNIERNAMES \
     '__git_complete_index_file - \nnn-escaped characters in ls-files output' '
        test_path_completion sep '$'separators\034in\035dir'' &&
        test_path_completion '$'separators\034i'' \
index c3b89ae783d0b5511718be6d6b9d9978dd9131cd..994a676a6bfcb76d3e20c4421b859763041d0787 100755 (executable)
@@ -63,18 +63,15 @@ test_expect_success 'prompt - unborn branch' '
        test_cmp expected "$actual"
 '
 
-repo_with_newline='repo
-with
-newline'
-
-if test_have_prereq !MINGW && mkdir "$repo_with_newline" 2>/dev/null
-then
-       test_set_prereq FUNNYNAMES
-else
+if test_have_prereq !FUNNYNAMES; then
        say 'Your filesystem does not allow newlines in filenames.'
 fi
 
 test_expect_success FUNNYNAMES 'prompt - with newline in path' '
+    repo_with_newline="repo
+with
+newline" &&
+       mkdir "$repo_with_newline" &&
        printf " (master)" >expected &&
        git init "$repo_with_newline" &&
        test_when_finished "rm -rf \"$repo_with_newline\"" &&
index 28315706be709d28c85785e389b381a8617337e3..f221aa95e51f16cea16c96e28ad6d2c8b20927bf 100644 (file)
@@ -1103,6 +1103,20 @@ test_lazy_prereq CASE_INSENSITIVE_FS '
        test "$(cat CamelCase)" != good
 '
 
+test_lazy_prereq FUNNYNAMES '
+       test_have_prereq !MINGW &&
+       touch -- \
+               "FUNNYNAMES tab embedded" \
+               "FUNNYNAMES \"quote embedded\"" \
+               "FUNNYNAMES newline
+embedded" 2>/dev/null &&
+       rm -- \
+               "FUNNYNAMES tab embedded" \
+               "FUNNYNAMES \"quote embedded\"" \
+               "FUNNYNAMES newline
+embedded" 2>/dev/null
+'
+
 test_lazy_prereq UTF8_NFD_TO_NFC '
        # check whether FS converts nfd unicode to nfc
        auml=$(printf "\303\244")