2019-07-30 18:07:40 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
umask 077
|
|
|
|
|
|
|
|
TMPDIR=""
|
|
|
|
clean () {
|
|
|
|
if [ -n "$TMPDIR" ] && [ -d "$TMPDIR" ]; then
|
|
|
|
rm -rf "$TMPDIR"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
trap clean EXIT HUP INT TERM
|
|
|
|
|
|
|
|
if test "${PRACTRACKER_DIR}" = "" ||
|
|
|
|
test ! -e "${PRACTRACKER_DIR}/practracker.py" ; then
|
|
|
|
PRACTRACKER_DIR=$(dirname "$0")
|
|
|
|
fi
|
|
|
|
|
|
|
|
TMPDIR="$(mktemp -d -t pracktracker.test.XXXXXX)"
|
|
|
|
if test -z "${TMPDIR}" || test ! -d "${TMPDIR}" ; then
|
|
|
|
echo >&2 "mktemp failed."
|
|
|
|
exit 1;
|
|
|
|
fi
|
|
|
|
|
|
|
|
DATA="${PRACTRACKER_DIR}/testdata"
|
|
|
|
|
|
|
|
run_practracker() {
|
|
|
|
"${PYTHON:-python}" "${PRACTRACKER_DIR}/practracker.py" \
|
2019-09-02 21:31:31 +02:00
|
|
|
--include-dir "" \
|
2019-07-30 18:07:40 +02:00
|
|
|
--max-include-count=0 --max-file-size=0 --max-function-size=0 --terse \
|
|
|
|
"${DATA}/" "$@";
|
|
|
|
}
|
2019-08-01 21:05:34 +02:00
|
|
|
compare() {
|
|
|
|
# we can't use cmp because we need to use -b for windows
|
|
|
|
diff -b -u "$@" > "${TMPDIR}/test-diff"
|
|
|
|
if test -z "$(cat "${TMPDIR}"/test-diff)"; then
|
|
|
|
echo "OK"
|
|
|
|
else
|
|
|
|
cat "${TMPDIR}/test-diff"
|
|
|
|
echo "FAILED"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
2019-07-30 18:07:40 +02:00
|
|
|
|
2019-08-01 20:01:43 +02:00
|
|
|
echo "unit tests:"
|
|
|
|
|
|
|
|
"${PYTHON:-python}" "${PRACTRACKER_DIR}/practracker_tests.py" || exit 1
|
|
|
|
|
2019-07-30 18:07:40 +02:00
|
|
|
echo "ex0:"
|
|
|
|
|
|
|
|
run_practracker --exceptions "${DATA}/ex0.txt" > "${TMPDIR}/ex0-received.txt"
|
|
|
|
|
2019-08-01 21:05:34 +02:00
|
|
|
compare "${TMPDIR}/ex0-received.txt" "${DATA}/ex0-expected.txt"
|
2019-07-30 18:07:40 +02:00
|
|
|
|
|
|
|
echo "ex1:"
|
|
|
|
|
|
|
|
run_practracker --exceptions "${DATA}/ex1.txt" > "${TMPDIR}/ex1-received.txt"
|
|
|
|
|
2019-08-01 21:05:34 +02:00
|
|
|
compare "${TMPDIR}/ex1-received.txt" "${DATA}/ex1-expected.txt"
|