Skip to content

Commit

Permalink
Do not reload the runner itself
Browse files Browse the repository at this point in the history
Fixes #2
  • Loading branch information
PEZ committed Jan 22, 2024
1 parent bb6a443 commit 509dc9f
Showing 1 changed file with 22 additions and 16 deletions.
38 changes: 22 additions & 16 deletions .joyride/src/seatbelt/runner.cljs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(ns seatbelt.runner
(:require ["vscode" :as vscode]
(:require ["vscode" :as vscode]
[clojure.string :as string]
[cljs.test]
[promesa.core :as p]))
Expand Down Expand Up @@ -124,25 +124,29 @@
([uri reason]
(watcher-test-run!+ uri reason nil))
([uri reason waiting-message]
(println reason (vscode/workspace.asRelativePath uri))
(println "Running tests...")
(when-not (= "." uri)
(require (uri->ns-symbol uri) :reload-all))
(-> (run-tests!+ waiting-message)
(p/then (fn [_]
(js/setImmediate
#(println "🟢 YAY! 🟢"))))
(p/catch (fn [e]
(let [relative-path (vscode/workspace.asRelativePath uri)]
(println reason relative-path)
(println "Running tests...")
(println "BOOM! relative-path:" relative-path)
(when-not (or (= "." uri)
; We do not handle reloading of the runner itself yet
(.endsWith relative-path "seatbelt/runner.cljs"))
(require (uri->ns-symbol uri) :reload-all))
(-> (run-tests!+ waiting-message)
(p/then (fn [_]
(js/setImmediate
#(println "🟢 YAY! 🟢"))))
(p/catch (fn [e]
; No sound? Check your settings for terminal.integrated.enableBell
(js/setImmediate #(do (println "\u0007")
(println "🔴 NAY! 🔴" e)))))
(p/finally (fn []
(js/setImmediate
#(println "Waiting for changes...")))))))
(js/setImmediate #(do (println "\u0007")
(println "🔴 NAY! 🔴" e)))))
(p/finally (fn []
(js/setImmediate
#(println "Waiting for changes..."))))))))

#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]}
(defn watch!+ [waiting-message]
(let [glob-pattern "**/.joyride/**/*.cljs"
(let [glob-pattern "**/.joyride/**/*.clj[sc]"
watcher (vscode/workspace.createFileSystemWatcher glob-pattern)]
(.onDidChange watcher (fn [uri]
(watcher-test-run!+ uri "File changed:")))
Expand All @@ -153,3 +157,5 @@
(watcher-test-run!+ "." "Watcher started" waiting-message))
; We leave the vscode electron test runner waiting for this promise
(p/deferred))

(.endsWith ".joyride/src/seatbelt/runner.cljs" "seatbelt/runner.cljs")

0 comments on commit 509dc9f

Please sign in to comment.