commit 86d3d310f529bc1e13ce1ca5013c674837c9856b Author: Nick Mathewson nickm@torproject.org Date: Wed Jul 17 14:02:17 2019 +0200
Practracker: allow tabs in include lines
This isn't actually something that Tor does, but it's cleaner to do it this way. Part of 29746. --- scripts/maint/practracker/metrics.py | 2 +- scripts/maint/practracker/practracker_tests.py | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/scripts/maint/practracker/metrics.py b/scripts/maint/practracker/metrics.py index b35029b51..82f1cd64e 100644 --- a/scripts/maint/practracker/metrics.py +++ b/scripts/maint/practracker/metrics.py @@ -16,7 +16,7 @@ def get_include_count(f): """Get number of #include statements in the file""" include_count = 0 for line in f: - if re.match(r' *# *include', line): + if re.match(r'\s*#\s*include', line): include_count += 1 return include_count
diff --git a/scripts/maint/practracker/practracker_tests.py b/scripts/maint/practracker/practracker_tests.py index f11c55a3b..865f68d18 100755 --- a/scripts/maint/practracker/practracker_tests.py +++ b/scripts/maint/practracker/practracker_tests.py @@ -48,5 +48,15 @@ class TestFunctionLength(unittest.TestCase): for name, lines in metrics.get_function_lines(funcs): self.assertEqual(lines, 4)
+class TestIncludeCount(unittest.TestCase): + def test_include_count(self): + f = StringIO.StringIO(""" + # include <abc.h> + # include "def.h" +#include "ghi.h" +\t#\t include "jkl.h" +""") + self.assertEqual(metrics.get_include_count(f),4) + if __name__ == '__main__': unittest.main()
tor-commits@lists.torproject.org