elm-test-rs icon indicating copy to clipboard operation
elm-test-rs copied to clipboard

Improve --watch mode performance

Open mpizenberg opened this issue 4 years ago • 5 comments

Currently, the --watch mode re-run everything. This is a simple but very useful strategy. Few improvements may come to mind.

  1. Only rerun tests potentially impacted by the change
  2. 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.

mpizenberg avatar Dec 20 '20 15:12 mpizenberg

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!

BrianHicks avatar Jan 06 '21 12:01 BrianHicks

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 :)

mpizenberg avatar Jan 06 '21 12:01 mpizenberg

oh, that's interesting. Why does this project need to be compiled with musl?

BrianHicks avatar Jan 06 '21 14:01 BrianHicks

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.

mpizenberg avatar Jan 06 '21 14:01 mpizenberg

See https://github.com/avh4/elm-format/issues/709 for a motivating example

harrysarson avatar Jan 06 '21 15:01 harrysarson