diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 57381f9..0df5c07 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,4 +29,4 @@ jobs: - uses: actions/checkout@v2 - name: Run tests - run: make check + run: make test diff --git a/Makefile b/Makefile index 91a391c..4bfef7f 100644 --- a/Makefile +++ b/Makefile @@ -23,43 +23,31 @@ ELFILES = \ purescript-unicode-input-method.el \ purescript-utils.el \ purescript-decl-scan.el \ - purescript-yas.el + purescript-yas.el \ + tests/purescript-sort-imports-tests.el \ + tests/purescript-str-tests.el ELCFILES = $(ELFILES:.el=.elc) AUTOLOADS = purescript-mode-autoloads.el PKG_DIST_FILES = $(ELFILES) logo.svg NEWS purescript-mode.info dir PKG_TAR = purescript-mode-$(VERSION).tar -ELCHECKS=$(addprefix check-, $(ELFILES:.el=)) %.elc: %.el @$(BATCH) \ - -f batch-byte-compile $< + --eval "(setq byte-compile-error-on-warn t)" -f batch-byte-compile $(ELFILES) -.PHONY: all compile info clean check $(ELCHECKS) elpa package +.PHONY: all compile info clean test elpa package all: compile $(AUTOLOADS) info compile: $(ELCFILES) -$(ELCHECKS): check-%: %.el - @$(BATCH) --eval '(when (check-declare-file "$*.el") (error "check-declare failed"))' - @$(BATCH) \ - --eval "(setq byte-compile-error-on-warn t)" \ - -f batch-byte-compile $*.el - @$(RM) $*.elc - @if [ -f "$(<:%.el=tests/%-tests.el)" ]; then \ - if $(BATCH) --eval "(require 'ert)" 2> /dev/null; then \ - echo; \ - $(BATCH) -l "$(<:%.el=tests/%-tests.el)" -f ert-run-tests-batch-and-exit; \ - else \ - echo "ERT not available, skipping unit tests"; \ - fi; \ - fi - @echo "--" - -check: clean $(ELCHECKS) - @echo "checks passed!" +test: compile + @$(BATCH) -l tests/purescript-sort-imports-tests.elc \ + -l tests/purescript-str-tests.elc \ + -f ert-run-tests-batch-and-exit + @echo "tests passed!" clean: $(RM) $(ELCFILES) $(AUTOLOADS) $(AUTOLOADS:.el=.elc) $(PKG_TAR) purescript-mode.tmp.texi purescript-mode.info dir diff --git a/tests/haskell-sort-imports-tests.el b/tests/purescript-sort-imports-tests.el similarity index 89% rename from tests/haskell-sort-imports-tests.el rename to tests/purescript-sort-imports-tests.el index 7670fb2..e24fec1 100644 --- a/tests/haskell-sort-imports-tests.el +++ b/tests/purescript-sort-imports-tests.el @@ -28,7 +28,7 @@ (ert-deftest single-line () (should (with-temp-buffer (insert "import A\n") - (goto-line 1) + (goto-char (point-min)) (purescript-sort-imports) (string= (buffer-string) "import A\n")))) @@ -38,7 +38,7 @@ (insert "import A import B ") - (goto-line 1) + (goto-char (point-min)) (purescript-sort-imports) (string= (buffer-string) "import A @@ -48,7 +48,7 @@ import B (insert "import qualified A import B ") - (goto-line 1) + (goto-char (point-min)) (purescript-sort-imports) (string= (buffer-string) "import qualified A @@ -58,7 +58,7 @@ import B (insert "import qualified \"mtl\" A import B ") - (goto-line 1) + (goto-char (point-min)) (purescript-sort-imports) (string= (buffer-string) "import qualified \"mtl\" A @@ -70,7 +70,7 @@ import B (insert "import B import A ") - (goto-line 1) + (goto-char (point-min)) (purescript-sort-imports) (string= (buffer-string) "import A @@ -83,7 +83,9 @@ import B import B import A ") - (goto-line 2) + ;; test at line 2 + (goto-char (point-min)) + (forward-line 1) (purescript-sort-imports) (string= (buffer-string) "module A where @@ -96,7 +98,9 @@ import B import B import A ") - (goto-line 3) + ;; test at line 3 + (goto-char (point-min)) + (forward-line 2) (purescript-sort-imports) (string= (buffer-string) "module C where @@ -115,7 +119,7 @@ import Data.Aeson.Parser.Internal (decodeWith, decodeStrictWith, import qualified Data.ByteString as B import qualified Data.ByteString.Lazy as L ") - (goto-line 1) + (goto-char (point-min)) (purescript-sort-imports) (string= (buffer-string) "import Data.Aeson.Encode (encode) diff --git a/tests/haskell-str-tests.el b/tests/purescript-str-tests.el similarity index 98% rename from tests/haskell-str-tests.el rename to tests/purescript-str-tests.el index 6273fdb..bfd4e88 100644 --- a/tests/haskell-str-tests.el +++ b/tests/purescript-str-tests.el @@ -1,4 +1,4 @@ -;; unit tests for purescript-str.el +;; unit tests for purescript-str.el -*- lexical-binding: t -*- (require 'ert)