Added func_coverage.py script to identify untested functions.

This commit is contained in:
Revar Desmera 2019-11-06 22:24:24 -08:00
parent 5cca83958f
commit aa7e1cf681
2 changed files with 42 additions and 1 deletions

41
scripts/func_coverage.py Executable file
View file

@ -0,0 +1,41 @@
#!/usr/bin/env python3
import os
funcs = {}
for filename in os.listdir("."):
if filename.endswith(".scad"):
filepath = os.path.join(".",filename)
with open(filepath, "r") as f:
for i,line in enumerate(f.readlines()):
if line.startswith("function "):
funcname = line[9:].strip().split("(")[0].strip()
if funcname.startswith("_"):
continue
if funcname in funcs:
print("WARNING!!! Function {} re-defined at {}:{}".format(funcname, filename, i));
print(" Previously defined at {}".format(funcs[funcname]));
else:
funcs[funcname] = filename + ":" + str(i)
covered = []
for filename in os.listdir("tests"):
if filename.startswith("test_") and filename.endswith(".scad"):
filepath = os.path.join("tests",filename)
with open(filepath, "r") as f:
for i,line in enumerate(f.readlines()):
if line.startswith("module "):
funcname = line[7:].strip().split("(")[0].strip().split("_",1)[1]
if funcname in funcs:
covered.append(funcname)
del funcs[funcname]
for funcname in sorted(covered):
print("COVERED: function {}".format(funcname))
for funcname in sorted(list(funcs.keys())):
print("NOT COVERED: function {} ({})".format(funcname, funcs[funcname]))
# vim: expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap

View file

@ -8,7 +8,7 @@
//////////////////////////////////////////////////////////////////////
BOSL_VERSION = [2,0,10];
BOSL_VERSION = [2,0,11];
// Section: BOSL Library Version Functions