Skip to content

Commit

Permalink
Make test runner glob the namespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
PEZ committed Jan 21, 2024
1 parent 40d609d commit 49fc241
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 17 deletions.
6 changes: 0 additions & 6 deletions .joyride/src/test/config.cljs

This file was deleted.

35 changes: 26 additions & 9 deletions .joyride/src/test_runner/runner.cljs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
(ns test-runner.runner
(:require [clojure.string :as string]
(:require ["vscode" :as vscode]
["path" :as path]
[clojure.string :as string]
[cljs.test]
[promesa.core :as p]))

Expand Down Expand Up @@ -101,13 +103,28 @@
(run-tests-impl!+ test-nss))))))
runner+))

(comment
(run-ns-tests!+ ['test.backseat-driver.ui-test
'test.backseat-driver.util-test]
"Something good")
@!state
(swap! !state assoc :ready-to-run? false)
(swap! !state assoc :ready-to-run? true)
(defn- uri->ns-symbol [uri]
(-> uri
(vscode/workspace.asRelativePath)
(string/split path/sep)
(->> (drop 2)
(string/join "."))
(string/replace "_" "-")
(string/replace #"\.clj[cs]$" "")
symbol))

(defn- glob->ns-symbols [glob]
(p/let [uris (vscode/workspace.findFiles glob)]
(def uris uris)
(map uri->ns-symbol uris)))

(defn run-tests!+
"Runs the tests in any `_test.cljs` files in `.joyride/src/test/`
NB: Will wait for `ready-to-run-tests!` to be called before doing so.
`waiting-message` will be logged if the test runner is waiting."
[waiting-message]
(p/let [nss (glob->ns-symbols ".joyride/src/test/**/*_test.cljs")]
(println "test-runner: Running tests in these" (count nss) "namespaces" (pr-str nss))
(run-ns-tests!+ nss waiting-message)))

:rcf)

3 changes: 1 addition & 2 deletions runTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ exports.run = async () => {
return vscode.commands.executeCommand(
'joyride.runCode',
`(require '[test-runner.runner :as runner])
(require '[test.config :as config])
(runner/run-ns-tests!+ config/namespaces "Waiting for workspace to activate...")`
(runner/run-tests!+ "Waiting for workspace to activate...")`
);
};

0 comments on commit 49fc241

Please sign in to comment.