Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions test/benchee_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -1057,14 +1057,29 @@ defmodule BencheeTest do
assert_receive {^port, {:data, "Warning: " <> message}}, 20_000
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
# waiting for iex to be ready for input again/the benchmark to be finished
# sometimes we get "iex(2)>" as a separate message, sometimes it's attached to the
# previous output - hence we gotta doe out own `receive` checking.
assert :ok = wait_for_benchmark_finished(port)
after
# https://elixirforum.com/t/starting-shutting-down-iex-with-a-port-gracefully/60388/2?u=pragtob
send(port, {self(), {:command, "\a"}})
send(port, {self(), {:command, "q\n"}})
end
end

defp wait_for_benchmark_finished(port) do
receive do
{^port, {:data, output}} ->
if String.contains?(output, "iex(2)>") do
:ok
else
wait_for_benchmark_finished(port)
end
after
20_000 -> raise RuntimeError, "Waited too long for iex benchmark to finish/send iex(2)>"
end
end
end

describe "escript building" do
Expand Down