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
This commit is contained in:
Nahor
2026-04-04 18:11:29 -07:00
committed by Johannes Altmanninger
parent 34535fcb61
commit 944ab91fab
5 changed files with 46 additions and 8 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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