Getting count of suites/cases from common test hook

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Getting count of suites/cases from common test hook

Roger Lipscombe-2
I'd like to display progress for my common test suites (~275 cases across ~50 suites), which means that I'd like to get hold of the count of suites and cases from inside a common test hook (which I already have).

I know that CT has this information, because it prints it out (in ct_run:do_run_test/3) just before it starts running the tests.

Can I get at this information?


_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Getting count of suites/cases from common test hook

Max Lapshin-2
You want to get number of test suites  _before_  launching tests?

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Getting count of suites/cases from common test hook

Roger Lipscombe-2
On 12 May 2017 at 15:22, Max Lapshin <[hidden email]> wrote:
You want to get number of test suites  _before_  launching tests?

Yes. A full test run takes about 20 minutes, so I'd like to display test progress (probably in the title bar of the terminal window). That requires knowing the number of tests suites/cases up front. CT itself can figure this out; I was wondering if there was a way to get at that information (probably in a CTH, because I already have one of those).

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Getting count of suites/cases from common test hook

Max Lapshin-2
It requires calling functions in each module.

As far as I remember,  ct_hook don't tell it before.


It is easy to add handler:

ct_run ... -event_handler flussonic_ct_handler

in the handler you get:




-module(flussonic_ct_handler).

-record(event, {name, node, data}).


-compile(export_all).




init(_Args) ->
  % io:fwrite(standard_error, "ARGS: ~p\n\n", [Args]),
  {ok, #state{started_at = now_ms()}}.

handle_event(#event{name=start_make}, #state{first_make_at = undefined} =State) ->
  {ok, State#state{first_make_at = now_ms()}};

.....


But I don't remember there a total count of tests _before_ launching.  However, the progress bar is a cool idea.


_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Getting count of suites/cases from common test hook

Roger Lipscombe-2
On 12 May 2017 at 19:14, Max Lapshin <[hidden email]> wrote:
ct_run ... -event_handler flussonic_ct_handler

Thanks, Max. There are event hooks for all of the things I'm interested in. This is perfect.

Except... I'll raise another question for the follow-up.

Cheers,
Roger.

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Getting count of suites/cases from common test hook

Max Lapshin-2
handle_event(#event{name=start_info, data = {_NoOfTests,_NoOfSuites,NoOfCases}}, #state{} =State) ->
  {ok, State#state{cases = NoOfCases}};


handle_event(#event{name=tc_done, data = _Data}, #state{done = Done, started_at = Start} =State) ->
  Out = io_lib:format("~5.2f% ~Bs", [Done1*100/State#state.cases, (now_ms() - Start) div 1000]),
  io:format(standard_error, "~s\e[~BD", [Out, iolist_size(Out)]),
  {ok, State#state{done = Done1}};


handle_event(#event{name=test_stats,data = {Ok,Failed,{UserSkipped,AutoSkipped}}}, #state{} = State) ->
  {ok, State#state{
    ok = Ok + State#state.ok,
    failed = Failed + State#state.failed,
    skipped = UserSkipped + AutoSkipped + State#state.skipped
  }};


handle_event(#event{name=test_done}, #state{} =State) ->
  io:format(standard_error, "Total: ~Bs \n"
  ....


ct_run calculates number of test cases before start, so you can make a spinner with percents.


_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Loading...