example of test running in deps and cli guide not current?
ergodicbreak opened this issue · comments
hi, the example of test running at https://clojure.org/guides/deps_and_cli#test_runner may not be working (I'm new to Clojure so it's probable I'm doing something wrong too).
As written my terminal output was
lucretius:~/work/living_clojure/serpent-talk$ clj -X:test
No function found on command line or in :exec-fn
But using the example from the test runner repo at https://github.com/cognitect-labs/test-runner (which references the dependency differently) I received the expected output (my test ran).
Can you paste your full deps.edn file that's not working here? Also clojure --version
output?
The git dependency format in the test-runner repo is the most current and you should prefer that one, but the older format should still be working too.
Thanks for the reply, here's a paste of a terminal session describing the issue:
lucretius:~/work/living_clojure/serpent-talk$ clojure --version
Clojure CLI version 1.11.1.1182
lucretius:~/work/living_clojure/serpent-talk$ ls -R
.:
deps.edn deps.edn~ src test
./src:
serpent_talk
./src/serpent_talk:
#talk.clj# talk.clj
./test:
serpent_talk
./test/serpent_talk:
talk_test.clj
lucretius:~/work/living_clojure/serpent-talk$ cat deps.edn
{
:aliases
{:test {:extra-paths ["test"]
:extra-deps {io.github.cognitect-labs/test-runner
{:git/url "https://github.com/cognitect-labs/test-runner.git"
:sha "9e35c979860c75555adaff7600070c60004a0f44"}}}}}
lucretius:~/work/living_clojure/serpent-talk$ clj -X:test
No function found on command line or in :exec-fn
lucretius:~/work/living_clojure/serpent-talk$ cat deps.edn
{
;; v0.5.1
:aliases {:test {:extra-paths ["test"]
:extra-deps {io.github.cognitect-labs/test-runner
{:git/tag "v0.5.1" :git/sha "dfb30dd"}}
:main-opts ["-m" "cognitect.test-runner"]
:exec-fn cognitect.test-runner.api/test}}}
lucretius:~/work/living_clojure/serpent-talk$ clj -X:test
Running tests in #{"test"}
Testing serpent-talk.talk-test
FAIL in (a-test) (talk_test.clj:7)
FIXME, I fail.
expected: (= 0 1)
actual: (not (= 0 1))
Ran 1 tests containing 1 assertions.
1 failures, 0 errors.
Execution error (ExceptionInfo) at cognitect.test-runner.api/test (api.clj:30).
Test failures or errors occurred.
Full report at:
/tmp/clojure-10743848608230992085.edn
lucretius:~/work/living_clojure/serpent-talk$
In the one that didn't work, you missed the :exec-fn cognitect.test-runner.api/test
line. That specifies the function to run and is why you got "No function found on command line or in :exec-fn".
I did sync up the site example to match the one on the test-runner repo so those are in sync now.
Hope that helps!
Thank you! That might have been a copy/paste mistake (I grabbed the old from the commit log) so I'm not sure if that's the error I originally hit. But it definitely works now.