Skip to content

Commit b648244

Browse files
xiongtxbbatsov
authored andcommitted
Add byte-comp and checkdoc tests
1 parent 464c4dd commit b648244

File tree

4 files changed

+88
-10
lines changed

4 files changed

+88
-10
lines changed

.travis.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
sudo: false
22
language: emacs-lisp
33
env:
4-
- EMACS_BINARY=emacs-24.4-travis
5-
- EMACS_BINARY=emacs-24.5-travis
6-
- EMACS_BINARY=emacs-25.1-travis
7-
- EMACS_BINARY=emacs-25.2-travis
4+
- EMACS_BINARY=emacs-24.4-travis MAKE_TEST=test
5+
- EMACS_BINARY=emacs-24.4-travis MAKE_TEST=test-bytecomp
6+
- EMACS_BINARY=emacs-24.5-travis MAKE_TEST=test
7+
- EMACS_BINARY=emacs-24.5-travis MAKE_TEST=test-bytecomp
8+
- EMACS_BINARY=emacs-25.1-travis MAKE_TEST=test
9+
- EMACS_BINARY=emacs-25.1-travis MAKE_TEST=test-bytecomp
10+
- EMACS_BINARY=emacs-25.2-travis MAKE_TEST=test
11+
- EMACS_BINARY=emacs-25.2-travis MAKE_TEST=test-bytecomp
12+
- EMACS_BINARY=emacs-25.2-travis MAKE_TEST=test-checks
813
- EMACS_BINARY=emacs-git-snapshot-travis
914
matrix:
1015
allow_failures:
@@ -15,4 +20,4 @@ before_script:
1520
- make elpa
1621
script:
1722
- emacs --version
18-
- make compile test
23+
- make $MAKE_TEST

Makefile

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,12 @@ clean:
2525
test: $(PKGDIR)
2626
$(CASK) exec ert-runner $(TESTFLAGS)
2727

28-
%.elc : %.el $(PKGDIR)
29-
$(CASK) exec $(EMACS) -Q --batch $(EMACSFLAGS) -f batch-byte-compile $<
28+
test-checks:
29+
$(CASK) exec $(EMACS) --no-site-file --no-site-lisp --batch \
30+
-l test/test-checks.el ./
3031

31-
$(PKGDIR) : Cask
32-
$(CASK) install
33-
touch $(PKGDIR)
32+
test-bytecomp: $(SRCS:.el=.elc-test)
33+
34+
%.elc-test: %.el elpa
35+
$(CASK) exec $(EMACS) --no-site-file --no-site-lisp --batch \
36+
-l test/clojure-mode-bytecomp-warnings.el $
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
;;; clojure-mode-bytecomp-warnings.el --- Check for byte-compilation problems
2+
3+
;; Copyright © 2012-2017 Bozhidar Batsov and contributors
4+
;;
5+
;; This program is free software: you can redistribute it and/or modify
6+
;; it under the terms of the GNU General Public License as published by
7+
;; the Free Software Foundation, either version 3 of the License, or
8+
;; (at your option) any later version.
9+
10+
;; This program is distributed in the hope that it will be useful,
11+
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
;; GNU General Public License for more details.
14+
15+
;; You should have received a copy of the GNU General Public License
16+
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
18+
;; This file is not part of GNU Emacs.
19+
20+
;;; Commentary:
21+
22+
;; This is a script to be loaded while visiting a `clojure-mode' source file.
23+
;; It will prepare all requirements and then byte-compile the file and signal an
24+
;; error on any warning. For example:
25+
;;
26+
;; emacs -Q --batch -l test/clojure-mode-bytecomp-warnings.el clojure-mode.el
27+
28+
;; This assumes that all `clojure-mode' dependencies are already on the package
29+
;; dir (probably from running `cask install').
30+
31+
(setq load-prefer-newer t)
32+
(add-to-list 'load-path (expand-file-name "./"))
33+
(require 'package)
34+
(package-generate-autoloads 'clojure-mode default-directory)
35+
(package-initialize)
36+
(load-file "clojure-mode-autoloads.el")
37+
(setq byte-compile-error-on-warn t)
38+
(batch-byte-compile)
39+
40+
;;; clojure-mode-bytecomp-warnings.el ends here

test/test-checks.el

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
;; This is a script to be loaded from the root `clojure-mode' directory. It will
2+
;; prepare all requirements and then run `check-declare-directory' on
3+
;; `default-directory'. For example: emacs -Q --batch -l test/test-checkdoc.el
4+
5+
;; This assumes that all `clojure-mode' dependencies are already on the package
6+
;; dir (probably from running `cask install').
7+
8+
(add-to-list 'load-path (expand-file-name "./"))
9+
(require 'package)
10+
(require 'check-declare)
11+
(package-initialize)
12+
13+
;; disable some annoying (or non-applicable) checkdoc checks
14+
(setq checkdoc-package-keywords-flag nil)
15+
(setq checkdoc-arguments-in-order-flag nil)
16+
(setq checkdoc-verb-check-experimental-flag nil)
17+
18+
(let ((files (directory-files default-directory t
19+
"\\`[^.].*\\.el\\'" t)))
20+
21+
;; `checkdoc-file' was introduced in Emacs 25
22+
(when (fboundp 'checkdoc-file)
23+
(dolist (file files)
24+
(checkdoc-file file))
25+
(when (get-buffer "*Warnings*")
26+
(message "Failing due to checkdoc warnings...")
27+
(kill-emacs 1)))
28+
29+
(when (apply #'check-declare-files files)
30+
(kill-emacs 1)))

0 commit comments

Comments
 (0)