Skip to content

Commit f37c888

Browse files
alysbrooksjoannecheng
authored andcommitted
Switch from embeds to equals to improve messages
Artificially dividing it up produced weird errors when there was a mismach. Using equals results in more coherent diffs and only required adding a few lines. I also didn't have that much confidence that a different change in test output wouidn't trigger a long delay. This does make the test slightly more fragile, as any thing added to the beginning of the output or the end of the output will cause this to fail. Also, if there's more lines in the output than in the test, you don't get a great diff either.
1 parent 86d69d0 commit f37c888

1 file changed

Lines changed: 28 additions & 27 deletions

File tree

test/unit/kaocha/watch_test.clj

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@
111111
(assoc-in [:kaocha/cli-options :config-file] (str config-file))
112112
(assoc-in [:kaocha/tests 0 :kaocha/source-paths] [])
113113
(assoc-in [:kaocha/tests 0 :kaocha/test-paths] [(str test-dir)]))
114+
;; _ (println config)
114115
prefix (str (gensym "foo"))
115116
finish? (atom false)
116117
q (w/make-queue)
@@ -132,33 +133,33 @@
132133
(w/qput q :finish)
133134
(Thread/sleep 100)
134135

135-
(let [split-str (str/split-lines @out-str)]
136-
(is (match?
137-
(matchers/embeds
138-
["[(F)]"
139-
""
140-
(str/replace "FAIL in foo.bar-test/xxx-test (bar_test.clj:1)" "foo" prefix)
141-
"Expected:"
142-
" :xxx"
143-
"Actual:"
144-
" -:xxx +:yyy"
145-
"1 tests, 1 assertions, 1 failures."])
146-
split-str))
147-
148-
(is (match?
149-
(matchers/embeds
150-
[(format "bin/kaocha --config-file %s --focus '%s.bar-test/xxx-test'" (str config-file) prefix)
151-
""
152-
(str/replace "[watch] Reloading #{foo.bar-test}" "foo" prefix)
153-
(str/replace "[watch] Re-running failed tests #{:foo.bar-test/xxx-test}" "foo" prefix)
154-
"[(F)]"
155-
""
156-
(str/replace "FAIL in foo.bar-test/xxx-test (bar_test.clj:1)" "foo" prefix)
157-
"Expected:"
158-
" :xxx"
159-
"Actual:"
160-
" -:xxx +:zzz" ])
161-
split-str)))))
136+
(is (match?
137+
(matchers/equals
138+
["[(F)]"
139+
""
140+
(str/replace "FAIL in foo.bar-test/xxx-test (bar_test.clj:1)" "foo" prefix)
141+
"Expected:"
142+
" :xxx"
143+
"Actual: "
144+
" -:xxx +:yyy"
145+
"1 tests, 1 assertions, 1 failures."
146+
""
147+
(format "bin/kaocha --config-file %s --focus '%s.bar-test/xxx-test'" (str config-file) prefix)
148+
""
149+
(str/replace "[watch] Reloading #{foo.bar-test}" "foo" prefix)
150+
(str/replace "[watch] Re-running failed tests #{:foo.bar-test/xxx-test}" "foo" prefix)
151+
"[(F)]"
152+
""
153+
(str/replace "FAIL in foo.bar-test/xxx-test (bar_test.clj:1)" "foo" prefix)
154+
"Expected:"
155+
" :xxx"
156+
"Actual:"
157+
" -:xxx +:zzz"
158+
"1 tests, 1 assertions, 1 failures."
159+
""
160+
(format "bin/kaocha --config-file %s --focus '%s.bar-test/xxx-test'" (str config-file) prefix)
161+
])
162+
(str/split-lines @out-str)))))
162163

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

0 commit comments

Comments
 (0)