Okay, I think I may have run into another complication with Polylith and Shadow-cljs... Details in ๐งต
poly test builds the full classpath for all the directories that contain source and tests. The per-project "build" process would only have access to the (source) dependencies, libraries, and potentially any project-specific tests -- because tools.deps isn't transitive, the test files in bases/components in Polylith are not visible directly to anything running in a project.
Test runners for Polylith accept all those paths and build their own classpath for any Java processes they would run.
This seems at odds with running shadow-cljs via npx even with shadow-cljs.edn having :deps {:aliases [:shadow :test]} (for example) since Shadow is relying on tools.deps style logic and the "brick" tests are not deducible from that.
So, it seems like I would be forced to run shadow-cljs as a Java process in the context of a dynamically constructed classpath that includes all of those "brick" test files? @thheller
LMK if you need more context for this.
BTW, the dynamically-constructed --config-merge works beautifully! Which is how I figured out the classpath wasn't right ๐
if you have a constructed classpath just use java
https://code.thheller.com/blog/shadow-cljs/2017/11/18/the-many-ways-to-use-shadow-cljs.html
or am I missing something?
java -cp $(get-classpath) clojure.main -m shadow.cljs.devtools.cli compile test
Yeah, I think that's the way I have to go, and specify the path to the project's shadow edn file...
Since the test runner assumes it runs in the root in terms of how it builds the class path
I know next to nothing about polylith, so not really sure what brickes/bases/components are
so shadow-cljs.edn in the "root" is no option?
There can be multiple cljs projects in a repo, so multiple shadow config files
I assume I can tell shadow to use a specific edn file (in another folder)?
no, that is hardcoded to the directory the JVM was started in
Hmm, that might make this impossible then
do you have an example app for how this would actually all look?
Not really. But the test runner itself is a Polylith app: https://github.com/seancorfield/polylith-external-test-runner
Each projects/* folder that is building a cljs app would have a shadow-cljs.edn file for that build.
so you are starting shadow-cljs in that folder?
poly test figures out which "modules" need to be tested based on what code has changed since a specific git tag.
Then it builds a classpath etc from the repo (workspace) root -- which includes the project being tested -- and the test runner is executed in the root of the repo.
That works for Cognitect's test-runner and Olical's cljs-test-runner.
The shadow-cljs.edn file in the project is being read (by my test runner) to figure out builds and targets and a few other options, and I would have to run Shadow in that project folder for it to pick up the config file.
However, the classpath is relative to the repo root, not the project root, so Shadow still can't find the test nses.
I guess I could add ../../ to each piece of the classpath that is a directory, rather than a JAR file...
ah so you are using relative paths. well yeah would need to rewrite those
well this is how shadow-cljs finds its config (io/file "shadow-cljs.edn")
Success!!!!!
Running ClojureScript tests...
[:test] Compiling ...
WARNING: A terminally deprecated method in sun.misc.Unsafe has been called
WARNING: sun.misc.Unsafe::arrayBaseOffset has been called by com.google.javascript.jscomp.jarjar.com.google.protobuf.UnsafeUtil$MemoryAccessor (file:/home/sean/.m2/repository/com/google/javascript/closure-compiler/v20250407/closure-compiler-v20250407.jar)
WARNING: Please consider reporting this to the maintainers of class com.google.javascript.jscomp.jarjar.com.google.protobuf.UnsafeUtil$MemoryAccessor
WARNING: sun.misc.Unsafe::arrayBaseOffset will be removed in a future release
[:test] Build completed. (53 files, 9 compiled, 0 warnings, 10.82s)
no "source-map-support" (run "npm install source-map-support --save-dev" to get it)
This is a ClojureScript test file.
Common test running as ClojureScript.
Testing org.corfield.external-test-runner.ignored-test
Testing org.corfield.external-test-runner.interface-test
Ran 2 tests containing 2 assertions.
0 failures, 0 errors.wasn't there a JVM option to adjust what it uses for reference ๐
Not within the Polylith machinery that builds the paths, no.
(because it isn't using tools.deps directly, because every "module" in a Polylith repo has its own deps.edn that only has some dependencies -- and Polylith merges them all together to build the full classpath)
At work, our repo has over 200 deps.edn files ๐
yikes ๐
We build 24 different apps from that, and poly test gives us incremental testing.