branch: master commit 588dab6cb5ed0c42ff3436311a8d9f831a29724b Author: Oleh Krehel <ohwoeo...@gmail.com> Commit: Oleh Krehel <ohwoeo...@gmail.com>
ivy-test.el: Add testing * Makefile: Add a test and compile target. --- .travis.yml | 12 ++++++++++++ Makefile | 16 ++++++++++++++++ ivy-test.el | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 74 insertions(+), 0 deletions(-) diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..1f5dbc7 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,12 @@ +language: emacs-lisp +env: + matrix: + - EMACS=emacs24 + +before_install: + - sudo add-apt-repository -y ppa:cassou/emacs + - sudo apt-get update -qq + - sudo apt-get install -qq $EMACS + +script: + - make test diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..453f709 --- /dev/null +++ b/Makefile @@ -0,0 +1,16 @@ +emacs ?= emacs + +LOAD = -l ivy.el -l swiper.el + +.PHONY: all compile clean + +all: test + +test: + $(emacs) -batch $(LOAD) -l ivy-test.el -f ert-run-tests-batch-and-exit + +compile: + $(emacs) -batch $(LOAD) --eval "(mapc #'byte-compile-file '(\"ivy.el\" \"swiper.el\"))" + +clean: + rm -f *.elc diff --git a/ivy-test.el b/ivy-test.el new file mode 100644 index 0000000..af17414 --- /dev/null +++ b/ivy-test.el @@ -0,0 +1,46 @@ +(require 'ert) + +(defvar ivy-expr nil + "Holds a test expression to evaluate with `ivy-eval'.") + +(defvar ivy-result nil + "Holds the eval result of `ivy-expr' by `ivy-eval'.") + +(defun ivy-eval () + "Evaluate `ivy-expr'." + (interactive) + (setq ivy-result (eval ivy-expr))) + +(global-set-key (kbd "C-c e") 'ivy-eval) + +(defun ivy-with (expr keys) + "Evaluate EXPR followed by KEYS." + (let ((ivy-expr expr)) + (execute-kbd-macro + (vconcat (kbd "C-c e") + (kbd keys))) + ivy-result)) + +(ert-deftest ivy-read () + (should (equal + (ivy-read "pattern: " nil) + nil)) + (should (equal + (ivy-read "pattern: " '("42")) + "42")) + (should (equal + (ivy-with '(ivy-read "pattern: " '("blue" "yellow")) + "C-m") + "blue")) + (should (equal + (ivy-with '(ivy-read "pattern: " '("blue" "yellow")) + "y C-m") + "yellow")) + (should (equal + (ivy-with '(ivy-read "pattern: " '("blue" "yellow")) + "y DEL b C-m") + "blue")) + (should (equal + (ivy-with '(ivy-read "pattern: " '("blue" "yellow")) + "z C-m") + nil)))