lazytest

seancorfield 2025-03-14T23:31:43.623509Z

I think something is a bit broken with the Expectations support in 1.6.1? I'm just switching deps-new from Expectations to LazyTest and I updated the :require to this:

[lazytest.extensions.expectations
             :refer [defexpect expect expecting from-each
                     more more-> more-of side-effects]]
and when I run clojure -M:test:runner I get no output at all. However, if I change a test so it fails, I get the fail -- but only the failure, no context around it:
(!2009)-> clojure -M:test:runner
Execution error (ExpectationFailed) at (REPL:1).
matches: ""
>>>  expected diverges: "xorg.corfield.new.impl-test"
>>>    actual diverges: "org.corfield.new.impl-test"


Full report at:
/tmp/clojure-3004742020900254945.edn

seancorfield 2025-03-14T23:32:24.084839Z

I noticed this in a namespace at work too and wasn't sure if I was just doing something wrong.

seancorfield 2025-03-14T23:44:23.766489Z

I converted the first test to defdescribe etc and that is reported just fine -- but it's as if the other tests are not reporting anything. Again tho', if I change one of the non-reporting Expectations tests to fail, I get that raw failure ExceptionFailed with no context at all.

seancorfield 2025-03-14T23:45:46.237169Z

I get the same behavior with 1.5.0 so it isn't a newly-introduced breakage. Weird. @nbtheduke any ideas?

seancorfield 2025-03-14T23:53:51.840349Z

I'm wondering if this is due to some of the refactoring of the Expectations code in LazyTest in 1.4.1 and/or 1.5.0? And I just didn't notice because I only have passing tests (and not seeing a few Expectations-style tests reported in the massive sea of tests tests).

seancorfield 2025-03-14T23:57:48.297009Z

I changed one of the Expectations tests to deftest/`testing`/`is` (and added the experiment clojure-test support require) and that test does get reported, so the bug is only in the Expectations stuff...

2025-03-15T00:29:12.796739Z

hmmmmmm

seancorfield 2025-03-15T00:29:19.010849Z

Looking at the code, I think the problem is that ?= doesn't expand to (lt/expect ...) (or the calls to (?= ...) are not wrapped in (lt/expect ...) whereas in the legacy Expectations v2 they are wrapped in (is ...)...?

seancorfield 2025-03-15T00:30:42.349809Z

Perhaps that call to ?=-impl is where the lt/expect call is missing?

seancorfield 2025-03-15T00:52:07.627159Z

Hmm, nope, it's not quite that simple.

seancorfield 2025-03-15T00:54:06.081799Z

I'm pretty sure it's that an lt/expect call is missing but now I'm not entirely sure where it should go...

seancorfield 2025-03-15T01:13:45.025329Z

Ah... there's no it anywhere in the expect stack! Is that the problem?

seancorfield 2025-03-15T01:20:02.646099Z

I think defexpect should be this:

(defmacro defexpect
  "Given a name (a symbol that may include metadata) and a test body,
  produce a standard `lazytest.core` test var (using `defdescribe`)."
  [n & body]
  (with-meta `(lt/defdescribe ~n (lt/it ~(str n) ~@body)) (meta &form)))
That seems to produce the reporting I would expect (and matches the clojure.test compatibility approach).

seancorfield 2025-03-15T01:23:38.703869Z

OK, PR submitted. I tested this locally with deps-new's tests and it works.