Skip to content

Commit

Permalink
[Fix #1425] Define cider-auto-test-mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Malabarba committed Mar 28, 2016
1 parent 655848d commit 5cf86b8
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ an individual test using `C-c C-t t`.

### New Features

* [#1636](https://github.com/clojure-emacs/cider/pull/1636): New minor-mode `cider-auto-test-mode` for test-driven-development. When activated, tests are rerun after every load-file.
* Javadoc commands take into account the variable `clojure.java.javadoc/*remote-javadocs*`.
* Javadoc also works on classes of the AmazonAWS Java SDK.
* Apropos commands now accept lists of space-separated words as arguments, in addition to regular expressions (similar to Emacs's own apropos commands).
Expand Down
23 changes: 23 additions & 0 deletions cider-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,29 @@ is searched."
(cider-test-execute ns (cdr def))
(message "No test at point"))))))

;;; Auto-test mode
(defun cider--test-silently ()
"Like `cider-test-run-tests', but with less feedback.
Only notify the user if there actually were any tests to run and only after
the results are received."
(when (cider-connected-p)
(let ((cider-auto-select-test-report-buffer nil)
(cider-test-show-report-on-success nil))
(cider-test-run-ns-tests nil 'soft))))

;;;###autoload
(define-minor-mode cider-auto-test-mode
"Toggle automatic testing of Clojure files.
When enabled this reruns tests every time a Clojure file is loaded.
Only runs tests corresponding to the loaded file's namespace and does
nothing if no tests are defined or if the file failed to load."
nil nil nil
:global t
(if cider-auto-test-mode
(add-hook 'cider-file-loaded-hook #'cider--test-silently)
(remove-hook 'cider-file-loaded-hook #'cider--test-silently)))

(provide 'cider-test)

;;; cider-test.el ends here

0 comments on commit 5cf86b8

Please sign in to comment.