From dc8a0ec178df9bb8a5f774670864cc084d12325c Mon Sep 17 00:00:00 2001
From: Jean-Paul Calderone <exarkun@twistedmatrix.com>
Date: Fri, 16 Aug 2019 12:19:41 -0400
Subject: [PATCH] Collect and expose coverage as part of the build

---
 zkapauthorizer.nix | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/zkapauthorizer.nix b/zkapauthorizer.nix
index 282bdc8..8265f89 100644
--- a/zkapauthorizer.nix
+++ b/zkapauthorizer.nix
@@ -8,6 +8,8 @@ buildPythonPackage rec {
   name = "${pname}-${version}";
   src = ./.;
 
+  outputs = [ "out" "doc" ];
+
   depsBuildBuild = [
     sphinx
     circleci-cli
@@ -30,7 +32,15 @@ buildPythonPackage rec {
   ];
 
   checkPhase = ''
-    ${pyflakes}/bin/pyflakes src/_zkapauthorizer
-    python -m coverage run --source _zkapauthorizer,twisted.plugins.zkapauthorizer --module twisted.trial _zkapauthorizer
+    runHook preCheck
+    "${pyflakes}/bin/pyflakes" src/_zkapauthorizer
+    python -m coverage run --branch --source _zkapauthorizer,twisted.plugins.zkapauthorizer --module twisted.trial _zkapauthorizer
+    runHook postCheck
+  '';
+
+  postCheck = ''
+    python -m coverage html
+    mkdir -p "$doc/share/doc/${name}"
+    cp -vr .coverage htmlcov "$doc/share/doc/${name}"
   '';
 }
-- 
GitLab