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>

Adam Dinwoodie committed Apr 8, 2022 at 10:53 UTC 6d340dfaef25453a7d95a3e3960aea06fe69dbdf
1 file changed +26 -9
t/t9902-completion.sh
+26 -9
@@ -1529,28 +1529,45 @@ test_expect_success 'cone mode sparse-checkout completes directory names with sp
1529 )
1530 '
1531
1532 -# use FUNNYNAMES to avoid running on Windows, which doesn't permit backslashes or tabs in paths
1533 -test_expect_success FUNNYNAMES 'cone mode sparse-checkout completes directory names with backslashes and tabs' '
1532 +# use FUNNYNAMES to avoid running on Windows, which doesn't permit tabs in paths
1533 +test_expect_success FUNNYNAMES 'cone mode sparse-checkout completes directory names with tabs' '
1534 # reset sparse-checkout
1535 git -C sparse-checkout sparse-checkout disable &&
1536 (
1537 cd sparse-checkout &&
1538 - mkdir "directory\with\backslashes" &&
1538 mkdir "$(printf "directory\twith\ttabs")" &&
1540 - >"directory\with\backslashes/randomfile" &&
1539 >"$(printf "directory\twith\ttabs")/randomfile" &&
1540 git add . &&
1543 - git commit -m "Add directory with backslashes and directory with tabs" &&
1544 - git sparse-checkout set --cone "directory\with\backslashes" \
1541 + git commit -m "Add directory with tabs" &&
1542 + git sparse-checkout set --cone \
1543 "$(printf "directory\twith\ttabs")" &&
1544 test_completion "git sparse-checkout add dir" <<-\EOF &&
1547 - directory\with\backslashes/
1545 directory with tabs/
1546 EOF
1550 - rm -rf "directory\with\backslashes" &&
1547 rm -rf "$(printf "directory\twith\ttabs")" &&
1548 git add . &&
1553 - git commit -m "Remove directory with backslashes and directory with tabs"
1549 + git commit -m "Remove directory with tabs"
1550 + )
1551 +'
1552 +
1553 +# use FUNNYNAMES to avoid running on Windows, and !CYGWIN for Cygwin, as neither permit backslashes in paths
1554 +test_expect_success FUNNYNAMES,!CYGWIN 'cone mode sparse-checkout completes directory names with backslashes' '
1555 + # reset sparse-checkout
1556 + git -C sparse-checkout sparse-checkout disable &&
1557 + (
1558 + cd sparse-checkout &&
1559 + mkdir "directory\with\backslashes" &&
1560 + >"directory\with\backslashes/randomfile" &&
1561 + git add . &&
1562 + git commit -m "Add directory with backslashes" &&
1563 + git sparse-checkout set --cone \
1564 + "directory\with\backslashes" &&
1565 + test_completion "git sparse-checkout add dir" <<-\EOF &&
1566 + directory\with\backslashes/
1567 + EOF
1568 + rm -rf "directory\with\backslashes" &&
1569 + git add . &&
1570 + git commit -m "Remove directory with backslashes"
1571 )
1572 '
1573