Skip to content

Commit 0e34b29

Browse files
committed
Fix tests for real this time.
1 parent f20bdf0 commit 0e34b29

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

test/unit/kaocha/watch_test.clj

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@
103103
(spit tmp-file "#kaocha/v1 {:tests [{:id :foo}]}")
104104
(first (w/reload-config {:kaocha/cli-options {:config-file (str tmp-file)}} []))))))
105105

106+
106107
(deftest watch-test
107108
(let [{:keys [config-file test-dir] :as m} (integration/test-dir-setup {})
108109
config (-> (config/load-config config-file)
@@ -112,26 +113,31 @@
112113
prefix (str (gensym "foo"))
113114
finish? (atom false)
114115
q (w/make-queue)
115-
out-str (promise)]
116+
out-str (promise)
117+
test-file-path (str "test/" prefix "/bar_test.clj")
118+
]
116119
(integration/spit-file m "tests.edn" (prn-str config))
117-
(integration/spit-file m (str "test/" prefix "/bar_test.clj") (str "(ns " prefix ".bar-test (:require [clojure.test :refer :all])) (deftest xxx-test (is (= :xxx :yyy)))"))
120+
(integration/spit-file m test-file-path (str "(ns " prefix ".bar-test (:require [clojure.test :refer :all])) (deftest xxx-test (is (= :xxx :yyy)))"))
118121

119122
(future (deliver out-str (util/with-test-out-str
120123
(t/with-test-out
121124
(util/with-test-ctx
122125
(w/run* config finish? q))))))
123126

124127
(Thread/sleep 100)
125-
(integration/spit-file m (str "test/" prefix "/bar_test.clj") (str "(ns " prefix ".bar-test (:require [clojure.test :refer :all])) (deftest xxx-test (is (= :xxx :zzz)))"))
126-
(w/qput q (.resolve (:dir m) (str "test/" prefix "/bar_test.clj")))
127-
(Thread/sleep 100)
128+
(integration/spit-file m test-file-path (str "(ns " prefix ".bar-test (:require [clojure.test :refer :all])) (deftest xxx-test (is (= :xxx :zzz)))"))
129+
(w/qput q (.resolve (:dir m) test-file-path))
130+
(Thread/sleep 500)
128131
(reset! finish? true)
129132
(w/qput q :finish)
130-
(Thread/sleep 500)
133+
(Thread/sleep 100)
131134

132-
(is (str/includes?
133-
@out-str
134-
(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\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 +:yyy\n1 tests, 1 assertions, 1 failures.\n\n"
135+
(is (str/includes?
136+
@out-str
137+
(str/replace
138+
139+
"[(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\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"
140+
135141
"foo"
136142
prefix)))))
137143

0 commit comments

Comments
 (0)