mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-12-06 19:41:15 +01:00
Merge branch 'tor-github/pr/1195'
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user