gfredericks / test.chuck

A utility library for test.check
Eclipse Public License 1.0
214 stars 26 forks source link

subsequence, after a tools.ns refresh, sometimes isn't a generator #53

Closed mattly closed 11 months ago

mattly commented 7 years ago

With varying frequency, sometimes when running clojure.tools.namespace.repl/refresh, I'll get an error similar to:

#error {
 :cause "Assert failed: Arg to not-empty must be a generator\n(generator? gen)"
 :via
 [{:type clojure.lang.Compiler$CompilerException
   :message "java.lang.AssertionError: Assert failed: Arg to not-empty must be a generator\n(generator? gen), compiling:(dimensions_test.clj:17:3)"
   :at [clojure.lang.Compiler$InvokeExpr eval "Compiler.java" 3657]}
  {:type java.lang.AssertionError
   :message "Assert failed: Arg to not-empty must be a generator\n(generator? gen)"
   :at [clojure.test.check.generators$not_empty invokeStatic "generators.cljc" 360]}]

The location and source of the error varies, but it's always some place that's using subsequence as a generator. I'm not entirely sure what's going on, and it's difficult to reproduce, but once it happens, the problem persists until I quit the running JVM and restart it again.

gfredericks commented 7 years ago

My only experience with this error message & code reloading is when developing test.check itself, where I might accidentally redefine the Generator defrecord and suddenly any existing generators or code that references that class will be referencing the older version of the class.

I'm not sure why that would happen to you since I assume you're developing your own project and test.check is just a library that tools.namespace should not be reloading.

If none of that rings a bell, I will probably need some sort of succinct way of reproducing the problem, because this isn't much to go on, and subsequence doesn't look strange at all.

(I did just glance at it and saw that it used the test.chuck/for macro, which raises the possibility that the macroexpansion somehow references an older Generator class, but I see no such reference, and that still wouldn't explain why Generator would be getting reloaded anyhow)

mattly commented 7 years ago

hm.. I'm not defining any of my own Generator or doing anything with test.check or test.chuck, but I do have a macro in my own project (that rarely should get reloaded by tools.namespace that wraps checking to provide me with status on my test runs, since they can take a long time.

It's good to know that this is a known problem, at least.

I'll see if I can narrow the problem down a bit to something reproducible. It might take a while... the problem has been happening for a while in my own project, but recently I was refactoring some non-test code that uses the generators for "demo data" purposes and this was happening a lot, so I've got some ideas on where to look.

bilus commented 1 year ago

I found this issue because it suddenly started happening for me. If I can narrow it down, I'll post here.