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

Fix warnings in tests and compile tests #12

Merged
merged 8 commits into from
Oct 15, 2024
Merged
1 change: 0 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ jobs:
strategy:
matrix:
emacs_version:
- 24.3
- 24.5
- 25.3
- 26.3
Expand Down
38 changes: 24 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
EMACS ?= emacs
BATCH_W_ERROR = -batch --eval "(setq byte-compile-error-on-warn t)"

# A space-separated list of required package names
NEEDED_PACKAGES = package-lint ert
NEEDED_PACKAGES = package-lint

INIT_PACKAGES="(progn \
(require 'package) \
Expand All @@ -14,23 +15,32 @@ INIT_PACKAGES="(progn \
(package-install pkg))) \
)"

all: compile test package-lint clean-elc
all: compile-tests test package-lint clean-elc

package-lint:
${EMACS} -Q --eval ${INIT_PACKAGES} -batch -f package-lint-batch-and-exit hcl-mode.el

compile: clean-elc
${EMACS} -Q --eval ${INIT_PACKAGES} -L . -batch -f batch-byte-compile *.el

test:
$(EMACS) -Q --eval ${INIT_PACKAGES} -L . -batch \
-l test/test-helper.el \
-l test/test-indentation.el \
-l test/test-command.el \
-l test/test-highlighting.el \
${EMACS} --eval ${INIT_PACKAGES} $(BATCH_W_ERROR) -f package-lint-batch-and-exit hcl-mode.el

hcl-mode.elc: hcl-mode.el Makefile
${EMACS} $(BATCH_W_ERROR) -f batch-byte-compile $<

test/test-helper.elc: test/test-helper.el hcl-mode.elc
${EMACS} -L . $(BATCH_W_ERROR) -f batch-byte-compile $<

TESTS-EL = test/test-command.el test/test-highlighting.el test/test-indentation.el
TESTS-ELC = test/test-command.elc test/test-highlighting.elc test/test-indentation.elc
$(TESTS-ELC): test/test-helper.elc hcl-mode.elc $(TESTS-EL)
${EMACS} -L . -l test/test-helper.elc $(BATCH_W_ERROR) -f batch-byte-compile test/test-command.el test/test-highlighting.el test/test-indentation.el
compile-tests: $(TESTS-ELC)

test: $(TESTS-ELC)
$(EMACS) -L . -batch \
-l test/test-helper.elc \
-l test/test-indentation.elc \
-l test/test-command.elc \
-l test/test-highlighting.elc \
-f ert-run-tests-batch-and-exit

clean-elc:
rm -f f.elc

.PHONY: all compile clean-elc package-lint test
.PHONY: all clean-elc package-lint test
2 changes: 1 addition & 1 deletion test/test-command.el
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;;; test-command.el --- test commands of hcl-mode
;;; test-command.el --- test commands of hcl-mode -*- lexical-binding: t -*-

;; Copyright (C) 2017 by Syohei YOSHIDA

Expand Down
10 changes: 8 additions & 2 deletions test/test-helper.el
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;;; test-helper.el --- helper for testing hcl-mode
;;; test-helper.el --- helper for testing hcl-mode -*- lexical-binding: t -*-

;; Copyright (C) 2017 by Syohei YOSHIDA

Expand All @@ -23,14 +23,20 @@

(require 'hcl-mode)

(if (fboundp 'font-lock-ensure)
(defalias 'hcl-mode--font-lock-ensure 'font-lock-ensure)
;; `font-lock-ensure' didn't exist prior to Emacs 25
(defun hcl-mode--font-lock-ensure ()
(with-no-warnings (font-lock-fontify-buffer))))

(defmacro with-hcl-temp-buffer (code &rest body)
"Insert `code' and enable `hcl-mode'. cursor is beginning of buffer"
(declare (indent 0) (debug t))
`(with-temp-buffer
(insert ,code)
(goto-char (point-min))
(hcl-mode)
(font-lock-fontify-buffer)
(hcl-mode--font-lock-ensure)
,@body))

(defun forward-cursor-on (pattern)
Expand Down
2 changes: 1 addition & 1 deletion test/test-highlighting.el
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;;; test-highlighting.el --- test for highlighting of hcl-mode
;;; test-highlighting.el --- test for highlighting of hcl-mode -*- lexical-binding: t -*-

;; Copyright (C) 2017 by Syohei YOSHIDA

Expand Down
2 changes: 1 addition & 1 deletion test/test-indentation.el
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;;; test-indentation.el --- test for indentation
;;; test-indentation.el --- test for indentation -*- lexical-binding: t -*-

;; Copyright (C) 2014 by Syohei YOSHIDA

Expand Down
Loading