Mix test --file-watch?

Here’s two language-agnostic options I have used in the past:

entr:

git ls-files **/*.ex* | entr -cdp mix test [--stale]

watchexec

watchexec -c -p -e 'ex,exs,lock' -- mix test [--stale]

Here’s an Elixir-specific snippet from my dotfiles that I’m not sure of the provenance of, and that seems kind of overwrought, but I think it might have been derived from a José/Plataformatec tweet or something?

fswatch --latency=0.01 --one-per-batch lib/ test/ | MIX_ENV=test mix do test --stale, run --no-halt -e "IO.gets(:stdio, ''); IO.puts 'Restarting...'; :init.restart()"

And a variant for umbrella apps:

fswatch --latency=0.01 --one-per-batch apps/ config/ mix.exs mix.lock | MIX_ENV=test mix do test --stale, run --no-halt -e "IO.gets(:stdio, ''); IO.puts 'Restarting...'; :init.restart()"

Edit: I wasn’t entirely mistaken, this was a José gist that maybe got tweeted about: A 1LOC bash script for re-running tests whenever a lib/ or test/ file changes keeping the same VM instance · GitHub