Created
September 30, 2016 19:20
-
-
Save myronmarston/adacf3884730133a19d033cfe1cc9500 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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