boot-check to 0.1.1 + fixing what it caught

This commit is contained in:
anatoly 2016-01-04 12:22:52 -05:00
parent 0bb137d53f
commit d2b14d0cb5
3 changed files with 13 additions and 12 deletions

View file

@ -25,7 +25,7 @@
[adzerk/bootlaces "0.1.13" :scope "test"] [adzerk/bootlaces "0.1.13" :scope "test"]
[adzerk/boot-logservice "1.0.1" :scope "test"] [adzerk/boot-logservice "1.0.1" :scope "test"]
[adzerk/boot-test "1.0.6" :scope "test"] [adzerk/boot-test "1.0.6" :scope "test"]
[tolitius/boot-check "0.1.0-SNAPSHOT" :scope "test"] [tolitius/boot-check "0.1.1" :scope "test"]
;; boot cljs ;; boot cljs
[adzerk/boot-cljs "1.7.170-3" :scope "test"] [adzerk/boot-cljs "1.7.170-3" :scope "test"]
@ -96,6 +96,7 @@
(set-env! :source-paths #(conj % "dev/clj" "dev/cljs" "test/core" "test/clj" "test/cljs")) (set-env! :source-paths #(conj % "dev/clj" "dev/cljs" "test/core" "test/clj" "test/cljs"))
;; (load-data-readers!) ;; (load-data-readers!)
(comp (comp
(check/with-bikeshed)
(check/with-eastwood) (check/with-eastwood)
;; (check/with-yagni) ;; yagni does not yet support (throws on) "cljc" ;; (check/with-yagni) ;; yagni does not yet support (throws on) "cljc"
(check/with-kibit))) (check/with-kibit)))

View file

@ -19,16 +19,16 @@
(or (:order (@meta-state state)) (or (:order (@meta-state state))
(swap! state-seq inc))) (swap! state-seq inc)))
(deftype NotStartedState [state] (deftype NotStartedState [state]
Object Object
(toString [this] (toString [this]
(str "'" state "' is not started (to start all the states call mount/start)"))) (str "'" state "' is not started (to start all the states call mount/start)")))
;;TODO validate the whole lifecycle ;;TODO validate the whole lifecycle
(defn- validate [{:keys [start stop suspend resume] :as lifecycle}] (defn- validate [{:keys [start stop suspend resume] :as lifecycle}]
(cond (cond
(not start) (throw-runtime "can't start a stateful thing without a start function. (i.e. missing :start fn)") (not start) (throw-runtime "can't start a stateful thing without a start function. (i.e. missing :start fn)")
(and suspend (and suspend
(not resume)) (throw-runtime "suspendable state should have a resume function (i.e. missing :resume fn)"))) (not resume)) (throw-runtime "suspendable state should have a resume function (i.e. missing :resume fn)")))
(defn- with-ns [ns name] (defn- with-ns [ns name]
@ -98,7 +98,7 @@
(defn- down [state {:keys [stop status] :as current} done] (defn- down [state {:keys [stop status] :as current} done]
(when (some status #{:started :suspended}) (when (some status #{:started :suspended})
(when stop (when stop
(on-error (str "could not stop [" state "] due to") (on-error (str "could not stop [" state "] due to")
(record! state stop done))) (record! state stop done)))
(alter-state! current (NotStartedState. state)) ;; (!) if a state does not have :stop when _should_ this might leak (alter-state! current (NotStartedState. state)) ;; (!) if a state does not have :stop when _should_ this might leak
@ -113,7 +113,7 @@
(alter-state! current s))) (alter-state! current s)))
(update-meta! [state :status] #{:suspended}))) (update-meta! [state :status] #{:suspended})))
(defn- sigcont [state {:keys [resume status] :as current} done] (defn- sigcont [state {:keys [resume status] :as current} done]
(when (:suspended status) (when (:suspended status)
(let [s (on-error (str "could not resume [" state "] due to") (let [s (on-error (str "could not resume [" state "] due to")
(record! state resume done))] (record! state resume done))]
@ -198,7 +198,7 @@
(defn- bring [states fun order] (defn- bring [states fun order]
(let [done (atom [])] (let [done (atom [])]
(as-> states $ (as-> states $
(map var-to-str $) (map var-to-str $)
(select-keys @meta-state $) (select-keys @meta-state $)
(sort-by (comp :order val) order $) (sort-by (comp :order val) order $)
@ -206,13 +206,13 @@
@done)) @done))
(defn- merge-lifecycles (defn- merge-lifecycles
"merges with overriding _certain_ non existing keys. "merges with overriding _certain_ non existing keys.
i.e. :suspend is in a 'state', but not in a 'substitute': it should be overriden with nil i.e. :suspend is in a 'state', but not in a 'substitute': it should be overriden with nil
however other keys of 'state' (such as :ns,:name,:order) should not be overriden" however other keys of 'state' (such as :ns,:name,:order) should not be overriden"
([state sub] ([state sub]
(merge-lifecycles state nil sub)) (merge-lifecycles state nil sub))
([state origin {:keys [start stop suspend resume status]}] ([state origin {:keys [start stop suspend resume status]}]
(assoc state :origin origin (assoc state :origin origin
:status status :status status
:start start :stop stop :suspend suspend :resume resume))) :start start :stop stop :suspend suspend :resume resume)))

View file

@ -8,7 +8,7 @@
deps (->> (filter (comp any val) refers) deps (->> (filter (comp any val) refers)
(map (comp str second)) (map (comp str second))
set)] set)]
(assoc (dissoc state :ns) (assoc (dissoc state :ns)
:deps deps)))) :deps deps))))
#?(:clj #?(:clj