Skip to content

Commit 3950130

Browse files
committed
Fix exit signal race condition in logger tests
Test process must wait for exit signal before untrapping exits, otherwise exit signal may cause it to exit.
1 parent 7f7aaa1 commit 3950130

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

lib/logger/test/logger/translator_test.exs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,7 @@ defmodule Logger.TranslatorTest do
351351
trap = Process.flag(:trap_exit, true)
352352
Supervisor.start_link([worker(__MODULE__, [], [function: :error])],
353353
[strategy: :one_for_one])
354+
receive do: ({:EXIT, _, {:shutdown, {:failed_to_start_child, _, _}}} -> :ok)
354355
Process.flag(:trap_exit, trap)
355356
end) =~ ~r"""
356357
\[error\] Child Logger.TranslatorTest of Supervisor #PID<\d+\.\d+\.\d+> \(Supervisor\.Default\) failed to start
@@ -364,6 +365,7 @@ defmodule Logger.TranslatorTest do
364365
trap = Process.flag(:trap_exit, true)
365366
Supervisor.start_link([worker(__MODULE__, [], [function: :undef])],
366367
[strategy: :one_for_one])
368+
receive do: ({:EXIT, _, {:shutdown, {:failed_to_start_child, _, _}}} -> :ok)
367369
Process.flag(:trap_exit, trap)
368370
end) =~ ~r"""
369371
\[error\] Child Logger.TranslatorTest of Supervisor #PID<\d+\.\d+\.\d+> \(Supervisor\.Default\) failed to start

0 commit comments

Comments
 (0)