At work, our current way of running our ExUnit tests is to set several environment variables before the mix test
. For example:
URL=http://dev-site.com mix test
or
URL=http://staging-site.com mix test
or
URL=http://pr-1234-staging-site.com mix test
There are a lot of environment variables besides these. Today I tried writing a mix task that would simplify and validate all this input. It works great, for example, I can run the above three tests on the command line like this:
mix my_test --dev
mix my_test --staging
mix my_test --pr 1234
That’s implemented in the mix task ultimately as:
Mix.Shell.IO.cmd(“URL=http://staging-site.com mix test”)
But!
These tests take a long time to run and when I try to Ctrl+C out of them as I normally would, I get my shell command like back, but the tests keep running in the background. What could be going on?
edit: Should I instead call Mix.Tasks.Test.run/1
directly, passing in the argv
list? I’d love to do that (it actually solved the Ctrl-C problem), but I don’t know how to set the temporary environment variables in that case.