Skip to content

Commit

Permalink
Initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
pjstadig committed Oct 29, 2010
0 parents commit 9e8966d
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
@@ -0,0 +1,4 @@
pom.xml
*jar
lib
classes
22 changes: 22 additions & 0 deletions README
@@ -0,0 +1,22 @@
# lein-fail-fast

Stop a testing run when the first test failure is received.

This is especially useful in a build server situation where you don't need to
finish out a test run once you know your tests have failed.

## Usage

Add as a development dependency to your lein project.clj, and turn on the
LEIN_FAIL_FAST environment variable in your build environment.

## Installation

Add lein-fail-fast as a development dependency to your lein project.clj and
robert-hooke as a non-dev dependency.

## License

Copyright (C) 2010 Paul Stadig

Distributed under the Eclipse Public License, the same as Clojure.
2 changes: 2 additions & 0 deletions project.clj
@@ -0,0 +1,2 @@
(defproject lein-fail-fast "1.0.0"
:description "Stop a testing run when the first failure is received.")
26 changes: 26 additions & 0 deletions src/leiningen/hooks/fail_fast.clj
@@ -0,0 +1,26 @@
(ns leiningen.hooks.fail-fast
(:use [robert.hooke]
[leiningen.compile :only [eval-in-project]]
[clojure.pprint :only [pprint]]))

(defn wrap [form]
`(do
(add-hook
#'clojure.test/do-report
(fn [f# & args#]
(let [result# (apply f# args#)]
(when (contains? #{:fail :error}
(:type (first args#)))
(System/exit 0))
result#)))
~form))

(defn fail-fast-hooke [f project form & [handler skip-auto init & args]]
(apply f project (wrap form) handler skip-auto
`(do (require 'clojure.test)
(require 'robert.hooke)
~init)
args))

(if (System/getenv "LEIN_FAIL_FAST")
(add-hook #'eval-in-project fail-fast-hooke))

0 comments on commit 9e8966d

Please sign in to comment.