Skip to content

Commit

Permalink
Merge pull request #46 from self-five/tests
Browse files Browse the repository at this point in the history
Add more tests
  • Loading branch information
tianon authored Jan 25, 2025
2 parents 9d45ba2 + 8f072da commit 54a7847
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .test/config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

# https://github.com/docker-library/official-images/blob/618a85a87796c8bbea059011d94d888dc7554158/test/config.sh

imageTests+=(
[bash]='bash-optional-features'
)
49 changes: 49 additions & 0 deletions .test/tests/bash-optional-features/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/usr/bin/env bash
set -Eeuo pipefail

# there's a lot of commands we expect Bash to have, but that it might not due to compilation quirks
# see https://github.com/tianon/docker-bash/pull/45
# and https://www.gnu.org/software/bash/manual/html_node/Optional-Features.html#:~:text=unless%20the%20operating%20system%20does%20not%20provide%20the%20necessary%20support

image="$1"

args=( --rm --interactive )
if [ -t 0 ] && [ -t 1 ]; then
args+=( --tty )
fi

docker run "${args[@]}" "$image" -Eeuo pipefail -xc '
# --enable-array-variables 😏
cmds=(
# --enable-alias
alias unalias
# --enable-command-timing
time
# --enable-cond-command
"[["
# --enable-directory-stack
pushd popd dirs
# --enable-disabled-builtins
builtin enable
# --enable-help-builtin
help
# --enable-history
fc history
# --enable-job-control
bg fg jobs kill wait disown suspend
# --enable-progcomp
complete
# --enable-select
select
)
if [ "${BASH_VERSINFO:-0}" -ge 4 ]; then
# Bash 3.0 does not support arr+=( ... ) and balks at this syntax even in an optional block 😂
cmds=( "${cmds[@]}"
# --enable-coprocesses
coproc
)
fi
for cmd in "${cmds[@]}"; do
PATH= command -v "$cmd"
done
'

0 comments on commit 54a7847

Please sign in to comment.