Run a namespace's tests in the session's ALREADY-RUNNING nREPL (the fast inner loop) or -- the default, and whenever there is no such REPL -- by shelling the project's own test command in a clean JVM. Nothing here EVER starts a REPL.
The in-REPL path is FRAMEWORK-AGNOSTIC: a ns whose vars carry clojure.test :test metadata runs through clojure.test/run-tests; otherwise it is treated as lazytest and run through lazytest.runner/run-tests. Either way the result is a uniform STRING-keyed map (crosses the strings-only boundary) with "mode" (repl or cli), "framework", "ns", "total", "pass", "fail" and "failures" [{"ns" "test" "message" "file" "line"} ...]. CLI and shadow-cljs retain complete stdout/stderr in "output" (ANSI-stripped) and collect per-fault diagnostics before rendering. Only the display preview may be bounded; the result data is never reduced to a log tail.
run-form is the code EVALED on the target nREPL. It is a quoted form (not a call into this namespace) so it works against ANY project's nREPL, including hosts that do not have the vis-agent extension on their classpath.
Run a namespace's tests in the session's ALREADY-RUNNING nREPL (the fast inner
loop) or -- the default, and whenever there is no such REPL -- by shelling the
project's own test command in a clean JVM. Nothing here EVER starts a REPL.
The in-REPL path is FRAMEWORK-AGNOSTIC: a ns whose vars carry clojure.test
:test metadata runs through clojure.test/run-tests; otherwise it is treated
as lazytest and run through lazytest.runner/run-tests. Either way the result
is a uniform STRING-keyed map (crosses the strings-only boundary) with
"mode" (repl or cli), "framework", "ns", "total", "pass", "fail" and
"failures" [{"ns" "test" "message" "file" "line"} ...].
CLI and shadow-cljs retain complete stdout/stderr in "output" (ANSI-stripped)
and collect per-fault diagnostics before rendering. Only the display preview
may be bounded; the result data is never reduced to a log tail.
run-form is the code EVALED on the target nREPL. It is a quoted form (not a
call into this namespace) so it works against ANY project's nREPL, including
hosts that do not have the vis-agent extension on their classpath.(build-eval-code ns-strs sel)(build-eval-code ns-strs sel ns-files)Self-contained Clojure source string that runs tests for ns-strs with sel. ns-files optionally maps namespace strings to absolute .clj paths to load when the target nREPL does not have test paths on the classpath.
The printer vars are pinned (no length/level/meta/dup limits) so the emitted
code is always COMPLETE and readable — a caller runtime that caps
print-level / print-length would otherwise render deep sub-forms of
run-form as # / ... and produce an unreadable, unbalanced string.
The emitted code RETURNS its result map pr-str'd to a STRING under those same
pinned vars. A plain string value is immune to a truncating nREPL SESSION
(a server whose print-length / print-level is set clips collections and
nesting with ... / #, but never a string's characters), so run-via-repl
always gets parseable EDN back — it reads the value twice: once to unwrap the
string literal, once to parse the map inside it.
Self-contained Clojure source string that runs tests for ns-strs with sel. ns-files optionally maps namespace strings to absolute .clj paths to load when the target nREPL does not have test paths on the classpath. The printer vars are pinned (no length/level/meta/dup limits) so the emitted code is always COMPLETE and readable — a caller runtime that caps *print-level* / *print-length* would otherwise render deep sub-forms of run-form as `#` / `...` and produce an unreadable, unbalanced string. The emitted code RETURNS its result map pr-str'd to a STRING under those same pinned vars. A plain string value is immune to a truncating nREPL SESSION (a server whose *print-length* / *print-level* is set clips collections and nesting with `...` / `#`, but never a string's characters), so run-via-repl always gets parseable EDN back — it reads the value twice: once to unwrap the string literal, once to parse the map inside it.
(clj-test-fn env arg)Run tests selected by paths, namespaces or vars. Source paths map to their nearest *-test namespace; JS/shared files also recognize the configured shadow-cljs :ns-regexp/:namespaces instead of requiring a _test filename. Missing paths and explicit-but-empty selections fail instead of running all.
The files and an optional build choose the runtime. .cljs cannot run on the JVM, .clj cannot run in JS, and .cljc can accompany either. An explicit build selects JS for shared tests. Mixed JVM/JS selections are refused, never silently trimmed. The nearest project manifest roots the command.
No REPL is started: reuse this session's JVM REPL or shell an executable project runner. aliases add classpath or select that runner. Lazytest/Kaocha receive their own focus arguments; unsupported focus fails before launch. A reused REPL cannot apply aliases and says so. JS uses the project's own shadow launcher/config; no shadow dependency is loaded into Vis. JS var/tag selectors are refused instead of widened to namespace runs.
An unfiltered CLI run leaves suite discovery to the project runner/build; local filename discovery does not override its configured suite. A reused REPL still uses the local index, loading only the test namespaces (callers must reload changed production dependencies or stop that REPL themselves). CLI verdicts require nonempty test summaries; selected is the executed test count, while ns/command identify effective focus. Language stays clojure.
Run tests selected by paths, namespaces or vars. Source paths map to their nearest *-test namespace; JS/shared files also recognize the configured shadow-cljs :ns-regexp/:namespaces instead of requiring a _test filename. Missing paths and explicit-but-empty selections fail instead of running all. The files and an optional build choose the runtime. .cljs cannot run on the JVM, .clj cannot run in JS, and .cljc can accompany either. An explicit build selects JS for shared tests. Mixed JVM/JS selections are refused, never silently trimmed. The nearest project manifest roots the command. No REPL is started: reuse this session's JVM REPL or shell an executable project runner. aliases add classpath or select that runner. Lazytest/Kaocha receive their own focus arguments; unsupported focus fails before launch. A reused REPL cannot apply aliases and says so. JS uses the project's own shadow launcher/config; no shadow dependency is loaded into Vis. JS var/tag selectors are refused instead of widened to namespace runs. An unfiltered CLI run leaves suite discovery to the project runner/build; local filename discovery does not override its configured suite. A reused REPL still uses the local index, loading only the test namespaces (callers must reload changed production dependencies or stop that REPL themselves). CLI verdicts require nonempty test summaries; selected is the executed test count, while ns/command identify effective focus. Language stays clojure.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |