Permalink
Browse files
Consolidate the definition of the 'all-passing' test function.
- Loading branch information...
Showing
with
50 additions
and
52 deletions.
-
+1
−1
spec/builtins.test.sh
-
+12
−0
test/common.sh
-
+1
−8
test/gold.sh
-
+1
−8
test/osh2oil.sh
-
+1
−9
test/oshc-deps.sh
-
+34
−26
test/smoke.sh
|
|
@@ -88,7 +88,7 @@ echo status=$? |
|
|
# OK bash stdout: status=2
|
|
|
# OK dash stdout: status=127
|
|
|
|
|
|
### Exit builtin
|
|
|
### Exit out of function
|
|
|
f() { exit 3; }
|
|
|
f
|
|
|
exit 4
|
|
|
|
|
|
@@ -54,6 +54,18 @@ run-task-with-status-test() { |
|
|
test "$(wc -l < _tmp/status.txt)" = '1' || die "Expected only one line"
|
|
|
}
|
|
|
|
|
|
# Each test file should define PASSING
|
|
|
run-all() {
|
|
|
for t in "$@"; do
|
|
|
# fail calls 'exit 1'
|
|
|
$t
|
|
|
echo "OK $t"
|
|
|
done
|
|
|
|
|
|
echo
|
|
|
echo "All $0 tests passed."
|
|
|
}
|
|
|
|
|
|
if test "$(basename $0)" = 'common.sh'; then
|
|
|
"$@"
|
|
|
fi
|
|
|
@@ -146,14 +146,7 @@ readonly -a PASSING=( |
|
|
)
|
|
|
|
|
|
all-passing() {
|
|
|
for t in "${PASSING[@]}"; do
|
|
|
# fail calls 'exit 1'
|
|
|
$t
|
|
|
echo "OK $t"
|
|
|
done
|
|
|
|
|
|
echo
|
|
|
echo "All gold tests passed."
|
|
|
run-all "${PASSING[@]}"
|
|
|
}
|
|
|
|
|
|
run-for-release() {
|
|
|
|
|
|
@@ -919,14 +919,7 @@ readonly -a PASSING=( |
|
|
)
|
|
|
|
|
|
all-passing() {
|
|
|
for t in "${PASSING[@]}"; do
|
|
|
# fail calls 'exit 1'
|
|
|
$t
|
|
|
echo "OK $t"
|
|
|
done
|
|
|
|
|
|
echo
|
|
|
echo "All osh2oil tests passed."
|
|
|
run-all "${PASSING[@]}"
|
|
|
}
|
|
|
|
|
|
run-for-release() {
|
|
|
|
|
|
@@ -93,15 +93,7 @@ readonly -a PASSING=( |
|
|
)
|
|
|
|
|
|
all-passing() {
|
|
|
for t in "${PASSING[@]}"; do
|
|
|
# fail calls 'exit 1'
|
|
|
$t
|
|
|
echo "OK $t"
|
|
|
done
|
|
|
|
|
|
echo
|
|
|
echo "All $0 tests passed."
|
|
|
run-all "${PASSING[@]}"
|
|
|
}
|
|
|
|
|
|
|
|
|
"$@"
|
|
|
@@ -9,7 +9,28 @@ set -o nounset |
|
|
set -o pipefail
|
|
|
set -o errexit
|
|
|
|
|
|
readonly OSH=bin/osh
|
|
|
source test/common.sh
|
|
|
|
|
|
assert() {
|
|
|
test "$@" || die "$@ failed"
|
|
|
}
|
|
|
|
|
|
ast() {
|
|
|
bin/osh -n -c 'echo hi'
|
|
|
bin/osh -n --ast-format text -c 'echo hi'
|
|
|
bin/osh -n --ast-format abbrev-html -c 'echo hi'
|
|
|
bin/osh -n --ast-format html -c 'echo hi'
|
|
|
|
|
|
# Not dumping to terminal
|
|
|
if bin/osh -n --ast-format oheap -c 'echo hi'; then
|
|
|
die "Should have failed"
|
|
|
fi
|
|
|
local ast_bin=_tmp/smoke-ast.bin
|
|
|
bin/osh -n --ast-format oheap -c 'echo hi' > $ast_bin
|
|
|
ls -l $ast_bin
|
|
|
hexdump -C $ast_bin
|
|
|
}
|
|
|
|
|
|
|
|
|
# Read from a file.
|
|
|
osh-file() {
|
|
|
@@ -81,31 +102,6 @@ osh-interactive() { |
|
|
echo 'exit' | $OSH -i
|
|
|
}
|
|
|
|
|
|
die() {
|
|
|
echo 1>&2 "$@"
|
|
|
exit 1
|
|
|
}
|
|
|
|
|
|
assert() {
|
|
|
test "$@" || die "$@ failed"
|
|
|
}
|
|
|
|
|
|
ast() {
|
|
|
bin/osh -n -c 'echo hi'
|
|
|
bin/osh -n --ast-format text -c 'echo hi'
|
|
|
bin/osh -n --ast-format abbrev-html -c 'echo hi'
|
|
|
bin/osh -n --ast-format html -c 'echo hi'
|
|
|
|
|
|
# Not dumping to terminal
|
|
|
if bin/osh -n --ast-format oheap -c 'echo hi'; then
|
|
|
die "Should have failed"
|
|
|
fi
|
|
|
local ast_bin=_tmp/smoke-ast.bin
|
|
|
bin/osh -n --ast-format oheap -c 'echo hi' > $ast_bin
|
|
|
ls -l $ast_bin
|
|
|
hexdump -C $ast_bin
|
|
|
}
|
|
|
|
|
|
help() {
|
|
|
set +o errexit
|
|
|
|
|
|
@@ -144,4 +140,16 @@ parse-errors() { |
|
|
#_error-case 'echo ${'
|
|
|
}
|
|
|
|
|
|
readonly -a PASSING=(
|
|
|
ast
|
|
|
osh-file
|
|
|
osh-stdin
|
|
|
osh-interactive
|
|
|
help
|
|
|
)
|
|
|
|
|
|
all-passing() {
|
|
|
run-all "${PASSING[@]}"
|
|
|
}
|
|
|
|
|
|
"$@"
|
0 comments on commit
c001d41