diff --git a/lib/common_test/src/ct_framework.erl b/lib/common_test/src/ct_framework.erl index 242fd3ce1e06..18ec9faae829 100644 --- a/lib/common_test/src/ct_framework.erl +++ b/lib/common_test/src/ct_framework.erl @@ -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 -> @@ -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);