mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2024-12-29 16:29:40 +00:00
Added func_coverage.py script to identify untested functions.
This commit is contained in:
parent
5cca83958f
commit
aa7e1cf681
2 changed files with 42 additions and 1 deletions
41
scripts/func_coverage.py
Executable file
41
scripts/func_coverage.py
Executable 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
|
|
@ -8,7 +8,7 @@
|
|||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
BOSL_VERSION = [2,0,10];
|
||||
BOSL_VERSION = [2,0,11];
|
||||
|
||||
|
||||
// Section: BOSL Library Version Functions
|
||||
|
|
Loading…
Reference in a new issue