Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Tinkered with colorizing

  • Loading branch information...
commit 38ab2e8b82add8ba8a93e4ba4634cce6d432f622 1 parent 5cff581
@marick marick authored
View
1  .gitignore
@@ -9,3 +9,4 @@ test/midje/scratch
semantic.cache
*.iml
*.idea
+.lein-*
View
3  project.clj
@@ -2,4 +2,5 @@
:author "See README"
:description "Run Midje and clojure.test tests"
:url "https://github.com/marick/lein-midje"
- :eval-in-leiningen true)
+ :eval-in-leiningen true
+ :dev-dependencies [[midje "1.3.0-RC2"]])
View
30 src/leiningen/midje.clj
@@ -36,8 +36,10 @@
midje-fails# (:fail @clojure.test/*report-counters*)
midje-failure-message# (condp = midje-fails#
0 (color/pass (format "All claimed facts (%d) have been confirmed." midje-passes#))
- 1 (color/fail (format "FAILURE: %d fact was not confirmed." midje-fails#))
- (color/fail (format "FAILURE: %d facts were not confirmed." midje-fails#)))
+ 1 (str (color/fail "FAILURE:")
+ (format " %d fact was not confirmed." midje-fails#))
+ (str (color/fail "FAILURE:")
+ (format " %d facts were not confirmed." midje-fails#)))
potential-consolation# (condp = midje-passes#
0 ""
@@ -47,23 +49,25 @@
midje-consolation# (if (> midje-fails# 0) potential-consolation# "")
; Stashed clojure.test output
- clojure-test-output-catcher# (java.io.StringWriter.)
- clojure-test-result# (binding [clojure.test/*test-out* clojure-test-output-catcher#]
+ ct-output-catcher# (java.io.StringWriter.)
+ ct-result# (binding [clojure.test/*test-out* ct-output-catcher#]
(apply ~'clojure.test/run-tests namespaces#))
- clojure-test-output# (-> clojure-test-output-catcher#
+ ct-output# (-> ct-output-catcher#
.toString
- clojure.string/split-lines)]
+ clojure.string/split-lines)
+ ct-failures-and-errors# (+ (:fail ct-result#) (:error ct-result#))
+ ct-some-kind-of-fail?# (> ct-failures-and-errors# 0)]
- (when (> (+ (:fail clojure-test-result#) (:error clojure-test-result#))
- 0)
+ (when ct-some-kind-of-fail?#
;; For some reason, empty lines are swallowed, so I use >>> to
;; demarcate sections.
(println (color/note ">>> Output from clojure.test tests:"))
- (dorun (map println (drop-last 2 clojure-test-output#))))
+ (dorun (map println (drop-last 2 ct-output#))))
- (when (> (:test clojure-test-result#) 0)
+ (when (> (:test ct-result#) 0)
(println (color/note ">>> clojure.test summary:"))
- (dorun (map println (take-last 2 clojure-test-output#)))
+ (println (first (take-last 2 ct-output#)))
+ (println ( (if ct-some-kind-of-fail?# color/fail color/pass) (last ct-output#)))
(println (color/note ">>> Midje summary:")))
(println midje-failure-message# midje-consolation#)
@@ -71,8 +75,8 @@
;; A non-nil return value is printed, so I'll just exit here.
(when ~*exit-after-tests*
(System/exit (+ midje-fails#
- (:error clojure-test-result#)
- (:fail clojure-test-result#)))))
+ (:error ct-result#)
+ (:fail ct-result#)))))
))
(defn- get-namespaces [namespaces]
View
8 test/sample/midje_only_fail.clj
@@ -0,0 +1,8 @@
+(ns sample.midje-only-fail
+ (:use midje.sweet))
+
+(future-fact "This is a note"
+ (+ 1 1) => 2)
+
+(fact "this fails"
+ (+ 1 1) => 3)
View
5 test/sample/midje_only_pass.clj
@@ -0,0 +1,5 @@
+(ns sample.midje-only-pass
+ (:use midje.sweet))
+
+(fact "this succeeds"
+ (+ 1 1) => 2)
View
7 test/sample/test_only_fail.clj
@@ -0,0 +1,7 @@
+(ns sample.test-only-fail
+ (:use clojure.test))
+
+(deftest fail-test
+ (is (= (+ 1 1) 3)))
+
+(fail-test)
View
7 test/sample/test_only_pass.clj
@@ -0,0 +1,7 @@
+(ns sample.test-only-pass
+ (:use clojure.test))
+
+(deftest pass-test
+ (is (= (+ 1 1) 2)))
+
+(pass-test)
Please sign in to comment.
Something went wrong with that request. Please try again.