diff options
author | George Kadianakis <desnacked@riseup.net> | 2019-08-06 14:51:47 +0300 |
---|---|---|
committer | George Kadianakis <desnacked@riseup.net> | 2019-08-06 14:51:47 +0300 |
commit | d7afdb3b0fef4db30c9eb8cdad5890bfc241bb8d (patch) | |
tree | 3580fe81d8e383b1269c81cf582461923453b988 /scripts | |
parent | 4ee65a6f877e841739f037ad27d2d588ce4e0c51 (diff) | |
parent | 1440c2cb340f904cafb402474b538725abdeb04f (diff) | |
download | tor-d7afdb3b0fef4db30c9eb8cdad5890bfc241bb8d.tar.gz tor-d7afdb3b0fef4db30c9eb8cdad5890bfc241bb8d.zip |
Merge branch 'tor-github/pr/1195'
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/maint/practracker/practracker_tests.py | 11 | ||||
-rwxr-xr-x | scripts/maint/practracker/test_practracker.sh | 27 |
2 files changed, 25 insertions, 13 deletions
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" |