diff options
| author | Nathaniel Nicandro <nathanielnicandro@gmail.com> | 2019-09-18 23:08:37 -0500 |
|---|---|---|
| committer | gcv <vetoshev@gmail.com> | 2019-09-27 12:02:24 -0700 |
| commit | 7d3c966eec9ffcf3aea044fb70a82b8179a44de7 (patch) | |
| tree | bf051ae5cb83e9d5b7dd6c0dc1009bc750b02682 | |
| parent | 519838e2647268567c086b77158a55b01feb7f6c (diff) | |
Add test framework
| -rw-r--r-- | .travis.yml | 16 | ||||
| -rw-r--r-- | Makefile | 16 | ||||
| -rw-r--r-- | perspective.el | 1 | ||||
| -rw-r--r-- | test/test-perspective.el | 61 |
4 files changed, 94 insertions, 0 deletions
diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..de36102 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,16 @@ +sudo: required +# for evm binaries +dist: trusty +env: + - EMACS_VERSION=26.2 + - EMACS_VERSION=26.1 + - EMACS_VERSION=25.1 + - EMACS_VERSION=24.3 +script: + - cd $TRAVIS_BUILD_DIR + - git clone https://github.com/rejeep/evm ${TRAVIS_BUILD_DIR}/.evm + - export PATH=${TRAVIS_BUILD_DIR}/.evm/bin:${PATH} + - evm config path /tmp + - evm install emacs-${EMACS_VERSION}-travis --use --skip + - emacs --version + - make diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..9771ba8 --- /dev/null +++ b/Makefile @@ -0,0 +1,16 @@ +EMACS ?= emacs +ELFILES := perspective.el +ELCFILES = $(ELFILES:.el=.elc) + +all: test + +.PHONY: test +test: + $(EMACS) -nw -Q -batch -L . -l ert $(addprefix -l ,$(wildcard test/*.el)) \ + --eval "(ert-run-tests-batch-and-exit)" + +.PHONY: compile +compile: $(ELCFILES) + +$(ELCFILES): %.elc: %.el + $(EMACS) --batch -Q -L . -f batch-byte-compile $< diff --git a/perspective.el b/perspective.el index b6bdc86..97d1a9f 100644 --- a/perspective.el +++ b/perspective.el @@ -28,6 +28,7 @@ ;; available by default. (require 'cl-lib) +(require 'subr-x) ; hash-table-values ;; 'cl' is still required because the use of 'lexical-let'. 'lexical-let' has ;; been deprecated since emacs 24.1, and it should be replaced with true diff --git a/test/test-perspective.el b/test/test-perspective.el new file mode 100644 index 0000000..ee4d824 --- /dev/null +++ b/test/test-perspective.el @@ -0,0 +1,61 @@ +;;; test-perspective.el --- Tests for perspective + +;; Licensed under the same terms as Emacs and under the MIT license. + +;; URL: http://github.com/nex3/perspective-el +;; Created: 2019-09-18 +;; By: Nathaniel Nicandro <nathanielnicandro@gmail.com> + +;;; Commentary: + +;;; Code: + +(require 'perspective) +(require 'cl-lib) +(require 'ert) + +(persp-mode 1) + +(defmacro persp-test-with-temp-buffers (vars &rest body) + "Bind temporary buffers to VARS and evaluate BODY." + (declare (indent 1)) + (let ((binds (cl-loop + for var in vars + collect `(,var (generate-new-buffer "persp-test")))) + (cleanup (cl-loop + for var in vars + collect `(when (buffer-live-p ,var) + (kill-buffer ,var))))) + `(let (,@binds) + (unwind-protect + (progn ,@body) + ,@cleanup)))) + +(ert-deftest issue-85 () + (persp-test-with-temp-buffers (b1 b2 b3 b4) + (persp-switch "A") + ;; Show b1 and b2 in two windows of A + (switch-to-buffer b1) + (select-window (split-window)) + (switch-to-buffer b2) + (should (eq (window-buffer (previous-window)) b1)) + (should (eq (window-buffer (selected-window)) b2)) + (persp-switch "B") + ;; Show b3 and b4 in two windows of B + (switch-to-buffer b3) + (select-window (split-window)) + (switch-to-buffer b4) + (should (eq (window-buffer (previous-window)) b3)) + (should (eq (window-buffer (selected-window)) b4)) + ;; Switch back to A and do the main test + (persp-switch "A") + (should (eq (window-buffer (previous-window)) b1)) + (should (eq (window-buffer (selected-window)) b2)) + (kill-buffer) + (should (= (count-windows) 2)) + (should (eq (window-buffer (previous-window)) b1)) + (should (eq (window-buffer (selected-window)) b1)))) + + + +;;; test-perspective.el ends here |
