|
133 | 133 |
|
134 | 134 | (is (str/includes? |
135 | 135 | @out-str |
136 | | - (str/replace |
| 136 | + (str/replace |
137 | 137 | (str/replace |
138 | 138 | "[(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" |
139 | 139 | "foo" |
|
203 | 203 | (let [orig-config (config/load-config-for-cli-and-validate "test/unit/kaocha/config/loaded-test-profile.edn" {:profile :test}) |
204 | 204 | [reloaded-config _] (w/reload-config orig-config nil)] |
205 | 205 | (is (= orig-config reloaded-config))))) |
206 | | - |
207 | | -;;TODO move to cucumber |
208 | | -(deftest ^{:min-java-version "1.11"} watch-load-error-test |
209 | | - (let [{:keys [config-file test-dir] :as m} (integration/test-dir-setup {}) |
210 | | - config (-> (config/load-config config-file) |
211 | | - (assoc-in [:kaocha/cli-options :config-file] (str config-file)) |
212 | | - (update :kaocha/tests (fn [suites] |
213 | | - (let [base-suite (assoc (first suites) |
214 | | - :kaocha/source-paths [] |
215 | | - :kaocha/test-paths [(str test-dir)])] |
216 | | - [(assoc base-suite :kaocha.testable/id :first-suite) |
217 | | - (assoc base-suite :kaocha.testable/id :second-suite)])))) |
218 | | - _ (spit (str config-file) (pr-str config)) |
219 | | - spit-good-test #(integration/spit-file m "test/bar_test.clj" (str "(ns bar-test (:require [clojure.test :refer :all])) (deftest good-test (is true))")) |
220 | | - spit-bad-test #(integration/spit-file m "test/bar_test.clj" (str "(ns bar-test) (throw (Exception. \"Intentional compilation error\"))")) |
221 | | - |
222 | | - dbg (bound-fn* prn) |
223 | | - _ (dbg "before") |
224 | | - _ (spit-good-test) |
225 | | - exit (integration/interactive-process m [":second-suite" "--watch"] |
226 | | - (try |
227 | | - (dbg "first lines") |
228 | | - (integration/expect-lines |
229 | | - ["[(.)]" |
230 | | - "1 tests, 1 assertions, 0 failures." |
231 | | - ""]) |
232 | | - (spit-bad-test) |
233 | | - (dbg "after bad test") |
234 | | - (integration/expect-regexes |
235 | | - [#"\[watch\] Reloading #\{bar-test\}" |
236 | | - #"\[E\]" |
237 | | - #"" |
238 | | - #"ERROR in second-suite \(.*?/bar_test.clj:35\)" |
239 | | - #"Failed reloading bar-test:"]) |
240 | | - (dbg "compiler exception") |
241 | | - (integration/next-line-matches |
242 | | - ;; Errors usually look something along the lines of: |
243 | | - ;; {"Exception: clojure.lang.Compiler$CompilerException: Syntax error macroexpanding at (test/bar_test.clj:1:15)." |
244 | | - ;; "Exception: clojure.lang.Compiler$CompilerException: Syntax error compiling at (test/bar_test.clj:1:15)." |
245 | | - ;; "Exception: clojure.lang.Compiler$CompilerException: java.lang.Exception: Intentional compilation error, compiling:(test/bar_test.clj:1:15)"} |
246 | | - #(re-matches #"Exception: clojure\.lang\.Compiler\$CompilerException: (Syntax error macroexpanding at |Syntax error compiling at |java.lang.Exception: Intentional compilation error, compiling:)\(.*bar_test.clj:1:15\)\.?" %)) |
247 | | - (dbg "big trace") |
248 | | - (integration/read-until #{"1 tests, 1 assertions, 1 errors, 0 failures."}) |
249 | | - (integration/expect-lines |
250 | | - ["" |
251 | | - "[watch] Error reloading, all tests skipped."]) |
252 | | - ;; fix the compilation error... |
253 | | - (spit-good-test) |
254 | | - (dbg "after good-test") |
255 | | - (integration/expect-lines |
256 | | - ["[watch] Reloading #{bar-test}" |
257 | | - "[(.)]" |
258 | | - "1 tests, 1 assertions, 0 failures."]) |
259 | | - (finally |
260 | | - ;; FIXME unsure how to exit process via (println) ... eg., how to enter ^C ? |
261 | | - ;; Idea from Alys: What you have seems to work, but maybe if *process* were a map in an atom, |
262 | | - ;; you could have a :process key containing an actual Process and :continue key telling it whether to keep going? |
263 | | - ;; I think this might make *interactive-process* a little tidier, too. |
264 | | - (.destroy integration/*process*))))] |
265 | | - (is (= 143 exit)))) |
0 commit comments