Skip to content

Commit f94fb1a

Browse files
authored
Merge pull request #276 from lambdaisland/cjohansen/fix-test-rebased2
Partially fix watch test bug
2 parents 3be245e + 0e34b29 commit f94fb1a

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

test/unit/kaocha/watch_test.clj

Lines changed: 16 additions & 8 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,33 @@
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)
133+
(Thread/sleep 100)
130134

131-
(is (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] 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\n1 tests, 1 assertions, 1 failures.\n\n[watch] watching stopped.\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+
132141
"foo"
133-
prefix)
134-
@out-str)))
142+
prefix)))))
135143

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

0 commit comments

Comments
 (0)