Skip to content

Commit

Permalink
Merge pull request #3 from tonini/introduce-testing
Browse files Browse the repository at this point in the history
Introduce testing
  • Loading branch information
tonini committed Oct 24, 2013
2 parents a08e55a + c03d4d8 commit be631a3
Show file tree
Hide file tree
Showing 6 changed files with 102 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
language: emacs-lisp

env:
- EMACS=emacs24
- EMACS=emacs-snapshot

before_script:
- export DEBIAN_FRONTEND='noninteractive'
- sudo apt-add-repository -y ppa:cassou/emacs
- sudo apt-get update -qq
- sudo apt-get install -yy emacs24 emacs24-el emacs24-common-non-dfsg emacs-snapshot emacs-snapshot-el

script:
- make EMACS=${EMACS} test
12 changes: 12 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
EMACS=emacs

.PHONY: show-version test

show-version:
@ echo "### Emacs Information ###"
@ echo "PATH = `which ${EMACS}`"
${EMACS} --version

test: show-version
@ echo "### elixir-mix test suite ###"
${EMACS} -batch -Q -l test/test-runner.el
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# elixir-mix.el

[![Build Status](https://travis-ci.org/tonini/elixir-mix.el.png?branch=introduce-testing)](https://travis-ci.org/tonini/elixir-mix.el)

Integration of Elixir's building and deployment tool: mix into Emacs.

## Installation
Expand Down
6 changes: 6 additions & 0 deletions elixir-mix.el
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,12 @@
(defun elixir-mix--completing-read (prompt command-list)
(completing-read prompt command-list nil t nil nil (car command-list)))

(defun elixir-mix-flatten (alist)
(cond ((null alist) nil)
((atom alist) (list alist))
(t (append (elixir-mix-flatten (car alist))
(elixir-mix-flatten (cdr alist))))))

(defun elixir-mix-new (name)
"Create a new elixir project with mix."
(interactive "Gmix new: ")
Expand Down
50 changes: 50 additions & 0 deletions test/elixir-mix-tests.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
;;; elixir-mix-tests.el --- elixir-mix ert unit tests

;; Copyright © 2013 Samuel Tonini

;; Author: Samuel Tonini
;; Maintainer: Samuel Tonini
;; Description: Integration of Elixir's building and deployment tool: mix into Emacs.
;; Created: So Jun 9 10:01:02 2013 (+0200)
;; URL: https://github.com/tonini/elixir-mix

;; This file is NOT part of GNU Emacs.

;; The MIT License (MIT)
;;
;; Copyright (c) Samuel Tonini
;;
;; Permission is hereby granted, free of charge, to any person obtaining a copy of
;; this software and associated documentation files (the "Software"), to deal in
;; the Software without restriction, including without limitation the rights to
;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
;; the Software, and to permit persons to whom the Software is furnished to do so,
;; subject to the following conditions:
;;
;; The above copyright notice and this permission notice shall be included in all
;; copies or substantial portions of the Software.
;;
;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
;; FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
;; COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
;; IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
;; CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

;;; Commentary:

;;; Code:

(provide 'elixir-mix-tests)

(require 'ert)
(require 'elixir-mix)

(ert-deftest test-flatten-of-list ()
(should (equal (elixir-mix-flatten '(1 2 (3 4) 5))
'(1 2 3 4 5)))
(should (equal (elixir-mix-flatten '(1 2 ("wood" "fire" (3)) 4 5))
'(1 2 "wood" "fire" 3 4 5))))


;;; elixir-mix-tests.el ends here
18 changes: 18 additions & 0 deletions test/test-runner.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
;; Usage:
;;
;; emacs -Q -l test/test-runner.el # interactive mode
;; emacs -batch -Q -l test/test-runner.el # batch mode

(let ((current-directory (file-name-directory load-file-name)))
(setq elixir-mix-test-path (expand-file-name "." current-directory))
(setq elixir-mix-root-path (expand-file-name ".." current-directory)))

(add-to-list 'load-path elixir-mix-root-path)
(add-to-list 'load-path elixir-mix-test-path)

(require 'elixir-mix)

(dolist (test-file (or argv (directory-files elixir-mix-test-path t "-tests.el$")))
(load test-file nil t))

(ert-run-tests-batch-and-exit t)

0 comments on commit be631a3

Please sign in to comment.