Skip to content

Commit

Permalink
feat: add basic test (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
kiennq committed Apr 8, 2020
1 parent 12406d6 commit b761e41
Show file tree
Hide file tree
Showing 6 changed files with 151 additions and 1 deletion.
42 changes: 42 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@
tags
.DS_Store
.#*
*.elc
dist/
.cask/
.cask/
emacs_backtrace.*
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions mini-modeline.el
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
(require 'dash)
(require 'frame)
(require 'timer)
(require 'face-remap)

(eval-when-compile
(require 'subr-x)
Expand Down
53 changes: 53 additions & 0 deletions test/bootstrap.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
;;; bootstrap.el --- -*- lexical-binding: t; -*-

;; Copyright (C) 2020

;; Author: Kien Nguyen <kien.n.quang <at> 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 <https://www.gnu.org/licenses/>.

;;; 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
42 changes: 42 additions & 0 deletions test/test-utils.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
;;; test-utils.el --- -*- lexical-binding: t; -*-

;; Copyright (C) 2020

;; Author: Kien Nguyen <kien.n.quang <at> 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 <https://www.gnu.org/licenses/>.

;;; 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

0 comments on commit b761e41

Please sign in to comment.