mirror of
https://github.com/eth-p/bat-extras.git
synced 2025-06-20 11:47:43 +02:00
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.
This commit is contained in:
parent
a0d3a9bd63
commit
86fd93e47e
@ -1,14 +1,4 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# Find the real fish.
|
# Run bash, but with executable name as `fish`.
|
||||||
HERE="$(cd "$(dirname "$0")" && pwd)"
|
exec -a "${SHIM_ARGV0:-fish}" bash "$@"
|
||||||
while read -d ':' -r dir; do
|
exit $?
|
||||||
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
|
|
||||||
|
@ -11,9 +11,7 @@ test:detected_bash_shell() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
test:detected_fish_shell() {
|
test:detected_fish_shell() {
|
||||||
description "Test it can detect a bash shell."
|
description "Test it can detect a fish 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.
|
|
||||||
|
|
||||||
output="$(SHELL="fish" fish --login -c "$(batpipe_path)")"
|
output="$(SHELL="fish" fish --login -c "$(batpipe_path)")"
|
||||||
grep '^set -x' <<< "$output" >/dev/null || fail "Detected the wrong shell for fish."
|
grep '^set -x' <<< "$output" >/dev/null || fail "Detected the wrong shell for fish."
|
||||||
|
Loading…
x
Reference in New Issue
Block a user