Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 92f7b4c

Browse files
committed
Replace is_output_reporter by get_reporters_list
The list should return all known Reporters and information about whether the reporter is an output reporter or not
1 parent bfde057 commit 92f7b4c

2 files changed

Lines changed: 40 additions & 23 deletions

File tree

source/api/ut_runner.pkb

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -141,22 +141,38 @@ create or replace package body ut_runner is
141141
return;
142142
end;
143143

144-
function is_output_reporter( a_reporter_name varchar2 ) return varchar is
145-
l_result varchar2(1);
146-
l_reporter_name varchar2(32) := regexp_replace(a_reporter_name, '[^a-zA-Z0-9_]', '');
144+
function get_reporters_list return tt_reporters_info pipelined
145+
AS
146+
l_cursor sys_refcursor;
147147
l_owner varchar2(128) := ut_utils.ut_owner();
148-
begin
149-
execute immediate '
150-
select
151-
case
152-
when '||l_reporter_name||'() is of ('||l_owner||'.ut_output_reporter_base) then ''Y''
153-
when '||l_reporter_name||'() is of ('||l_owner||'.ut_reporter_base) then ''N''
154-
end
155-
from dual' into l_result;
156-
return l_result;
157-
exception when others then
158-
return null;
159-
end;
148+
l_results tt_reporters_info;
149+
c_bulk_limit constant integer := 10;
150+
begin
151+
open l_cursor for 'SELECT
152+
owner || ''.'' || type_name,
153+
CASE
154+
WHEN sys_connect_by_path(owner
155+
|| ''.''
156+
|| type_name,'','') LIKE ''%' || l_owner || '''
157+
|| ''.UT_OUTPUT_REPORTER_BASE%'' THEN ''Y''
158+
ELSE ''N''
159+
END
160+
is_output_reporter
161+
FROM dba_types t
162+
WHERE instantiable = ''YES''
163+
CONNECT BY supertype_name = PRIOR type_name AND supertype_owner = PRIOR owner
164+
START WITH type_name = ''UT_REPORTER_BASE'' AND owner = '''|| l_owner || '''';
165+
loop
166+
fetch l_cursor bulk collect into l_results limit c_bulk_limit;
167+
for i in 1 .. l_results.count loop
168+
pipe row (l_results(i));
169+
end loop;
170+
exit when l_cursor%notfound;
171+
end loop;
172+
close l_cursor;
173+
end;
174+
175+
160176

161177
end ut_runner;
162178
/

source/api/ut_runner.pks

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -99,16 +99,17 @@ create or replace package ut_runner authid current_user is
9999
*/
100100
function get_unit_test_info(a_owner varchar2, a_package_name varchar2 := null) return tt_annotations pipelined;
101101

102-
/** Checks whether a reporter is an output reporter or not
103-
* If reporter is of ut_output_reporter_base, returns 'Y'
104-
* If reporter is of ut_reporter_base, returns 'N'
105-
* Otherwise returns NULL
102+
type t_reporter_rec is record (
103+
reporter_object_name varchar2(250),
104+
is_output_reporter varchar2(1) --Y/N flag
105+
);
106+
type tt_reporters_info is table of t_reporter_rec ;
107+
108+
/** Returns a list of available reporters. Gives information about whether a reporter is an output reporter or not
106109
*
107-
* @param a_reporter_name Name of the reporter to check
108-
* @return Y, N or NULL
110+
* @return tt_reporters_info
109111
*/
110-
function is_output_reporter( a_reporter_name varchar2 ) return varchar;
111-
112+
function get_reporters_list return tt_reporters_info pipelined;
112113

113114
end ut_runner;
114115
/

0 commit comments

Comments
 (0)