runtests 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #!/bin/bash
  2. # tfkit - Shellfu's movable test framework
  3. # See LICENSE file for copyright and license details.
  4. TF_VERSION="0.0.10"
  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. #
  18. # Location of own directory
  19. #
  20. TF_DIR=${TF_DIR:-$(dirname "$0")}
  21. #
  22. # Location of test suite
  23. #
  24. TF_SUITE="${TF_SUITE:-tests}"
  25. #
  26. # Artifact directory path
  27. #
  28. TF_ARTIFACTS="${TF_ARTIFACTS:-artifacts}"
  29. #
  30. # Artifact collection mode
  31. #
  32. # 'always' to always collect, 'never` to never collect and 'auto'
  33. # to collect only on failed tests.
  34. #
  35. TF_COLLECT="${TF_COLLECT:-auto}"
  36. while true; do case "$1" in
  37. -c|--collect) TF_COLLECT=always; shift ;;
  38. -C|--no-collect) TF_COLLECT=never; shift ;;
  39. -d|--debug) TF_DEBUG=true; shift ;;
  40. -p|--prefix) export PATH="$(readlink -f "$2")/bin:$PATH"
  41. shift 2 || usage ;;
  42. -s|--filter-subtest) TF_FILTER_SUBTEST="$2"; shift 2 || usage ;;
  43. -t|--filter-test) TF_FILTER_TEST="$2"; shift 2 || usage ;;
  44. -v|--verbose) TF_VERBOSE=true; shift ;;
  45. --version-semver) echo "$TF_VERSION"; exit 0 ;;
  46. --version) version ;;
  47. "") break ;;
  48. *) usage ;;
  49. esac done
  50. export LC_ALL
  51. export TF_DIR TF_SUITE TF_ARTIFACTS
  52. export TF_COLLECT TF_FILTER_SUBTEST TF_FILTER_TEST
  53. export TF_DEBUG TF_VERBOSE
  54. export TF_VERSION
  55. . "$TF_DIR/include/harness.sh" \
  56. || die "cannot import harness; is TF_DIR set properly?: $TF_DIR"
  57. time tf_run_tests