Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add unit test suite, disable test-checks #507

Merged
merged 1 commit into from
Nov 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


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!
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You also link to buttercup's docs here.

;; 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")))