Skip to content
Open
Show file tree
Hide file tree
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
31 changes: 23 additions & 8 deletions src/riak_test_escript.erl
Original file line number Diff line number Diff line change
Expand Up @@ -341,17 +341,32 @@ print_summary(TestResults, CoverResult, Verbose) ->
[ atom_to_list(proplists:get_value(test, SingleTestResult)) ++ "-" ++
backend_list(proplists:get_value(backend, SingleTestResult)),
proplists:get_value(status, SingleTestResult),
proplists:get_value(reason, SingleTestResult)]
proplists:get_value(reason, SingleTestResult),
proplists:get_value(duration, SingleTestResult)]
|| SingleTestResult <- TestResults],
Width = test_name_width(Results),

Print = fun(Test, Status, Reason) ->
case {Status, Verbose} of
{fail, true} -> io:format("~s: ~s ~p~n", [string:left(Test, Width), Status, Reason]);
_ -> io:format("~s: ~s~n", [string:left(Test, Width), Status])
end
end,
[ Print(Test, Status, Reason) || [Test, Status, Reason] <- Results],
Print = fun(Test, Status, Reason, DurationUSec) ->
Duration =
case DurationUSec of
DurationUSec when is_integer(DurationUSec) ->
io_lib:format("~6.1f sec", [DurationUSec / 1000000]);
DurationUSec ->
io_lib:format("~p", [DurationUSec])
end,

case {Status, Verbose} of
{fail, true} ->
io:format("~s: ~s (~s) ~p~n",
[string:left(Test, Width), Status, Duration, Reason]);
_ ->
io:format("~s: ~s (~s)~n",
[string:left(Test, Width), Status, Duration])
end
end,
lists:foreach(fun(SingleTestResult) ->
erlang:apply(Print, SingleTestResult)
end, Results),

PassCount = length(lists:filter(fun(X) -> proplists:get_value(status, X) =:= pass end, TestResults)),
FailCount = length(lists:filter(fun(X) -> proplists:get_value(status, X) =:= fail end, TestResults)),
Expand Down
22 changes: 12 additions & 10 deletions src/riak_test_runner.erl
Original file line number Diff line number Diff line change
Expand Up @@ -51,21 +51,23 @@ confirm(TestModule, Outdir, TestMetaData, HarnessArgs) ->
end,
Backend = rt:set_backend(proplists:get_value(backend, TestMetaData), BackendExtras),
{Mod, Fun} = function_name(TestModule),
{Status, Reason} = case check_prereqs(Mod) of
true ->
lager:notice("Running Test ~s", [TestModule]),
execute(TestModule, {Mod, Fun}, TestMetaData);
not_present ->
{fail, test_does_not_exist};
_ ->
{fail, all_prereqs_not_present}
end,
{USec, {Status, Reason}} =
case check_prereqs(Mod) of
true ->
lager:notice("Running Test ~s", [TestModule]),
timer:tc(fun() -> execute(TestModule, {Mod, Fun}, TestMetaData) end);
not_present ->
{'N/A', {fail, test_does_not_exist}};
_ ->
{'N/A', {fail, all_prereqs_not_present}}
end,

lager:notice("~s Test Run Complete", [TestModule]),
{ok, Logs} = stop_lager_backend(),
Log = unicode:characters_to_binary(Logs),

RetList = [{test, TestModule}, {status, Status}, {log, Log}, {backend, Backend} | proplists:delete(backend, TestMetaData)],
RetList = [{test, TestModule}, {status, Status}, {log, Log}, {backend, Backend}, {duration, USec}
| proplists:delete(backend, TestMetaData)],
case Status of
fail -> RetList ++ [{reason, iolist_to_binary(io_lib:format("~p", [Reason]))}];
_ -> RetList
Expand Down