Skip to content

Instantly share code, notes, and snippets.

@josevalim
Last active February 28, 2024 07:42
Show Gist options
  • Star 75 You must be signed in to star a gist
  • Fork 7 You must be signed in to fork a gist
  • Save josevalim/a5e747c90a72e40a4b52062ea6919877 to your computer and use it in GitHub Desktop.
Save josevalim/a5e747c90a72e40a4b52062ea6919877 to your computer and use it in GitHub Desktop.
A 1LOC bash script for re-running tests whenever a lib/ or test/ file changes keeping the same VM instance
# You will need fswatch installed (available in homebrew and friends)
# The command below will run tests and wait until fswatch writes something.
# The --stale flag will only run stale entries, it requires Elixir v1.3.
fswatch lib/ test/ | mix test --stale --listen-on-stdin
@maxnordlund
Copy link

maxnordlund commented Jul 1, 2016

You probably want the --one-per-batch flag, and perhaps also --latency=0.01 or similar to make it more snappy. These are for fswatch, as you might have guess, but just to be crystal clear.

@kuon
Copy link

kuon commented Jan 29, 2017

--listen-on-stdin doesn't seem to be supported, my take on this:

fswatch -0 --latency=0.01 --one-per-batch lib test web  | xargs -0 -n 1 mix test --stale test/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment