diff options
-rw-r--r-- | Makefile.am | 19 | ||||
-rw-r--r-- | changes/ticket31304 | 3 | ||||
-rw-r--r-- | changes/ticket31311 | 3 | ||||
-rwxr-xr-x | scripts/maint/practracker/practracker_tests.py | 11 | ||||
-rwxr-xr-x | scripts/maint/practracker/test_practracker.sh | 27 | ||||
-rw-r--r-- | src/test/include.am | 6 |
6 files changed, 52 insertions, 17 deletions
diff --git a/Makefile.am b/Makefile.am index 7ada42f9d0..bb5dee52e9 100644 --- a/Makefile.am +++ b/Makefile.am @@ -167,9 +167,22 @@ EXTRA_DIST+= \ README \ ReleaseNotes \ scripts/maint/checkIncludes.py \ - scripts/maint/checkSpace.pl \ - scripts/maint/practracker - + scripts/maint/checkSpace.pl \ + scripts/maint/practracker/exceptions.txt \ + scripts/maint/practracker/metrics.py \ + scripts/maint/practracker/practracker.py \ + scripts/maint/practracker/practracker_tests.py \ + scripts/maint/practracker/problem.py \ + scripts/maint/practracker/testdata/a.c \ + scripts/maint/practracker/testdata/b.c \ + scripts/maint/practracker/testdata/ex0-expected.txt \ + scripts/maint/practracker/testdata/ex0.txt \ + scripts/maint/practracker/testdata/ex1-expected.txt \ + scripts/maint/practracker/testdata/ex1.txt \ + scripts/maint/practracker/testdata/ex.txt \ + scripts/maint/practracker/testdata/not_c_file \ + scripts/maint/practracker/test_practracker.sh \ + scripts/maint/practracker/util.py ## This tells etags how to find mockable function definitions. AM_ETAGSFLAGS=--regex='{c}/MOCK_IMPL([^,]+,\W*\([a-zA-Z0-9_]+\)\W*,/\1/s' diff --git a/changes/ticket31304 b/changes/ticket31304 new file mode 100644 index 0000000000..ca60148b0c --- /dev/null +++ b/changes/ticket31304 @@ -0,0 +1,3 @@ + o Minor features (tests): + - The practracker tests are now run as part of the Tor test suite. + Closes ticket 31304. diff --git a/changes/ticket31311 b/changes/ticket31311 new file mode 100644 index 0000000000..88dfb85736 --- /dev/null +++ b/changes/ticket31311 @@ -0,0 +1,3 @@ + o Minor bugfixes (distribution): + - Do not ship any temporary files found in the scripts/maint/practracker + directory. Fixes bug 31311; bugfix on 0.4.1.1-alpha. diff --git a/scripts/maint/practracker/practracker_tests.py b/scripts/maint/practracker/practracker_tests.py index 865f68d186..45719d6cb7 100755 --- a/scripts/maint/practracker/practracker_tests.py +++ b/scripts/maint/practracker/practracker_tests.py @@ -4,7 +4,12 @@ import unittest -import StringIO +try: + # python 2 names the module this way... + from StringIO import StringIO +except ImportError: + # python 3 names the module this way. + from io import StringIO import metrics @@ -38,7 +43,7 @@ fun,( class TestFunctionLength(unittest.TestCase): def test_function_length(self): - funcs = StringIO.StringIO(function_file) + funcs = StringIO(function_file) # All functions should have length 2 for name, lines in metrics.get_function_lines(funcs): self.assertEqual(name, "fun") @@ -50,7 +55,7 @@ class TestFunctionLength(unittest.TestCase): class TestIncludeCount(unittest.TestCase): def test_include_count(self): - f = StringIO.StringIO(""" + f = StringIO(""" # include <abc.h> # include "def.h" #include "ghi.h" diff --git a/scripts/maint/practracker/test_practracker.sh b/scripts/maint/practracker/test_practracker.sh index 590525660b..c878ca5580 100755 --- a/scripts/maint/practracker/test_practracker.sh +++ b/scripts/maint/practracker/test_practracker.sh @@ -28,23 +28,30 @@ run_practracker() { --max-include-count=0 --max-file-size=0 --max-function-size=0 --terse \ "${DATA}/" "$@"; } +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 +} + +echo "unit tests:" + +"${PYTHON:-python}" "${PRACTRACKER_DIR}/practracker_tests.py" || exit 1 echo "ex0:" run_practracker --exceptions "${DATA}/ex0.txt" > "${TMPDIR}/ex0-received.txt" -if cmp "${TMPDIR}/ex0-received.txt" "${DATA}/ex0-expected.txt" ; then - echo " OK" -else - exit 1 -fi +compare "${TMPDIR}/ex0-received.txt" "${DATA}/ex0-expected.txt" echo "ex1:" run_practracker --exceptions "${DATA}/ex1.txt" > "${TMPDIR}/ex1-received.txt" -if cmp "${TMPDIR}/ex1-received.txt" "${DATA}/ex1-expected.txt" ;then - echo " OK" -else - exit 1 -fi +compare "${TMPDIR}/ex1-received.txt" "${DATA}/ex1-expected.txt" diff --git a/src/test/include.am b/src/test/include.am index 0ec4d96ad4..7cd1ecae36 100644 --- a/src/test/include.am +++ b/src/test/include.am @@ -31,7 +31,11 @@ TESTSCRIPTS += \ endif if USEPYTHON -TESTSCRIPTS += src/test/test_ntor.sh src/test/test_hs_ntor.sh src/test/test_bt.sh +TESTSCRIPTS += \ + src/test/test_ntor.sh \ + src/test/test_hs_ntor.sh \ + src/test/test_bt.sh \ + scripts/maint/practracker/test_practracker.sh if COVERAGE_ENABLED # ... |