Skip to content

Commit

Permalink
Use public version of ctn-repl/remove-disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
plexus committed Aug 30, 2023
1 parent 2b9b421 commit a81f4cb
Showing 1 changed file with 33 additions and 34 deletions.
67 changes: 33 additions & 34 deletions src/kaocha/watch.clj
Original file line number Diff line number Diff line change
Expand Up @@ -238,40 +238,39 @@ Behind the scenes we add this plugin to the start of the plugin chain. It takes
care of reloading namespaces inside a Kaocha run, so we can report any load
errors as test errors."
(pre-load [{::keys [tracker focus] :as config}]
(let [tracker (;; TODO: Remove #' when this is made public.
#'ctn-repl/remove-disabled tracker)]
(print-scheduled-operations! tracker focus)
(let [tracker (track-reload! tracker)
config (assoc config ::tracker tracker)
error (or (::tracker-error tracker)
(::ctn-reload/error tracker))
error-ns (if (circular-dependency? error)
(:node (ex-data error))
(::ctn-reload/error-ns tracker))]
(if (and error error-ns)
(let [[file line] (util/compiler-exception-file-and-line error)]
(-> config
(assoc ::error? true)
(update :kaocha/tests
(fn [suites]
;; We don't really know which suite the load error
;; belongs to, it could well be in a file shared by all
;; suites, so we arbitrarily put the load error on the
;; first non-skipped suite and skip all others, so that
;; it gets reported properly.
(let [applied? (volatile! false)]
(mapv (fn [suite]
(if (and (not @applied?)
(not (::testable/skip suite)))
(do (vreset! applied? true)
(assoc suite
::testable/load-error error
::testable/load-error-file (or file (util/ns-file error-ns))
::testable/load-error-line line
::testable/load-error-message (str "Failed reloading " error-ns ":")))
(assoc suite ::testable/skip true)))
suites))))))
config)))))
(let [tracker (ctn-repl/remove-disabled tracker)
_ (print-scheduled-operations! tracker focus)
tracker (track-reload! tracker)
config (assoc config ::tracker tracker)
error (or (::tracker-error tracker)
(::ctn-reload/error tracker))
error-ns (if (circular-dependency? error)
(:node (ex-data error))
(::ctn-reload/error-ns tracker))]
(if (and error error-ns)
(let [[file line] (util/compiler-exception-file-and-line error)]
(-> config
(assoc ::error? true)
(update :kaocha/tests
(fn [suites]
;; We don't really know which suite the load error
;; belongs to, it could well be in a file shared by all
;; suites, so we arbitrarily put the load error on the
;; first non-skipped suite and skip all others, so that
;; it gets reported properly.
(let [applied? (volatile! false)]
(mapv (fn [suite]
(if (and (not @applied?)
(not (::testable/skip suite)))
(do (vreset! applied? true)
(assoc suite
::testable/load-error error
::testable/load-error-file (or file (util/ns-file error-ns))
::testable/load-error-line line
::testable/load-error-message (str "Failed reloading " error-ns ":")))
(assoc suite ::testable/skip true)))
suites))))))
config))))

(defn watch-paths [config]
(->> (into #{}
Expand Down

0 comments on commit a81f4cb

Please sign in to comment.