branch: elpa/popup
commit 9dcce09f59d50560cb8bfad0f7d8cc2615f25014
Merge: 03b23bf 07901c6
Author: Tomohiro Matsuyama <[email protected]>
Commit: Tomohiro Matsuyama <[email protected]>
Merge branch 'master' of github.com:auto-complete/popup-el
---
.gitmodules | 3 ++
.travis.yml | 14 ++++++++
Makefile | 5 +++
lib/ert | 1 +
popup.el | 2 +-
popup-test.el => tests/popup-interactive-test.el | 0
tests/popup-test.el | 18 ++++++++++
tests/run-test.el | 42 ++++++++++++++++++++++++
8 files changed, 84 insertions(+), 1 deletion(-)
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.el b/popup.el
index 8062cfd..34d3ad8 100644
--- a/popup.el
+++ b/popup.el
@@ -132,7 +132,7 @@ untouched."
(declare (indent 0))
`(save-excursion
(let ((buffer-undo-list t)
- (buffer-read-only nil)
+ (inhibit-read-only t)
(modified (buffer-modified-p)))
(unwind-protect
(progn ,@body)
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))