chore(tests): Allow test-watch-for-repl target to run while the app is running (#20827)
Fix a long standing problem where we can't run in parallel the make target run-clojure and test-watch-for-repl, or in other words, we can't run tests via the REPL while the app is running. Details: I found out that shadow-cljs fails to build because it does not expand the environment variables SHADOW_OUTPUT_TO and SHADOW_NS_REGEXP if and only if the run-clojure target was executed. This is the top of the stacktrace, and it happens because it doesn't know where to output the test build because the env var wasn't expanded: [build] NullPointerException: [build] shadow.build.node/configure (node.clj:59) [build] shadow.build.node/configure (node.clj:45) [build] shadow.build.targets.node-script/configure (node_script.clj:37) The solution is to pass the option --config-merge to shadow-cljs and override both :ns-regexp and :output-to because CLI args override options from env vars in shadow-cljs.
This commit is contained in:
parent
4b8a612df4
commit
cef1308b3a
6
Makefile
6
Makefile
|
@ -353,13 +353,17 @@ test: export SHADOW_NS_REGEXP := .*-test$$
|
|||
test: ##@test Run all Clojure tests
|
||||
test: _test-clojure
|
||||
|
||||
# Note: we need to override the :output-to and :ns-regexp options because
|
||||
# shadow-cljs has a bug where it will not read from the env vars to expand the
|
||||
# configuration when the shadow-cljs mobile target is already running.
|
||||
test-watch-for-repl: export TARGET := default
|
||||
test-watch-for-repl: export SHADOW_OUTPUT_TO := target/test/test.js
|
||||
test-watch-for-repl: export SHADOW_NS_REGEXP := .*-test$$
|
||||
test-watch-for-repl: ##@test Watch all Clojure tests and support REPL connections
|
||||
rm -f "$$SHADOW_OUTPUT_TO" && \
|
||||
yarn install && shadow-cljs compile mocks && \
|
||||
concurrently --kill-others --prefix-colors 'auto' --names 'build,repl' \
|
||||
'yarn shadow-cljs watch test --verbose' \
|
||||
"yarn shadow-cljs watch test --verbose --config-merge '{:output-to \"$(SHADOW_OUTPUT_TO)\" :ns-regexp \"$(SHADOW_NS_REGEXP)\"}'" \
|
||||
"until [ -f $$SHADOW_OUTPUT_TO ] ; do sleep 1 ; done ; node --require ./test-resources/override.js $$SHADOW_OUTPUT_TO --repl"
|
||||
|
||||
test-unit: export SHADOW_OUTPUT_TO := target/unit_test/test.js
|
||||
|
|
Loading…
Reference in New Issue