aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile22
-rw-r--r--evil-integration.el6
-rw-r--r--evil-tests.el62
3 files changed, 68 insertions, 22 deletions
diff --git a/Makefile b/Makefile
index 35a52b4..661d04f 100644
--- a/Makefile
+++ b/Makefile
@@ -2,11 +2,12 @@ SHELL = /bin/bash
EMACS = emacs
FILES = $(filter-out evil-tests.el,$(filter-out evil-pkg.el,$(wildcard evil*.el)))
ELPAPKG = evil-`sed -n '3s/.*"\(.*\)".*/\1/p' evil-pkg.el`
+PROFILER =
TAG =
ELCFILES = $(FILES:.el=.elc)
-.PHONY: all compile compile-batch clean tests test emacs term terminal indent elpa version
+.PHONY: all compile compile-batch clean tests test emacs term terminal profiler indent elpa version
# Byte-compile Evil.
all: compile
@@ -41,30 +42,31 @@ clean:
# The TAG variable may specify a test tag or a test name:
# make test TAG=repeat
# This will only run tests pertaining to the repeat system.
-test: clean
+test:
$(EMACS) --batch -Q -L . -L lib -l evil-tests.el \
---eval "(evil-tests-run '(${TAG}))"
+--eval "(evil-tests-initialize '(${TAG}) '(${PROFILER}))"
# Byte-compile Evil and run all tests.
tests: compile-batch
$(EMACS) --batch -Q -L . -L lib -l evil-tests.el \
---eval "(evil-tests-run '(${TAG}))"
+--eval "(evil-tests-initialize '(${TAG}) '(${PROFILER}))"
rm -f *.elc
# Load Evil in a fresh instance of Emacs and run all tests.
emacs:
$(EMACS) -Q -L . -L lib -l evil-tests.el --eval "(evil-mode 1)" \
---eval "(if (y-or-n-p-with-timeout \"Run tests? \" 2 t) \
-(evil-tests-run '(${TAG}) t) \
-(message \"You can run the tests at any time with \`M-x evil-tests-run\'\"))" &
+--eval "(evil-tests-initialize '(${TAG}) '(${PROFILER}) t)" &
# Load Evil in a terminal Emacs and run all tests.
term: terminal
terminal:
$(EMACS) -nw -Q -L . -L lib -l evil-tests.el --eval "(evil-mode 1)" \
---eval "(if (y-or-n-p-with-timeout \"Run tests? \" 2 t) \
-(evil-tests-run '(${TAG}) t) \
-(message \"You can run the tests at any time with \`M-x evil-tests-run\'\"))"
+--eval "(evil-tests-initialize '(${TAG}) '(${PROFILER}) t)"
+
+# Run all tests with profiler.
+profiler:
+ $(EMACS) --batch -Q -L . -L lib -l evil-tests.el \
+--eval "(evil-tests-initialize '(${TAG}) (or '(${PROFILER}) t))"
# Re-indent all Evil code.
# Loads Evil into memory in order to indent macros properly.
diff --git a/evil-integration.el b/evil-integration.el
index b58dc3d..b634fbb 100644
--- a/evil-integration.el
+++ b/evil-integration.el
@@ -33,6 +33,12 @@
(defadvice wdired-change-to-dired-mode (after evil activate)
(evil-change-to-initial-state nil t))))
+;;; ELP
+
+(eval-after-load 'elp
+ '(defadvice elp-results (after evil activate)
+ (evil-motion-state)))
+
;;; Folding
(eval-after-load 'hideshow
diff --git a/evil-tests.el b/evil-tests.el
index 7485025..fbc83b9 100644
--- a/evil-tests.el
+++ b/evil-tests.el
@@ -9,26 +9,64 @@
;;
;; This file is NOT part of Evil itself.
+(require 'elp)
(require 'ert)
(require 'evil)
(defvar evil-tests-run nil
"*Run Evil tests.")
+(defvar evil-tests-profiler nil
+ "*Profile Evil tests.")
+
+(defun evil-tests-initialize (&optional tests profiler interactive)
+ (setq profiler (or profiler evil-tests-profiler))
+ (when (listp profiler)
+ (setq profiler (car profiler)))
+ (when profiler
+ (setq evil-tests-profiler t)
+ (setq profiler
+ (or (cdr (assq profiler
+ '((call . elp-sort-by-call-count)
+ (average . elp-sort-by-average-time)
+ (total . elp-sort-by-total-time))))))
+ (setq elp-sort-by-function (or profiler 'elp-sort-by-call-count))
+ (elp-instrument-package "evil"))
+ (if interactive
+ (if (y-or-n-p-with-timeout "Run tests? " 2 t)
+ (evil-tests-run tests interactive)
+ (message "You can run the tests at any time \
+with `M-x evil-tests-run'"))
+ (evil-tests-run tests)))
+
(defun evil-tests-run (&optional tests interactive)
"Run Evil tests."
(interactive '(nil t))
- (setq tests
- (or (null tests)
- `(or ,@(mapcar (lambda (test)
- (or (null test)
- (and (memq test '(evil t)) t)
- `(or (tag ,test)
- ,(format "^%s$" test))))
- tests))))
- (if interactive
+ (let ((elp-use-standard-output (not interactive)))
+ (setq tests
+ (or (null tests)
+ `(or ,@(mapcar (lambda (test)
+ (or (null test)
+ (and (memq test '(evil t)) t)
+ `(or (tag ,test)
+ ,(format "^%s$" test))))
+ tests))))
+ (cond
+ (interactive
(ert-run-tests-interactively tests)
- (ert-run-tests-batch-and-exit tests)))
+ (when evil-tests-profiler
+ (elp-results)))
+ (evil-tests-profiler
+ (ert-run-tests-batch tests)
+ (elp-results))
+ (t
+ (ert-run-tests-batch-and-exit tests)))))
+
+(defun evil-tests-profiler (&optional force)
+ "Profile Evil tests."
+ (when (or evil-tests-profiler force)
+ (setq evil-tests-profiler t)
+ (elp-instrument-package "evil")))
(defvar evil-test-point nil
"Marker for point.")
@@ -3816,8 +3854,8 @@ if no previous selection")
(should (equal (evil-ex-parse-range ".+42cmd arg" 0)
(cons 4 '((current-line . 42) nil nil)))))
-(when evil-tests-run
- (evil-tests-run))
+(when (or evil-tests-profiler evil-tests-run)
+ (evil-tests-initialize))
(provide 'evil-tests)