Skip to content

Commit

Permalink
Redo test as a vector of lines instead of a string.
Browse files Browse the repository at this point in the history
This test is difficult to work with as-is because it's one big string,
and deep-diff2 (currently) shows only that two strings differ, and not
the substrings in particular that cause the mismatch.
  • Loading branch information
alysbrooks committed May 6, 2023
1 parent 1dc8802 commit 91f29b2
Showing 1 changed file with 26 additions and 10 deletions.
36 changes: 26 additions & 10 deletions test/unit/kaocha/watch_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
[kaocha.config :as config]
[clojure.test :as t]
[clojure.string :as str]
[slingshot.slingshot :refer [try+]])
[slingshot.slingshot :refer [try+]]
[matcher-combinators.matchers :as matchers]
)
(:import (java.io File)))

(require 'matcher-combinators.test)
Expand Down Expand Up @@ -131,15 +133,29 @@
(w/qput q :finish)
(Thread/sleep 100)

(is (str/includes?
@out-str
(str/replace
(str/replace
"[(F)]\n\nFAIL in foo.bar-test/xxx-test (bar_test.clj:1)\nExpected:\n :xxx\nActual:\n -:xxx +:yyy\n1 tests, 1 assertions, 1 failures.\n\nbin/kaocha --config-file PATH --focus 'foo.bar-test/xxx-test'\n\n[watch] Reloading #{foo.bar-test}\n[watch] Re-running failed tests #{:foo.bar-test/xxx-test}\n[(F)]\n\nFAIL in foo.bar-test/xxx-test (bar_test.clj:1)\nExpected:\n :xxx\nActual:\n -:xxx +:zzz"
"foo"
prefix)
"PATH"
(str config-file))))))
(is (match?
(matchers/embeds
["[(F)]"
""
(str/replace "FAIL in foo.bar-test/xxx-test (bar_test.clj:1)" "foo" prefix)
"Expected:"
" :xxx"
"Actual:"
" -:xxx +:yyy"
"1 tests, 1 assertions, 1 failures."
""
(format "bin/kaocha --config-file %s --focus '%s.bar-test/xxx-test'" (str config-file) prefix)
""
(str/replace "[watch] Reloading #{foo.bar-test}" "foo" prefix)
(str/replace "[watch] Re-running failed tests #{:foo.bar-test/xxx-test}" "foo" prefix)
"[(F)]"
""
(str/replace "FAIL in foo.bar-test/xxx-test (bar_test.clj:1)" "foo" prefix)
"Expected:"
" :xxx"
"Actual:"
" -:xxx +:zzz"])
(str/split-lines @out-str)))))

(deftest ignore-files-merged
(let [{:keys [_config-file test-dir] :as m} (integration/test-dir-setup {})]
Expand Down

0 comments on commit 91f29b2

Please sign in to comment.