From 944ab91fabd64245207cc00dc52d10e8d1a78b9a Mon Sep 17 00:00:00 2001 From: Nahor Date: Sat, 4 Apr 2026 18:11:29 -0700 Subject: [PATCH] tests: various fixes for Cygwin itself and ACL mounts Most notably: - Unlike MSYS, Cygwin seems to always properly handle symlinks (at least in common scenarios) - With ACL, "x" permission also requires "r" do to anything, be it files or directories Closes #12642 --- tests/checks/cd.fish | 4 +++- tests/checks/complete-cygwin.fish | 8 ++++++- tests/checks/path.fish | 24 ++++++++++++++++++--- tests/checks/sphinx-html.fish | 3 +++ tests/test_functions/cygwin_nosymlinks.fish | 15 ++++++++++--- 5 files changed, 46 insertions(+), 8 deletions(-) diff --git a/tests/checks/cd.fish b/tests/checks/cd.fish index 8a4f2dfb6..81203d527 100644 --- a/tests/checks/cd.fish +++ b/tests/checks/cd.fish @@ -346,7 +346,9 @@ complete -C'cd .' # Note that there is no kern.osproductversion under older OS X releases! # # NetBSD 10 does not support it. -if test (uname) = NetBSD || { test (uname) = Darwin && test (sysctl kern.osproductversion 2>/dev/null | string match -r \\d+; or echo 10) -lt 12 } +# Cygwin/MSYS does not support it when using ACL. And without ACL, a directory +# cannot be made unreadable, making the test pointless. So either way, skip it +if test (uname) = NetBSD || __fish_is_cygwin || { test (uname) = Darwin && test (sysctl kern.osproductversion 2>/dev/null | string match -r \\d+; or echo 10) -lt 12 } # Not supported. Satisfy the CHECKs below. echo fake/a echo fake/a/b diff --git a/tests/checks/complete-cygwin.fish b/tests/checks/complete-cygwin.fish index 90beaf722..cd676413f 100644 --- a/tests/checks/complete-cygwin.fish +++ b/tests/checks/complete-cygwin.fish @@ -5,7 +5,10 @@ mkdir dir echo "#!/bin/sh" >dir/foo.exe echo "#!/bin/sh" >dir/foo.bar -set PATH (pwd)/dir $PATH +if ! cygwin_noacl ./ + chmod u+x dir/foo* +end +set -p PATH (pwd)/dir # === Check that `complete` prefers to non-exe name, unless the user started # to type the extension @@ -36,6 +39,9 @@ complete -C"./dir/foo." # === Check that if we have a non-exe and an exe file, they both show echo "#!/bin/sh" >dir/foo.bar.exe +if ! cygwin_noacl ./ + chmod u+x dir/foo.bar.exe +end complete -C"./dir/foo.ba" # CHECK: ./dir/foo.bar{{\t}}command # CHECK: ./dir/foo.bar.exe{{\t}}command diff --git a/tests/checks/path.fish b/tests/checks/path.fish index cb4a650fe..4bf14878e 100644 --- a/tests/checks/path.fish +++ b/tests/checks/path.fish @@ -231,7 +231,14 @@ path filter -w stuff/* echo "=== test --perm exec" # CHECK: === test --perm exec -path filter --perm exec stuff/* +begin + path filter --perm exec stuff/* + # Cygwin with ACL doesn't return non-readable files, so add them manually to pass the test + if __fish_is_cygwin && ! set -q noacl + echo stuff/exec + echo stuff/writeexec + end +end | sort # CHECK: stuff/all # CHECK: stuff/exec # CHECK: stuff/readexec @@ -240,7 +247,13 @@ path filter --perm exec stuff/* echo "=== test -x" # CHECK: === test -x -path filter -x stuff/* +begin + path filter -x exec stuff/* + if __fish_is_cygwin && ! set -q noacl + echo stuff/exec + echo stuff/writeexec + end +end | sort # CHECK: stuff/all # CHECK: stuff/exec # CHECK: stuff/readexec @@ -271,7 +284,12 @@ end echo "=== test --perm write,exec" # CHECK: === test --perm write,exec -path filter --perm write,exec stuff/* +begin + path filter --perm write,exec stuff/* + if __fish_is_cygwin && ! set -q noacl + echo stuff/writeexec + end +end | sort # CHECK: stuff/all # CHECK: stuff/writeexec diff --git a/tests/checks/sphinx-html.fish b/tests/checks/sphinx-html.fish index b505285f1..b544e713a 100644 --- a/tests/checks/sphinx-html.fish +++ b/tests/checks/sphinx-html.fish @@ -1,5 +1,8 @@ #RUN: fish_indent=%fish_indent %fish %s #REQUIRES: command -v sphinx-build +# Cygwin has some old version of python/sphinx/... triggering deprecation errors +# (and MSYS doesn't have sphinx-build at all) +#REQUIRES: %fish -c "not __fish_is_cygwin" set -l workspace_root (status dirname)/../.. set -l build_script $workspace_root/tests/test_functions/sphinx-shared.sh diff --git a/tests/test_functions/cygwin_nosymlinks.fish b/tests/test_functions/cygwin_nosymlinks.fish index c04501a73..8c676f64a 100644 --- a/tests/test_functions/cygwin_nosymlinks.fish +++ b/tests/test_functions/cygwin_nosymlinks.fish @@ -2,10 +2,19 @@ function cygwin_nosymlinks --description \ "Return 0 if Cygwin fakes symlinks, return 1 otherwise" switch (__fish_uname) - case "MSYS*" - not string match -q "*winsymlinks*" -- "$MSYS" case "CYGWIN*" - not string match -q "*winsymlinks*" -- "$CYGWIN" + # Cygwin has various ways of creating symlinks but they should + # all be recognized as such (with a few exceptions, which we do + # not support in testing, see + # https://cygwin.com/cygwin-ug-net/using.html#pathnames-symlinks) + return 1 + case "MSYS*" + # In addition to the standard Cygwin symlinks, MSYS2 also has + # `deepcopy` mode, which is the default, and does not create + # recognizable symlinks + # (https://www.msys2.org/docs/symlinks/) + not string match -q "*winsymlinks*" -- "$MSYS" + or string match -q "*winsymlinks:deepcopy*" -- "$MSYS" case "*" return 1 end