branch: elpa/popup commit 07901c6092ccbee2a6977dbbe670bd2c70cccb06 Merge: f15c82b 2609811 Author: Takafumi Arakaki <aka....@gmail.com> Commit: Takafumi Arakaki <aka....@gmail.com>
Merge pull request #15 from tkf/travis-ci This PR adds: * Automated tests in Travis CI. * ERT as git submodules `lib/ert`. * `travis-ci` make target in Makfile, so that tests ran on Travis CI server can be ran in local machine by `make travis-ci`. --- .gitmodules | 3 ++ .travis.yml | 14 ++++++++ Makefile | 5 +++ lib/ert | 1 + popup-test.el => tests/popup-interactive-test.el | 0 tests/popup-test.el | 18 ++++++++++ tests/run-test.el | 42 ++++++++++++++++++++++++ 7 files changed, 83 insertions(+) diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..e31e75c --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "lib/ert"] + path = lib/ert + url = git://github.com/ohler/ert.git diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..57f385b --- /dev/null +++ b/.travis.yml @@ -0,0 +1,14 @@ +language: emacs-lisp +before_install: + - git submodule update --init + - if [ "$EMACS" = 'emacs-snapshot' ]; then + sudo add-apt-repository -y ppa:cassou/emacs && + sudo apt-get update -qq && + sudo apt-get install -qq + emacs-snapshot-el emacs-snapshot-gtk emacs-snapshot; + fi +env: + - EMACS=emacs + - EMACS=emacs-snapshot +script: + make travis-ci EMACS=$EMACS diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..418837a --- /dev/null +++ b/Makefile @@ -0,0 +1,5 @@ +EMACS=emacs + +travis-ci: + ${EMACS} --version + ${EMACS} -batch -Q -l tests/run-test.el diff --git a/lib/ert b/lib/ert new file mode 160000 index 0000000..00aef6e --- /dev/null +++ b/lib/ert @@ -0,0 +1 @@ +Subproject commit 00aef6e43d44c6f25323d1a7bdfdc929a3b4ce04 diff --git a/popup-test.el b/tests/popup-interactive-test.el similarity index 100% rename from popup-test.el rename to tests/popup-interactive-test.el diff --git a/tests/popup-test.el b/tests/popup-test.el new file mode 100644 index 0000000..e51e01f --- /dev/null +++ b/tests/popup-test.el @@ -0,0 +1,18 @@ +(require 'ert) + +(require 'popup) + +(defmacro popup-test-with-common-setup (&rest body) + (declare (indent 0) (debug t)) + `(save-excursion + (with-temp-buffer + (erase-buffer) + (let ((popup (popup-create (point) 10 10))) + ,@body + (popup-delete popup))))) + +(ert-deftest popup-test-simple () + (popup-test-with-common-setup + (popup-set-list popup '("foo" "bar" "baz")) + (popup-draw popup) + (should (equal (popup-list popup) '("foo" "bar" "baz"))))) diff --git a/tests/run-test.el b/tests/run-test.el new file mode 100644 index 0000000..4cb8022 --- /dev/null +++ b/tests/run-test.el @@ -0,0 +1,42 @@ +;; Usage: +;; +;; emacs -Q -l tests/run-test.el # interactive mode +;; emacs -batch -Q -l tests/run-test.el # batch mode + + +;; Utils +(defun popup-test-join-path (path &rest rest) + "Join a list of PATHS with appropriate separator (such as /). + +\(fn &rest paths)" + (if rest + (concat (file-name-as-directory path) (apply 'popup-test-join-path rest)) + path)) + +(defvar popup-test-dir (file-name-directory load-file-name)) +(defvar popup-root-dir (concat popup-test-dir "..")) + + +;; Setup `load-path' +(mapc (lambda (p) (add-to-list 'load-path p)) + (list popup-test-dir + popup-root-dir)) + + +;; Use ERT from github when this Emacs does not have it +(unless (locate-library "ert") + (add-to-list + 'load-path + (popup-test-join-path popup-root-dir "lib" "ert" "lisp" "emacs-lisp")) + (require 'ert-batch) + (require 'ert-ui)) + + +;; Load tests +(load "popup-test") + + +;; Run tests +(if noninteractive + (ert-run-tests-batch-and-exit) + (ert t))