aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile7
-rw-r--r--evil-tests.el30
2 files changed, 29 insertions, 8 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..a955e18
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,7 @@
+test:
+ emacs --batch -Q -L . -l evil-tests.el -f ert-run-tests-batch-and-exit
+
+clean:
+ rm -f *~
+ rm -f \#*\#
+ rm -f *.elc
diff --git a/evil-tests.el b/evil-tests.el
index a93e50b..7fec074 100644
--- a/evil-tests.el
+++ b/evil-tests.el
@@ -1,8 +1,10 @@
;; evil-tests.el --- unit tests for Evil -*- coding: utf-8 -*-
;; This file is for developers. It runs some unit tests on Evil.
-;; To load it, add the following line to .emacs:
+;; To load it, add the following lines to .emacs:
;;
+;; (setq evil-tests-run t) ; run tests immediately
+;; (global-set-key [f12] 'evil-tests-run) ; hotkey
;; (require 'evil-tests)
;;
;; This file is NOT part of Evil itself.
@@ -19,12 +21,18 @@
;; For the time being, we remove the explainer.
(put 'equal 'ert-explainer nil)
-(defvar evil-tests-run t
+(defvar evil-tests-run nil
"Run Evil tests.")
+(defun evil-tests-run ()
+ "Run Evil tests."
+ (interactive)
+ (ert-run-tests-batch '(tag evil)))
+
(defmacro evil-test-buffer (&rest body)
"Execute BODY in a temporary buffer.
-The buffer contains the familiar *scratch* message."
+The buffer contains the familiar *scratch* message,
+and `evil-local-mode' is enabled."
(declare (indent defun)
(debug t))
`(let ((kill-ring kill-ring)
@@ -36,7 +44,7 @@ The buffer contains the familiar *scratch* message."
(switch-to-buffer-other-window (current-buffer))
(buffer-enable-undo)
(evil-local-mode 1)
- (insert ";; This buffer is for notes you don't want to save, \
+ (insert ";; This buffer is for notes you don't want to save, \ ;
and for Lisp evaluation.\n;; If you want to create a file, visit \
that file with C-x C-f,\n;; then enter the text in that file's own \
buffer.\n")
@@ -158,9 +166,15 @@ buffer.\n")
"Verify that `self-insert-command' is suppressed in STATE"
(evil-test-buffer
(evil-test-change-state state)
- (should-error (execute-kbd-macro "abc"))
- (should (string= ";; " (buffer-substring
- (point-min) (+ (point-min) 3))))))
+ (should (eq (key-binding "a") 'undefined))
+ (should (eq (key-binding "b") 'undefined))
+ (should (eq (key-binding "c") 'undefined))
+ (ert-info ("Don't insert text")
+ ;; may or may not signal an error, depending on batch mode
+ (condition-case nil
+ (execute-kbd-macro "abc")
+ (error nil))
+ (should (string= (buffer-substring 1 4) ";; ")))))
(ert-deftest evil-test-emacs-state-suppress-keymap ()
"`self-insert-command' works in emacs-state"
@@ -179,7 +193,7 @@ of `self-insert-command' from Normal state"
(evil-test-suppress-keymap 'operator))
(when evil-tests-run
- (ert-run-tests-batch '(tag evil)))
+ (evil-tests-run))
(provide 'evil-tests)