š
Is there a way to include speculative in all namespaces, from a leiningen project.clj
?
Iād like to add a CI job that does a test run with it enabled in all cases.
@marc-omorain if you (require '[speculative.instrument :refer [instrument]])
and call instrument, the speculative functions will be instrumented
you could do this as a test fixture, but there is no global test fixture in clojure.test š
aha, we use circleci.test
the way I worked around this is by depending on the alphabetical ordering of a test runner and call it in the first namespace š
ah, thatās good then
Iām still wondering if I should have made the PR with the snapshot at your rollbar library š
since there might be a breaking change in a snapshot
donāt worry about it - Iāll know how to fix it
also Iām still wondering if speculative.instrument
is a good name for this namespaceā¦ maybe speculative.load
is better. feedback welcome
providing a function that can be used as a clojure.test
fixture would be neat
what it does, it loads all relevant namespaces (speculative.core, speculative.string, speculative.set)
@marc-omorain that would be a nice one for speculative.test
which already has a bunch of test tooling
@marc-omorain no wait, the function is already speculative.instrument/instrument
, so Iām not sure what you need
(and coming to think of it, Iād like to keep speculative.test independent from loading the specs in speculative, that should be optional)
@marc-omorain whatās currently missing in rollbar is the call to the instrument function. I introduced this because @mfikes suggested that instrumenting as a side effect of loading the namespace might not be a good idea, I agreed
so, a fixture would look like:
(fn [test] (speculative.instrument/instrument) (test))
Yup, Iām thinking something like this:
(in-ns 'speculative.test)
(defn with-instrumentation [test]
(try
(speculative.instrument/instrument)
(test)
(finally
(speculative.instrument/unstrument))))
(in-ns 'my-tests
(clojure.test/use-fixtures :once speculative.test/with-instrumentation)
I think that function should live in speculative.instrument
because speculative.test
should not load the speculative specs, itās kind of an independent testing library for clojure.spec.test.
but thatās a detail
This would very much be a convenience to save me having to define the function in my code š
Iāll run speculative on the CircleCI monolith once I get it compiling with 1.10. itās currently on 1.8 and I have 2 failing tests with 1.10
Thatās 66,469 LOC
@marc-omorain how about this? https://github.com/slipset/speculative/pull/162/files
PR welcome as we say š
@borkdude doc string somewhat poor english š
You might be missing āusedā
yes
updated
Iām considering pulling speculative.test out as a separate lib
not sure about it yet
also not sure about the name speculative.instrument
, so if you have better suggestionsā¦
so that speculative-test
depends on speculative
?
no, the other way around
the name should not have speculative. itās a bunch of helpers around clojure.spec.test. nothing to do with speculative, apart from that we use it in our tests
cool
go for it!
maybe we should make a speculative organization where that lib can live?
(or some other name for the org)
could also do it under āborkdudeā, no problem
Hmm.
That hmm, was to myselfā¦ I might have found somethingā¦
Ha! a bug (maybe)
17:48 $ clj
Clojure 1.9.0
user=> (require '[clojure.spec.test.alpha :as st])
nil
user=> (require '[clojure.spec.alpha :as s])
nil
user=> (defmulti foo identity)
#'user/foo
user=> (s/fdef foo :args (s/cat :wat string?))
user/foo
user=> (defmethod foo :bar [lol])
#object[clojure.lang.MultiFn 0x4bff64c2 "clojure.lang.MultiFn@4bff64c2"]
user=> (st/instrument)
[user/foo]
user=> (defmethod foo :baz [lol])
ClassCastException clojure.spec.test.alpha$spec_checking_fn$fn__2943 cannot be cast to clojure.lang.MultiFn user/eval159 (NO_SOURCE_FILE:7)
user=>
would doing it under borkdude be a problem for you? since there is a macro in that ns that you started and I finished š
No, go ahead!
@alexmiller would the above be considered a bug?
Iāve never tried to spec a multimethod, but there is something around multimethods in spec.
Yeah, but I do believe that is to do checking on dispatch and such.
So you can have different specs on different dispatch values. But it might be that you have to use multi-specs on multi-methods.
Anyways, it stopped speculative cold on our project š
stopped speculative or your project?
stopped speculative on my project.
interesting. https://groups.google.com/forum/#!topic/clojure/BBWc3c40RDI
Hmmm.
itās known (to me at least) that you canāt currently spec multimethods
donāt remember if anyone actually logged it or not
if not, feel free to do so
and happy to fix as well, just havenāt looked at it
defmultis have defonce semantics so not sure if that hoses instrumentation or not