From b761e41479a2564e801ac6c427956203de3d62ca Mon Sep 17 00:00:00 2001 From: kiennq Date: Wed, 8 Apr 2020 16:23:50 +0900 Subject: [PATCH] feat: add basic test (#30) --- .github/workflows/test.yml | 42 ++++++++++++++++++++++++++++++ .gitignore | 4 ++- Makefile | 10 +++++++ mini-modeline.el | 1 + test/bootstrap.el | 53 ++++++++++++++++++++++++++++++++++++++ test/test-utils.el | 42 ++++++++++++++++++++++++++++++ 6 files changed, 151 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/test.yml create mode 100644 Makefile create mode 100644 test/bootstrap.el create mode 100644 test/test-utils.el diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..d6ffca4 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,42 @@ +name: "CI" +on: + pull_request: + paths-ignore: + - '**.md' + - '**.org' + - '.dir-locals.el' + branches: + - master + push: + paths-ignore: + - '**.md' + - '**.org' + - '.dir-locals.el' + +jobs: + build: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + emacs_version: + - 25.1 + - 25.2 + - 25.3 + - 26.1 + - 26.2 + - 26.3 + - snapshot + + steps: + - uses: purcell/setup-emacs@master + with: + version: ${{ matrix.emacs_version }} + + - uses: actions/checkout@v2 + + - name: Check emacs version + run: emacs --version + + - name: Test + run: make test diff --git a/.gitignore b/.gitignore index 706ed6a..394c449 100755 --- a/.gitignore +++ b/.gitignore @@ -3,5 +3,7 @@ tags .DS_Store .#* +*.elc dist/ -.cask/ \ No newline at end of file +.cask/ +emacs_backtrace.* \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..931445d --- /dev/null +++ b/Makefile @@ -0,0 +1,10 @@ +.PHONY : test + +EMACS ?= emacs + +LOADPATH = -L . -L ./test + +test: + $(EMACS) -Q -batch $(LOADPATH) \ + -l test/test-utils.el \ + -f ert-run-tests-batch-and-exit diff --git a/mini-modeline.el b/mini-modeline.el index f523c98..efdc63b 100755 --- a/mini-modeline.el +++ b/mini-modeline.el @@ -32,6 +32,7 @@ (require 'dash) (require 'frame) (require 'timer) +(require 'face-remap) (eval-when-compile (require 'subr-x) diff --git a/test/bootstrap.el b/test/bootstrap.el new file mode 100644 index 0000000..7e3f948 --- /dev/null +++ b/test/bootstrap.el @@ -0,0 +1,53 @@ +;;; bootstrap.el --- -*- lexical-binding: t; -*- + +;; Copyright (C) 2020 + +;; Author: Kien Nguyen gmail.com> + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . + +;;; Commentary: + +;; + +;;; Code: +(require 'package) + +(let* ((package-archives '(("melpa" . "https://melpa.org/packages/") + ("gnu" . "https://elpa.gnu.org/packages/"))) + (no-byte-compile t) + (user-emacs-directory (expand-file-name (make-temp-name ".emacs.d") + "~")) + (package-user-dir (expand-file-name (make-temp-name "mimo-tmp-elpa") + user-emacs-directory)) + (custom-file (expand-file-name "custom.el" package-user-dir)) + (deps '(dash f))) + (package-initialize) + + ;; bootstrap quelpa + (unless (package-installed-p 'quelpa) + (with-temp-buffer + (url-insert-file-contents "https://github.com/quelpa/quelpa/raw/master/quelpa.el") + (eval-buffer) + (quelpa-self-upgrade))) + + (mapc (lambda (pkg) + (quelpa pkg) + (require pkg)) + deps) + (add-hook 'kill-emacs-hook `(lambda () + (delete-directory ,user-emacs-directory t)))) + +(provide 'bootstrap) +;;; bootstrap.el ends here diff --git a/test/test-utils.el b/test/test-utils.el new file mode 100644 index 0000000..6237287 --- /dev/null +++ b/test/test-utils.el @@ -0,0 +1,42 @@ +;;; test-utils.el --- -*- lexical-binding: t; -*- + +;; Copyright (C) 2020 + +;; Author: Kien Nguyen gmail.com> + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . + +;;; Commentary: + +;; + +;;; Code: +(require 'bootstrap) +(require 'ert) + +(ert-deftest mimo-byte-compilation-test () + (seq-doseq (library (-filter + (lambda (file) + (and (f-ext? file "el") + (not (string-match-p "test" file)))) + (append (when (or load-file-name buffer-file-name) + (f-files (f-parent (f-dirname (or load-file-name buffer-file-name))))) + (f-files default-directory)))) + (let ((byte-compile-error-on-warn t)) + (message "Testing file %s" library) + (should (byte-compile-file (save-excursion + (find-library library) + (buffer-file-name))))))) + +;;; test-utils.el ends here