Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
@doc """
Will ensure the processes with the test does not complete until the process with the
provided pid has exited. This is necessary when writing multiple tests that start the
same named process. See https://github.com/elixir-lang/elixir/issues/3854 for more info.
This accepts either `{:ok, pid}` or just `pid` so that you can use it in a pipeline
after a `start_link` call.
"""
def synchronize_death_on_exit({:ok, pid}) when is_pid(pid), do: synchronize_death_on_exit(pid)
def synchronize_death_on_exit(pid) when is_pid(pid) do
ExUnit.Callbacks.on_exit fn ->
ref = Process.monitor(pid)
receive do
{:DOWN, ^ref, _, _, _} -> :ok
end
end
pid
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.