Permalink
Browse files

Add coverage

  • Loading branch information...
1 parent 0723355 commit a8ad6b95442385d36af2354adf2bbceb5c8d8c4a @frenchy64 frenchy64 committed Sep 4, 2013
Showing with 18 additions and 3 deletions.
  1. +1 −1 project.clj
  2. +17 −2 src/leiningen/typed.clj
View
@@ -1,3 +1,3 @@
-(defproject lein-typed "0.2.0"
+(defproject lein-typed "0.3.0-SNAPSHOT"
:description "Type checking with Typed Clojure"
:eval-in-leiningen true)
View
@@ -8,9 +8,13 @@
" lein typed check - type check all namespaces declared in project.clj,
via :core.typed {:check [...]}")
(println " lein typed check nsym+ - only type check namespaces nsyms")
+ (println
+" lein typed coverage - basic type coverage for all namespaces declared in project.clj,
+ via :core.typed {:check [...]}")
+ (println " lein typed coverage nsym+ - basic type coverage for namespaces nsyms")
(flush))
-(defn check-all [project & args]
+(defn check [project & args]
(let [nsyms (or (when args (map symbol args)) (-> project :core.typed :check))]
(eval-in-project project
`(if-let [nsyms# (seq '~nsyms)]
@@ -23,10 +27,21 @@
(flush)))
'(require '[clojure.core.typed]))))
+(defn coverage [project & args]
+ (let [nsyms (or (when args (map symbol args)) (-> project :core.typed :check))]
+ (eval-in-project project
+ `(if-let [nsyms# (seq '~nsyms)]
+ (if-let [var-coverage# (resolve 'clojure.core.typed/var-coverage)]
+ (var-coverage# nsyms#)
+ (println "Coverage only supported with core.typed 0.2.3+"))
+ (do (println "No namespaces provided in project.clj. Add namespaces in :core.typed {:check [...]}")
+ (flush)))
+ '(require '[clojure.core.typed]))))
(defn typed
"Type check a namespace"
[project & [mode & args]]
(case mode
- "check" (apply check-all project args)
+ "check" (apply check project args)
+ "coverage" (apply coverage project args)
(help)))

0 comments on commit a8ad6b9

Please sign in to comment.