diff --git a/project.clj b/project.clj index 823cc31..1bb8063 100644 --- a/project.clj +++ b/project.clj @@ -1,16 +1,18 @@ -(defproject pjstadig/humane-test-output "0.8.4-SNAPSHOT" - :description "Humane test output for clojure.test" - :url "http://github.com/pjstadig/humane-test-output/" +(defproject org.clojars.tristefigure.temp_forks/humane-test-output "0.8.4-SNAPSHOT" + :description "Fork of humane-test-output. See: https://github.com/pjstadig/humane-test-output/pull/34." + :url "https://github.com/TristeFigure/humane-test-output" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :deploy-repositories [["releases" :clojars]] :test-selectors {:default (complement :intentionally-failing) :yes-i-know-the-tests-are-supposed-to-fail :intentionally-failing} - :profiles {:dev {:dependencies [[org.clojure/clojure "1.8.0"] + :profiles {:dev {:dependencies [[org.clojure/clojure "1.9.0"] [org.clojure/clojurescript "1.7.228"] [org.seleniumhq.selenium/selenium-java "2.52.0"] - [com.codeborne/phantomjsdriver "1.2.1"]] + [com.codeborne/phantomjsdriver "1.2.1"] + [org.clojure/spec.alpha "0.2.176"] + [lambdaisland/deep-diff "0.0-8"]] :plugins [[lein-cljsbuild "1.1.2"]] :cljsbuild {:test-commands {"test" ["phantomjs" "dev-resources/test/phantom/run.js" "dev-resources/test/test.html"]} :builds [{:id "test" diff --git a/src/pjstadig/humane_test_output.clj b/src/pjstadig/humane_test_output.clj index 3d9cad0..c9b49cd 100644 --- a/src/pjstadig/humane_test_output.clj +++ b/src/pjstadig/humane_test_output.clj @@ -1,7 +1,7 @@ (ns pjstadig.humane-test-output (:use [clojure.test] [pjstadig.util]) - (:require [clojure.data :as data] + (:require [lambdaisland.deep-diff :as deep] [clojure.pprint :as pp])) (defn =-body @@ -15,10 +15,8 @@ :expected a#, :actual more#}) (do-report {:type :fail, :message ~msg, :expected a#, :actual more#, - :diffs (map vector - more# - (map #(take 2 (data/diff a# %)) - more#))})) + :diffs (map #(vector % (deep/diff a# %)) + more#)})) result#) `(throw (Exception. "= expects more than one argument")))) diff --git a/src/pjstadig/util.cljc b/src/pjstadig/util.cljc index b7d46ea..7194954 100644 --- a/src/pjstadig/util.cljc +++ b/src/pjstadig/util.cljc @@ -2,7 +2,8 @@ #?(:clj (:use [clojure.test])) (:require #?@(:clj [[clojure.pprint :as pp] - [pjstadig.print :as p]] + [pjstadig.print :as p] + [lambdaisland.deep-diff :as deep]] :cljs [[cljs.pprint :as pp :include-macros true] [pjstadig.print :as p] [cljs.test :refer [inc-report-counter! testing-vars-str testing-contexts-str get-current-env]]])) @@ -45,21 +46,16 @@ (p/with-pretty-writer (fn [] (let [print-expected (fn [actual] (p/rprint "expected: ") - (pp/pprint expected *out*) + (deep/pretty-print expected) (p/rprint " actual: ") - (pp/pprint actual *out*) + (deep/pretty-print actual) (p/clear))] (if (seq diffs) - (doseq [[actual [a b]] diffs] + (doseq [[actual diff] diffs] (print-expected actual) (p/rprint " diff:") - (if a - (do (p/rprint " - ") - (pp/pprint a *out*) - (p/rprint " + ")) - (p/rprint " + ")) - (when b - (pp/pprint b *out*)) + (p/rprint " ") + (deep/pretty-print diff) (p/clear)) (print-expected actual)))))) diff --git a/test/pjstadig/humane_test_output/formatting_test.cljc b/test/pjstadig/humane_test_output/formatting_test.cljc index 127257c..c84e4e4 100644 --- a/test/pjstadig/humane_test_output/formatting_test.cljc +++ b/test/pjstadig/humane_test_output/formatting_test.cljc @@ -34,3 +34,8 @@ #?(:clj (deftest ^:intentionally-failing non-seq-actual (clojure.test/report {:type :fail :expected 4 :actual 5} ))) + +(deftest test-deep-diff + (let [a [1 2 {:a 1 :b 2}] + b [1 0 {:a 1 :b 0 :c 3}]] + (is (= a b))))