1
0
Fork 0
mirror of https://gitlab.alpinelinux.org/alpine/aports.git synced 2025-07-13 03:09:51 +03:00
aports/community/elixir/consistently-apply-timeout.patch

177 lines
6.2 KiB
Diff

From 920a6a0a42a80317e0d297273f35a8aac42731c3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jos=C3=A9=20Valim?= <jose.valim@dashbit.co>
Date: Fri, 18 Apr 2025 12:11:12 +0200
Subject: [PATCH] Consistenly apply timeouts across suites (#14444)
Closes #14443.
---
lib/elixir/test/elixir/process_test.exs | 4 ++--
lib/elixir/test/elixir/stream_test.exs | 4 ++--
lib/elixir/test/elixir/test_helper.exs | 5 ++---
lib/ex_unit/examples/one_of_each.exs | 2 +-
lib/ex_unit/test/ex_unit/assertions_test.exs | 2 +-
lib/ex_unit/test/test_helper.exs | 3 ++-
lib/iex/test/test_helper.exs | 5 ++---
lib/logger/test/test_helper.exs | 3 ++-
lib/mix/test/mix/dep_test.exs | 2 +-
lib/mix/test/mix/umbrella_test.exs | 2 +-
lib/mix/test/test_helper.exs | 3 ++-
11 files changed, 18 insertions(+), 17 deletions(-)
--- a/lib/elixir/test/elixir/process_test.exs
+++ b/lib/elixir/test/elixir/process_test.exs
@@ -59,7 +59,7 @@ test "sleep/1" 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
@@ -126,7 +126,7 @@ test "exit(pid, :normal) does not cause the target process to exit" 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
--- a/lib/elixir/test/elixir/stream_test.exs
+++ b/lib/elixir/test/elixir/stream_test.exs
@@ -314,14 +314,14 @@ test "drop/2 with negative count stream entries" 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
--- a/lib/elixir/test/elixir/test_helper.exs
+++ b/lib/elixir/test/elixir/test_helper.exs
@@ -92,7 +92,6 @@ defmacro assert_format(bad, good, opts \\ []) 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]
@@ -118,7 +117,7 @@ defmacro assert_format(bad, good, opts \\ []) do
ExUnit.start(
trace: !!System.get_env("TRACE"),
- assert_receive_timeout: assert_timeout,
exclude: epmd_exclude ++ os_exclude ++ line_exclude ++ distributed_exclude ++ source_exclude,
- include: line_include
+ include: line_include,
+ assert_receive_timeout: String.to_integer(System.get_env("ELIXIR_ASSERT_TIMEOUT", "300"))
)
--- a/lib/ex_unit/examples/one_of_each.exs
+++ b/lib/ex_unit/examples/one_of_each.exs
@@ -100,7 +100,7 @@ test "18. refute a value with a message" 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
--- a/lib/ex_unit/test/ex_unit/assertions_test.exs
+++ b/lib/ex_unit/test/ex_unit/assertions_test.exs
@@ -597,7 +597,7 @@ test "refute received does not wait" do
end
test "refute receive waits" do
- false = refute_receive :hello
+ false = refute_receive :hello, 100
end
test "refute received when equal" do
--- a/lib/ex_unit/test/test_helper.exs
+++ b/lib/ex_unit/test/test_helper.exs
@@ -6,5 +6,6 @@
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"))
)
--- a/lib/iex/test/test_helper.exs
+++ b/lib/iex/test/test_helper.exs
@@ -1,4 +1,3 @@
-assert_timeout = String.to_integer(System.get_env("ELIXIR_ASSERT_TIMEOUT") || "500")
System.put_env("ELIXIR_EDITOR", "echo")
{:ok, _} = Application.ensure_all_started(:iex)
@@ -23,10 +22,10 @@
end
ExUnit.start(
- assert_receive_timeout: assert_timeout,
trace: !!System.get_env("TRACE"),
include: line_include,
- exclude: line_exclude ++ erlang_doc_exclude ++ source_exclude
+ exclude: line_exclude ++ erlang_doc_exclude ++ source_exclude,
+ assert_receive_timeout: String.to_integer(System.get_env("ELIXIR_ASSERT_TIMEOUT", "300"))
)
defmodule IEx.Case do
--- a/lib/logger/test/test_helper.exs
+++ b/lib/logger/test/test_helper.exs
@@ -4,7 +4,8 @@
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
--- a/lib/mix/test/mix/dep_test.exs
+++ b/lib/mix/test/mix/dep_test.exs
@@ -942,7 +942,7 @@ def project 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
--- a/lib/mix/test/mix/umbrella_test.exs
+++ b/lib/mix/test/mix/umbrella_test.exs
@@ -354,7 +354,7 @@ def project 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
--- a/lib/mix/test/test_helper.exs
+++ b/lib/mix/test/test_helper.exs
@@ -47,7 +47,8 @@
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"))
)
# Clear environment variables that may affect tests