Skip to content

Commit

Permalink
Small fixes for the overly long iex warning CI test
Browse files Browse the repository at this point in the history
  • Loading branch information
PragTob committed Jul 7, 2024
1 parent a62708c commit 50d77c0
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions test/benchee_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -1039,27 +1039,31 @@ defmodule BencheeTest do
end
end

# timeout huge because of CI
@overly_long_ci_waiting_time 20_000
describe "warn when functions are evaluated" do
test "warns when run in iex" do

Check failure on line 1045 in test/benchee_test.exs

View workflow job for this annotation

GitHub Actions / Test on Ubuntu (Elixir 1.13.4, OTP 24.3)

test warn when functions are evaluated warns when run in iex (BencheeTest)
# test env to avoid repeated compilation on CI
port = Port.open({:spawn, "iex -S mix"}, [:binary, env: [{~c"MIX_ENV", ~c"test"}]])

try do
# wait for startup
# timeout huge because of CI
assert_receive {^port, {:data, "iex(1)> "}}, 20_000
assert_receive {^port, {:data, "iex(1)> "}}, @overly_long_ci_waiting_time

send(
port,
{self(),
{:command, "Benchee.run(%{\"test\" => fn -> 1 end}, time: 0.001, warmup: 0)\n"}}
{
self(),
# end with nil to avoid printing of the entire suite
{:command, "Benchee.run(%{\"test\" => fn -> 1 end}, time: 0.001, warmup: 0); nil\n"}
}
)

assert_receive {^port, {:data, "Warning: " <> message}}, 20_000
assert_receive {^port, {:data, "Warning: " <> message}}, @overly_long_ci_waiting_time
assert message =~ ~r/test.+evaluated.+slower.+compiled.+module.+/is

# waiting for iex to be ready for input again
assert_receive {^port, {:data, "iex(2)> "}}, 20_000
assert_receive {^port, {:data, "iex(2)> "}}, @overly_long_ci_waiting_time
after
# https://elixirforum.com/t/starting-shutting-down-iex-with-a-port-gracefully/60388/2?u=pragtob
send(port, {self(), {:command, "\a"}})
Expand Down

0 comments on commit 50d77c0

Please sign in to comment.