3 # Fail this script if any subprocess fails unexpectedly.
7 unset TOR_DISABLE_PRACTRACKER
11 if [ -n "$TMPDIR" ] && [ -d "$TMPDIR" ]; then
15 trap clean EXIT HUP INT TERM
17 if test "${PRACTRACKER_DIR}" = "" ||
18 test ! -e "${PRACTRACKER_DIR}/practracker.py" ; then
19 PRACTRACKER_DIR
=$
(dirname "$0")
22 # Change to the tor directory, and canonicalise PRACTRACKER_DIR,
23 # so paths in practracker output are consistent, even in out-of-tree builds
24 cd "${PRACTRACKER_DIR}"/..
/..
/..
25 PRACTRACKER_DIR
="scripts/maint/practracker"
27 TMPDIR
="$(mktemp -d -t pracktracker.test.XXXXXX)"
28 if test -z "${TMPDIR}" ||
test ! -d "${TMPDIR}" ; then
29 echo >&2 "mktemp failed."
33 DATA
="${PRACTRACKER_DIR}/testdata"
36 "${PYTHON:-python}" "${PRACTRACKER_DIR}/practracker.py" \
39 --max-function-size=0 \
41 --max-h-include-count=0 \
42 --max-include-count=0 \
44 "${DATA}/" "$@" ||
echo "practracker exit status: $?"
48 # we can't use cmp because we need to use -b for windows
49 diff -b -u "$@" > "${TMPDIR}/test-diff" || true
50 if test -z "$(cat "${TMPDIR}"/test-diff)"; then
53 cat "${TMPDIR}/test-diff"
61 "${PYTHON:-python}" "${PRACTRACKER_DIR}/practracker_tests.py"
65 run_practracker
--exceptions "${DATA}/ex0.txt" \
66 > "${TMPDIR}/ex0-received.txt" 2>&1
68 compare
"${TMPDIR}/ex0-received.txt" \
69 "${DATA}/ex0-expected.txt"
73 run_practracker
--exceptions "${DATA}/ex1.txt" \
74 > "${TMPDIR}/ex1-received.txt" 2>&1
76 compare
"${TMPDIR}/ex1-received.txt" \
77 "${DATA}/ex1-expected.txt"
81 run_practracker
--exceptions "${DATA}/ex1.txt" --list-overbroad \
82 > "${TMPDIR}/ex1-overbroad-received.txt" 2>&1
84 compare
"${TMPDIR}/ex1-overbroad-received.txt" \
85 "${DATA}/ex1-overbroad-expected.txt"
89 cp "${DATA}/ex1.txt" "${TMPDIR}/ex1-copy.txt"
90 run_practracker
--exceptions "${TMPDIR}/ex1-copy.txt" --regen >/dev
/null
2>&1
91 compare
"${TMPDIR}/ex1-copy.txt" "${DATA}/ex1-regen-expected.txt"
93 echo "ex1.regen_overbroad:"
95 cp "${DATA}/ex1.txt" "${TMPDIR}/ex1-copy.txt"
96 run_practracker
--exceptions "${TMPDIR}/ex1-copy.txt" --regen-overbroad >/dev
/null
2>&1
97 compare
"${TMPDIR}/ex1-copy.txt" "${DATA}/ex1-regen-overbroad-expected.txt"