mirror of
https://github.com/correl/rebar.git
synced 2024-11-27 11:09:55 +00:00
Handle ct_run exit codes in R15B02 and later
Since R15B02, ct_run returns a non-zero exit code when some tests failed or were auto-skipped. (See ticket OTP-9865.) This fix makes it so a non-0 code doesn't cause an instant failure, but still prompts for log verification before doing so. Given the behaviour was acceptable for pre-R15B02, it should be valid with it with post-R15B02. The fix should also be backwards compatible.
This commit is contained in:
parent
1a083672b1
commit
bcc57e9b04
1 changed files with 22 additions and 4 deletions
|
@ -108,8 +108,16 @@ run_test(TestDir, LogDir, Config, _File) ->
|
||||||
" 2>&1 | tee -a " ++ RawLog
|
" 2>&1 | tee -a " ++ RawLog
|
||||||
end,
|
end,
|
||||||
|
|
||||||
rebar_utils:sh(Cmd ++ Output, [{env,[{"TESTDIR", TestDir}]}]),
|
case rebar_utils:sh(Cmd ++ Output, [{env,[{"TESTDIR", TestDir}]}, return_on_error]) of
|
||||||
check_log(Config, RawLog).
|
{ok,_} ->
|
||||||
|
%% in older versions of ct_run, this could have been a failure
|
||||||
|
%% that returned a non-0 code. Check for that!
|
||||||
|
check_success_log(Config, RawLog);
|
||||||
|
{error,Res} ->
|
||||||
|
%% In newer ct_run versions, this may be a sign of a good compile
|
||||||
|
%% that failed cases. In older version, it's a worse error.
|
||||||
|
check_fail_log(Config, RawLog, Cmd ++ Output, Res)
|
||||||
|
end.
|
||||||
|
|
||||||
clear_log(LogDir, RawLog) ->
|
clear_log(LogDir, RawLog) ->
|
||||||
case filelib:ensure_dir(filename:join(LogDir, "index.html")) of
|
case filelib:ensure_dir(filename:join(LogDir, "index.html")) of
|
||||||
|
@ -124,7 +132,16 @@ clear_log(LogDir, RawLog) ->
|
||||||
|
|
||||||
%% calling ct with erl does not return non-zero on failure - have to check
|
%% calling ct with erl does not return non-zero on failure - have to check
|
||||||
%% log results
|
%% log results
|
||||||
check_log(Config, RawLog) ->
|
check_success_log(Config, RawLog) ->
|
||||||
|
check_log(Config, RawLog, fun(Msg) -> ?CONSOLE("DONE.\n~s\n", [Msg]) end).
|
||||||
|
|
||||||
|
check_fail_log(Config, RawLog, Command, {Rc, Output}) ->
|
||||||
|
check_log(Config, RawLog, fun(_Msg) ->
|
||||||
|
?ABORT("~s failed with error: ~w and output:~n~s~n",
|
||||||
|
[Command, Rc, Output])
|
||||||
|
end).
|
||||||
|
|
||||||
|
check_log(Config,RawLog,Fun) ->
|
||||||
{ok, Msg} =
|
{ok, Msg} =
|
||||||
rebar_utils:sh("grep -e 'TEST COMPLETE' -e '{error,make_failed}' "
|
rebar_utils:sh("grep -e 'TEST COMPLETE' -e '{error,make_failed}' "
|
||||||
++ RawLog, [{use_stdout, false}]),
|
++ RawLog, [{use_stdout, false}]),
|
||||||
|
@ -142,9 +159,10 @@ check_log(Config, RawLog) ->
|
||||||
?FAIL;
|
?FAIL;
|
||||||
|
|
||||||
true ->
|
true ->
|
||||||
?CONSOLE("DONE.\n~s\n", [Msg])
|
Fun(Msg)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
||||||
%% Show the log if it hasn't already been shown because verbose was on
|
%% Show the log if it hasn't already been shown because verbose was on
|
||||||
show_log(Config, RawLog) ->
|
show_log(Config, RawLog) ->
|
||||||
?CONSOLE("Showing log\n", []),
|
?CONSOLE("Showing log\n", []),
|
||||||
|
|
Loading…
Reference in a new issue