]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Practracker: allow tabs in include lines
authorNick Mathewson <nickm@torproject.org>
Wed, 17 Jul 2019 12:02:17 +0000 (14:02 +0200)
committerNick Mathewson <nickm@torproject.org>
Wed, 17 Jul 2019 12:33:49 +0000 (14:33 +0200)
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
scripts/maint/practracker/practracker_tests.py

index b35029b51d0a10415f97eab95259431d048045c7..82f1cd64e94e2f497e0d44c2b94cf7e5dfb70195 100644 (file)
@@ -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
 
index f11c55a3bd8d8a8fcf77456ac9c2f25ae0fb1486..865f68d186405f28aaaa187f67b6f93720c7ba61 100755 (executable)
@@ -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()