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 #6
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.

Where Next?

Popular in Questions Top

marius95
Hello everyone, I try to use an Javascript Event Handler in my root.html.leex file. Therefore I created a function in the app.js file: ...
New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
myronmarston
The Elixir Typespec docs show the following syntax for keyword lists in typespecs: # ... | [key: type] # keyword lists...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
Lily
In templates/appointment/index.html.eex: <%= for appointment <- @appointments do %> <tr> <td><%= appoi...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ā€˜elixir’ comma...
New
script
If I have a string ā€œ1000 cfu/mlā€ . I want to remove the characters and / and space . So the string is like this "1000" What is the ...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New

Other popular topics Top

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
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? Ecto.Repo — Ecto v3.14.0 has exampl...
New
josevalim
Hi everyone, One of the features added to Elixir early on to help integration with Erlang code was the idea of overridable function defi...
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
boundedvariable
I am going through the kafka architecture. All the features what the kafka is providing are already in Erlang. I would like hear your opi...
New
komlanvi
Hi everyone, I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New
dogweather
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something… Haskell reminds me of Java, and e...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New

We're in Beta

About us Mission Statement