Skip to content

Commit

Permalink
Add unit test suite, disable test-checks (#507)
Browse files Browse the repository at this point in the history
Reflects the decisions we made over #493.

Code has been copied as is, except for the unit tests in question, which are for `cljr--ns-name` (as a random example that I picked).
  • Loading branch information
vemv committed Nov 18, 2021
1 parent af1bde5 commit 363b95c
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 16 deletions.
5 changes: 3 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ default: &default-steps
- run: make test
# Make sure to run test-checks before test-bytecomp, as test-bytecomp autogenerates
# files which won't pass test-checks.
- run: make test-checks
- run: make test-bytecomp
# disabled - see https://github.com/clojure-emacs/clj-refactor.el/issues/491
#- run: make test-checks
#- run: make test-bytecomp

# Enumerated list of Emacs versions
jobs:
Expand Down
3 changes: 2 additions & 1 deletion Cask
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@

(development
(depends-on "ecukes")
(depends-on "espuds"))
(depends-on "espuds")
(depends-on "buttercup"))
9 changes: 7 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ PKGDIR := $(shell EMACS=$(EMACS) $(CASK) package-directory)
SRCS = $(wildcard *.el)
OBJS = $(SRCS:.el=.elc)

.PHONY: compile test clean elpa
.PHONY: compile unit-tests integration-tests test clean elpa

all: compile

Expand All @@ -28,9 +28,14 @@ compile: elpa
clean:
rm -f $(OBJS)

test: $(PKGDIR)
integration-tests: $(PKGDIR)
$(CASK) exec ecukes --no-win

unit-tests:
$(CASK) exec buttercup -L .

test: unit-tests integration-tests

test-checks:
$(CASK) exec $(EMACS) --no-site-file --no-site-lisp --batch \
-l test/test-checks.el ./
Expand Down
1 change: 1 addition & 0 deletions feature/feature.el
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(provide 'feature)
23 changes: 12 additions & 11 deletions test/test-checks.el
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,17 @@
(setq checkdoc-arguments-in-order-flag nil)
(setq checkdoc-verb-check-experimental-flag nil)

(let ((files (directory-files default-directory t
"\\`[^.].*\\.el\\'" t)))
(when (not (getenv "CI")) ;; See https://github.com/clojure-emacs/clj-refactor.el/issues/491
(let ((files (directory-files default-directory t
"\\`[^.].*\\.el\\'" t)))

;; `checkdoc-file' was introduced in Emacs 25
(when (fboundp 'checkdoc-file)
(dolist (file files)
(checkdoc-file file))
(when (get-buffer "*Warnings*")
(message "Failing due to checkdoc warnings...")
(kill-emacs 1)))
;; `checkdoc-file' was introduced in Emacs 25
(when (fboundp 'checkdoc-file)
(dolist (file files)
(checkdoc-file file))
(when (get-buffer "*Warnings*")
(message "Failing due to checkdoc warnings...")
(kill-emacs 1)))

(when (apply #'check-declare-files files)
(kill-emacs 1)))
(when (apply #'check-declare-files files)
(kill-emacs 1))))
11 changes: 11 additions & 0 deletions tests/unit-test.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
(require 'paredit)
(require 'clj-refactor)

;; NOTE: please remember, without an `it` block, your tests will not be run!
;; You can learn about Buttercup's syntax here:
;; https://github.com/jorgenschaefer/emacs-buttercup/blob/v1.24/docs/running-tests.md

(describe "cljr--ns-name"
(it "returns the ns name of its argument"
(expect (cljr--ns-name "com.corp.foo") :to-equal "foo")
(expect (cljr--ns-name "foo") :to-equal "foo")))

0 comments on commit 363b95c

Please sign in to comment.