test_practracker.sh 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/bin/sh
  2. umask 077
  3. TMPDIR=""
  4. clean () {
  5. if [ -n "$TMPDIR" ] && [ -d "$TMPDIR" ]; then
  6. rm -rf "$TMPDIR"
  7. fi
  8. }
  9. trap clean EXIT HUP INT TERM
  10. if test "${PRACTRACKER_DIR}" = "" ||
  11. test ! -e "${PRACTRACKER_DIR}/practracker.py" ; then
  12. PRACTRACKER_DIR=$(dirname "$0")
  13. fi
  14. TMPDIR="$(mktemp -d -t pracktracker.test.XXXXXX)"
  15. if test -z "${TMPDIR}" || test ! -d "${TMPDIR}" ; then
  16. echo >&2 "mktemp failed."
  17. exit 1;
  18. fi
  19. DATA="${PRACTRACKER_DIR}/testdata"
  20. run_practracker() {
  21. "${PYTHON:-python}" "${PRACTRACKER_DIR}/practracker.py" \
  22. --max-include-count=0 --max-file-size=0 --max-function-size=0 --terse \
  23. "${DATA}/" "$@";
  24. }
  25. echo "ex0:"
  26. run_practracker --exceptions "${DATA}/ex0.txt" > "${TMPDIR}/ex0-received.txt"
  27. if cmp "${TMPDIR}/ex0-received.txt" "${DATA}/ex0-expected.txt" ; then
  28. echo " OK"
  29. else
  30. exit 1
  31. fi
  32. echo "ex1:"
  33. run_practracker --exceptions "${DATA}/ex1.txt" > "${TMPDIR}/ex1-received.txt"
  34. if cmp "${TMPDIR}/ex1-received.txt" "${DATA}/ex1-expected.txt" ;then
  35. echo " OK"
  36. else
  37. exit 1
  38. fi