@@ -120,30 +120,28 @@ create or replace package body ut_expectation_processor as
120120
121121 end;
122122
123- function who_called_expectation return varchar2 is
124- c_call_stack constant varchar2(32767) := dbms_utility.format_call_stack();
123+ function who_called_expectation(a_call_stack varchar2) return varchar2 is
125124 l_caller_stack_line varchar2(4000);
126- l_caller_type_and_name varchar2(4000);
127125 l_line_no integer;
128126 l_owner varchar2(1000);
129- l_object_name varchar2(1000);
127+ l_object_name varchar2(1000);
128+ l_result varchar2(4000);
130129 -- in 12.2 format_call_stack reportes not only package name, but also the procedure name
131130 -- when 11g and 12c reports only package name
132- c_expectation_search_pattern constant varchar2(500) :=
131+ c_expectation_search_pattern constant varchar2(500) :=
133132 '(.*\.(UT_EXPECTATION[A-Z0-9#_$]*|UT|UTASSERT2?)(\.[A-Z0-9#_$]+)?\s+)+(.*)';
134133 begin
135- l_caller_stack_line := regexp_substr( c_call_stack, c_expectation_search_pattern, 1, 1, 'm', 4);
136- l_line_no := to_number( regexp_substr(l_caller_stack_line,'0x[0-9a-f]+\s+(\d+)',subexpression => 1) );
137- l_caller_type_and_name := trim(regexp_substr(l_caller_stack_line,'0x[0-9a-f]+\s+\d+\s+(.+)',subexpression => 1));
134+ l_caller_stack_line := regexp_substr( a_call_stack, c_expectation_search_pattern, 1, 1, 'm', 4);
138135 if l_caller_stack_line like '%.%' then
136+ l_line_no := to_number( regexp_substr(l_caller_stack_line,'(0x)?[0-9a-f]+\s+(\d+)',subexpression => 2) );
139137 l_owner := regexp_substr(l_caller_stack_line,'([A-Za-z0-9$#_]+)\.([A-Za-z0-9$#_]|\.)+',subexpression => 1);
140138 l_object_name := regexp_substr(l_caller_stack_line,'([A-Za-z0-9$#_]+)\.(([A-Za-z0-9$#_]|\.)+)',subexpression => 2);
139+ if l_owner is not null and l_object_name is not null and l_line_no is not null then
140+ l_result := 'at "' || l_owner || '.' || l_object_name || '", line '|| l_line_no || ' '
141+ || ut_metadata.get_source_definition_line(l_owner, l_object_name, l_line_no);
142+ end if;
141143 end if;
142- return
143- case when l_owner is not null and l_object_name is not null and l_line_no is not null then
144- 'at "' || l_owner || '.' || l_object_name || '", line '|| l_line_no || ' ' ||
145- ut_metadata.get_source_definition_line(l_owner, l_object_name, l_line_no)
146- end;
144+ return l_result;
147145 end;
148146end;
149147/
0 commit comments