From 1f0e2574cca6afd34c682df0b1f83d7882975b9f Mon Sep 17 00:00:00 2001
From: Brian Warner <warner@lothar.com>
Date: Thu, 25 Nov 2010 12:38:32 -0800
Subject: [PATCH] update Makefile and coverage2el.py to coverage-3.4

It might still work with coverage-3.3 if you run with COVERAGE_OMIT=""
---
 Makefile                         |  2 ++
 misc/coding_tools/coverage2el.py | 14 ++++++++++++--
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index 316c7d1f..a5c11adc 100644
--- a/Makefile
+++ b/Makefile
@@ -132,6 +132,8 @@ quicktest-coverage:
 	$(PYTHON) misc/build_helpers/run-with-pythonpath.py trial --reporter=bwverbose-coverage $(TEST)
 # on my laptop, "quicktest" takes 239s, "quicktest-coverage" takes 304s
 
+# --include appeared in coverage-3.4
+COVERAGE_OMIT=--include '$(CURDIR)/src/allmydata/*' --omit '$(CURDIR)/src/allmydata/test/*'
 coverage-output:
 	rm -rf coverage-html
 	coverage html -i -d coverage-html $(COVERAGE_OMIT)
diff --git a/misc/coding_tools/coverage2el.py b/misc/coding_tools/coverage2el.py
index 7d03a273..f2b7ee4b 100644
--- a/misc/coding_tools/coverage2el.py
+++ b/misc/coding_tools/coverage2el.py
@@ -1,10 +1,20 @@
 
+import os.path
 from coverage import coverage, summary, misc
 
 class ElispReporter(summary.SummaryReporter):
     def report(self):
-        self.find_code_units(None, ["/System", "/Library", "/usr/lib",
-                                    "support/lib", "src/allmydata/test"])
+        try:
+            # coverage-3.4 has both omit= and include= . include= is applied
+            # first, then omit= removes items from what's left. These are
+            # tested with fnmatch, against fully-qualified filenames.
+            self.find_code_units(None,
+                                 omit=[os.path.abspath("src/allmydata/test/*")],
+                                 include=[os.path.abspath("src/allmydata/*")])
+        except TypeError:
+            # coverage-3.3 only had omit=
+            self.find_code_units(None, ["/System", "/Library", "/usr/lib",
+                                        "support/lib", "src/allmydata/test"])
 
         out = open(".coverage.el", "w")
         out.write("""
-- 
2.45.2