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.
This commit is contained in:
Nick Mathewson 2019-07-17 14:02:17 +02:00
parent 4c09532996
commit 86d3d310f5
2 changed files with 11 additions and 1 deletions

View 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

View File

@ -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()