Skip to content

Commit

Permalink
[refactor] More simplification of test harnesses.
Browse files Browse the repository at this point in the history
Hook them up to soil more consistently.
  • Loading branch information
Andy C committed Feb 16, 2022
1 parent 607294b commit 3fff71c
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 75 deletions.
21 changes: 3 additions & 18 deletions benchmarks/time-test.sh
Expand Up @@ -214,7 +214,7 @@ test-print-header() {
--print-header --rusage --stdout DUMMY --tsv --field a --field b
assert $? -eq 0

set -x
#set -x
head _tmp/time-test-1
}

Expand Down Expand Up @@ -253,23 +253,8 @@ test-time-helper() {
assert $? -eq 2
}


all-passing() {
test-usage
test-csv
test-tsv
test-append
# Spews some errors
test-bad-tsv-chars
test-stdout
test-rusage
test-maxrss
test-print-header

test-time-helper

echo
echo "All tests in $0 passed."
soil-run() {
run-test-funcs
}

"$@"
35 changes: 18 additions & 17 deletions soil/worker.sh
Expand Up @@ -102,24 +102,24 @@ dev-minimal-tasks() {

# (task_name, script, action, result_html)
cat <<EOF
dump-user-host soil/worker.sh dump-user-host -
build-minimal build/dev.sh minimal -
repo-overview metrics/source-code.sh overview -
lint test/lint.sh soil-run -
typecheck-slice types/oil-slice.sh soil-run -
typecheck-other types/run.sh soil-run -
unit test/unit.sh soil-run -
stateful test/stateful.sh soil-run _tmp/stateful/index.html
arena test/arena.sh all-passing -
dump-user-host soil/worker.sh dump-user-host -
build-minimal build/dev.sh minimal -
repo-overview metrics/source-code.sh overview -
lint test/lint.sh soil-run -
typecheck-slice types/oil-slice.sh soil-run -
typecheck-other types/run.sh soil-run -
unit test/unit.sh soil-run -
stateful test/stateful.sh soil-run _tmp/stateful/index.html
arena test/arena.sh soil-run -
parse-errors test/parse-errors.sh soil-run-py -
runtime-errors test/runtime-errors.sh run-all-with-osh -
oil-runtime-errors test/oil-runtime-errors.sh run-all-with-osh -
oil-spec test/spec.sh oil-all-serial _tmp/spec/oil-language/oil.html
tea-spec test/spec.sh tea-all-serial _tmp/spec/tea-language/tea.html
oil-large oil_lang/run.sh soil-run -
tea-large tea/run.sh soil-run -
link-busybox-ash test/spec.sh link-busybox-ash -
osh-minimal test/spec.sh osh-minimal _tmp/spec/survey/osh-minimal.html
oil-spec test/spec.sh oil-all-serial _tmp/spec/oil-language/oil.html
tea-spec test/spec.sh tea-all-serial _tmp/spec/tea-language/tea.html
oil-large oil_lang/run.sh soil-run -
tea-large tea/run.sh soil-run -
link-busybox-ash test/spec.sh link-busybox-ash -
osh-minimal test/spec.sh osh-minimal _tmp/spec/survey/osh-minimal.html
EOF
}

Expand Down Expand Up @@ -203,8 +203,9 @@ all-markdown build/doc.sh all-markdown -
syscall-by-code test/syscall.sh by-code _tmp/syscall/by-code.txt
syscall-by-input test/syscall.sh by-input _tmp/syscall/by-input.txt
osh-spec test/spec.sh soil-run-osh _tmp/spec/survey/osh.html
gold test/gold.sh all-passing -
osh-usage test/osh-usage.sh all-passing -
gold test/gold.sh soil-run -
osh-usage test/osh-usage.sh soil-run -
oshc-deps test/oshc-deps.sh soil-run -
make-tarball devtools/release.sh quick-oil-tarball _release/oil.tar
test-tarball build/test.sh oil-tar -
EOF
Expand Down
8 changes: 4 additions & 4 deletions test/arena.sh
Expand Up @@ -49,12 +49,12 @@ FAIL-test-wild() {
cat $MANIFEST | xargs -n 2 -- $0 _compare-wild
}

all-passing() {
test-func-manifest | xargs --verbose -- $0 run-all
run-for-release() {
run-other-suite-for-release arena run-test-funcs
}

run-for-release() {
run-other-suite-for-release arena all-passing
soil-run() {
run-test-funcs
}

"$@"
16 changes: 7 additions & 9 deletions test/common.sh
Expand Up @@ -64,10 +64,13 @@ run-task-with-status-test() {
test "$(wc -l < _tmp/status.txt)" = '1' || die "Expected only one line"
}

# TODO: We should run them like $0? To get more fine-grained reporting.
run-all() {
for t in "$@"; do
# fail calls 'exit 1'
test-func-manifest() {
### Shell funcs that start with 'test-' are cases that will pass or fail
compgen -A function | egrep '^test-'
}

run-test-funcs() {
test-func-manifest | while read t; do
$t
echo "OK $t"
done
Expand Down Expand Up @@ -129,11 +132,6 @@ html-head() {
PYTHONPATH=. doctools/html_head.py "$@"
}

test-func-manifest() {
### Shell funcs that start with 'test-' are cases that will pass or fail
compgen -A function | egrep '^test-'
}

filename=$(basename $0)
if test "$filename" = 'common.sh'; then
"$@"
Expand Down
20 changes: 8 additions & 12 deletions test/gold.sh
Expand Up @@ -10,7 +10,7 @@ set -o pipefail
set -o errexit
shopt -s strict:all 2>/dev/null || true # dogfood for OSH

source test/common.sh # $OSH, run-all
source test/common.sh # $OSH, run-test-funcs

readonly GOLD_DIR='test/gold'

Expand Down Expand Up @@ -152,20 +152,16 @@ FAIL-test-ostype() {
}

# TODO:
# - Add --allowed-failures mechanism
# - and maybe a timeout
#
# Does it make sense to have some sort of TAP-like test protocol?
# - Probably not when it's one test cases per process
# - But spec/ and spec/stateful have multiple test cases per file

all-passing() {
test-func-manifest | xargs --verbose -- $0 run-all
}
# - Run the failing tests, and add an --allowed-failures mechanism
# - and a timeout for big-here-doc

# TODO: Turn it into a table?
run-for-release() {
run-other-suite-for-release gold all-passing
run-other-suite-for-release gold run-test-funcs
}

soil-run() {
run-test-funcs
}

"$@"
8 changes: 2 additions & 6 deletions test/opyc.sh
Expand Up @@ -105,12 +105,8 @@ FAIL-test-help() {
bin/opyc --help
}

all-passing() {
test-func-manifest | xargs --verbose -- $0 run-all
}

run-for-release() {
run-other-suite-for-release opyc all-passing
run-other-suite-for-release opyc run-test-funcs
}

soil-run() {
Expand All @@ -123,7 +119,7 @@ soil-run() {
# Has to come after the previous step
make _build/opy/py27.grammar.marshal

all-passing
run-test-funcs
}


Expand Down
8 changes: 4 additions & 4 deletions test/osh-usage.sh
Expand Up @@ -182,12 +182,12 @@ test-version() {
assert $? -eq 0
}

all-passing() {
test-func-manifest | xargs --verbose -- $0 run-all
run-for-release() {
run-other-suite-for-release osh-usage run-test-funcs
}

run-for-release() {
run-other-suite-for-release osh-usage all-passing
soil-run() {
run-test-funcs
}

"$@"
8 changes: 7 additions & 1 deletion test/osh2oil.sh
Expand Up @@ -1348,7 +1348,13 @@ list-all-tests() {
}
all-passing() {
run-all "${PASSING[@]}"
for t in "${PASSING[@]}"; do
$t
echo "OK $t"
done
echo
echo "All $0 tests passed."
}
run-for-release() {
Expand Down
8 changes: 4 additions & 4 deletions test/oshc-deps.sh
Expand Up @@ -89,12 +89,12 @@ grep
DEPS
}

all-passing() {
test-func-manifest | xargs --verbose -- $0 run-all
run-for-release() {
run-other-suite-for-release oshc-deps run-test-funcs
}

run-for-release() {
run-other-suite-for-release oshc-deps all-passing
soil-run() {
run-test-funcs
}

"$@"

0 comments on commit 3fff71c

Please sign in to comment.