diff options
| author | Vegard Øye <vegard_oye@hotmail.com> | 2011-03-04 11:45:02 +0100 |
|---|---|---|
| committer | Vegard Øye <vegard_oye@hotmail.com> | 2011-03-04 11:45:02 +0100 |
| commit | fb62e44ab38c4b0793cfcb7cff17e173f1acc129 (patch) | |
| tree | 31600397ab2db5285a867d8f1f553b0f70297908 | |
| parent | 592ee6f73ade5919b1dd568a47e40c36141873b0 (diff) | |
Add makefile and test target
The tests can now be run from the command line with "make test".
| -rw-r--r-- | Makefile | 7 | ||||
| -rw-r--r-- | evil-tests.el | 30 |
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) |
