This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-07-27
Channels
- # announcements (12)
- # babashka (18)
- # bangalore-clj (3)
- # beginners (110)
- # calva (14)
- # cestmeetup (4)
- # cider (4)
- # clj-kondo (2)
- # clojure (34)
- # clojure-colombia (5)
- # clojure-europe (11)
- # clojure-nl (8)
- # clojure-spec (19)
- # clojure-uk (11)
- # clojurescript (16)
- # clojureverse-ops (8)
- # community-development (4)
- # conjure (65)
- # core-async (19)
- # cursive (22)
- # data-science (7)
- # datascript (1)
- # datomic (20)
- # devcards (1)
- # figwheel-main (64)
- # fulcro (10)
- # graalvm (3)
- # helix (3)
- # kaocha (22)
- # malli (68)
- # meander (6)
- # off-topic (39)
- # pathom (6)
- # pedestal (2)
- # reagent (5)
- # remote-jobs (2)
- # reveal (30)
- # rum (4)
- # shadow-cljs (83)
- # specter (3)
- # tools-deps (9)
- # xtdb (18)
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.
Made a repro case to demonstrate this issue: https://github.com/cursive-ide/cursive/issues/1641#issuecomment-664513197
added more repro cases to a related issue: https://github.com/cursive-ide/cursive/issues/2204
@U086D6TBN Thanks for these examples, I haven’t had a chance to read them in detail yet but I should get to that tomorrow.
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
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?
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.
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.
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.
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)
report
(report-on
(logged? logger
{:level :info
:type type
:context context
:meta {:ns (find-ns 'cartus.test-test)
:line 1
:column 1}}))]
(is (= :pass (:type (first report))))))
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 🙂
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 🙂
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.
@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 🙂