elm-test-rs
elm-test-rs copied to clipboard
Improve --watch mode performance
Currently, the --watch
mode re-run everything. This is a simple but very useful strategy. Few improvements may come to mind.
- Only rerun tests potentially impacted by the change
- Avoid re-launching a Node.js instance for the supervisor
(1) is quite complicated since it involves analyzing the modules dependency graph to know which tests might need to be re-run.
(2) could be achieved without too much trouble I believe. It would just require not exiting the supervisor when the run ended if we are in watch mode. The supervisor is already capable of restarting the runners when it receives the paths to a runner file via stdin.
the first is not awful, actually! I've got a script that does it for me (although it depends on private code, so I can't just give it to you.) I've made steps towards publishing it, though—the first is https://git.bytes.zone/brian/tree-grepper. With that, you can query for (say) the module name and all imports in each file, then make a mapping from the module names to their paths by examining source-directories
in elm.json
. At that point, the tests to run are just all the test-containing nodes reachable from the changed file.
Since this is a Rust project, it's pretty easy to pull in tree-sitter. That means it would be possible to do this without any external program calls!
We used to pull tree-sitter but we're not anymore. It contains C++ code and was impossible to compile with musl unfortunately despite quite some energy spent by Harry trying. So I guess this will eventually need some new code but I'm hopeful a motivated contributor will show up :)
oh, that's interesting. Why does this project need to be compiled with musl?
Having a single binary for linux is something dear to me. I'm too often annoyed by projects compiled in ubuntu and not working on arch or the reverse.
See https://github.com/avh4/elm-format/issues/709 for a motivating example