Fork me on GitHub

what's the workflow with cursive if someone wants to develop a library, but in the context of an application, which depends on that library? i assumed that i would just provide a :classpath-overrides {some/lib "/Users/me/src/some-lib"} in ~/.clojure/deps.edn and then if i navigate to the library source code from my application's intellij project, i would end up in "/Users/me/src/some-lib" and i could just edit the file. instead of this, i still end up somewhere inside ~/.m2/repositories/.../some/lib/...", like i would without the override and of course i can't edit the source code of some/lib`, since the opened file is coming from inside a jar.


added more repro cases to a related issue:


@U086D6TBN Thanks for these examples, I haven’t had a chance to read them in detail yet but I should get to that tomorrow.

👍 3

that would be a great help because we are starting a new project in a monorepo and would like to use :local/root deps extensively

Toby Clemson13:07:12

Hi all, I'm trying to write a clojure.test extension, i.e., a custom assert-expr implementation. I'd like to test this by intercepting clojure.test/report within some scope. However, Cursive's test runner appears to intercept clojure.test at some level higher up for its own purposes. Is there some way I can turn off Cursive's interception within some scope?


You could try running the test directly from the repl instead of through cursive


although that won't help in the long term

Toby Clemson13:07:24

Yes, I'm able to run the tests that way, or using other test runners like eftest. Was just hoping to maintain my current workflow.


or you can use a clojure.main REPL. that doesn't have cursive test support

Toby Clemson14:07:16

I'm looking to maintain the Cursive test support whilst testing test infrastructure. An edge case I'm aware. After some digging I think I've got a solution. It appears Cursive redefs clojure.test/do-report. If I capture the original and redef it back within the scope of my test code, I can capture the reports:

(def do-report clojure.test/do-report)

(defmacro report-on [form]
  `(let [reports# (atom nil)]
     (with-redefs [clojure.test/do-report do-report]
       (binding [clojure.test/report (fn [m#] (swap! reports# conj m#))]
         (is ~form)))
     (deref reports#)))


also, maybe try to test your custom extension more directly somehow... eg extract the code of it into functions and have tests for those bits only. wiring it up to the test framework should be trivial code then, which you can omit tests for after observing it to work once.

Toby Clemson14:07:05

Yes, I'll definitely pull out the bulk of the assertion logic. However there are some bits I'd like to test in the assert-expr implementation.

Toby Clemson14:07:00

With this in place, I can write a test like:

(deftest logged?-exactly-matches-single-log-event
  (let [logger (cartus-test/logger)
        type ::some.event
        context {:some "context"}

        _ ^{:line 1 :column 1} (cartus-core/info logger type context)

          (logged? logger
            {:level   :info
             :type    type
             :context context
             :meta    {:ns     (find-ns 'cartus.test-test)
                       :line   1
                       :column 1}}))]
    (is (= :pass (:type (first report))))))

Toby Clemson14:07:48

Can be cleaned up a little as there should only be one report but I'm capturing everything for now in order to test whether that assumption is correct 🙂


just make sure you leave some notes in the code explaining why is it so convoluted ;D

Toby Clemson14:07:00

Of course 🙂


incidentally, i just came across cartus a few days ago and it's on my list of libraries to evaluate. just saying. as an inspiration 🙂

Toby Clemson14:07:33

Great! Let me know if anything is unclear, I've tried to be quite comprehensive in the documentation but would be great to get feedback.


@UDA9YHF8V Yes, you’re right that Cursive monkey-patches do-report. I can’t remember all the gory details, it was a long time ago, but IIRC I had to do it at that level to get the metadata from failing forms, which I need to paint the passed/failed icons. I’ve been planning to investigate using eftest instead, but (also IIRC) part of the problem was actually in the is macro and the way assert-expr works. I’d have to go back and dig into the code in depth to remember all the details though.

Toby Clemson09:07:03

@U0567Q30W Ok great, thanks. I have something up and running that's working nicely by capturing and rebinding clojure.test/do-report within the scope of my test so it's no longer a problem 🙂