tools-deps 2025-02-13

is there a way to run a single test with clojure -X:test based on namespace and test name? Equivalent to lein test :only /?

depends on the test runner you're using

io.github.cognitect-labs/test-runner

I see the options

-d, --dir DIRNAME            Name of the directory containing tests. Defaults to "test".
  -n, --namespace SYMBOL       Symbol indicating a specific namespace to test.
  -r, --namespace-regex REGEX  Regex for namespaces to test. Defaults to #".*-test$"
                               (i.e, only namespaces ending in '-test' are evaluated)
  -v, --var SYMBOL             Symbol indicating the fully qualified name of a specific test.
  -i, --include KEYWORD        Run only tests that have this metadata keyword.
  -e, --exclude KEYWORD        Exclude tests with this metadata keyword.
  -H, --test-help              Display this help message

you're using the -X exec style, so you gotta pass in key-value pairs: clojure -X:test :vars '[namespace/test-name]'

great, that works

thank you

glad to help

🙏 1

(this isn't exactly a tools-deps issue, so maybe next time post to #clojure or #beginners or even #testing)

Ah okay, I saw “Discuss tools.deps.alpha, tools.build, and the clj/clojure command-line scripts! ”

yeah no worries, that's why i answered first

we’ve written a wrapper around eftest https://github.com/metabase/hawk which lets you do nice things like

clj -X:test :only ns/var
clj -X:test :only [ns/var ns2/var2]
clj -X:test :only "test/module"
clj -X:test :only ["test/module"  name.space.2/var]

👍 3

but thanks for suggestions, will go there next time