runtests 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #!/bin/bash
  2. # tfkit - Shellfu's movable test framework
  3. # See LICENSE file for copyright and license details.
  4. TF_VERSION="0.0.7"
  5. die() {
  6. echo "$@" && exit 9
  7. }
  8. usage() {
  9. echo "usage: $(basename "$0") [-c|-C] [-t tests_re] [-s subtest_re] [-p binpath] [-v] [-d]" >&2
  10. exit 2
  11. }
  12. version() {
  13. echo "TFKit (A trivial test kit) $TF_VERSION"
  14. exit 0
  15. }
  16. LC_ALL=C
  17. TF_DIR=${TF_DIR:-$(dirname "$0")}
  18. TF_SUITE="${TF_SUITE:-tests}"
  19. TF_ARTIFACTS="${TF_ARTIFACTS:-tfkit-artifacts}"
  20. TF_COLLECT="${TF_COLLECT:-auto}"
  21. while true; do case "$1" in
  22. -c|--collect) TF_COLLECT=always; shift ;;
  23. -C|--no-collect) TF_COLLECT=never; shift ;;
  24. -d|--debug) TF_DEBUG=true; shift ;;
  25. -p|--prefix) export PATH="$(readlink -f "$2")/bin:$PATH"
  26. shift 2 || usage ;;
  27. -s|--filter-subtest) TF_FILTER_SUBTEST="$2"; shift 2 || usage ;;
  28. -t|--filter-test) TF_FILTER_TEST="$2"; shift 2 || usage ;;
  29. -v|--verbose) TF_VERBOSE=true; shift ;;
  30. --version-semver) echo "$TF_VERSION"; exit 0 ;;
  31. --version) version ;;
  32. "") break ;;
  33. *) usage ;;
  34. esac done
  35. export LC_ALL
  36. export TF_DIR TF_SUITE TF_ARTIFACTS
  37. export TF_COLLECT TF_FILTER_SUBTEST TF_FILTER_TEST
  38. export TF_DEBUG TF_VERBOSE
  39. export TF_VERSION
  40. . "$TF_DIR/include/harness.sh" \
  41. || die "cannot import harness; is TF_DIR set properly?: $TF_DIR"
  42. time tf_run_tests