diff --git a/src/riak_test_escript.erl b/src/riak_test_escript.erl index b883364cc..8df428297 100644 --- a/src/riak_test_escript.erl +++ b/src/riak_test_escript.erl @@ -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)), diff --git a/src/riak_test_runner.erl b/src/riak_test_runner.erl index eac78838b..3808862b5 100644 --- a/src/riak_test_runner.erl +++ b/src/riak_test_runner.erl @@ -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