3 from coverage import coverage, summary, misc
5 class ElispReporter(summary.SummaryReporter):
8 # coverage-3.4 has both omit= and include= . include= is applied
9 # first, then omit= removes items from what's left. These are
10 # tested with fnmatch, against fully-qualified filenames.
11 self.find_code_units(None,
12 omit=[os.path.abspath("src/allmydata/test/*")],
13 include=[os.path.abspath("src/allmydata/*")])
15 # coverage-3.3 only had omit=
16 self.find_code_units(None, ["/System", "/Library", "/usr/lib",
17 "support/lib", "src/allmydata/test"])
19 out = open(".coverage.el", "w")
21 ;; This is an elisp-readable form of the coverage data. It defines a
22 ;; single top-level hash table in which the key is an asolute pathname, and
23 ;; the value is a three-element list. The first element of this list is a
24 ;; list of line numbers that represent actual code statements. The second is
25 ;; a list of line numbers for lines which got used during the unit test. The
26 ;; third is a list of line numbers for code lines that were not covered
27 ;; (since 'code' and 'covered' start as sets, this last list is equal to
31 out.write("(let ((results (make-hash-table :test 'equal)))\n")
32 for cu in self.code_units:
35 (fn, executable, missing, mf) = self.coverage.analysis(cu)
38 code_linenumbers = executable
39 uncovered_code = missing
40 covered_linenumbers = sorted(set(executable) - set(missing))
41 out.write(" (puthash \"%s\" '((%s) (%s) (%s)) results)\n"
43 " ".join([str(ln) for ln in sorted(code_linenumbers)]),
44 " ".join([str(ln) for ln in sorted(covered_linenumbers)]),
45 " ".join([str(ln) for ln in sorted(uncovered_code)]),
47 out.write(" results)\n")
53 ElispReporter(c).report()
55 if __name__ == '__main__':