Skip to content

Commit 83d8161

Browse files
committed
Fix race condition in logger translator test
1 parent b87ea61 commit 83d8161

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

lib/logger/test/logger/translator_test.exs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,6 @@ defmodule Logger.TranslatorTest do
3131
end
3232
end
3333

34-
defmodule MyTemporaryWorker do
35-
use GenServer
36-
def start_link, do: GenServer.start_link(__MODULE__, [], [])
37-
def init([]), do: 1 / 0
38-
end
39-
4034
setup_all do
4135
sasl_reports? = Application.get_env(:logger, :handle_sasl_reports, false)
4236
Application.put_env(:logger, :handle_sasl_reports, true)
@@ -483,12 +477,13 @@ defmodule Logger.TranslatorTest do
483477
end
484478

485479
test "handles :undefined MFA properly" do
486-
children = [Supervisor.Spec.worker(MyTemporaryWorker, [], restart: :temporary)]
480+
children = [Supervisor.Spec.worker(GenServer, [], restart: :temporary)]
487481
opts = [strategy: :simple_one_for_one]
488482
{:ok, sup} = Supervisor.start_link(children, opts)
489483
assert capture_log(:info, fn ->
490-
{:error, {:badarith, _}} = Supervisor.start_child(sup, [])
491-
end) =~ "Start Call: Logger.TranslatorTest.MyTemporaryWorker.start_link/?"
484+
{:ok, pid} = Supervisor.start_child(sup, [MyGenServer, []])
485+
catch_exit(GenServer.call(pid, :error))
486+
end) =~ "Start Call: GenServer.start_link/?"
492487
end
493488

494489
def task(parent, fun \\ (fn() -> raise "oops" end)) do

0 commit comments

Comments
 (0)