This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-09-17
Channels
- # announcements (17)
- # aws (2)
- # babashka (21)
- # beginners (67)
- # calva (19)
- # cider (29)
- # clara (3)
- # clj-kondo (6)
- # cljsrn (10)
- # clojure (140)
- # clojure-europe (164)
- # clojure-nl (3)
- # clojure-uk (8)
- # clojurescript (62)
- # conjure (7)
- # core-async (24)
- # cursive (21)
- # datomic (5)
- # docker (40)
- # emacs (14)
- # fulcro (25)
- # gratitude (1)
- # honeysql (6)
- # introduce-yourself (1)
- # jobs (1)
- # jobs-discuss (32)
- # juxt (7)
- # lsp (13)
- # minecraft (2)
- # off-topic (49)
- # pathom (24)
- # practicalli (8)
- # re-frame (18)
- # react (23)
- # remote-jobs (6)
- # reveal (2)
- # shadow-cljs (75)
- # tools-deps (7)
So I’m progressing through the video internalising non Evil keyboard shortcuts and differences with Spacemacs which is helping me learn so much about vanilla Emacs. Thanks again for this excellent resource.
One further question… Further on, you seem to be able to use *n*
within testing
blocks, but your first passing test fails for me. If I change *n*
to the test namespace symbol it works okay? Is this a cider configuration you’ve applied - is it cider-test-infer-test-ns
?
*ns*
is a dynamic variable that should evaluate to the current namespace. I dont recall adding anything special in Spacemacs to make this work.
If using cider-test, then remember that the test code and any code it tests must be evaluated (loaded) into the REPL, as cider-test runs only within the REPL.
The test
directory also needs to be included in classpath settings, so for Clojure CLI tools projects I include the :test
alias that adds test
directory using :extra-paths
Is there a specific place in the video that is not working for you?
One Spacemacs specific thing. When calling the cider-test runner, Spacemacs will evaluate the namespace of the current buffer (and picks up changes). I usually evaluate the source and test buffers before running tests to ensure that all changes have been picked up (that may not be the case in the video)
Right, so even explicitly evaluating the test namespace, *ns*
still doesn’t bind to that namespace - instead it binds to 'user
But if I change the namespace in the repl to the random function test namespace it works…
The video I’m talking about is at https://practical.li/spacemacs/ and I suppose my results differ from yours around 16:22
To be more specific, *ns*
dynamically binds to the namespace it is called from. So if you call the tests from the default user
namespace, then *ns*
will be user
.
Calling any of the cider-test-
commands from the test buffer will automatically be evaluated in the test namespace, so *ns*
will evaluate to that test namespace name.
In fact, any Cider function called with a Clojure buffer as active will evaluate in the context of that buffers namespace
You have to manually switch namespace if the REPL buffer is the active window when running commands (or of course evaluating code in the REPL buffer)
This is one of many reasons I don't use the REPL buffer directly.