mirror of
https://github.com/eth-p/bat-extras.git
synced 2025-03-06 09:21:12 +01:00
test: Add tests for nu shell detection
This commit is contained in:
parent
58e7f52717
commit
3860f0f148
7
test/shimexec/nu
Executable file
7
test/shimexec/nu
Executable file
@ -0,0 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
# Run bash, but with executable name as `nu`.
|
||||
#
|
||||
# Spawn the process in the background and wait on it to ensure we keep
|
||||
# the fake shell as a parent process.
|
||||
exec -a "${SHIM_ARGV0:-nu}" bash "$@"
|
||||
exit $?
|
@ -26,6 +26,22 @@ test:detected_fish_shell() {
|
||||
grep '^set -x' <<< "$output" >/dev/null || fail 'Detected wrong shell when checking parent process.'
|
||||
}
|
||||
|
||||
test:detected_nu_shell() {
|
||||
description "Test it can detect a nushell shell."
|
||||
|
||||
# Note: We don't use bash's `-c` option when testing with a fake nu 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)" | nu -l)"
|
||||
grep '^\$env' <<< "$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='-nu' nu -l)"
|
||||
grep '^\$env' <<< "$output" >/dev/null || fail 'Detected wrong shell when checking parent process.'
|
||||
}
|
||||
|
||||
test:viewer_gzip() {
|
||||
description "Test it can view .gz files."
|
||||
command -v "gunzip" &>/dev/null || skip "Test requires gunzip."
|
||||
|
Loading…
Reference in New Issue
Block a user