Closed jvah closed 9 years ago
A stacktrace without source code isn't that useful, I'm afraid. I can't tell much without knowing what line of code produced the exception.
See the test case in https://github.com/jvah/compojure-cloverage-crash.
If I run lein test
everything passes but lein cloverage
crashes, so I'm suspecting this might actually be a bug in how cloverage instruments the code. The following patch would seem to fix the issue, but it's up to you to decide if this is a compojure problem or a problem somewhere else:
From 2a5404c85a08cd026f697bd7ee71f558dad2aeca Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Juho=20V=C3=A4h=C3=A4-Herttua?=
<juho.vaha-herttua@futurice.com>
Date: Sun, 1 Mar 2015 09:07:23 +0200
Subject: [PATCH] Reintroduce syntax quote in clout route compilation.
---
src/compojure/core.clj | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/src/compojure/core.clj b/src/compojure/core.clj
index df35656..58b3d23 100644
--- a/src/compojure/core.clj
+++ b/src/compojure/core.clj
@@ -48,11 +48,11 @@
(defn- prepare-route [route]
(cond
(string? route)
- (clout/route-compile route)
+ `(clout/route-compile ~route)
(and (vector? route) (literal? route))
- (clout/route-compile
- (first route)
- (apply hash-map (rest route)))
+ `(clout/route-compile
+ ~(first route)
+ ~(apply hash-map (rest route)))
(vector? route)
`(clout/route-compile
~(first route)
@@ -201,11 +201,11 @@
(let [re-context {:__path-info #"|/.*"}]
(cond
(string? route)
- (clout/route-compile (str route ":__path-info") re-context)
+ `(clout/route-compile ~(str route ":__path-info") ~re-context)
(and (vector? route) (literal? route))
- (clout/route-compile
- (str (first route) ":__path-info")
- (merge (apply hash-map (rest route)) re-context))
+ `(clout/route-compile
+ (str ~(first route) ":__path-info")
+ ~(merge (apply hash-map (rest route)) re-context))
(vector? route)
`(clout/route-compile
(str ~(first route) ":__path-info")
--
1.9.3 (Apple Git-50)
Looks like this is an issue with Cloverage. I can't apply the patch you've provided, because it would revert the performance gains in Compojure 1.3.2.
Just wanted to get a confirmation that there should be nothing wrong with compojure here. Indeed after looking at the code more thoroughly it seems like a cloverage bug, there should be nothing wrong with running the route-compile at compile-time instead of runtime. The discussion is moved to cloverage repository issue, thank you for your help.
@weavejester I have a workaround that doesn't revert the performance gains in 1.3.2, if you're interested
Isn't this a cloverage bug?
It absolutely is, I'm just kind of worried that Cloverage might have been abandoned and I'm not quite sure what to do about that.
I haven't investigated this further yet, and I'm not sure if this is a problem with compojure, clout or cloverage, but I suspect this might be related to commit 639fffd3f8b77153644d0c9b87bca5af56be0cb0.