This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-03-11
Channels
- # announcements (1)
- # aws (5)
- # beginners (35)
- # calva (18)
- # clerk (5)
- # clojure (20)
- # clojure-berlin (1)
- # clojure-dev (12)
- # clojure-europe (16)
- # clojure-nl (1)
- # clojure-norway (159)
- # clojure-uk (5)
- # clojurescript (8)
- # conjure (1)
- # cursive (18)
- # events (10)
- # fulcro (23)
- # hyperfiddle (5)
- # introduce-yourself (3)
- # juxt (2)
- # off-topic (1)
- # polylith (4)
- # portal (11)
- # releases (1)
- # shadow-cljs (4)
- # xtdb (9)
- # yamlscript (1)
given
(deftest aaa
(= true true))
I would like to shadow deftest macro with my own "identity" macro that does nothing.
i.e.
(defmacro deftest
[name & body]
body)
The reason is, i want to run individual tests without the annoying dance of moving back one character before evaluating.
Can this be done? do i need to load up my macro redefinition at some specific time?It's good that you've provided the reason because it's an instance of the XY problem. Why do you have to have that "annoying dance" in the first place?
when navigating around s-exps i land at the end of the form and then evaluate the form before cursor. So normally i land at the closing bracket of deftest. Need to step back one bracket, to eval the insides.
If I were you, I would try my damndest to figure out how to navigate in a way that precludes it. Changing how the code runs just to make code navigation slightly less annoying feels incredibly wrong. :)
FWIW, I use Vim bindings, so I usually just /deft<Enter>
and then navigate between the tests with n
and N
.
well in my dev alias i see no reason to not override deftest macro. It is mostly used from "test" alias. Also, this being clojurescript makes all that double whammy. In clojure cider understands deftest and can do sth meaningful. I am tired of trying to wrangle all that tooling around, and what i do on daily basics is run the "insides" of a test 😄
i use emacs, and navigating forward by a sexp lands me rightly on the closing bracket
You have elisp. ;)
But to answer your original question - it gets really finicky as it's not about evaluating a set of forms and being done with it. It's about evaluating forms in a REPL, potentially from multiple namespaces, potentially with changing the state of the REPL in some relevant way, on top of CLJS.
You can try evaluating that defmacro
from your original post before you evaluate any of the tests. If done within the context of the namespace where you run tests, should work. You'd have to do it again if you switch the namespace though.
elisp is cool indeed. but writing an advice for standard move command that inspects whether we are in context of deftest sounds very wrong 🙂