glom icon indicating copy to clipboard operation
glom copied to clipboard

coverage of gloms (track unevaluated child sub-specs)

Open kurtbrose opened this issue 6 years ago • 3 comments

as we are building larger and larger glom-specs it is important to make sure unit tests are covering all the nooks and crannies; for that reason add to Inspect or wherever is appropriate a coverage ability --

c = Coverage(SPEC)
result = glom(target, c)
print(c.coverage_report())

something akin to this (maybe Coverage is really Inspect)

two steps:

1- walk the whole spec and get all children specs and put them in a set

2- during execution, remove specs from the set as they are hit

afterwards, generate a report -- first idea for this is a pretty-printed version of the glom with children that were hit colored green and children that are missed colored red

kurtbrose avatar Jun 01 '18 22:06 kurtbrose

once this first phase is working, probably second phase is to set a global variable that means "hook all gloms in the system and accumulate a report"

-- similar to how coverage and cprofile work

in that case, each glom should keep track of the stack that allocated it so you can get a report like this

glom (module x, line 123) ..... coverage 90%
glom (module y, line 456) ..... coverage 70%

kurtbrose avatar Jun 01 '18 22:06 kurtbrose

Yeah I could see this being integrated into Inspect's functionality as a flag. Could also see it being a global thing that one would want to set once for all gloms during the test suite, too. The latter is probably the more common case, but there have definitely been times where I just wanted to know, in an interactive setting, which parts of the spec were being hit.

mahmoud avatar Jun 03 '18 23:06 mahmoud

this seems really dependent on having separate "compile" and "execute" walks of the spec

kurtbrose avatar Jun 04 '18 16:06 kurtbrose