Fork me on GitHub
#clojure-spec
<
2016-08-21
>
lvh04:08:30

I’m trying to run stest/check for my entire coebase. It’s failing, but I can’t tell which thing is failing. All I get is:

ExceptionInfo Couldn't satisfy such-that predicate after 100 tries.  clojure.core/ex-info (core.clj:4725)

lvh04:08:13

It’s also not clear how I run this as part of clojure.test; puting it in the toplevel of a ns doesn’t work (`lein test` doesn’t pick it up) — wrapping it in a deftest makes lein test see that ns as a test ns, but doesn’t seem to run the actual checking (no exception)

lvh04:08:23

I only get the exception when manually evaling stest/check in a repl

seancorfield05:08:34

The generative testing behind check is / should be very different from your unit testing with clojure.test...

seancorfield05:08:52

... you should see something in the stacktrace explaining which identifies which spec's generator is unable to satisfy the predicate ...

seancorfield05:08:21

... as you're writing specs, you probably want to exercise them to make sure the generators are working as expected: that would help you find problems like the one above as you created each spec. Not sure whether that's helpful advice @lvh?

robert-stuttaford09:08:35

@lvh that particular error means that your generator can't produce something that matches your spec. i had this when i tried to s/and two s/keys together; it would generate for the first keys and never find anything that satisfied the second keys

lvh11:08:34

robert-stuttaford; yep; I know what the error means, but I have more than 1 spec

lvh11:08:07

@seancorfield: I’ve manually arrowed it down to a particular spec; and gen/sample + s/gen works fine

lvh11:08:35

@seancorfield: I’ve used test.check before: is the generative testing behind check different enough to not want to run it as part of lein test? Because that’s how I run my normal generative tests

lvh11:08:59

Also, judging by the Guide, just running all the tests for all the namespaces is an explicitly supported feature

lvh12:08:10

Is there any intention to make named? publicly available as a predicate such that s/and can maybe take advantage of if? Ideally also not-named 🙂

Alex Miller (Clojure team)13:08:41

That was added to core (named? really needs to be replaced in that code)

gfredericks14:08:33

oooh found another thing that clojure allowed before specs were added: (fn a/b [])

Alex Miller (Clojure team)14:08:32

Yeah, I fixed a bunch of those, nearly always in a sloppy macro

Alex Miller (Clojure team)14:08:11

algo.monads is actually broken on alpha11 due to a similar problem but with defn

seancorfield17:08:03

@lvh I'm basing those comments on what Rich and others have said about generative testing not being part of "normal" (fast) unit testing.

seancorfield17:08:57

Like you, in the past, what little generative testing we've done has been okay in our regular Expectations-based test suite. But with the much more extensive use of generative testing in spec.test/check that is not a realistic approach. Unit tests should give near-immediate feedback and take "seconds" to run overall. Generative testing takes much longer so it needs a different approach.

lvh18:08:03

Sure, that makes sense; I still want to run the tests as part of a test suite even if it isn't the fast, rapid-feedback one though :)

lvh21:08:52

I’m seeing a lot of failures with stest/check like:

6. { :failure clojure.lang.ExceptionInfo: No fn to spec #:clojure.spec{:failure :no-fn}, :sym clojure.core/ns, :spec [email protected] }
  7. { :failure clojure.lang.ExceptionInfo: No fn to spec #:clojure.spec{:failure :no-fn}, :sym clojure.core/defn, :spec [email protected] }
defn and ns not having fns seems like not my problem though — I’m guessing the real solution is to explicitly specify namespaces?

lvh22:08:31

@alexmiller: I’m guessing that means “you should go file a bug?” 🙂

lvh22:08:05

Also probably something for core.typed to stop using versions of core.contracts that pull in old versions of core.unified that no longer work 🙂

atroche23:08:39

has anyone been working on a macro that combines defn and fdef, in a similar way to schema’s defnk?