From 86fd93e47e80ad89f63aed859a9be76ad0e9ba4f Mon Sep 17 00:00:00 2001 From: "Ethan P." Date: Fri, 21 Feb 2025 18:12:48 -0800 Subject: [PATCH] test: Test shell detection with fake `fish` shell Rather than using a real fish shell for tests, we're faking it so package maintainers don't need to add multiple shells as build dependencies. --- test/shimexec/fish | 16 +++------------- test/suite/batpipe.sh | 4 +--- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/test/shimexec/fish b/test/shimexec/fish index cd5574c..3cd2b4d 100755 --- a/test/shimexec/fish +++ b/test/shimexec/fish @@ -1,14 +1,4 @@ #!/usr/bin/env bash -# Find the real fish. -HERE="$(cd "$(dirname "$0")" && pwd)" -while read -d ':' -r dir; do - if [[ "$dir" == "$HERE" || -z "$dir" ]]; then continue; fi - if [[ -f "${dir}/fish" ]]; then - TMPDIR='' "${dir}/fish" "$@" - exit $? - fi -done <<<"$PATH:" - -# Print error and exit. -echo "fish was not found on \$PATH" 1>&2 -exit 127 +# Run bash, but with executable name as `fish`. +exec -a "${SHIM_ARGV0:-fish}" bash "$@" +exit $? diff --git a/test/suite/batpipe.sh b/test/suite/batpipe.sh index 66c4c24..4a4776c 100644 --- a/test/suite/batpipe.sh +++ b/test/suite/batpipe.sh @@ -11,9 +11,7 @@ test:detected_bash_shell() { } test:detected_fish_shell() { - description "Test it can detect a bash shell." - command -v "fish" &>/dev/null || skip "Test requires fish shell." - fish -c 'exit 0' &>/dev/null || skip "Test requires fish shell." # This is in case it finds "fish" in shimexec dir. + description "Test it can detect a fish shell." output="$(SHELL="fish" fish --login -c "$(batpipe_path)")" grep '^set -x' <<< "$output" >/dev/null || fail "Detected the wrong shell for fish."