Skip to content

Commit

Permalink
Ensure custom data readers are installed before running cloverage
Browse files Browse the repository at this point in the history
If any custom `data_readers.clj` file is provided either in sources or
through dependencies, currently `cloverage` ignores them and fails to read
the sources. I discovered the issue while working with `honeysql` and its
`#sql/call` literals.

This change ensures that all data readers from either source code or through
dependencies are properly communicated to `tools.reader` before unleashing
`cloverage`.
  • Loading branch information
skuro committed Sep 18, 2019
1 parent 589fa37 commit 8adb81c
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lein-cloverage/src/leiningen/cloverage.clj
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,16 @@
:test-ns-path (vec (:test-paths project)))]
(try
(eval/eval-in-project project
;; test-selectors needs unquoted here to be read as functions
`(cloverage.coverage/run-project (assoc '~opts :test-selectors ~test-selectors) ~@args)
`(let [decls# (-> []
(.getClass)
(.getClassLoader)
(.getResources "data_readers.clj")
enumeration-seq)
read-decls# (comp read-string slurp)
readers# (reduce merge {} (map read-decls# decls#))]
(binding [clojure.tools.reader/*data-readers* readers#]
;; test-selectors needs unquoted here to be read as functions
(cloverage.coverage/run-project (assoc '~opts :test-selectors ~test-selectors) ~@args)))
'(require 'cloverage.coverage))
(catch ExceptionInfo e
(main/exit (:exit-code (ex-data e) 1))))))

0 comments on commit 8adb81c

Please sign in to comment.