From 58e7f527178e31a9914ac9e0393f25c63a2c542c Mon Sep 17 00:00:00 2001 From: "Ethan P." Date: Fri, 21 Feb 2025 18:17:46 -0800 Subject: [PATCH] test: Add more robust tests for shell detection --- test/suite/batpipe.sh | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/test/suite/batpipe.sh b/test/suite/batpipe.sh index 4a4776c..d942b41 100644 --- a/test/suite/batpipe.sh +++ b/test/suite/batpipe.sh @@ -12,9 +12,18 @@ test:detected_bash_shell() { test:detected_fish_shell() { 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." + + # Note: We don't use bash's `-c` option when testing with a fake fish shell. + # Bash `-c` will automatically exec() into the last process, which loses the + # argv0 we intentionally named after a different shell. + + # Test detection via `*sh -l` parent process. + output="$(printf "%q" "$(batpipe_path)" | fish -l)" + grep '^set -x' <<< "$output" >/dev/null || fail 'Detected wrong shell when checking parent process args.' + + # Test detection via hypen-prefixed parent process. + output="$(printf "%q" "$(batpipe_path)" | SHIM_ARGV0='-fish' fish)" + grep '^set -x' <<< "$output" >/dev/null || fail 'Detected wrong shell when checking parent process.' } test:viewer_gzip() {