That's how I'm already using it:
http://tahoe-lafs.org/trac/trialcoverage/browser/trialcoverage/trialcoverage.py?rev=30#L99
Actually that's not quite right. Here, updated for your new API and fixed:
http://tahoe-lafs.org/trac/trialcoverage/browser/trialcoverage/trialcoverage.py?rev=34#L89
Regards,
Zooko
Also, I'm thinking of another twist to this: usually, the way people
want to describe a pile of source code is in terms of the roots of
trees: either a package or a directory. To make this possible, I'd like
to add a --source=XYZ option that would be like --include, but would
include the entire tree rooted at XYZ, which is either a Python package
name or a directory. This I think will mesh well with people's
instincts about how to talk about code. The current arguments to the
reporting commands will be extended to work this way also.
--Ned.
Pseudo-code:
def is_file_interesting(fpath):
if SOURCE:
for src in SOURCE:
if file_in_source(fpath, src):
break
else:
# File wasn't in any of our sources.
return False
if INCLUDE:
for inc in INCLUDE:
if file_matches(fpath, inc):
break
else:
# File didn't match any include pattern.
return False
if OMIT:
for om in OMIT:
if file_matches(fpath, om):
return False
So, you can't extend the source list with includes, includes are
evaluated within the sources. And for reporting, the sources will
effectively also clip your morfs, since there won't be any measurement
of files outside of the sources specified.
Does this sounds reasonable? As I looked at what people really wanted
to do when controlling coverage.py's attention, it seemed to me that it
was most natural to talk about code as directories or packages, and
"source" gives that direct control.
--Ned.
I still don't see why I would want to use source when I already have
include and omit. I guess this is just because I always organize my
source code so that one or two inclusions or exclusions of a complete
subtree defines all the source files I care about. I.e., I never have
.py files sitting in my source tree that I don't want to have covered,
nor do I ever want to cover .py files that are not sitting in my
source tree.
Regards,
Zooko
--Ned.
Okay so it would obviate the need for line 246 of trialcoverage.py:
http://tahoe-lafs.org/trac/trialcoverage/browser/trialcoverage/trialcoverage.py?rev=36#L246
> think conceptually, talking
> about trees of source code rooted at directories or packages feels much more
> direct than providing a powerful but geeky feature like file patterns.
Sure, that's what I've wanted all along: just do coverage analysis of
the source code in this package.
Regards,
Zooko
--Ned.
--Ned.