Skip to content
Open
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
24 changes: 19 additions & 5 deletions lib/common_test/src/ct_framework.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1013,17 +1013,21 @@ error_notification(Mod,Func,_Args,{Error,Loc}) ->
%% if a function specified by all/0 does not exist, we
%% pick up undef here
[{LastMod,LastFunc}|_] when ErrorStr == "undef" ->
PrintError("~w:~tw could not be executed~nReason: ~ts",
[LastMod,LastFunc,ErrorStr]);
LastSource = error_notification_source_info(LastMod),
PrintError("~w:~tw at ~ts could not be executed~nReason: ~ts",
[LastMod,LastFunc,LastSource,ErrorStr]);

[{LastMod,LastFunc}|_] ->
PrintError("~w:~tw failed~nReason: ~ts", [LastMod,LastFunc,ErrorStr]);
LastSource = error_notification_source_info(LastMod),
PrintError("~w:~tw at ~ts failed~nReason: ~ts",
[LastMod,LastFunc,LastSource,ErrorStr]);

[{LastMod,LastFunc,LastLine}|_] ->
%% print error to console, we are only
%% interested in the last executed expression
PrintError("~w:~tw failed on line ~w~nReason: ~ts",
[LastMod,LastFunc,LastLine,ErrorStr]),
LastSource = error_notification_source_info(LastMod),
PrintError("~w:~tw at ~ts:~w failed~nReason: ~ts",
[LastMod,LastFunc,LastSource,LastLine,ErrorStr]),

case ct_util:read_suite_data({seq,Mod,Func}) of
undefined ->
Expand All @@ -1035,6 +1039,16 @@ error_notification(Mod,Func,_Args,{Error,Loc}) ->
end,
ok.

error_notification_source_info(Mod) ->
maybe
{Mod, Beam, _} ?= code:get_object_code(Mod),
{ok, {Mod, [{abstract_code, {_, Forms}}]}} ?= beam_lib:chunks(Beam, [abstract_code]),
[{attribute, _, file, {File, _}}|_] ?= Forms,
File
else
_ -> atom_to_list(Mod) ++ ".erl"
end.

%% cases in seq that have already run
mark_as_failed(Seq,Mod,Func,[Func|TCs]) ->
mark_as_failed1(Seq,Mod,Func,TCs);
Expand Down
Loading