2013-10-31 21:54:04 -07:00
|
|
|
#!/usr/bin/python
|
|
|
|
|
|
|
|
|
|
import glob
|
2013-12-04 07:46:23 -08:00
|
|
|
import itertools
|
2013-10-31 21:54:04 -07:00
|
|
|
import re
|
|
|
|
|
|
2013-11-05 07:57:18 -08:00
|
|
|
TODO_PATTERN = re.compile(r'\s*// TODO\(')
|
|
|
|
|
DOC_PATTERN = re.compile(r'\s*//')
|
2013-11-10 11:12:38 -08:00
|
|
|
EXPECT_PATTERN = re.compile(r'// expect')
|
2013-10-31 21:54:04 -07:00
|
|
|
|
|
|
|
|
num_files = 0
|
2013-11-05 07:57:18 -08:00
|
|
|
num_docs = 0
|
|
|
|
|
num_code = 0
|
|
|
|
|
num_empty = 0
|
2013-10-31 21:54:04 -07:00
|
|
|
num_todos = 0
|
2013-11-07 07:04:25 -08:00
|
|
|
num_semicolons = 0
|
2013-11-10 11:12:38 -08:00
|
|
|
num_test_files = 0
|
|
|
|
|
num_test_todos = 0
|
|
|
|
|
num_expects = 0
|
|
|
|
|
num_test_empty = 0
|
|
|
|
|
num_test = 0
|
2013-10-31 21:54:04 -07:00
|
|
|
|
2013-12-04 07:46:23 -08:00
|
|
|
files = itertools.chain(glob.iglob("src/*.[ch]"), glob.iglob("include/*.[ch]"))
|
|
|
|
|
for source_path in files:
|
2013-10-31 21:54:04 -07:00
|
|
|
num_files += 1
|
|
|
|
|
with open(source_path, "r") as input:
|
|
|
|
|
for line in input:
|
2013-11-07 07:04:25 -08:00
|
|
|
num_semicolons += line.count(';')
|
2013-11-05 07:57:18 -08:00
|
|
|
match = TODO_PATTERN.match(line)
|
2013-10-31 21:54:04 -07:00
|
|
|
if match:
|
|
|
|
|
num_todos += 1
|
2013-11-05 07:57:18 -08:00
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
match = DOC_PATTERN.match(line)
|
|
|
|
|
if match:
|
|
|
|
|
num_docs += 1
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
if (line.strip() == ""):
|
|
|
|
|
num_empty += 1
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
num_code += 1
|
2013-10-31 21:54:04 -07:00
|
|
|
|
2013-11-10 11:12:38 -08:00
|
|
|
for test_path in glob.iglob("test/*.wren"):
|
|
|
|
|
num_test_files += 1
|
|
|
|
|
with open(test_path, "r") as input:
|
|
|
|
|
for line in input:
|
|
|
|
|
if (line.strip() == ""):
|
|
|
|
|
num_test_empty += 1
|
|
|
|
|
else:
|
|
|
|
|
num_test += 1
|
|
|
|
|
|
|
|
|
|
match = TODO_PATTERN.match(line)
|
|
|
|
|
if match:
|
|
|
|
|
num_test_todos += 1
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
match = EXPECT_PATTERN.search(line)
|
|
|
|
|
if match:
|
|
|
|
|
num_expects += 1
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
print "source:"
|
|
|
|
|
print " files ", num_files
|
|
|
|
|
print " semicolons ", num_semicolons
|
|
|
|
|
print " TODOs ", num_todos
|
|
|
|
|
print " comment lines ", num_docs
|
|
|
|
|
print " code lines ", num_code
|
|
|
|
|
print " empty lines ", num_empty
|
|
|
|
|
print
|
|
|
|
|
print "test:"
|
|
|
|
|
print " files ", num_test_files
|
|
|
|
|
print " TODOs ", num_test_todos
|
|
|
|
|
print " expectations ", num_expects
|
|
|
|
|
print " non-empty lines", num_test
|
|
|
|
|
print " empty lines ", num_test_empty
|