[Proposal] `start_link_supervised`

48 views
Skip to first unread message

johanna.a...@gmail.com

unread,
Mar 29, 2022, 12:57:36 PM3/29/22
to elixir-lang-core
Hello all!

Basically, `start_supervised` in ExUnit is great in lots of ways. It integrates well with the ExUnit test lifecycle and provides nice guarantees. What it doesn't do is ensure that any failure in the process you're testing is properly propagated to the test process. This means you risk scenarios where your assertions are all fine, but behind the scenes the process actually crashed. This is assuming your final assertions in the test don't need the process to still be alive, or you're doing Mox stuff and verifying expectations.

I've found myself frequently, although not always, adding a `Process.link` of the pid of the supervised process to guarantee it's not silently crashing during tests, and I've caught broken tests this way. You get nice and pretty outputs and test failures.

This is a super simple proposal to add a `link` version of `start_supervised` that ensures the supervised process is also linked to the test process, with some nice docs highlighting the difference. I guess it's as much about the docs as anything else, since it's easy to link manually!

Andrea Leopardi

unread,
Mar 30, 2022, 2:53:30 AM3/30/22
to elixir-lang-core
Hey there,

I like this idea. I don't feel strongly on whether this is a new pair of functions (start_supervised_link/2 and start_supervised_link!/2) or if this is a callout in the docs for the existing start_supervised* functions, but I like the idea of having one of those two 🙃

If others in the team agree, we can open an issue for this in the tracker to keep track of it.

Andrea

Johanna Larsson

unread,
Mar 30, 2022, 5:54:25 AM3/30/22
to elixir-l...@googlegroups.com
I'm happy to take a stab at it, whichever direction we want to go.

--
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/V-Kkr4erDN4/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/98c29853-41f2-4bdc-88e6-37524d7798e2n%40googlegroups.com.

Andrea Leopardi

unread,
Mar 31, 2022, 3:53:10 AM3/31/22
to elixir-l...@googlegroups.com
Heyo,

I spoke with the team. Let's go with amending the documentation. I created an issue to track this: https://github.com/elixir-lang/elixir/issues/11737

Feel free to grab it!

Andrea
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.

Reply all
Reply to author
Forward
0 new messages