Permalink
Browse files

Consolidate the definition of the 'all-passing' test function.

  • Loading branch information...
Andy Chu
Andy Chu committed Mar 5, 2018
1 parent 2eaaa49 commit c001d411d58b478812af73ba27081e3d2745a853
Showing with 50 additions and 52 deletions.
  1. +1 −1 spec/builtins.test.sh
  2. +12 −0 test/common.sh
  3. +1 −8 test/gold.sh
  4. +1 −8 test/osh2oil.sh
  5. +1 −9 test/oshc-deps.sh
  6. +34 −26 test/smoke.sh
View
@@ -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
View
@@ -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
View
@@ -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() {
View
@@ -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() {
View
@@ -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[@]}"
}
"$@"
View
@@ -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

Please sign in to comment.