System.stop/1 seems to have its status code swallowed by Mix for some reason. I'm not entirely sure why but when checking other implementations such as credo, they are using the exit/1 kernel function instead.
After testing, this properly produces an exit code of 1 for failure cases where previously they were 0, despite the call System.stop(1).
This allows the cli commands to properly halt CI processes and makes building wrapper scripts easier.
Test example
# Call with `mix text_exit && echo $?` to see true exit code
defmodule Mix.Tasks.TestExit do
use Mix.Task
require Logger
def run(args) do
Logger.info("Trying to exit with status code 1")
System.stop(1)
end
end
Corrected example
# Call with `mix text_exit_corrected && echo $?` to see true exit code
defmodule Mix.Tasks.TestExitCorrected do
use Mix.Task
require Logger
def run(args) do
Logger.info("Trying to exit with status code 1")
exit({:shutdown, 1})
end
end
System.stop/1
seems to have its status code swallowed by Mix for some reason. I'm not entirely sure why but when checking other implementations such as credo, they are using theexit/1
kernel function instead.After testing, this properly produces an exit code of
1
for failure cases where previously they were0
, despite the callSystem.stop(1)
.This allows the cli commands to properly halt CI processes and makes building wrapper scripts easier.
Test example
Corrected example