Skip to content

Consistenly apply timeouts across suites #14444

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/elixir/test/elixir/process_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ defmodule ProcessTest do

test "sleep/1 with 2^32" do
{pid, monitor_ref} = spawn_monitor(fn -> Process.sleep(2 ** 32) end)
refute_receive {:DOWN, ^monitor_ref, :process, ^pid, {:timeout_value, _trace}}
refute_receive {:DOWN, ^monitor_ref, :process, ^pid, {:timeout_value, _trace}}, 100
Process.exit(pid, :kill)
end

Expand Down Expand Up @@ -130,7 +130,7 @@ defmodule ProcessTest do
end)

true = Process.exit(pid, :normal)
refute_receive {:EXIT, ^pid, :normal}
refute_receive {:EXIT, ^pid, :normal}, 100
assert Process.alive?(pid)

# now exit the process for real so it doesn't hang around
Expand Down
4 changes: 2 additions & 2 deletions lib/elixir/test/elixir/stream_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -318,14 +318,14 @@ defmodule StreamTest do
send(pid, {:stream, 1})
send(pid, {:stream, 2})
send(pid, {:stream, 3})
refute_receive {:stream, 1}
refute_receive {:stream, 1}, 100

send(pid, {:stream, 4})
assert_receive {:stream, 1}

send(pid, {:stream, 5})
assert_receive {:stream, 2}
refute_receive {:stream, 3}
refute_receive {:stream, 3}, 100
end

test "drop_every/2" do
Expand Down
5 changes: 2 additions & 3 deletions lib/elixir/test/elixir/test_helper.exs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ defmodule CodeFormatterHelpers do
end
end

assert_timeout = String.to_integer(System.get_env("ELIXIR_ASSERT_TIMEOUT") || "500")
epmd_exclude = if match?({:win32, _}, :os.type()), do: [epmd: true], else: []
os_exclude = if PathHelpers.windows?(), do: [unix: true], else: [windows: true]

Expand Down Expand Up @@ -135,9 +134,9 @@ cover_exclude =

ExUnit.start(
trace: !!System.get_env("TRACE"),
assert_receive_timeout: assert_timeout,
exclude:
epmd_exclude ++
os_exclude ++ line_exclude ++ distributed_exclude ++ source_exclude ++ cover_exclude,
include: line_include
include: line_include,
assert_receive_timeout: String.to_integer(System.get_env("ELIXIR_ASSERT_TIMEOUT", "300"))
)
2 changes: 1 addition & 1 deletion lib/ex_unit/examples/one_of_each.exs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ defmodule TestOneOfEach do

test "19. refute a message is received within a timeout" do
send(self(), {:hello, "Dave"})
refute_receive {:hello, _}, 1000
refute_receive {:hello, _}, 100
end

test "20. refute a message is ready to be received" do
Expand Down
2 changes: 1 addition & 1 deletion lib/ex_unit/test/ex_unit/assertions_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ defmodule ExUnit.AssertionsTest do
end

test "refute receive waits" do
false = refute_receive :hello
false = refute_receive :hello, 100
end

test "refute received when equal" do
Expand Down
2 changes: 1 addition & 1 deletion lib/ex_unit/test/ex_unit/capture_log_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ defmodule ExUnit.CaptureLogTest do
Logger.error("oh no!")
end)

refute_receive {:EXIT, _, _}
refute_receive {:EXIT, _, _}, 100
end

describe "with_log/2" do
Expand Down
3 changes: 2 additions & 1 deletion lib/ex_unit/test/test_helper.exs
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ CoverageRecorder.maybe_record("ex_unit")
ExUnit.start(
trace: !!System.get_env("TRACE"),
include: line_include,
exclude: line_exclude
exclude: line_exclude,
assert_receive_timeout: String.to_integer(System.get_env("ELIXIR_ASSERT_TIMEOUT", "300"))
)
6 changes: 2 additions & 4 deletions lib/iex/test/test_helper.exs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ path = Path.expand("../tmp/beams", __DIR__)
File.rm_rf!(path)
File.mkdir_p!(path)
Code.prepend_path(path)

assert_timeout = String.to_integer(System.get_env("ELIXIR_ASSERT_TIMEOUT") || "500")
System.put_env("ELIXIR_EDITOR", "echo")

{:ok, _} = Application.ensure_all_started(:iex)
Expand Down Expand Up @@ -42,10 +40,10 @@ cover_exclude =
end

ExUnit.start(
assert_receive_timeout: assert_timeout,
trace: !!System.get_env("TRACE"),
include: line_include,
exclude: line_exclude ++ erlang_doc_exclude ++ source_exclude ++ cover_exclude
exclude: line_exclude ++ erlang_doc_exclude ++ source_exclude ++ cover_exclude,
assert_receive_timeout: String.to_integer(System.get_env("ELIXIR_ASSERT_TIMEOUT", "300"))
)

defmodule IEx.Case do
Expand Down
2 changes: 1 addition & 1 deletion lib/logger/test/logger/translator_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -1275,7 +1275,7 @@ defmodule Logger.TranslatorTest do
test "drops events if otp report handling is switched off" do
{:ok, pid} = GenServer.start(MyGenServer, :ok)
catch_exit(GenServer.call(pid, :error))
refute_receive {:event, _, _}, 200
refute_receive {:event, _, _}, 100
end

def task(parent, fun \\ fn -> raise "oops" end) do
Expand Down
3 changes: 2 additions & 1 deletion lib/logger/test/test_helper.exs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ CoverageRecorder.maybe_record("logger")
ExUnit.start(
trace: !!System.get_env("TRACE"),
include: line_include,
exclude: line_exclude
exclude: line_exclude,
assert_receive_timeout: String.to_integer(System.get_env("ELIXIR_ASSERT_TIMEOUT", "300"))
)

defmodule Logger.Case do
Expand Down
2 changes: 1 addition & 1 deletion lib/mix/test/mix/dep_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -946,7 +946,7 @@ defmodule Mix.DepTest do

Mix.Tasks.Deps.Get.run([])
Mix.Tasks.Deps.Compile.run([])
refute_receive {:mix_shell, :error, ["Could not compile :git_repo" <> _]}
refute_receive {:mix_shell, :error, ["Could not compile :git_repo" <> _]}, 100
end)
end)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/mix/test/mix/umbrella_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ defmodule Mix.UmbrellaTest do

Mix.Task.run("compile", ["--verbose"])
assert_receive {:mix_shell, :info, ["no compile bar"]}
refute_receive {:mix_shell, :info, ["Compiled lib/bar.ex"]}
refute_receive {:mix_shell, :info, ["Compiled lib/bar.ex"]}, 100
end)
end)
end
Expand Down
3 changes: 2 additions & 1 deletion lib/mix/test/test_helper.exs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ CoverageRecorder.maybe_record("mix")
ExUnit.start(
trace: !!System.get_env("TRACE"),
exclude: epmd_exclude ++ os_exclude ++ git_exclude ++ line_exclude ++ cover_exclude,
include: line_include
include: line_include,
assert_receive_timeout: String.to_integer(System.get_env("ELIXIR_ASSERT_TIMEOUT", "300"))
)

defmodule MixTest.Case do
Expand Down
Loading