Permalink
Browse files

Added: Cask and ert-runner support

  • Loading branch information...
1 parent 2955076 commit a3421ff7b6796b95b86c9bb6785caf9139513b73 @sviridov sviridov committed Sep 8, 2014
View
@@ -0,0 +1,2 @@
+-L .
+--quiet
View
@@ -1,2 +1,4 @@
*\~
._*
+/.cask/
+/dist/
View
@@ -0,0 +1,9 @@
+(source gnu)
+(source melpa)
+
+(package-file "elixir-mode.el")
+
+(files "*.el")
+
+(development
+ (depends-on "ert-runner"))
View
@@ -102,10 +102,6 @@ add the following in your .emacs file:
<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>
</tr>
View
@@ -1,28 +0,0 @@
-(require 'ert)
-(require 'ert-x)
-
-(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))
-
-(load "test/elixir-mode-indentation-tests.el")
-(load "test/elixir-mode-font-tests.el")
-(load "test/elixir-quoted-minor-mode-tests.el")
-
-(provide 'elixir-mode-tests)
-;;; elixir-mode-tests.el ends here
View
@@ -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.
@@ -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
View
@@ -1,8 +0,0 @@
-;; Add the current directory to load path.
-(add-to-list 'load-path (file-name-directory
- (or load-file-name buffer-file-name)))
-;; 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)
-(setq-default indent-tabs-mode nil)
-(require 'elixir-mode)
View
@@ -1,36 +0,0 @@
-#!/bin/bash
-# -*- shell-script -*-
-OUTPUT=/tmp/test-output.txt
-
-EMACS_BINARY="emacs"
-
-EMACS_VERSION=$1
-if [ -n "$EMACS_VERSION" ]; then
- EMACS_BINARY=`evm bin $EMACS_VERSION`
-fi
-
-LOAD_FILES="-l ert-bootstrap.el -l elixir-mode-tests.el"
-
-$EMACS_BINARY -batch $LOAD_FILES -f ert-run-tests-batch-and-exit 2> $OUTPUT
-
-if [ $? == 0 ]; then
- echo "Success -- All tests passed."
- rm $OUTPUT
-else
- # Give the user to re-do the tests in emacs proper
- cat /tmp/test-output.txt
- while [[ 1 ]]
- do
- read -p "There were test failures. Re-run in regular Emacs? [Yn]" choice
- case $choice in
- n|N)
- break
- ;;
- *)
- $EMACS_BINARY -q $LOAD_FILES -f ert-run-tests-interactively
- break
- ;;
- esac
- done
-fi
-
@@ -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.
View
@@ -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)))

0 comments on commit a3421ff

Please sign in to comment.