From 8f072da9478f542cd853ae77f841edce1510a54e Mon Sep 17 00:00:00 2001 From: Tianon Gravi Date: Fri, 24 Jan 2025 16:57:10 -0800 Subject: [PATCH] Add more tests Hopefully, this helps us catch more missing functionality. --- .test/config.sh | 7 ++++ .test/tests/bash-optional-features/run.sh | 49 +++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 .test/config.sh create mode 100755 .test/tests/bash-optional-features/run.sh diff --git a/.test/config.sh b/.test/config.sh new file mode 100644 index 0000000..525b28d --- /dev/null +++ b/.test/config.sh @@ -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' +) diff --git a/.test/tests/bash-optional-features/run.sh b/.test/tests/bash-optional-features/run.sh new file mode 100755 index 0000000..e9915b8 --- /dev/null +++ b/.test/tests/bash-optional-features/run.sh @@ -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 +'