2 from coverage import coverage, summary
4 class ElispReporter(summary.SummaryReporter):
6 self.find_code_units(None, ["/System", "/Library", "/usr/lib",
7 "support/lib", "src/allmydata/test"])
9 out = open(".coverage.el", "w")
11 ;; This is an elisp-readable form of the figleaf coverage data. It defines a
12 ;; single top-level hash table in which the key is an asolute pathname, and
13 ;; the value is a three-element list. The first element of this list is a
14 ;; list of line numbers that represent actual code statements. The second is
15 ;; a list of line numbers for lines which got used during the unit test. The
16 ;; third is a list of line numbers for code lines that were not covered
17 ;; (since 'code' and 'covered' start as sets, this last list is equal to
21 out.write("(let ((results (make-hash-table :test 'equal)))\n")
22 for cu in self.code_units:
24 (fn, executable, missing, mf) = self.coverage.analysis(cu)
25 code_linenumbers = executable
26 uncovered_code = missing
27 covered_linenumbers = sorted(set(executable) - set(missing))
28 out.write(" (puthash \"%s\" '((%s) (%s) (%s)) results)\n"
30 " ".join([str(ln) for ln in sorted(code_linenumbers)]),
31 " ".join([str(ln) for ln in sorted(covered_linenumbers)]),
32 " ".join([str(ln) for ln in sorted(uncovered_code)]),
34 out.write(" results)\n")
40 ElispReporter(c).report()
42 if __name__ == '__main__':