Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce testing #3

Merged
merged 3 commits into from Oct 24, 2013
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 14 additions & 0 deletions .travis.yml
@@ -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
@@ -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
@@ -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
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
@@ -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
@@ -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)