t9902: split test to run on appropriate systems

The "FUNNYNAMES" test prerequisite passes on Cygwin, as the Cygwin
file system interface has a workaround for the underlying operating
system's lack of support for tabs, newlines or quotes.  However, it does
not add support for backslash, which is treated as a directory
separator, meaning one of the tests added by 48803821b1 ("completion:
handle unusual characters for sparse-checkout", 2022-02-07) will fail on
Cygwin.

To avoid this failure while still getting maximal test coverage, split
that test into two: test handling of paths that include tabs on anything
that has the FUNNYNAMES prerequisite, but skip testing handling of paths
that include backslashes unless both FUNNYNAMES is set and the system is
not Cygwin.

It might be nice to have more granularity than "FUNNYNAMES" and its
sibling "FUNNIERNAMES" provide, so that tests could be run based on
specific individual characters supported by the file system being
tested, but that seems like it would make the prerequisite checks in
this area much more verbose for very little gain.

Signed-off-by: Adam Dinwoodie <adam@dinwoodie.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Adam Dinwoodie 2022-04-08 10:53:53 +01:00 committed by Junio C Hamano
parent 48803821b1
commit 6d340dfaef

View file

@ -1529,28 +1529,45 @@ test_expect_success 'cone mode sparse-checkout completes directory names with sp
) )
' '
# use FUNNYNAMES to avoid running on Windows, which doesn't permit backslashes or tabs in paths # use FUNNYNAMES to avoid running on Windows, which doesn't permit tabs in paths
test_expect_success FUNNYNAMES 'cone mode sparse-checkout completes directory names with backslashes and tabs' ' test_expect_success FUNNYNAMES 'cone mode sparse-checkout completes directory names with tabs' '
# reset sparse-checkout
git -C sparse-checkout sparse-checkout disable &&
(
cd sparse-checkout &&
mkdir "$(printf "directory\twith\ttabs")" &&
>"$(printf "directory\twith\ttabs")/randomfile" &&
git add . &&
git commit -m "Add directory with tabs" &&
git sparse-checkout set --cone \
"$(printf "directory\twith\ttabs")" &&
test_completion "git sparse-checkout add dir" <<-\EOF &&
directory with tabs/
EOF
rm -rf "$(printf "directory\twith\ttabs")" &&
git add . &&
git commit -m "Remove directory with tabs"
)
'
# use FUNNYNAMES to avoid running on Windows, and !CYGWIN for Cygwin, as neither permit backslashes in paths
test_expect_success FUNNYNAMES,!CYGWIN 'cone mode sparse-checkout completes directory names with backslashes' '
# reset sparse-checkout # reset sparse-checkout
git -C sparse-checkout sparse-checkout disable && git -C sparse-checkout sparse-checkout disable &&
( (
cd sparse-checkout && cd sparse-checkout &&
mkdir "directory\with\backslashes" && mkdir "directory\with\backslashes" &&
mkdir "$(printf "directory\twith\ttabs")" &&
>"directory\with\backslashes/randomfile" && >"directory\with\backslashes/randomfile" &&
>"$(printf "directory\twith\ttabs")/randomfile" &&
git add . && git add . &&
git commit -m "Add directory with backslashes and directory with tabs" && git commit -m "Add directory with backslashes" &&
git sparse-checkout set --cone "directory\with\backslashes" \ git sparse-checkout set --cone \
"$(printf "directory\twith\ttabs")" && "directory\with\backslashes" &&
test_completion "git sparse-checkout add dir" <<-\EOF && test_completion "git sparse-checkout add dir" <<-\EOF &&
directory\with\backslashes/ directory\with\backslashes/
directory with tabs/
EOF EOF
rm -rf "directory\with\backslashes" && rm -rf "directory\with\backslashes" &&
rm -rf "$(printf "directory\twith\ttabs")" &&
git add . && git add . &&
git commit -m "Remove directory with backslashes and directory with tabs" git commit -m "Remove directory with backslashes"
) )
' '