In my Mix app, there is a particular set of circumstances that seems to be causing the process that runs the test suite to hang. Here's the scenario -
In test/test_helper.exs
, prior to the call to ExUnit.start()
, I have a call to Mix.Shell.IO.yes?
, where the user confirms some aspect of the test behavior.
if Mix.Shell.IO.yes?("Set up additional test assets?") do
Mix.Task.run "run", ["test/support/fetch_and_start.exs"]
end
ExUnit.start()
When I run $ mix test
, this all goes off without a hitch.
At some point a few months back, another contributer to the repo added an additional testing scenario, which can be be run by calling $ mix test.options
- to mix.exs
, she added
defp aliases do
[
{:"test.options", [&run_options_tests/1]}
]
end
defp run_options_tests(_) do
IO.puts "\nRunning tests with options enabled."
Mix.shell.cmd(
"mix test --color",
env: [{"MIX_ENV", "test_options"}]
)
end
(the test_options
config imports the 'normal' test config, just adds a bit to it)
Before I added this Mix.Shell.IO.yes?
business, the $ mix test.options
command also worked just fine. However, now that I've added that logic, $ mix test.options
is failing - Mix.Shell.IO.yes?
asks for the user's input, and then just hangs - it doesn't execute any code inside the block, and the behavior is the same regardless of the user's input.
So in brief summary -
$ mix test
causesMix.Shell.IO.yes?
to be called, which works as expected.$ mix test.options
, which invokes$ mix test
viaMix.shell.cmd()
used to work beforeMix.Shell.IO.yes?
was added to the flow.$ mix test.options
now results in the process hanging after receiving the users's input fromMix.Shell.IO.yes?
.
It seems that the combination of these methods is the problem, but I'm not clear on what's causing the issue or how to resolve it. Any guidance would be greatly appreciated.
Elixir version 1.8.1, Erlang/OTP version 21, MacOS