Skip to content

Commit

Permalink
improve iex test, but it still leaks and breaks shell
Browse files Browse the repository at this point in the history
  • Loading branch information
PragTob committed Dec 15, 2023
1 parent c826d35 commit db9ef98
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions test/benchee_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -1034,18 +1034,25 @@ defmodule BencheeTest do
# test env to avoid repeated compilation on CI
port = Port.open({:spawn, "iex -S mix"}, [:binary, env: [{~c"MIX_ENV", ~c"test"}]])

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

send(
port,
{self(), {:command, "Benchee.run(%{\"test\" => fn -> 1 end}, time: 0.001, warmup: 0)\n"}}
)
try do
# wait for startup
# timeout huge because of CI
assert_receive {^port, {:data, "iex(1)> "}}, 20_000

send(
port,
{self(),
{:command, "Benchee.run(%{\"test\" => fn -> 1 end}, time: 0.001, warmup: 0)\n"}}
)

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

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
after
Port.close(port)
end
end
end

Expand Down

0 comments on commit db9ef98

Please sign in to comment.