Fork me on GitHub
#babashka-sci-dev
<
2023-07-12
>
teodorlu06:07:24

Hi! Question about Neil development with tests, a REPL and Emacs. Something in my workflow feels a bit off, so I’m wondering if I’m doing something wrong. Previously, I’ve been leaning heavily on a development version of neil as a unix script, and running tests from the command line. I really like this for working with small unix tools — just run the code to see what it does. It’s also really nice for playing with CLI arguments to see how it feels. But it didn’t work too well for me on https://github.com/babashka/neil/pull/179, and I got a stuck. I’m now trying to lean on tests more heavily. Run the existing tests frequently, and be very explicit about the changes I’m making. Make sure things are testable rather than making the changes first and figuring out how to test them later. https://github.com/babashka/neil/blob/ece39617404d28f0f0692a1ad24ab711a38a2bae/deps.edn file has a :test alias that adds "tests" to the classpath, and adds a test runner dependency. It also sets :main-opts to run the test runner from the command line. I tried using that alias from a repl, setting cider-clojure-cli-global-options to "-A:test" as a dir-local variable. That caused some behavior I didn’t want: it ran the tests (with the test runner), and terminated the REPL. I see that cognitect-labs/test-runner also has a similar https://github.com/cognitect-labs/test-runner/tree/7284cda41fb9edc0f3bc6b6185cfb7138fc8a023/deps.edn, a :test alias that adds dependencies for testing, and sets the main function to run a command. --- Is there a way to get an editor-connected REPL that has test dependencies and test paths with the current Neil setup?

borkdude09:07:51

You can just develop neil in the JVM right and run the tests with CIDER?

teodorlu10:07:11

Yeah, that’s what I want to do.

teodorlu10:07:12

But how should I start the REPL? Using a plain M-x cider -jack-in like i normally do, doesn’t add the "test/" folder to the classpath. What are you doing when running tests from the REPL? Do you just jack into a JVM repl, evaluate all the forms in the test namespaces, and then use M-x cider-test-run-test and the likes?

borkdude10:07:51

I usually don't use cider to run tests, but just run then manually using clojure.test

borkdude10:07:22

but don't take this as an example, this is just me being spartan in tooling

teodorlu10:07:10

Gotcha 👍

teodorlu10:07:20

I added this to the neil deps.edn for local development:

:dev
  {:extra-paths ["test"]
   :extra-deps {io.github.cognitect-labs/test-runner
                {:git/url ""
                 :git/tag "v0.5.1"
                 :git/sha "dfb30dd"}}}
Should we merge it? It’s a copy of the :test alias, with :main-opts and :exec-fn removed.

mkvlr10:07:51

-A shouldn’t run anything, are you sure you’re not using -M or -X?

👀 2
teodorlu10:07:50

let me double check.

teodorlu10:07:31

@U5H74UNSF that was also what I expected! But when I run clj -A:test in the neil repo, the tests start running:

$ clj -A:test
WARNING: Use of :main-opts with -A is deprecated. Use -M instead.

Running tests in #{"test"}

Testing babashka.neil.dep-add-test

Testing babashka.neil.dep-upgrade-test
[...]

borkdude10:07:58

-A + main-opts still runs something and this should change. It's been deprecated for ages, but not removed. Advocate for removal in #C6QH853H8!

👍 2
teodorlu10:07:21

Ah, ok. Thanks! I was wondering whether I was seeing some weird behavior on my system, good to know things are working as expected locally.