hello
i'm trying to build a test-runner for cljs with shadow-cljs
my strategy is to find bricks of projects that contain a build name :node-test
how can i find the modified bricks in a project and their locations?
i could do it with string bashing and bricks-to-test but i don't like it
(defn brick-dir
"Get the directory path for a brick (e.g., 'bases/presets' or 'components/foo').
Avoids string concatenation by using io/file to construct the path."
[{:keys [type name]}]
(-> (io/file (str type "s") name) ; "base" + "presets" → "bases/presets"
(.getPath)))
(defn find-shadow-cljs-dir
"Find the directory containing shadow-cljs.edn with :node-test build.
Only checks bricks marked for testing in :bricks-to-test."
[runner-opts]
(let [project-dir (get-in runner-opts [:project :project-dir])
workspace (get runner-opts :workspace)
bricks-to-test (set (get-in runner-opts [:project :bricks-to-test]))
;; Get only the bricks that need testing
all-bricks (concat (:bases workspace) (:components workspace))
bricks-needing-test (filter #(contains? bricks-to-test (:name %)) all-bricks)
;; Get directories for bricks being tested
brick-dirs (map brick-dir bricks-needing-test)
dirs-to-check (cons project-dir brick-dirs)]
;; Find first directory that has shadow-cljs.edn with :node-test
(some (fn [dir]
(when (.exists (io/file dir "shadow-cljs.edn"))
(try
(let [shadow-config (edn/read-string
(slurp (io/file dir "shadow-cljs.edn")))
builds (:builds shadow-config)]
(when (contains? builds :node-test)
dir))
(catch Exception _
nil))))
dirs-to-check)))
what do you think?i have added an implementation proposal i am working on something locally how do you suggest sharing it?
Would a draft PR work, so we can go back and forth/discuss?
https://github.com/seancorfield/polylith-external-test-runner/pull/19
Thanks. Will look at this tomorrow.
The test runner is created for each project that has changes / needs testing.
Have you looked at my external test runner?
BTW, I'm planning to add .cljs capability to my external test runner -- I think there are two options: via Shadow-cljs or via Olical's cljs-test-runner. I'm only familiar with the latter but maybe you could help contribute machinery for the former?
yes! i would like, i'm doing it now internally for my project and i think it will be very useful yes i am looking at your external test runner for inspiration and i see that you also build the dir of the bricks from the project
specifically the "brick-test-namespaces"
The workspace map is passed in when the test runner is created, and that probably has mappings to directories etc so the ns->directory mapping could probably be done that way, but it is easy to do the mapping directly.
I created placeholder issues for cljs support if you want to add notes there https://github.com/seancorfield/polylith-external-test-runner/issues