From 61af43d08ba2bad650d68e410a6d6edc1aa52f20 Mon Sep 17 00:00:00 2001
From: Ben Gamari <ben@smart-cactus.org>
Date: Mon, 4 Nov 2019 10:27:41 -0500
Subject: [PATCH] ci: Describe cause for failure

---
 ci/TestPatches.hs | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/ci/TestPatches.hs b/ci/TestPatches.hs
index b0890b2a..191f7c5d 100644
--- a/ci/TestPatches.hs
+++ b/ci/TestPatches.hs
@@ -122,11 +122,18 @@ testPatches cfg = do
 
   print $ resultSummary (configExpectedBrokenPkgs cfg) runResult
   BSL.writeFile "results.json" $ encode runResult
-  exitWith $ if anyFailures (configExpectedBrokenPkgs cfg) runResult then ExitFailure 1 else ExitSuccess
-
-anyFailures :: BrokenPackages -> RunResult -> Bool
-anyFailures broken (RunResult testedPatches) =
-    any failed testedPatches
+  case failedPatches (configExpectedBrokenPkgs cfg) runResult of
+    [] -> return ()
+    badPatches -> do
+      print $ "Failed due to unexpected failures in:" PP.<$$> PP.indent 2 (
+        vcat [ prettyPkgVer (patchedPackageName tp) (patchedPackageVersion tp)
+             | tp <- badPatches
+             ])
+      exitWith $ ExitFailure 1
+
+failedPatches :: BrokenPackages -> RunResult -> [TestedPatch]
+failedPatches broken (RunResult testedPatches) =
+    filter failed testedPatches
   where
     failed tp =
       patchFailed tp /= failureExpected broken (patchedPackageName tp)
-- 
GitLab