@@ -196,7 +196,14 @@ pre_init_per_group(_Suite,Group,Config,State) ->
196
196
post_init_per_group (Suite ,Group ,Config ,Result ,Proxy ) when is_pid (Proxy ) ->
197
197
{gen_server :call (Proxy ,{? FUNCTION_NAME , [Suite , Group , Config , Result ]}),Proxy };
198
198
post_init_per_group (_Suite ,_Group ,Config ,Result ,State ) ->
199
- {Result , end_tc (init_per_group ,Config ,Result ,State )}.
199
+ NewState = end_tc (init_per_group ,Config ,Result ,State ),
200
+ case Result of
201
+ {skip , _ } ->
202
+ % % on_tc_skip will be called which will re-add this group
203
+ {Result , NewState # state { curr_group = tl (NewState # state .curr_group ) }};
204
+ _ ->
205
+ {Result , NewState }
206
+ end .
200
207
201
208
pre_end_per_group (Suite ,Group ,Config ,Proxy ) when is_pid (Proxy ) ->
202
209
{gen_server :call (Proxy ,{? FUNCTION_NAME , [Suite , Group , Config ]}),Proxy };
@@ -253,26 +260,30 @@ get_line_from_result(_, _) ->
253
260
on_tc_skip (Suite ,TC ,Result ,Proxy ) when is_pid (Proxy ) ->
254
261
_ = gen_server :call (Proxy ,{? FUNCTION_NAME , [Suite ,TC ,Result ]}),
255
262
Proxy ;
256
- on_tc_skip (Suite ,{ConfigFunc ,_GrName }, Res , State ) ->
257
- on_tc_skip (Suite ,ConfigFunc , Res , State );
263
+ on_tc_skip (Suite ,{init_per_group ,GrName }, Res , State ) ->
264
+ on_tc_skip (Suite ,init_per_group , Res , State # state { curr_group = [GrName | State # state .curr_group ]});
265
+ on_tc_skip (Suite ,{end_per_group ,GrName }, Res , State ) ->
266
+ NewState = on_tc_skip (Suite ,end_per_group , Res , State ),
267
+ NewState # state { curr_group = tl (State # state .curr_group )};
268
+ on_tc_skip (Suite ,{ConfigFunc ,GrName }, Res , State ) ->
269
+ if GrName =:= hd (State # state .curr_group ) ->
270
+ on_tc_skip (Suite ,ConfigFunc , Res , State );
271
+ true ->
272
+ NewState = on_tc_skip (Suite ,ConfigFunc , Res ,
273
+ State # state { curr_group = [GrName | State # state .curr_group ]}),
274
+ NewState # state { curr_group = tl (NewState # state .curr_group )}
275
+ end ;
258
276
on_tc_skip (Suite ,Tc , Res , State0 ) ->
259
277
TcStr = atom_to_list (Tc ),
278
+ CurrGroup = make_group_string (State0 # state .curr_group ),
260
279
State1 =
261
280
case State0 # state .test_cases of
262
- [# testcase {name = TcStr }|TCs ] ->
281
+ [# testcase {name = TcStr , group = CurrGroup }|TCs ] ->
263
282
State0 # state {test_cases = TCs };
264
283
_ ->
265
284
State0
266
285
end ,
267
- State2 = end_tc (Tc ,[],Res ,init_tc (set_suite (Suite ,State1 ),[])),
268
- CurrGroup = State2 # state .curr_group ,
269
- State =
270
- case {Tc , is_list (CurrGroup ) andalso length (CurrGroup )> 0 }of
271
- {end_per_group , true } ->
272
- State2 # state {curr_group = tl (CurrGroup )};
273
- _ ->
274
- State2
275
- end ,
286
+ State = end_tc (Tc ,[],Res ,init_tc (set_suite (Suite ,State1 ),[])),
276
287
do_tc_skip (Res , State ).
277
288
278
289
do_tc_skip (Res , State ) ->
@@ -313,7 +324,7 @@ end_tc(Name, _Config, _Res, State = #state{ curr_suite = Suite,
313
324
end ,
314
325
Url = make_url (UrlBase ,Log ),
315
326
ClassName = atom_to_list (Suite ),
316
- PGroup = lists : concat ( lists : join ( " . " , lists : reverse ( Groups )) ),
327
+ PGroup = make_group_string ( Groups ),
317
328
TimeTakes = io_lib :format (" ~f " ,[timer :now_diff (? now ,TS ) / 1000000 ]),
318
329
State # state { test_cases = [# testcase { log = Log ,
319
330
url = Url ,
@@ -329,6 +340,9 @@ end_tc(Name, _Config, _Res, State = #state{ curr_suite = Suite,
329
340
State # state .test_cases ],
330
341
tc_log = " " }. % so old tc_log is not set if next is on_tc_skip
331
342
343
+ make_group_string (Groups ) ->
344
+ lists :concat (lists :join (" ." ,lists :reverse (Groups ))).
345
+
332
346
set_suite (Suite ,# state {curr_suite = undefined }= State ) ->
333
347
State # state {curr_suite = Suite , curr_suite_ts = ? now };
334
348
set_suite (_ ,State ) ->
0 commit comments