diff --git a/app/crawler/notea_test.sh b/app/crawler/notea_test.sh index 5074f58..1a3148e 100644 --- a/app/crawler/notea_test.sh +++ b/app/crawler/notea_test.sh @@ -1,21 +1,5 @@ #! /bin/bash -main() { - for t in $(grep ^test_* ./notea_test.sh | sed 's/(.*//'); do - each - echo run $t >&2 - if ! eval "$t"; then - echo failed $t >&2 - fi - done -} - -each() { - export CACHE=$(mktemp -d) - source ./notea.sh - source ./cache.sh -} - test_ids() { notea eval "$(cat <&2 + ret=$((ret+1)) + fi + done + if [ $ret != 0 ]; then + echo failed >&2 + fi + return $ret +} + +one_main() ( + echo testing $f >&2 + local f="$1" + local ret=0 + for t in $(grep ^test_ "$f" | sed 's/(.*//'); do + echo testing $f:$t >&2 + each + source "${f%_test.sh}.sh" + source "$f" + if ! eval "$t"; then + echo failed $f:$t >&2 + ret=$((ret+1)) + fi + done + return $ret +) + +each() { + export CACHE=$(mktemp -d) + source ./cache.sh +} + +if [ "$0" == "$BASH_SOURCE" ]; then + main "$@" +fi