branch: elpa/cider commit 74be055295c92252a62f1d6647f75352d69c166c Author: vemv <v...@users.noreply.github.com> Commit: GitHub <nore...@github.com>
Introduce fail-fast functionality (#3374) * Prefer `format` https://github.com/clojure-emacs/cider/pull/3373#discussion_r1270531001 * Document indentation inference * Bump cider-nrepl https://github.com/clojure-emacs/cider-nrepl/blob/39c39e3f57a79dad7333ad0220093556feb87a9a/CHANGELOG.md#master-unreleased * Introduce `cider-test-fail-fast` * PR feedback --- CHANGELOG.md | 5 ++++- cider-test.el | 20 +++++++++++++---- cider.el | 2 +- doc/modules/ROOT/pages/indent_spec.adoc | 26 +++++++++++++++++++++++ doc/modules/ROOT/pages/testing/running_tests.adoc | 9 ++++++++ 5 files changed, 56 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a638bb62c4..8917d8f5d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ - [#3352](https://github.com/clojure-emacs/cider/pull/3352) Add CIDER Log Mode, a major mode that allows you to capture, debug, inspect and view log events emitted by Java logging frameworks. - [#3354](https://github.com/clojure-emacs/cider/issues/3354): Add new customization variable `cider-reuse-dead-repls` to control how dead REPL buffers are reused on new connections. - `cider-test`: add timing information. +- `cider-test`: only show diffs for collections. +- `cider-test`: fail-fast by default, as controlled by the new `cider-test-fail-fast` defcustom. +- Infer indentation specs when possible ([doc](https://docs.cider.mx/cider/indent_spec.html#indentation-inference)). ### Bugs fixed @@ -17,7 +20,7 @@ ### Changes -- Bump the injected `cider-nrepl` to 0.31. +- Bump the injected `cider-nrepl` to [0.32](https://github.com/clojure-emacs/cider-nrepl/blob/master/CHANGELOG.md). ## 1.7.0 (2023-03-23) diff --git a/cider-test.el b/cider-test.el index 3436077ab0..b53f558a97 100644 --- a/cider-test.el +++ b/cider-test.el @@ -389,6 +389,9 @@ With the actual value, the outermost '(not ...)' s-expression is removed." (cider-insert (format "%d errors" error) 'cider-test-error-face t)) (when (zerop (+ fail error)) (cider-insert (format "%d passed" pass) 'cider-test-success-face t)) + (when cider-test-fail-fast + (cider-insert "cider-test-fail-fast: " 'font-lock-comment-face nil) + (cider-insert "t" 'cider-test-constant-face t)) (insert "\n\n")))) (defun cider-test-render-assertion (buffer test) @@ -466,7 +469,7 @@ With the actual value, the outermost '(not ...)' s-expression is removed." (insert (cider-propertize ns 'ns) (or (let ((ms (nrepl-dict-get (nrepl-dict-get ns-elapsed-time ns) "ms"))) - (format " (%s ms)" ms)) + (propertize (format " %s ms" ms) 'face 'font-lock-comment-face)) "") "\n")) (cider-insert "\n") @@ -525,7 +528,7 @@ The optional arg TEST denotes an individual test name." "Did you forget to use `is' in your tests?")) (let* ((ms (nrepl-dict-get elapsed-time "ms")) (ms (if ms - (propertize (concat " in " (prin1-to-string ms) "ms") 'face 'font-lock-comment-face) + (propertize (format " in %s ms" ms ) 'face 'font-lock-comment-face) "."))) (message (propertize "%sRan %d assertions, in %d test functions. %d failures, %d errors%s" @@ -653,6 +656,11 @@ The selectors can be either keywords or strings." (split-string (cider-read-from-minibuffer message)))) +(defcustom cider-test-fail-fast t + "Controls whether to stop a test run on failure/error." + :type 'boolean + :package-version '(cider . "1.8.0")) + (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', @@ -682,10 +690,11 @@ running them." ;; we generate a different message when running individual tests (cider-test-echo-running ns (car tests)) (cider-test-echo-running ns))) - (let ((request `("op" ,(cond ((stringp ns) "test") + (let ((retest? (eq :non-passing ns)) + (request `("op" ,(cond ((stringp ns) "test") ((eq :project ns) "test-all") ((eq :loaded ns) "test-all") - ((eq :non-passing ns) "retest"))))) + (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)))) @@ -697,6 +706,9 @@ running them." (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) diff --git a/cider.el b/cider.el index 0e70211b91..adfa7545c5 100644 --- a/cider.el +++ b/cider.el @@ -489,7 +489,7 @@ the artifact.") (defconst cider-latest-clojure-version "1.10.1" "Latest supported version of Clojure.") -(defconst cider-required-middleware-version "0.32.0-alpha2" +(defconst cider-required-middleware-version "0.32.0-alpha3" "The CIDER nREPL version that's known to work properly with CIDER.") (defcustom cider-injected-middleware-version cider-required-middleware-version diff --git a/doc/modules/ROOT/pages/indent_spec.adoc b/doc/modules/ROOT/pages/indent_spec.adoc index b72a5d612a..145779c479 100644 --- a/doc/modules/ROOT/pages/indent_spec.adoc +++ b/doc/modules/ROOT/pages/indent_spec.adoc @@ -156,3 +156,29 @@ so that it will be indented like this: The indent spec does this as well. It lets you specify that, for each argument beyond the 2nd, if it is a form, it should be internally indented as having 1 special argument. + +== Indentation inference + +It's worth noting that starting from cider-nrepl 0.32, indentation can be inferred for you, +so you wouldn't have to specify it. + +For that to happen, it's most recommended that you write idiomatic Clojure macros: + +* If your macro is analog to a clojure.core one, name it identically + * e.g. name your macro `defprotocol`, not `my-defprotocol` + * (this is intentful usage of Clojure's namespace system) +* If your macro is analog to a clojure.core one, mirror all its arglists + * The exact names that you choose for your args do not matter + * It's the structure of the arglists that have to match. + * It doesn't matter if you express a given arg as a name, or as a destructured map/vector. +* Name 'body' args like using clojure.core customs + * good: `[opts body]` + * bad: `[opts etc]` + * good: `[& body]` + * bad: `[& etc]` + * Other commonly accepted names include `forms`, `clauses`, etc. + +You certainly don't _have_ to follow these suggestions - it's only for your convenience, +as the indentation produced by CIDER will be better. + +Other tools may eventually also use these very same inference rules. diff --git a/doc/modules/ROOT/pages/testing/running_tests.adoc b/doc/modules/ROOT/pages/testing/running_tests.adoc index 4e2934f694..8acc8b653d 100644 --- a/doc/modules/ROOT/pages/testing/running_tests.adoc +++ b/doc/modules/ROOT/pages/testing/running_tests.adoc @@ -91,6 +91,15 @@ kbd:[C-c C-t t] or kbd:[C-c C-t C-t]. You can configure CIDER's test execution behavior in multiple ways. +=== Fail-fast + +Starting from 1.8.0, CIDER has standard fail-fast functionality, +controlled by the `cider-test-fail-fast` defcustom (default `t`). + +NOTE: fail-fast will never be chosen for the "retest" functionality, +since that would cause you to lose the majority of the tests +that previously failed. + === Test Namespace Naming Convention If your tests are not following the `some.ns-test` naming convention