Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #163 from tkf/travis-ci

This PR adds:

* Automated tests in Travis CI based on the PR #162.
* AC's dependencies (popup/fuzzy) and ERT as git submodules under `lib/`.
* `travis-ci` make target in Makfile, so that tests ran on Travis CI
  server can be ran in local machine by `make travis-ci`.
  • Loading branch information...
commit 8ec385e27ad59983dd57669d1358f519e8aeca68 2 parents 03ac748 + 6e64d18
@tkf tkf authored
View
9 .gitmodules
@@ -0,0 +1,9 @@
+[submodule "lib/fuzzy"]
+ path = lib/fuzzy
+ url = git://github.com/auto-complete/fuzzy-el.git
+[submodule "lib/popup"]
+ path = lib/popup
+ url = git://github.com/auto-complete/popup-el.git
+[submodule "lib/ert"]
+ path = lib/ert
+ url = git://github.com/ohler/ert.git
View
14 .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
View
9 Makefile
@@ -1,11 +1,12 @@
VERSION=`perl -ne 'print $$1 if /;; Version: (.*)/' auto-complete.el`
PACKAGE=auto-complete-${VERSION}
+EMACS=emacs
byte-compile:
- emacs -Q -L . -batch -f batch-byte-compile auto-complete.el auto-complete-config.el
+ ${EMACS} -Q -L . -batch -f batch-byte-compile auto-complete.el auto-complete-config.el
install:
- emacs -Q -L . -batch -l etc/install ${DIR}
+ ${EMACS} -Q -L . -batch -l etc/install ${DIR}
clean:
rm -f *.elc
@@ -25,3 +26,7 @@ package.tar.bz2: tar
package.zip: package
zip -r ${PACKAGE}.zip ${PACKAGE}
+
+travis-ci:
+ ${EMACS} --version
+ ${EMACS} -batch -Q -l tests/run-test.el
1  lib/ert
@@ -0,0 +1 @@
+Subproject commit 00aef6e43d44c6f25323d1a7bdfdc929a3b4ce04
1  lib/fuzzy
@@ -0,0 +1 @@
+Subproject commit b47d801d4e1ff67323eda4d602e78c31fbc5a08a
1  lib/popup
@@ -0,0 +1 @@
+Subproject commit f15c82bf423e6d49cf107836ba1ce39fc1138933
View
53 tests/auto-complete-test.el
@@ -0,0 +1,53 @@
+(require 'ert)
+
+(require 'auto-complete)
+(require 'auto-complete-config)
+
+;; Move this into test case or setup macro once we start testing with
+;; non-default config.
+(ac-config-default)
+
+(defmacro ac-test-with-common-setup (&rest body)
+ (declare (indent 0) (debug t))
+ `(save-excursion
+ (with-temp-buffer
+ (switch-to-buffer (current-buffer))
+ (auto-complete-mode 1)
+ (emacs-lisp-mode)
+ ,@body
+ (ac-menu-delete)
+ )))
+
+(ert-deftest ac-test-simple-invocation ()
+ (ac-test-with-common-setup
+ (let ((ac-source-test
+ '((candidates list "Foo" "FooBar" "Bar" "Baz" "LongLongLine")))
+ (ac-source-action-test
+ '((candidates list "Action1" "Action2")
+ (action . (lambda () (message "Done!")))))
+ (ac-sources '(ac-source-test ac-source-action-test)))
+ (should-not (popup-live-p ac-menu))
+ (should (eq ac-menu nil))
+ (insert "Foo")
+ (auto-complete)
+ (should (popup-live-p ac-menu))
+ (should (equal (popup-list ac-menu) '("Foo" "FooBar")))
+ )))
+
+(ert-deftest ac-test-simple-update ()
+ (ac-test-with-common-setup
+ (let ((ac-source-test
+ '((candidates list "Foo" "FooBar" "Bar" "Baz" "LongLongLine")))
+ (ac-source-action-test
+ '((candidates list "Action1" "Action2")
+ (action . (lambda () (message "Done!")))))
+ (ac-sources '(ac-source-test ac-source-action-test)))
+ (should-not (popup-live-p ac-menu))
+ (should (eq ac-menu nil))
+ (insert "Foo")
+ (auto-complete)
+ (execute-kbd-macro "B")
+ (ac-update-greedy)
+ (should (popup-live-p ac-menu))
+ (should (equal (popup-list ac-menu) '("FooBar")))
+ )))
View
44 tests/run-test.el
@@ -0,0 +1,44 @@
+;; Usage:
+;;
+;; emacs -Q -l tests/run-test.el # interactive mode
+;; emacs -batch -Q -l tests/run-test.el # batch mode
+
+
+;; Utils
+(defun ac-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 'ac-test-join-path rest))
+ path))
+
+(defvar ac-test-dir (file-name-directory load-file-name))
+(defvar ac-root-dir (concat ac-test-dir ".."))
+
+
+;; Setup `load-path'
+(mapc (lambda (p) (add-to-list 'load-path p))
+ (list ac-test-dir
+ ac-root-dir
+ (ac-test-join-path ac-root-dir "lib" "popup")
+ (ac-test-join-path ac-root-dir "lib" "fuzzy")))
+
+
+;; Use ERT from github when this Emacs does not have it
+(unless (locate-library "ert")
+ (add-to-list
+ 'load-path
+ (ac-test-join-path ac-root-dir "lib" "ert" "lisp" "emacs-lisp"))
+ (require 'ert-batch)
+ (require 'ert-ui))
+
+
+;; Load tests
+(load "auto-complete-test")
+
+
+;; Run tests
+(if noninteractive
+ (ert-run-tests-batch-and-exit)
+ (ert t))
Please sign in to comment.
Something went wrong with that request. Please try again.