I keep wanting ::x/blah to expand to :current.namespace$x/blah
when there's no x alias. It'd open up "private namespaces" for spec use.
My use case is CLJS function arg specs. I have many fns in a ns. They expect different things from a :db key passed in as context. (re-frame handlers)
With the proposed change I could do things like this
(ns app.events (:require [clojure.spec.alpha :as s]))
(defn event1 [{:keys [db]}] ...)
(defn event2 [{:keys [db]}] ...)
(s/fdef event1 :args (s/cat :ctx (s/keys :req-un [::event1/db]))
(s/def ::event1/db (s/keys :req-un [::ddb])))
(s/fdef event2 :args (s/cat :ctx (s/keys :req-un [::event2/db]))
(s/def ::event2/db (s/keys :req-un [::form])))
Perhaps a macro would do the job so could add to replace keyword namespaces in a form
(rename-keyword-ns {*ns* :app.events$event1)
(s/fdef event1 (s/cat :ctx (s/keys :req-un [::db]))
(s/def ::db (s/keys :req-un [::ddb]))))
I suspect Spec 2 (a.k.a. what will eventually become just clojure.spec
🙂 ) will help you here because you can define a schema
will all the possible keys with their specs, all in one place -- and then you can select
the specific keys that are required for each individual handler.
Good point. If/when that lands it'll be an improvement.
I guess it'd look something like this...
(ns app.events (:require [clojure.spec2 :as s]))
(defn event1 [{:keys [db]}] ...)
(defn event2 [{:keys [db]}] ...)
(s/def ::ctx (s/schema {:db ::db}))
(s/def ::db (s/schema {:ddb ::ddb :form ::form}))
(s/fdef event1 :args (s/cat :ctx (s/select ::ctx [:db {:db [:ddb]}]))
(s/fdef event2 :args (s/cat :ctx (s/select ::ctx [:db {:db [:form]}]))
(Guessing at the unqualified key bits)
hi, does clojure.spec.test.alpha/check
run its test cases in sequence or in parallel ?
parallel via pmap
any way to tell it to do sequential? because my code under test is already parallel and is kicking off a bunch of promises
and the combination of the two is overwhelming the browser i'm afraid
not currently
ok, no worries. i can just limit the num-tests to a small amount for now