Skip to content

Commit dda2764

Browse files
committed
Tackle flakey iex warning test
Sometimes the iex(2)> (at least on CI) is sent together with the output of the benchmark/the benchmark suite. That caused it to be flakey. This change should accommodate for that and lead to less flakey results.
1 parent 27a9c1e commit dda2764

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

test/benchee_test.exs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,14 +1057,29 @@ defmodule BencheeTest do
10571057
assert_receive {^port, {:data, "Warning: " <> message}}, 20_000
10581058
assert message =~ ~r/test.+evaluated.+slower.+compiled.+module.+/is
10591059

1060-
# waiting for iex to be ready for input again
1061-
assert_receive {^port, {:data, "iex(2)> "}}, 20_000
1060+
# waiting for iex to be ready for input again/the benchmark to be finished
1061+
# sometimes we get "iex(2)>" as a separate message, sometimes it's attached to the
1062+
# previous output - hence we gotta doe out own `receive` checking.
1063+
assert :ok = wait_for_benchmark_finished(port)
10621064
after
10631065
# https://elixirforum.com/t/starting-shutting-down-iex-with-a-port-gracefully/60388/2?u=pragtob
10641066
send(port, {self(), {:command, "\a"}})
10651067
send(port, {self(), {:command, "q\n"}})
10661068
end
10671069
end
1070+
1071+
defp wait_for_benchmark_finished(port) do
1072+
receive do
1073+
{^port, {:data, output}} ->
1074+
if String.contains?(output, "iex(2)>") do
1075+
:ok
1076+
else
1077+
wait_for_benchmark_finished(port)
1078+
end
1079+
after
1080+
20_000 -> raise RuntimeError, "Waited too long for iex benchmark to finish/send iex(2)>"
1081+
end
1082+
end
10681083
end
10691084

10701085
describe "escript building" do

0 commit comments

Comments
 (0)