Function: cider-test-execute
cider-test-execute is a byte-compiled function defined in
cider-test.el.
Signature
(cider-test-execute NS &optional TESTS SILENT PROMPT-FOR-FILTERS)
Documentation
Run tests for NS, which may be a keyword, optionally specifying TESTS.
This tests a single NS, or multiple namespaces when using keywords :project,
:loaded or :non-passing. Optional TESTS are only honored when a single
namespace is specified. Upon test completion, results are echoed and a test
report is optionally displayed. When test failures/errors occur, their sources
are highlighted.
If SILENT is non-nil, suppress all messages other then test results.
If PROMPT-FOR-FILTERS is non-nil, prompt the user for a test selector filters.
The include/exclude selectors will be used to filter the tests before
running them.
Source Code
;; Defined in ~/.emacs.d/elpa/cider-20260414.1619/cider-test.el
(defun cider-test-execute (ns &optional tests silent prompt-for-filters)
"Run tests for NS, which may be a keyword, optionally specifying TESTS.
This tests a single NS, or multiple namespaces when using keywords `:project',
`:loaded' or `:non-passing'. Optional TESTS are only honored when a single
namespace is specified. Upon test completion, results are echoed and a test
report is optionally displayed. When test failures/errors occur, their sources
are highlighted.
If SILENT is non-nil, suppress all messages other then test results.
If PROMPT-FOR-FILTERS is non-nil, prompt the user for a test selector filters.
The include/exclude selectors will be used to filter the tests before
running them."
(cider-test-clear-highlights)
(let ((include-selectors
(if prompt-for-filters
(cider-test--prompt-for-selectors
"Test selectors to include (space separated): ")
cider-test-default-include-selectors))
(exclude-selectors
(if prompt-for-filters
(cider-test--prompt-for-selectors
"Test selectors to exclude (space separated): ")
cider-test-default-exclude-selectors)))
(cider-map-repls :clj-strict
(lambda (conn)
(unless silent
(if (and tests (= (length tests) 1))
;; we generate a different message when running individual tests
(cider-test-echo-running ns (car tests))
(cider-test-echo-running ns)))
(cider-test-spinner-start (current-buffer))
(setq cider-test--current-repl conn)
(let* ((retest? (eq :non-passing ns))
(request `("op" ,(cond ((stringp ns) "test")
((eq :project ns) "test-all")
((eq :loaded ns) "test-all")
(retest? "retest")))))
;; we add optional parts of the request only when relevant
(when (and (listp include-selectors) include-selectors)
(setq request (append request `("include" ,include-selectors))))
(when (and (listp exclude-selectors) exclude-selectors)
(setq request (append request `("exclude" ,exclude-selectors))))
(when (stringp ns)
(setq request (append request `("ns" ,ns))))
(when (stringp ns)
(setq request (append request `("tests" ,tests))))
(when (or (stringp ns) (eq :project ns))
(setq request (append request `("load?" ,"true"))))
(when (and cider-test-fail-fast
(not retest?))
(setq request (append request `("fail-fast" ,"true"))))
(cider-nrepl-send-request
request
(lambda (response)
(nrepl-dbind-response response (summary results status out err elapsed-time ns-elapsed-time var-elapsed-time)
(when (or (member "done" status)
(member "error" status)
(member "namespace-not-found" status))
(cider-test-spinner-stop))
(cond ((member "namespace-not-found" status)
(unless silent
(message "No test namespace: %s" (cider-propertize ns 'ns))))
(out (cider-emit-interactive-eval-output out))
(err (cider-emit-interactive-eval-err-output err))
(results
(nrepl-dbind-response summary (error fail)
(setq cider-test-last-summary summary)
(setq cider-test-last-results results)
(cider-test-highlight-problems results)
(cider-test-echo-summary summary results elapsed-time)
(if (or (not (zerop (+ error fail)))
cider-test-show-report-on-success)
(let ((b (cider-popup-buffer
cider-test-report-buffer
cider-auto-select-test-report-buffer)))
(with-current-buffer b
;; Change the default-directory so that it doesn't affect `sesman--linked-sessions` logic:
(setq-local default-directory
(with-current-buffer "*Messages*" default-directory)))
(cider-test-render-report
b
summary
results
elapsed-time
ns-elapsed-time
var-elapsed-time))
(when (get-buffer cider-test-report-buffer)
(with-current-buffer cider-test-report-buffer
(let ((inhibit-read-only t))
(erase-buffer)))
(cider-test-render-report
cider-test-report-buffer
summary
results
elapsed-time
ns-elapsed-time))))))))
conn))))))