浏览代码

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.
Nick Mathewson 5 年之前
父节点
当前提交
86d3d310f5
共有 2 个文件被更改,包括 11 次插入1 次删除
  1. 1 1
      scripts/maint/practracker/metrics.py
  2. 10 0
      scripts/maint/practracker/practracker_tests.py

+ 1 - 1
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
 

+ 10 - 0
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()