Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
181 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ | |
|
||
# Emacs byte-compiled files | ||
*.elc | ||
.cask |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
language: emacs-lisp | ||
env: | ||
- EMACS=emacs24 | ||
- EMACS=emacs-snapshot | ||
before_install: | ||
# Stable Emacs 24.3 | ||
- sudo add-apt-repository -y ppa:cassou/emacs | ||
# Nightly Emacs snapshot builds | ||
- sudo add-apt-repository -y ppa:ubuntu-elisp/ppa | ||
# Update and install the Emacs for our environment | ||
- sudo apt-get update -qq | ||
- sudo apt-get install -qq -yy ${EMACS}-nox | ||
# Install and bootstrap cask | ||
- curl -fsSkL https://raw.github.com/cask/cask/master/go | python | ||
- export PATH="${HOME}/.cask/bin:$PATH" | ||
install: | ||
- cask install | ||
script: | ||
- make compile test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
(source gnu) | ||
(source melpa) | ||
|
||
(package-file "clojure-mode.el") | ||
|
||
(development | ||
(depends-on "ert-runner")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
CASK = cask | ||
EMACS = emacs | ||
EMACSFLAGS = | ||
TESTFLAGS = | ||
|
||
export EMACS | ||
|
||
PKGDIR := $(shell EMACS=$(EMACS) $(CASK) package-directory) | ||
|
||
SRCS = clojure-mode.el | ||
OBJS = $(SRCS:.el=.elc) | ||
|
||
.PHONY: compile test clean | ||
|
||
compile: $(OBJS) | ||
|
||
clean: | ||
rm -f $(OBJS) | ||
|
||
test: $(PKGDIR) | ||
$(CASK) exec ert-runner $(TESTFLAGS) | ||
|
||
%.elc : %.el $(PKGDIR) | ||
$(CASK) exec $(EMACS) -Q --batch $(EMACSFLAGS) -f batch-byte-compile $< | ||
|
||
$(PKGDIR) : Cask | ||
$(CASK) install | ||
touch $(PKGDIR) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
;;; clojure-mode-test.el --- Clojure Mode: Unit test suite -*- lexical-binding: t; -*- | ||
|
||
;; Copyright (C) 2014 Bozhidar Batsov <bozhidar@batsov.com> | ||
|
||
;; This file is not part of GNU Emacs. | ||
|
||
;; This program is free software; you can redistribute it and/or modify | ||
;; it under the terms of the GNU General Public License as published by | ||
;; the Free Software Foundation, either version 3 of the License, or | ||
;; (at your option) any later version. | ||
|
||
;; This program is distributed in the hope that it will be useful, | ||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
;; GNU General Public License for more details. | ||
|
||
;; You should have received a copy of the GNU General Public License | ||
;; along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
;;; Commentary: | ||
|
||
;; The unit test suite of Clojure Mode | ||
|
||
;;; Code: | ||
|
||
(require 'clojure-mode) | ||
(require 'ert) | ||
|
||
|
||
;;;; Utilities | ||
|
||
(defmacro clojure-test-with-temp-buffer (content &rest body) | ||
"Evaluate BODY in a temporary buffer with CONTENTS." | ||
(declare (debug t) | ||
(indent 1)) | ||
`(with-temp-buffer | ||
(insert ,content) | ||
(clojure-mode) | ||
(font-lock-fontify-buffer) | ||
(goto-char (point-min)) | ||
,@body)) | ||
|
||
(defun clojure-test-face-at (pos &optional content) | ||
"Get the face at POS in CONTENT. | ||
If CONTENT is not given, return the face at POS in the current | ||
buffer." | ||
(if content | ||
(clojure-test-with-temp-buffer content | ||
(get-text-property pos 'face)) | ||
(get-text-property pos 'face))) | ||
|
||
(defconst clojure-test-syntax-classes | ||
[whitespace punctuation word symbol open-paren close-paren expression-prefix | ||
string-quote paired-delim escape character-quote comment-start | ||
comment-end inherit generic-comment generic-string] | ||
"Readable symbols for syntax classes. | ||
Each symbol in this vector corresponding to the syntax code of | ||
its index.") | ||
|
||
(defun clojure-test-syntax-at (pos) | ||
"Get the syntax at POS. | ||
Get the syntax class symbol at POS, or nil if there is no syntax a | ||
POS." | ||
(let ((code (syntax-class (syntax-after pos)))) | ||
(aref clojure-test-syntax-classes code))) | ||
|
||
|
||
;;;; Font locking | ||
|
||
(ert-deftest clojure-mode-syntax-table/fontify-clojure-keyword () | ||
:tags '(fontification syntax-table) | ||
(should (eq (clojure-test-face-at 2 "{:something 20}") 'font-lock-constant-face))) | ||
|
||
(provide 'clojure-mode-test) | ||
|
||
;; Local Variables: | ||
;; indent-tabs-mode: nil | ||
;; End: | ||
|
||
;;; clojure-mode-test.el ends here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
;;; test-helper.el --- Clojure Mode: Non-interactive unit-test setup -*- lexical-binding: t; -*- | ||
|
||
;; Copyright (C) 2014 Bozhidar Batsov <bozhidar@batsov.com> | ||
|
||
;; This file is not part of GNU Emacs. | ||
|
||
;; This program is free software; you can redistribute it and/or modify | ||
;; it under the terms of the GNU General Public License as published by | ||
;; the Free Software Foundation, either version 3 of the License, or | ||
;; (at your option) any later version. | ||
|
||
;; This program is distributed in the hope that it will be useful, | ||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
;; GNU General Public License for more details. | ||
|
||
;; You should have received a copy of the GNU General Public License | ||
;; along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
;;; Commentary: | ||
|
||
;; Non-interactive test suite setup for ERT Runner. | ||
|
||
;;; Code: | ||
|
||
(message "Running tests on Emacs %s" emacs-version) | ||
|
||
(let* ((current-file (if load-in-progress load-file-name (buffer-file-name))) | ||
(source-directory (locate-dominating-file current-file "Cask")) | ||
;; Do not load outdated byte code for tests | ||
(load-prefer-newer t)) | ||
;; Load the file under test | ||
(load (expand-file-name "clojure-mode" source-directory))) | ||
|
||
;; Local Variables: | ||
;; indent-tabs-mode: nil | ||
;; End: | ||
|
||
;;; test-helper.el ends here |