summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBozhidar Batsov <bozhidar@batsov.com>2013-08-15 16:25:43 +0300
committerBozhidar Batsov <bozhidar@batsov.com>2013-08-15 16:25:43 +0300
commit7a1ca0434574a0b75494d9284b9f0d9d023b0143 (patch)
tree65c7d35fe5c461bc9da653e42a5fc6f7e5a618db
parent73925f528db529513327fd6ccb1715663a739b69 (diff)
Simplify test infrastructure
* Manage dependencies with Cask * Add a Vagrantfile and a shell script for provisioning * Simplify Makefile * Add a script for running the tests in batch mode The one thing that remains to be done is to reintegrate the batch checkdoc check.
-rw-r--r--.gitignore6
-rw-r--r--.travis.yml32
-rw-r--r--Cask6
-rw-r--r--Makefile104
-rw-r--r--Vagrantfile9
-rwxr-xr-xtest/run-tests17
-rwxr-xr-xvagrant/provision.sh33
7 files changed, 102 insertions, 105 deletions
diff --git a/.gitignore b/.gitignore
index 0f7bcd6a..a57f3055 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,6 +2,6 @@
*\#*\#
*.\#*
*.elc
-test/stable/
-test/latest/
-test/lib/
+.cask
+elpa
+
diff --git a/.travis.yml b/.travis.yml
index ac0fa7ab..3240de77 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,29 +1,9 @@
language: emacs-lisp
-
env:
- matrix:
- - NREPL_DEPS=stable
- - NREPL_DEPS=latest
- global:
- - EMACS=emacs24
-
-install:
- - if [ "$EMACS" = "emacs24" ]; then
- sudo add-apt-repository -y ppa:cassou/emacs &&
- sudo apt-get update -qq &&
- sudo apt-get install -qq emacs24 emacs24-el;
- fi
- - if [ "$NREPL_DEPS" = "stable" ]; then
- make downloads-stable;
- fi
- - if [ "$NREPL_DEPS" = "latest" ]; then
- make downloads-latest;
- fi
-
+ - EMACS=emacs24
+ - EMACS=emacs-snapshot
+before_script:
+ - sh vagrant/provision.sh
+ - make elpa
script:
- - if [ "$NREPL_DEPS" = "latest" ]; then
- $EMACS --version && make test-latest-no-backtrace checkdoc EMACS=$EMACS;
- fi
- - if [ "$NREPL_DEPS" = "stable" ]; then
- $EMACS --version && make test-no-backtrace checkdoc EMACS=$EMACS;
- fi
+ - make EMACS=${EMACS} test \ No newline at end of file
diff --git a/Cask b/Cask
new file mode 100644
index 00000000..8bc43e69
--- /dev/null
+++ b/Cask
@@ -0,0 +1,6 @@
+(source melpa)
+
+(package "nrepl" "2.0.0" "Emacs Lisp client for nREPL")
+
+(depends-on "clojure-mode" "2.0.0")
+(depends-on "dash" "1.6.0")
diff --git a/Makefile b/Makefile
index 2cecebce..d49b39d8 100644
--- a/Makefile
+++ b/Makefile
@@ -1,83 +1,35 @@
-EMACS=emacs
-EMACS_BATCH=-batch
+EMACS = emacs
+EMACSFLAGS =
+CASK = cask
+VAGRANT = vagrant
-ERT_TARGET=-f ert-run-tests-batch-and-exit
-ERT_TARGET_NO_BACKTRACE=--eval \
- "(flet ((ert--print-backtrace (&rest args) \
- (insert \"no backtrace in batch mode\"))) \
- (ert-run-tests-batch-and-exit '(and \"$(TESTS)\" (not (tag :interactive)))))"
-NREPL_DEPS = stable
+OBJECTS = nrepl.elc
-CURL=curl --silent
-WGET=wget
-WORK_DIR=$(shell pwd)
-TRAVIS_FILE=.travis.yml
-TEST_DIR=test
-CLOJURE_MODE=clojure-mode.el
-CLOJURE_MODE_STABLE_URL=https://raw.github.com/clojure-emacs/clojure-mode/2.0.0/clojure-mode.el
-CLOJURE_MODE_LATEST_URL=https://raw.github.com/clojure-emacs/clojure-mode/master/clojure-mode.el
-CHECKDOC_BATCH=checkdoc_batch.el
-CHECKDOC_BATCH_URL=ftp://download.tuxfamily.org/user42/checkdoc-batch.el
+elpa:
+ $(CASK) install
+ $(CASK) update
+ touch $@
-.PHONY : build downloads-stable downloads-latest test-travis test default checkdoc latest no-backtrace dotest
+.PHONY: build
+build : elpa $(OBJECTS)
-default : test checkdoc
+.PHONY: test
+test : build
+ $(CASK) exec $(EMACS) --no-site-file --no-site-lisp --batch \
+ $(EMACSFLAGS) \
+ -l test/run-tests
- : test checkdoc
-
-test : downloads-stable dotest
-
-test-no-backtrace : ERT_TARGET = $(ERT_TARGET_NO_BACKTRACE)
-test-no-backtrace : downloads-latest dotest
-
-test-latest : NREPL_DEPS = latest
-test-latest : downloads-latest dotest
-
-test-latest-no-backtrace : NREPL_DEPS = latest
-test-latest-no-backtrace : ERT_TARGET = $(ERT_TARGET_NO_BACKTRACE)
-test-latest-no-backtrace : downloads-latest dotest
-
-build :
- $(EMACS) $(EMACS_BATCH) --eval \
- "(progn \
- (setq byte-compile-error-on-warn t) \
- (batch-byte-compile))" *.el
-
-$(TEST_DIR)/lib/$(CHECKDOC_BATCH) :
- mkdir -p $(TEST_DIR)/lib
- $(WGET) -O $(TEST_DIR)/lib/$(CHECKDOC_BATCH) '$(CHECKDOC_BATCH_URL)'
-
-$(TEST_DIR)/stable/$(CLOJURE_MODE) :
- mkdir -p $(TEST_DIR)/stable
- $(CURL) '$(CLOJURE_MODE_STABLE_URL)' -o $(TEST_DIR)/stable/$(CLOJURE_MODE)
-
-$(TEST_DIR)/latest/$(CLOJURE_MODE) :
- mkdir -p $(TEST_DIR)/latest
- $(CURL) '$(CLOJURE_MODE_LATEST_URL)' -o $(TEST_DIR)/latest/$(CLOJURE_MODE)
-
-downloads : $(TEST_DIR)/lib/$(CHECKDOC_BATCH)
-
-downloads-stable : $(TEST_DIR)/stable/$(CLOJURE_MODE)
-
-downloads-latest : $(TEST_DIR)/latest/$(CLOJURE_MODE)
-
-test-travis :
- @if test -z "$$TRAVIS" && test -e $(TRAVIS_FILE); then travis-lint $(TRAVIS_FILE); fi
-
-checkdoc : downloads
- @cd $(TEST_DIR) && \
- ${EMACS} -batch -L .. -L lib -l $(CHECKDOC_BATCH) \
- -f checkdoc-batch-commandline ../nrepl.el \
- | grep -e 'nrepl.el:[1-9]' && exit 1 || exit 0
-
-dotest :
- cd $(TEST_DIR) && \
- (for test_lib in *-tests.el; do \
- $(EMACS) $(EMACS_BATCH) -L . -L .. -L $(NREPL_DEPS) -L lib \
- -l cl -l $(CLOJURE_MODE) -l $$test_lib $(ERT_TARGET) \
- || exit 1; \
- done)
+.PHONY: virtual-test
+virtual-test :
+ $(VAGRANT) up
+ $(VAGRANT) ssh -c "make -C /vagrant EMACS=$(EMACS) clean test"
+.PHONY: clean
clean :
- @rm -f *.elc */*.elc */*~ \
- $(TEST_DIR)/stable/* $(TEST_DIR)/latest/* $(TEST_DIR)/lib/*
+ rm -f $(OBJECTS)
+ rm -rf .cask # Clean packages installed for development
+
+%.elc : %.el
+ $(CASK) exec $(EMACS) --no-site-file --no-site-lisp --batch \
+ $(EMACSFLAGS) \
+ -f batch-byte-compile $<
diff --git a/Vagrantfile b/Vagrantfile
new file mode 100644
index 00000000..9923762e
--- /dev/null
+++ b/Vagrantfile
@@ -0,0 +1,9 @@
+# -*- mode: ruby -*-
+# vi: set ft=ruby :
+
+Vagrant::Config.run do |config|
+ config.vm.box = "precise64"
+ config.vm.box_url = "http://files.vagrantup.com/precise64.box"
+
+ config.vm.provision :shell, :path => "vagrant/provision.sh"
+end
diff --git a/test/run-tests b/test/run-tests
new file mode 100755
index 00000000..c923b3ea
--- /dev/null
+++ b/test/run-tests
@@ -0,0 +1,17 @@
+#!/usr/bin/env emacs --script
+
+(let ((current-directory (file-name-directory load-file-name)))
+ (setq nrepl-test-path (expand-file-name "." current-directory))
+ (setq nrepl-root-path (expand-file-name ".." current-directory)))
+
+(add-to-list 'load-path nrepl-root-path)
+(add-to-list 'load-path nrepl-test-path)
+
+(require 'nrepl)
+(require 'cl)
+
+(dolist (test-file (or argv (directory-files nrepl-test-path t "-tests.el$")))
+ (load test-file nil t))
+
+;; run tests
+(ert-run-tests-batch-and-exit t)
diff --git a/vagrant/provision.sh b/vagrant/provision.sh
new file mode 100755
index 00000000..980d62cb
--- /dev/null
+++ b/vagrant/provision.sh
@@ -0,0 +1,33 @@
+#!/bin/sh
+
+ppa () {
+ sudo apt-add-repository -y "$1"
+}
+
+apt_update () {
+ sudo apt-get update -qq
+}
+
+apt () {
+ sudo apt-get install -yy "$@"
+}
+
+# Silence debconf
+export DEBIAN_FRONTEND='noninteractive'
+
+# Bring in the necessary PPAs
+ppa ppa:cassou/emacs
+apt_update
+
+# Install Emacs 24.x and Emacs snapshot
+apt emacs24 emacs24-el emacs24-common-non-dfsg \
+ emacs-snapshot emacs-snapshot-el
+
+# Install Cask for Emacs dependency management
+CASK_DIR=/opt/cask.el-0.4.5
+if ! [ -d "$CASK_DIR" -a -x "/$CASK_DIR/bin/cask" ]; then
+ sudo rm -rf "$CASK_DIR"
+ wget -O - https://github.com/rejeep/cask.el/archive/v0.4.5.tar.gz | sudo tar xz -C /opt
+ # Bring Cask into $PATH
+ sudo ln -fs "$CASK_DIR/bin/cask" /usr/local/bin
+fi