dogweather

dogweather

Mix test --file-watch?

I love this Haskell Stack feature:

  --file-watch             Watch for changes in local files and automatically
                           rebuild. Ignores files in VCS boring/ignore file

I do stack test --file-watch and it continuously re-tests as I work. Has anyone configured anything similar for mix test? Maybe using Guard?

Marked As Solved

Also Liked

OvermindDL1

OvermindDL1

I use Cortex myself:

11
Post #5
shanesveller

shanesveller

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

dogweather

dogweather

Thanks! mix-test.watch works perfectly, including --stale support and clearing the screen before each test run.

Last Post!

mr_smith

mr_smith

Your necro is much appreciated, was looking for this exact info today.

Gravedigging is dirty work but someone’s got to do it.

Where Next?

Popular in Questions Top

rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
PeterCarter
There are pre-rolled solutions for other frameworks that do work. However, Phoenix does not seem to have these. Have people had good expe...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New

Other popular topics Top

Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
sergio
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
New
AstonJ
Posting this to see if we can make things easier for people to get into Neovim. If you use Neovim and have a favourite distro please let ...
New

We're in Beta

About us Mission Statement