I'm trying to pinpoint the issue I'm having here, and was wondering if anyone has experience with something similar? I feel like the root of my problems is that boot-reload might be caching something that it ought not to be.
I'm running a cljs.test suite that serves up test.html
where my namespaces are loaded via the following:
<script>
function run_tests() {
load_namespaces() // hack that uses goog.require internals, but it works.
cljs.core.set_print_fn_BANG_(testPrintLn)
testing_util.runner.run()
}
function rerun_tests() {
run_tests()
}
window.addEventListener('load', run_tests);
</script>
And I'm using the boot hook for reloading as follows: (reload :on-jsload 'testing-util.runner/rerun)
. This simply invokes the following inside of my testing util:
(ns testing-util.runner
(:require [cljs.test :refer-macros [run-all-tests]]))
(enable-console-print!)
(defn ^:export run []
(run-all-tests #".*-test\z"))
(defn ^:export rerun
"Expose this function so boot-reload can invoke it in the context of
resources/test.html after a file has changed. Ultimately, the test.html
will simply invoke the run function above."
[]
(.rerun_tests js/window))
Now, here's the weird part. When I run the boot environment the first time, no tests are run. Even if I save a test file and see the reload message in a console.log
, no tests are run. It's not until I save my testing_util/runner.cljs
do I actually get any tests to run. Here is the reload message I get when saving the runner:
main.out/adzerk/boot_reload.cljs.cache.edn
main.out/testing_util/runner.js.map
main.out/testing_util/runner.cljs.cache.edn
main.out/testing_util/runner.js
After a safe of the runner, suddenly all my tests namespaced *-test
are run. Similarly, if I comment out a complete (deftest ...)
block, then save that file- the tests are run as if I didn't comment out the block at all.
The reload looks like:
main.out/some_tests/some_test.js.map
main.out/some_tests/some_test.cljs
main.out/some_tests/some_test.js
What's more confusing, though, is if I change a test to fail, then save the test file, it will fail as expected. So it seems like there are some namespaces being overwritten, but only some of the time, and I can't figure out the secret sauce. Is this aggressive caching that's causing the issue? Is it namespaces not being properly reloaded that need to (something to do with the run-all-tests
macro)?