From 8ae8c1823bbcac7d5212ea22446ed23c6830431b Mon Sep 17 00:00:00 2001 From: vemv Date: Thu, 18 Nov 2021 00:15:56 +0100 Subject: [PATCH] Add unit test suite, disable `test-checks` Reflects the decisions we made over https://github.com/clojure-emacs/clj-refactor.el/pull/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). --- .circleci/config.yml | 5 +++-- Cask | 3 ++- Makefile | 9 +++++++-- feature/feature.el | 1 + tests/unit-test.el | 11 +++++++++++ 5 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 feature/feature.el create mode 100644 tests/unit-test.el diff --git a/.circleci/config.yml b/.circleci/config.yml index 32a59b5b..4e2f151b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -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: diff --git a/Cask b/Cask index 4db805f9..1a711d10 100644 --- a/Cask +++ b/Cask @@ -5,4 +5,5 @@ (development (depends-on "ecukes") - (depends-on "espuds")) + (depends-on "espuds") + (depends-on "buttercup")) diff --git a/Makefile b/Makefile index c2ed45de..ce1716b0 100644 --- a/Makefile +++ b/Makefile @@ -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 @@ -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 ./ diff --git a/feature/feature.el b/feature/feature.el new file mode 100644 index 00000000..4d9d9679 --- /dev/null +++ b/feature/feature.el @@ -0,0 +1 @@ +(provide 'feature) diff --git a/tests/unit-test.el b/tests/unit-test.el new file mode 100644 index 00000000..625ffc20 --- /dev/null +++ b/tests/unit-test.el @@ -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")))