File tree Expand file tree Collapse file tree 1 file changed +19
-30
lines changed
src/spec-node/featuresCLI Expand file tree Collapse file tree 1 file changed +19
-30
lines changed Original file line number Diff line number Diff line change @@ -57,70 +57,59 @@ export interface LaunchResult {
5757
5858// dev-container-features-test-lib
5959export const testLibraryScript = `
60- #!/bin/bash
61- SCRIPT_FOLDER="$(cd "$(dirname $0)" && pwd)"
62- USERNAME=\${1:-root}
60+ #!/bin/sh
61+
62+ set -eu
6363
6464if [ -z $HOME ]; then
6565 HOME="/root"
6666fi
6767
68- FAILED=()
69-
70- echoStderr()
71- {
72- echo "$@" 1>&2
73- }
68+ FAILED=""
7469
7570check() {
7671 LABEL=$1
7772 shift
78- echo -e "\n"
79- echo -e "🔄 Testing '$LABEL'"
80- echo -e '\\033[37m'
73+ printf "\n🔄 Testing '%s'%s" "\${LABEL}" "$(tput setaf 7)"
8174 if "$@"; then
82- echo -e "\n"
83- echo "✅ Passed '$LABEL'!"
75+ printf "\n✅ Passed '%s'!" "\${LABEL}"
8476 return 0
8577 else
86- echo -e "\n"
87- echoStderr "❌ $LABEL check failed."
88- FAILED+=("$ LABEL")
78+ printf "\n"
79+ printf "❌ %s check failed." "\${LABEL}" >&2
80+ FAILED="\${FAILED}\n\${ LABEL}"
8981 return 1
9082 fi
9183}
9284
9385checkMultiple() {
9486 PASSED=0
9587 LABEL="$1"
96- echo -e "\n"
97- echo -e "🔄 Testing '$LABEL'."
88+ printf "\n🔄 Testing '%s'." "\${LABEL}"
9889 shift; MINIMUMPASSED=$1
9990 shift; EXPRESSION="$1"
10091 while [ "$EXPRESSION" != "" ]; do
101- if $EXPRESSION; then ((PASSED+= 1)); fi
92+ if $EXPRESSION; then PASSED=$ ((PASSED+1)); fi
10293 shift; EXPRESSION=$1
10394 done
10495 if [ $PASSED -ge $MINIMUMPASSED ]; then
105- echo -e "\n"
106- echo "✅ Passed!"
96+ printf "\n✅ Passed!"
10797 return 0
10898 else
109- echo -e "\n"
110- echoStderr "❌ '$LABEL ' check failed."
111- FAILED+=("$ LABEL")
99+ printf "\n"
100+ printf "❌ '%s ' check failed." "\${LABEL}" >&2
101+ FAILED="\${FAILED}\n\${ LABEL}"
112102 return 1
113103 fi
114104}
115105
116106reportResults() {
117- if [ \${# FAILED[@]} -ne 0 ]; then
118- echo -e "\n"
119- echoStderr -e "💥 Failed tests: \${FAILED[@]}"
107+ if [ " \${FAILED}" ]; then
108+ printf "\n"
109+ printf "💥 Failed tests: %s" " \${FAILED}" >&2
120110 exit 1
121111 else
122- echo -e "\n"
123- echo -e "Test Passed!"
112+ printf "\nTest Passed!"
124113 exit 0
125114 fi
126115}` ;
You can’t perform that action at this time.
0 commit comments