Skip to content

Commit 920a6a0

Browse files
authored
Consistenly apply timeouts across suites (#14444)
Closes #14443.
1 parent 7e6e700 commit 920a6a0

File tree

13 files changed

+20
-20
lines changed

13 files changed

+20
-20
lines changed

Diff for: lib/elixir/test/elixir/process_test.exs

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ defmodule ProcessTest do
6363

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

@@ -130,7 +130,7 @@ defmodule ProcessTest do
130130
end)
131131

132132
true = Process.exit(pid, :normal)
133-
refute_receive {:EXIT, ^pid, :normal}
133+
refute_receive {:EXIT, ^pid, :normal}, 100
134134
assert Process.alive?(pid)
135135

136136
# now exit the process for real so it doesn't hang around

Diff for: lib/elixir/test/elixir/stream_test.exs

+2-2
Original file line numberDiff line numberDiff line change
@@ -318,14 +318,14 @@ defmodule StreamTest do
318318
send(pid, {:stream, 1})
319319
send(pid, {:stream, 2})
320320
send(pid, {:stream, 3})
321-
refute_receive {:stream, 1}
321+
refute_receive {:stream, 1}, 100
322322

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

326326
send(pid, {:stream, 5})
327327
assert_receive {:stream, 2}
328-
refute_receive {:stream, 3}
328+
refute_receive {:stream, 3}, 100
329329
end
330330

331331
test "drop_every/2" do

Diff for: lib/elixir/test/elixir/test_helper.exs

+2-3
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ defmodule CodeFormatterHelpers do
100100
end
101101
end
102102

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

@@ -135,9 +134,9 @@ cover_exclude =
135134

136135
ExUnit.start(
137136
trace: !!System.get_env("TRACE"),
138-
assert_receive_timeout: assert_timeout,
139137
exclude:
140138
epmd_exclude ++
141139
os_exclude ++ line_exclude ++ distributed_exclude ++ source_exclude ++ cover_exclude,
142-
include: line_include
140+
include: line_include,
141+
assert_receive_timeout: String.to_integer(System.get_env("ELIXIR_ASSERT_TIMEOUT", "300"))
143142
)

Diff for: lib/ex_unit/examples/one_of_each.exs

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ defmodule TestOneOfEach do
104104

105105
test "19. refute a message is received within a timeout" do
106106
send(self(), {:hello, "Dave"})
107-
refute_receive {:hello, _}, 1000
107+
refute_receive {:hello, _}, 100
108108
end
109109

110110
test "20. refute a message is ready to be received" do

Diff for: lib/ex_unit/test/ex_unit/assertions_test.exs

+1-1
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ defmodule ExUnit.AssertionsTest do
601601
end
602602

603603
test "refute receive waits" do
604-
false = refute_receive :hello
604+
false = refute_receive :hello, 100
605605
end
606606

607607
test "refute received when equal" do

Diff for: lib/ex_unit/test/ex_unit/capture_log_test.exs

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ defmodule ExUnit.CaptureLogTest do
102102
Logger.error("oh no!")
103103
end)
104104

105-
refute_receive {:EXIT, _, _}
105+
refute_receive {:EXIT, _, _}, 100
106106
end
107107

108108
describe "with_log/2" do

Diff for: lib/ex_unit/test/test_helper.exs

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@ CoverageRecorder.maybe_record("ex_unit")
1313
ExUnit.start(
1414
trace: !!System.get_env("TRACE"),
1515
include: line_include,
16-
exclude: line_exclude
16+
exclude: line_exclude,
17+
assert_receive_timeout: String.to_integer(System.get_env("ELIXIR_ASSERT_TIMEOUT", "300"))
1718
)

Diff for: lib/iex/test/test_helper.exs

+2-4
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ path = Path.expand("../tmp/beams", __DIR__)
77
File.rm_rf!(path)
88
File.mkdir_p!(path)
99
Code.prepend_path(path)
10-
11-
assert_timeout = String.to_integer(System.get_env("ELIXIR_ASSERT_TIMEOUT") || "500")
1210
System.put_env("ELIXIR_EDITOR", "echo")
1311

1412
{:ok, _} = Application.ensure_all_started(:iex)
@@ -42,10 +40,10 @@ cover_exclude =
4240
end
4341

4442
ExUnit.start(
45-
assert_receive_timeout: assert_timeout,
4643
trace: !!System.get_env("TRACE"),
4744
include: line_include,
48-
exclude: line_exclude ++ erlang_doc_exclude ++ source_exclude ++ cover_exclude
45+
exclude: line_exclude ++ erlang_doc_exclude ++ source_exclude ++ cover_exclude,
46+
assert_receive_timeout: String.to_integer(System.get_env("ELIXIR_ASSERT_TIMEOUT", "300"))
4947
)
5048

5149
defmodule IEx.Case do

Diff for: lib/logger/test/logger/translator_test.exs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1275,7 +1275,7 @@ defmodule Logger.TranslatorTest do
12751275
test "drops events if otp report handling is switched off" do
12761276
{:ok, pid} = GenServer.start(MyGenServer, :ok)
12771277
catch_exit(GenServer.call(pid, :error))
1278-
refute_receive {:event, _, _}, 200
1278+
refute_receive {:event, _, _}, 100
12791279
end
12801280

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

Diff for: lib/logger/test/test_helper.exs

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ CoverageRecorder.maybe_record("logger")
1111
ExUnit.start(
1212
trace: !!System.get_env("TRACE"),
1313
include: line_include,
14-
exclude: line_exclude
14+
exclude: line_exclude,
15+
assert_receive_timeout: String.to_integer(System.get_env("ELIXIR_ASSERT_TIMEOUT", "300"))
1516
)
1617

1718
defmodule Logger.Case do

Diff for: lib/mix/test/mix/dep_test.exs

+1-1
Original file line numberDiff line numberDiff line change
@@ -946,7 +946,7 @@ defmodule Mix.DepTest do
946946

947947
Mix.Tasks.Deps.Get.run([])
948948
Mix.Tasks.Deps.Compile.run([])
949-
refute_receive {:mix_shell, :error, ["Could not compile :git_repo" <> _]}
949+
refute_receive {:mix_shell, :error, ["Could not compile :git_repo" <> _]}, 100
950950
end)
951951
end)
952952
end

Diff for: lib/mix/test/mix/umbrella_test.exs

+1-1
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ defmodule Mix.UmbrellaTest do
375375

376376
Mix.Task.run("compile", ["--verbose"])
377377
assert_receive {:mix_shell, :info, ["no compile bar"]}
378-
refute_receive {:mix_shell, :info, ["Compiled lib/bar.ex"]}
378+
refute_receive {:mix_shell, :info, ["Compiled lib/bar.ex"]}, 100
379379
end)
380380
end)
381381
end

Diff for: lib/mix/test/test_helper.exs

+2-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ CoverageRecorder.maybe_record("mix")
4949
ExUnit.start(
5050
trace: !!System.get_env("TRACE"),
5151
exclude: epmd_exclude ++ os_exclude ++ git_exclude ++ line_exclude ++ cover_exclude,
52-
include: line_include
52+
include: line_include,
53+
assert_receive_timeout: String.to_integer(System.get_env("ELIXIR_ASSERT_TIMEOUT", "300"))
5354
)
5455

5556
defmodule MixTest.Case do

0 commit comments

Comments
 (0)