Skip to content

Commit 02c9748

Browse files
committed
Implement testing with existing tests
The code that's being removed here made no sense. It is a `check` rule, and it did the following things: 1. For every `.el` file it was searching its `tests.el` counterpart. Which doesn't exist. 2. It was checking the correctness of `declare-function`s. Which would be fine, wasn't it for the fact the project has zero `declare-function`s. 3. It was checking that `ert` exists, which it does on all supported Emacs versions. 4. It was removing .elc files before running the tests. Why? 🤷‍♂️ Replace everything with a single `test` rule which simply loads the test files and runs the tests. Besides being actually useful, this also improves running time as: Initial state | Before | After | Non-compiled | 2.177 | 1.614 | Compiled | 2.182 | 0.340 |
1 parent eae0f4a commit 02c9748

File tree

2 files changed

+10
-22
lines changed

2 files changed

+10
-22
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ jobs:
2929

3030
- uses: actions/checkout@v2
3131
- name: Run tests
32-
run: make check
32+
run: make test

Makefile

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,43 +23,31 @@ ELFILES = \
2323
purescript-unicode-input-method.el \
2424
purescript-utils.el \
2525
purescript-decl-scan.el \
26-
purescript-yas.el
26+
purescript-yas.el \
27+
tests/purescript-sort-imports-tests.el \
28+
tests/purescript-str-tests.el
2729

2830
ELCFILES = $(ELFILES:.el=.elc)
2931
AUTOLOADS = purescript-mode-autoloads.el
3032

3133
PKG_DIST_FILES = $(ELFILES) logo.svg NEWS purescript-mode.info dir
3234
PKG_TAR = purescript-mode-$(VERSION).tar
33-
ELCHECKS=$(addprefix check-, $(ELFILES:.el=))
3435

3536
%.elc: %.el
3637
@$(BATCH) \
3738
--eval "(setq byte-compile-error-on-warn t)" -f batch-byte-compile $<
3839

39-
.PHONY: all compile info clean check $(ELCHECKS) elpa package
40+
.PHONY: all compile info clean test elpa package
4041

4142
all: compile $(AUTOLOADS) info
4243

4344
compile: $(ELCFILES)
4445

45-
$(ELCHECKS): check-%: %.el
46-
@$(BATCH) --eval '(when (check-declare-file "$*.el") (error "check-declare failed"))'
47-
@$(BATCH) \
48-
--eval "(setq byte-compile-error-on-warn t)" \
49-
-f batch-byte-compile $*.el
50-
@$(RM) $*.elc
51-
@if [ -f "$(<:%.el=tests/%-tests.el)" ]; then \
52-
if $(BATCH) --eval "(require 'ert)" 2> /dev/null; then \
53-
echo; \
54-
$(BATCH) -l "$(<:%.el=tests/%-tests.el)" -f ert-run-tests-batch-and-exit; \
55-
else \
56-
echo "ERT not available, skipping unit tests"; \
57-
fi; \
58-
fi
59-
@echo "--"
60-
61-
check: clean $(ELCHECKS)
62-
@echo "checks passed!"
46+
test: compile
47+
@$(BATCH) -l tests/purescript-sort-imports-tests.elc \
48+
-l tests/purescript-str-tests.elc \
49+
-f ert-run-tests-batch-and-exit
50+
@echo "tests passed!"
6351

6452
clean:
6553
$(RM) $(ELCFILES) $(AUTOLOADS) $(AUTOLOADS:.el=.elc) $(PKG_TAR) purescript-mode.tmp.texi purescript-mode.info dir

0 commit comments

Comments
 (0)