aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: 047039aa8fa70851b749e8c8204bbd161cc38d2a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# Makefile for gloss
# Run `make help' for available targets.

EMACS ?= emacs
EMACSFLAGS = --batch -Q
LOADPATH = -L . -L tests

PACKAGE_FILES = $(filter-out gloss-pkg.el,$(wildcard gloss*.el))
TEST_FILES = $(wildcard tests/test-*.el)
UNIT_TESTS = $(filter-out tests/test-integration-%.el,$(TEST_FILES))
INTEGRATION_TESTS = $(wildcard tests/test-integration-*.el)

.PHONY: help test test-unit test-integration test-file test-name validate-parens compile lint clean

help:
	@echo "Targets:"
	@echo "  make test                     Run all tests"
	@echo "  make test-unit                Unit tests only"
	@echo "  make test-integration         Integration tests only"
	@echo "  make test-file FILE=path/to/test-foo.el   Run one test file"
	@echo "  make test-name TEST=pattern   Run tests whose name matches PATTERN"
	@echo "  make validate-parens          check-parens on every .el"
	@echo "  make compile                  Byte-compile package files"
	@echo "  make lint                     elisp-lint pass"
	@echo "  make clean                    Remove .elc"

test:
	@$(EMACS) $(EMACSFLAGS) $(LOADPATH) -l ert $(addprefix -l ,$(TEST_FILES)) -f ert-run-tests-batch-and-exit

test-unit:
	@$(EMACS) $(EMACSFLAGS) $(LOADPATH) -l ert $(addprefix -l ,$(UNIT_TESTS)) -f ert-run-tests-batch-and-exit

test-integration:
	@$(EMACS) $(EMACSFLAGS) $(LOADPATH) -l ert $(addprefix -l ,$(INTEGRATION_TESTS)) -f ert-run-tests-batch-and-exit

test-file:
	@if [ -z "$(FILE)" ]; then echo "Usage: make test-file FILE=tests/test-NAME.el"; exit 1; fi
	@$(EMACS) $(EMACSFLAGS) $(LOADPATH) -l ert -l "$(FILE)" -f ert-run-tests-batch-and-exit

test-name:
	@if [ -z "$(TEST)" ]; then echo "Usage: make test-name TEST=pattern"; exit 1; fi
	@$(EMACS) $(EMACSFLAGS) $(LOADPATH) -l ert $(addprefix -l ,$(TEST_FILES)) --eval "(ert-run-tests-batch-and-exit \"$(TEST)\")"

validate-parens:
	@for f in $(PACKAGE_FILES) $(TEST_FILES); do \
		echo "  check-parens: $$f"; \
		$(EMACS) --batch --eval "(progn (find-file \"$$f\") (check-parens))" 2>&1 | grep -v '^Loading' || true; \
	done

compile:
	@for f in $(PACKAGE_FILES); do \
		echo "  byte-compile: $$f"; \
		$(EMACS) $(EMACSFLAGS) $(LOADPATH) --eval "(byte-compile-file \"$$f\")"; \
	done

lint:
	@$(EMACS) $(EMACSFLAGS) $(LOADPATH) -l elisp-lint --funcall elisp-lint-files-batch $(PACKAGE_FILES)

clean:
	@rm -f *.elc tests/*.elc