mirror of
https://github.com/eth-p/bat-extras.git
synced 2025-06-20 03:37:41 +02:00
test: Add more robust tests for shell detection
This commit is contained in:
parent
86fd93e47e
commit
58e7f52717
@ -13,8 +13,17 @@ 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() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user