Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .ert-runner
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-L .
--quiet
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
*\~
._*
/.cask/
/dist/
9 changes: 9 additions & 0 deletions Cask
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
(source gnu)
(source melpa)

(package-file "elixir-mode.el")

(files "*.el")

(development
(depends-on "ert-runner"))
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,6 @@ add the following in your .emacs file:
<td><code>elixir-mode-open-docs-stable</code></td>
<td>Open the Elixir documentation for the latest stable release.</td>
</tr>
<tr>
<td><code>elixir-mode-run-tests</code></td>
<td>Run ERT tests for `elixir-mode`.</td>
</tr>
<tr>
<td><code>elixir-mode-show-version</code></td>
<td>Print version info for elixir-mode.</td>
Expand Down
28 changes: 0 additions & 28 deletions elixir-mode-tests.el

This file was deleted.

11 changes: 0 additions & 11 deletions elixir-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,6 @@
;;
;; Open the Elixir documentation for the latest stable release.
;;
;; M-x elixir-mode-run-tests
;;
;; Run ERT tests for `elixir-mode`.
;;
;; M-x elixir-mode-show-version
;;
;; Print `elixir-mode` version.
Expand Down Expand Up @@ -667,13 +663,6 @@ Argument END End of the region."
:keymap '(("q" . quit-window))
(setq buffer-read-only t))

;;;###autoload
(defun elixir-mode-run-tests ()
"Run ERT test for `elixir-mode'."
(interactive)
(load "elixir-mode-tests")
(ert-run-tests-interactively "^elixir-ert-.*$"))

;; Invoke elixir-mode when appropriate

;;;###autoload
Expand Down
8 changes: 0 additions & 8 deletions ert-bootstrap.el

This file was deleted.

36 changes: 0 additions & 36 deletions run_tests

This file was deleted.

10 changes: 0 additions & 10 deletions test/elixir-mode-font-tests.el → test/elixir-mode-font-test.el
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
;; `elixir-test-with-temp-buffer' and `elixir-test-face-at' are both slightly
;; modified versions of the original at
;; https://github.com/lunaryorn/puppet-mode/blob/master/test/puppet-mode-test.el
(defmacro elixir-test-with-temp-buffer (content &rest body)
"Evaluate BODY in a temporary buffer with CONTENTS."
(declare (debug t)
(indent 1))
`(with-temp-buffer
(insert ,content)
(elixir-mode)
(font-lock-fontify-buffer)
(goto-char (point-min))
,@body))

(defun elixir-test-face-at (pos &optional content)
"Get the face at POS in CONTENT.
Expand Down
48 changes: 48 additions & 0 deletions test/test-helper.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@

(require 'ert-x)

(message "Running tests on Emacs %s" emacs-version)

;; The test fixtures assume an indentation width of 2, so we need to set that
;; up for the tests.
(setq-default default-tab-width 2
indent-tabs-mode nil)

;; Load the elixir-mode under test
(require 'elixir-mode)

;; Helpers

(defmacro* elixir-deftest (name args &body body)
(declare (indent 2)
(&define :name test name sexp
[&optional [":documentation" stringp]]
[&optional [":expected-result" sexp]]
def-body))
`(ert-deftest ,(intern (format "elixir-ert-%s" name)) ()
""
,@args
(let ((elixir-smie-verbose-p t))
,@body)))

(defmacro* elixir-ert-with-test-buffer ((&rest args) initial-contents &body body)
(declare (indent 2))
`(ert-with-test-buffer (,@args)
(elixir-mode)
(insert ,initial-contents)
,@body))

(defmacro elixir-test-with-temp-buffer (content &rest body)
"Evaluate BODY in a temporary buffer with CONTENTS."
(declare (debug t)
(indent 1))
`(with-temp-buffer
(insert ,content)
(elixir-mode)
(font-lock-fontify-buffer)
(goto-char (point-min))
,@body))

(when window-system
(defun ert-runner/run-tests-batch-and-exit (selector)
(ert-run-tests-interactively selector)))