-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathMakefile
108 lines (92 loc) · 3.38 KB
/
Makefile
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
SHELL = bash
EMACS ?= emacs
PORT ?= 8000
PACKAGES = packages
FONT_SIZE ?= 180
ENV ?= .venv
ACTIVATE = source $(ENV)/bin/activate
MAX_LINE_LEN = 80
WAIT_TIME ?= 0.5
SELECTOR ?= t
.PHONY: test
help: ## Display this help message.
@printf 'Summary of available Makefile recipes:\n\n'
@grep '##' Makefile | grep -v grep | column -t -s '##'
@echo
setup-tests: ## Install everything required for testing (Python dependencies).
python3 --version
test -d $(ENV) || python3 -m venv $(ENV)
$(ACTIVATE) && \
pip install -U pip wheel setuptools && \
pip install -r test/requirements-dev.txt
test: ## Run all ERT tests (set SELECTOR to specify only one).
test: clean server-bg
sleep $(WAIT_TIME)
$(EMACS) --batch -L . \
-l test/verb-test.el \
--eval "(ert-run-tests-batch-and-exit '$(SELECTOR))"; \
ret=$$?; \
make server-kill; \
exit $$ret
test-noserver:
$(EMACS) --batch -L . \
-l test/verb-test.el \
--eval "(ert-run-tests-batch-and-exit '$(SELECTOR))"; \
server: ## Run a testing HTTP server on port 8000 (default).
$(ACTIVATE) && \
SKIP_PIDFILE=1 PORT=$(PORT) python3 test/server.py
server-bg:
$(ACTIVATE) && \
PORT=$(PORT) python3 test/server.py &
server-kill:
kill $$(cat test/server.pid)
sleep 1
clean: ## Clean up all temporary files created during testing/runtime.
rm -f verb-autoloads.el test/server.pid
find . -name "*.elc" -type f -delete
setup-check: ## Install packages required for linting.
rm -rf $(PACKAGES)
$(EMACS) --batch \
--eval "(setq package-user-dir \"$$PWD/$(PACKAGES)\")" \
-l test/init-check.el
setup: setup-check setup-tests
lint-file:
@printf "\n<<<------------ Lint file: $(filename) ------------>>>\n"
@printf "\n--> Step: Byte-compile file\n\n"
$(EMACS) --batch -L . \
--eval "(setq byte-compile-error-on-warn t)" \
-f batch-byte-compile "$(filename)"
@printf "\n--> Step: Run checkdoc\n\n"
yes n | $(EMACS) --batch \
-l test/checkdoc-batch.el \
-f checkdoc-batch-and-exit "$(filename)"
@printf "\n--> Step: Run package-lint\n\n"
$(EMACS) --batch --eval "(setq package-user-dir \"$$PWD/$(PACKAGES)\")" \
--eval "(package-initialize)" \
--eval "(require 'package-lint)" \
-f package-lint-batch-and-exit "$(filename)"
@printf "\n--> Step: Run relint\n\n"
$(EMACS) --batch --eval "(setq package-user-dir \"$$PWD/$(PACKAGES)\")" \
--eval "(package-initialize)" \
--eval "(require 'relint)" \
-f relint-batch "$(filename)"
@printf "\n--> Step: Ensure maximum line length\n\n"
! grep -n '.\{$(MAX_LINE_LEN)\}' "$(filename)"
check: ## Lint all Emacs Lisp files in the package.
check: clean
make lint-file filename=verb.el
make lint-file filename=verb-util.el
make lint-file filename=ob-verb.el
test $$(cat *.el | grep Package-Version | uniq | wc -l) -eq 1
update: ## Update the package version number (version=X.Y.Z).
update:
@test -n "$(version)" || (echo "version not set!" && exit 1)
@grep -q "$(version)" CHANGELOG.md || (echo "Update changelog first!" && exit 1)
sed -i -e "s/^;; Package-Version: .*/;; Package-Version: $(version)/g" verb.el ob-verb.el verb-util.el
sed -i -e "s/defconst verb-version .*/defconst verb-version \"$(version)\"/g" verb.el
run: ## Run emacs -Q with the working version of verb.el loaded.
run: clean server-bg
make run-noserver; \
make server-kill
run-noserver: ## Same as "run", but without the test HTTP server running.
FONT_SIZE=$(FONT_SIZE) $(EMACS) -Q -L . --load test/init.el