Skip to content

Commit

Permalink
Files that contain saved state information are no longer reloaded dur…
Browse files Browse the repository at this point in the history
…ing vigilant run
  • Loading branch information
connor-kilgore committed Jul 22, 2024
1 parent fd03beb commit 5cc4435
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/speclj/config.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,4 @@
*omit-pending?* (:omit-pending config)
*full-stack-trace?* (some? (:stacktrace config))
*tag-filter* (parse-tags (:tags config))]
(action)))
(action)))
24 changes: 23 additions & 1 deletion src/speclj/freshener.clj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
(:require
[clojure.tools.namespace.dir :as dir]
[clojure.tools.namespace.repl :as repl]
[clojure.tools.namespace.reload :as reload]))
[clojure.tools.namespace.track :as track]
[clojure.tools.namespace.reload :as reload]
[clojure.tools.namespace.file :as file]))

(defn find-files-in
"Returns a seq of all files (matching the regex) contained in the given directories."
Expand All @@ -20,7 +22,27 @@
"Returns a seq of all clojure source files contained in the given directories."
[& dirs] (apply find-files-in clj-file-regex dirs))

(defn remove-value [val coll]
(remove #(= % val) coll))

(defn remove-ignore [tracker namespace]
(when-let [file (first (some #(when (= (val %) namespace) %) (::file/filemap tracker)))]
(alter-var-root #'repl/refresh-tracker
(constantly
(assoc tracker
::track/load (remove-value namespace (::track/load tracker))
::track/unload (remove-value namespace (::track/unload tracker))
::file/filemap (dissoc (::file/filemap tracker) file)
::dir/files (set (remove-value file (::dir/files tracker))))))))

(def ignored-namespaces ['speclj.config 'speclj.run.vigilant
'speclj.results 'speclj.core
'speclj.reporting 'speclj.running])

(defn freshen []
(repl/scan)
(doseq [namespace ignored-namespaces]
(remove-ignore repl/refresh-tracker namespace)
)
(alter-var-root #'repl/refresh-tracker reload/track-reload)
(repl/set-refresh-dirs))
8 changes: 3 additions & 5 deletions src/speclj/run/vigilant.clj
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
[speclj.results :as results]
[speclj.running :as running]
[clojure.tools.namespace.repl :as repl]
[clojure.tools.namespace.track :as track]
[clojure.tools.namespace.reload :as reload])
(:import (java.util.concurrent ScheduledThreadPoolExecutor TimeUnit)))

(def start-time (atom 0))

(def current-error-data (atom nil))

(defn get-error-data [e]
Expand All @@ -25,6 +25,7 @@
(try
(reset! start-time (current-time))
(freshen)
;(prn repl/refresh-tracker)
(cond
(::reload/error repl/refresh-tracker)
(throw (::reload/error repl/refresh-tracker))
Expand All @@ -36,12 +37,9 @@
(catch java.lang.Throwable e
(let [error-data (get-error-data e)]
(alter-var-root #'repl/refresh-tracker
(constantly (assoc repl/refresh-tracker :clojure.tools.namespace.track/load [])))
(constantly (assoc repl/refresh-tracker ::track/load [])))
(running/process-compile-error runner e)
(reporting/report-runs* reporters @(.results runner))
#_(when (not= error-data @current-error-data)
(running/process-compile-error runner e)
(reporting/report-runs* reporters @(.results runner)))
(reset! current-error-data error-data))
))
(reset! (.descriptions runner) [])
Expand Down

0 comments on commit 5cc4435

Please sign in to comment.