Add Watch Mode to mix test commnad

70 views
Skip to first unread message

Yordis Prieto

unread,
Mar 20, 2021, 6:56:10 PM3/20/21
to elixir-lang-core
Hey folks,

I never bothered me before not having the watch mode for test command, and I was totally fine using a package that allow me to have the functionality.

But I am wondering why we don't get a mix test --watch or something like that that allow us to have quick feedback loop.

Observing the words of somebody that is not an Elixir developer but passionate about TDD, not having such mode said a lot to the person about how Elixir developer think about TDD (shrug).

 The intention was given in a constructive manner, which without getting philosophical about the topic, I can see how having watch mode in testing will be welcoming for some folks and embracing the quick feedback loop (regardless if you do extreme TDD, or not). And personally I don't have to keep installing packages just for such feature.

Thoughts?

Adam Lancaster

unread,
Mar 20, 2021, 7:08:15 PM3/20/21
to elixir-l...@googlegroups.com
FWIW there is already a `mix test --listen-on-stdin` which you can combine with the `--stale` flag to get stale tests re-running with press of a button.

Not sure if that is sufficient for your needs.

--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/62b26b5c-2cbf-406f-b910-22f041565f76n%40googlegroups.com.

José Valim

unread,
Mar 20, 2021, 7:10:46 PM3/20/21
to elixir-l...@googlegroups.com
This feature already exists as —listen-to-stdin. You just need a tool, like fsevents, to watch the file:

    fsevents . | mix test —stale —listen-to-stdin 

The above will only run the files that changes (or the tests that depend on the files that have changed).

Yordis Prieto

unread,
Mar 21, 2021, 2:54:32 AM3/21/21
to elixir-l...@googlegroups.com
I mean define "already exists" since as you said, I need another tool to watch the files (which I have been doing that)

The point is that you don't have to pipe things or use packages in order to get the full experience.

You received this message because you are subscribed to a topic in the Google Groups "elixir-lang-core" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/elixir-lang-core/Vp6pSzdi5rw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4JPq6CoBOdYMEkcVgASxTjXoZ4g-2HEczPpsbDwjyL0PQ%40mail.gmail.com.

Jon Rowe

unread,
Mar 21, 2021, 4:21:52 AM3/21/21
to elixir-lang-core
Each os requires a different way of watching files, fsevents for MacOS, inotify for Linux, (sorry I don't know the equivalent for Windows people), or fall back to polling. All of which is a lot of unrelated work for exunit. Why not let an extra package do the work? 

You could always write a custom task (or a package could) to offer `mix test.watch` etc

José Valim

unread,
Mar 21, 2021, 4:27:49 AM3/21/21
to elixir-l...@googlegroups.com
> I mean define "already exists" since as you said, I need another tool to watch the files (which I have been doing that)

In this case it is a OS wide tool that you only install once instead of per project.

As Jon Rowe said, a file system watcher is non trivial to implement and outside the scope of Elixir. Plus a focus on having composable tools it is pretty much inline with Elixir’s philosophy.

Yordis Prieto

unread,
Mar 21, 2021, 5:00:47 AM3/21/21
to elixir-l...@googlegroups.com
Thank you so much for the response folks, now I can tell other people that love TDD why wasn't add it.

Jose, https://hexdocs.pm/mix/Mix.Tasks.Test.html documentation doesn't mention anything related to the topic, it would be helpful to add some recommendations about this. Showcasing integrations with inotify, fsevents, and windows stuff. That will give direction to people that didn't understand why the decision was made, or how to accomplish the desired outcome.

Thoughts?

José Valim

unread,
Mar 21, 2021, 5:11:50 AM3/21/21
to elixir-l...@googlegroups.com
Yup, I have already changed it in master. :)

Yordis Prieto

unread,
Mar 21, 2021, 5:22:40 AM3/21/21
to elixir-l...@googlegroups.com
It is hard not to fall in love with a language when people like you honestly care about the people programming on it.

From the bottom of my heart, even this is such a small thing, thank you. Never change, this is what makes me proud of being part of it.

Cheers,

On Sun, Mar 21, 2021 at 5:11 AM José Valim <jose....@dashbit.co> wrote:
Yup, I have already changed it in master. :)

--
You received this message because you are subscribed to a topic in the Google Groups "elixir-lang-core" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/elixir-lang-core/Vp6pSzdi5rw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to elixir-lang-co...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages