Initial commit.

This commit is contained in:
Paul Stadig 2014-03-26 17:54:35 -04:00
commit c017760acf
6 changed files with 136 additions and 0 deletions

9
.dir-locals.el Normal file
View file

@ -0,0 +1,9 @@
((nil
(fill-column . 80)
(whitespace-line-column . nil))
(clojure-mode
(clojure-test-ns-segment-position . 1)
(eval ignore-errors
(require 'whitespace)
(whitespace-mode 0)
(whitespace-mode 1))))

11
.gitignore vendored Normal file
View file

@ -0,0 +1,11 @@
/checkouts/
/classes/
/lib/
/native/
/target/
/.lein-deps-sum
/.lein-failures
/.lein-repl-history
/.nrepl-history
/pom.xml
*jar

61
README.org Normal file
View file

@ -0,0 +1,61 @@
#+STARTUP: hidestars showall
* Humane test output for clojure.test
Instead of this:
: FAIL in (a-test) (humane_test_output_test.clj:7)
: FIXME, I fail.
: expected: (= {:foo :bar, :baz :quux, :something "a long string?", :another-key "and another value"} {:fo :bar, :baz :quux, :something "a long string?", :another-key "and another value"})
: actual: (not (= {:another-key "and another value", :foo :bar, :something "a long string?", :baz :quux} {:another-key "and another value", :something "a long string?", :fo :bar, :baz :quux}))
:
: FAIL in (a-test) (humane_test_output_test.clj:11)
: FIXME, I fail.
: expected: (= {:foo :bar, :baz :quux} {:foo :bar, :baz :quux} {:fo :bar, :baz :quux})
: actual: (not (= {:foo :bar, :baz :quux} {:foo :bar, :baz :quux} {:fo :bar, :baz :quux}))
:
: FAIL in (a-test) (humane_test_output_test.clj:14)
: FIXME, I fail.
: expected: (list? foo)
: actual: (not (list? {:another-key "and another value", :foo :bar, :something "a long string?", :baz :quux}))
You get this:
: FAIL in (a-test) (humane_test_output_test.clj:7)
: FIXME, I fail.
: expected:
: {:another-key "and another value",
: :foo :bar,
: :something "a long string?",
: :baz :quux}
:
: actual:
: {:another-key "and another value",
: :something "a long string?",
: :fo :bar,
: :baz :quux}
:
: diff:
: {:foo :bar}
: {:fo :bar}
:
: FAIL in (a-test) (humane_test_output_test.clj:11)
: FIXME, I fail.
: expected:
: {:foo :bar, :baz :quux}
:
: actual:
: ({:foo :bar, :baz :quux} {:fo :bar, :baz :quux})
:
: FAIL in (a-test) (humane_test_output_test.clj:14)
: FIXME, I fail.
: expected:
: (list? foo)
:
: actual:
: (not
: (list?
: {:another-key "and another value",
: :foo :bar,
: :something "a long string?",
: :baz :quux}))
** License
: Copyright © Paul Stadig. All rights reserved.
:
: Distributed under the Eclipse Public License, the same as Clojure.

6
project.clj Normal file
View file

@ -0,0 +1,6 @@
(defproject pjstadig/humane-test-output "0.1.0-SNAPSHOT"
:description "Humane test output for clojure.test"
:url "http://github.com/pjstadig/humane-test-output/"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.5.1"]])

View file

@ -0,0 +1,35 @@
(ns pjstadig.humane-test-output
(:use [clojure.data]
[clojure.pprint :only [get-pretty-writer pprint pprint-indent pprint-logical-block write]]
[clojure.test]))
(defmethod assert-expr '= [msg [_ a & more]]
`(let [a# ~a
more# (list ~@more)
result# (apply = a# more#)]
(if result#
(do-report {:type :pass, :message ~msg,
:expected a#, :actual more#})
(do-report (merge {:type :fail, :message ~msg,
:expected a#, :actual more#}
(if (= (count more#) 1)
{:actual (first more#)
:diff (take 2 (diff a# (first more#)))}
{:actual more#}))))
result#))
(defmethod clojure.test/report :fail
[{:keys [type expected actual diff message] :as event}]
(with-test-out
(inc-report-counter :fail)
(println "\nFAIL in" (testing-vars-str event))
(when (seq *testing-contexts*) (println (testing-contexts-str)))
(when message (println message))
(println "expected:")
(pprint expected)
(println "\nactual:")
(pprint actual)
(when-let [[a b] diff]
(println "\ndiff:")
(pprint a)
(pprint b))))

View file

@ -0,0 +1,14 @@
(ns pjstadig.humane-test-output-test
(:use [clojure.test]
[pjstadig.humane-test-output]))
(deftest a-test
(testing "FIXME, I fail."
(is (= {:foo :bar :baz :quux :something "a long string?"
:another-key "and another value"}
{:fo :bar :baz :quux :something "a long string?"
:another-key "and another value"}))
(is (= {:foo :bar :baz :quux} {:foo :bar :baz :quux} {:fo :bar :baz :quux}))
(let [foo {:foo :bar :baz :quux :something "a long string?"
:another-key "and another value"}]
(is (list? foo)))))