Skip to content

Commit a33b98c

Browse files
committed
Merge branch 'kuba/common_test/cte_track_fix_not_exported_init_per_suite/OTP-20316' into maint
* kuba/common_test/cte_track_fix_not_exported_init_per_suite/OTP-20316: common_test: Fix cte_track suite name for suites without init_per_suite
2 parents b752625 + 0a43879 commit a33b98c

1 file changed

Lines changed: 22 additions & 2 deletions

File tree

lib/common_test/src/cte_track.erl

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,30 @@ handle_event(#event{name = tc_start,
6666
data = {Suite, init_per_suite}},
6767
State0 = #{device := D,
6868
test_stats := TestStats}) ->
69-
print(D, "~n~p: ", [Suite]),
70-
State1 = maps:put(suite, Suite, State0),
69+
%% When Suite is ct_framework the real suite lacks init_per_suite;
70+
%% defer header printing until the first real tc_start arrives.
71+
SuiteName = case Suite of
72+
ct_framework -> pending;
73+
_ -> print(D, "~n~p: ", [Suite]), Suite
74+
end,
75+
State1 = maps:put(suite, SuiteName, State0),
7176
State = maps:put(suite_stats0, TestStats, State1),
7277
{ok, State};
78+
handle_event(#event{name = tc_start,
79+
data = {Suite, {init_per_group, GroupName, _}}},
80+
State = #{device := D, suite := pending})
81+
when Suite =/= ct_framework ->
82+
%% Resolve deferred suite header from first init_per_group
83+
print(D, "~n~p: ", [Suite]),
84+
State1 = maps:put(suite, Suite, State),
85+
{ok, maps:put(group, GroupName, State1)};
86+
handle_event(#event{name = tc_start,
87+
data = {Suite, Case}},
88+
State = #{device := D, suite := pending})
89+
when is_atom(Case), Case =/= end_per_suite ->
90+
%% Resolve deferred suite header from first test case
91+
print(D, "~n~p: ", [Suite]),
92+
{ok, maps:put(suite, Suite, State)};
7393
handle_event(#event{name = tc_start,
7494
data = {_Suite, {init_per_group, GroupName, _}}},
7595
State) ->

0 commit comments

Comments
 (0)