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

Skip to content

Commit 9ab9155

Browse files
committed
Refactored reporters API so that you can use API in unified way regardless of reporter that is used.
All reporters are now parameter-agnostic and the parameters are defined at the `ut_run` level. Exception is ut_coverage_html_reporter, which is using two individual parameters (a_html_report_assets_path, a_project_name), but those are optional.
1 parent de9b5c1 commit 9ab9155

32 files changed

Lines changed: 693 additions & 587 deletions

source/api/ut.pkb

Lines changed: 184 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -94,20 +94,93 @@ create or replace package body ut is
9494
ut_expectation_processor.report_failure(a_message);
9595
end;
9696

97-
procedure run_autonomous(a_paths ut_varchar2_list, a_reporter ut_reporter_base, a_color_console integer) is
97+
procedure run_autonomous(
98+
a_paths ut_varchar2_list, a_reporter ut_reporter_base, a_color_console integer,
99+
a_project_file_mappings ut_file_mappings, a_test_file_mappings ut_file_mappings,
100+
a_include_object_list ut_varchar2_list, a_exclude_object_list ut_varchar2_list
101+
) is
98102
pragma autonomous_transaction;
99103
begin
100-
ut_runner.run(a_paths, a_reporter, ut_utils.int_to_boolean(a_color_console));
104+
ut_runner.run(
105+
a_paths, a_reporter, ut_utils.int_to_boolean(a_color_console),
106+
a_project_file_mappings, a_test_file_mappings, a_include_object_list, a_exclude_object_list
107+
);
101108
rollback;
102109
end;
103110

104-
function run(a_reporter ut_reporter_base := ut_documentation_reporter(), a_color_console integer := 0) return ut_varchar2_rows pipelined is
111+
procedure run_autonomous(
112+
a_paths ut_varchar2_list, a_reporter ut_reporter_base, a_color_console integer,
113+
a_project_files ut_varchar2_list, a_test_files ut_varchar2_list,
114+
a_include_object_list ut_varchar2_list, a_exclude_object_list ut_varchar2_list
115+
) is
116+
pragma autonomous_transaction;
117+
begin
118+
ut_runner.run(
119+
a_paths, a_reporter, ut_utils.int_to_boolean(a_color_console),
120+
a_project_files, a_test_files, a_include_object_list, a_exclude_object_list
121+
);
122+
rollback;
123+
end;
124+
125+
function run(
126+
a_reporter ut_reporter_base := null, a_color_console integer := 0,
127+
a_project_file_mappings ut_file_mappings := null, a_test_file_mappings ut_file_mappings := null,
128+
a_include_object_list ut_varchar2_list := null, a_exclude_object_list ut_varchar2_list := null
129+
) return ut_varchar2_rows pipelined is
105130
l_reporter ut_reporter_base := coalesce(a_reporter, ut_documentation_reporter());
106131
l_paths ut_varchar2_list := ut_varchar2_list(sys_context('userenv', 'current_schema'));
107132
l_lines sys_refcursor;
108133
l_line varchar2(4000);
109134
begin
110-
run_autonomous(l_paths, a_reporter, a_color_console );
135+
run_autonomous(
136+
l_paths, l_reporter, a_color_console, a_project_file_mappings, a_test_file_mappings,
137+
a_include_object_list, a_exclude_object_list
138+
);
139+
l_lines := ut_output_buffer.get_lines_cursor(l_reporter.reporter_id);
140+
loop
141+
fetch l_lines into l_line;
142+
exit when l_lines%notfound;
143+
pipe row(l_line);
144+
end loop;
145+
close l_lines;
146+
end;
147+
148+
function run(
149+
a_reporter ut_reporter_base := null, a_color_console integer := 0,
150+
a_project_files ut_varchar2_list, a_test_files ut_varchar2_list,
151+
a_include_object_list ut_varchar2_list := null, a_exclude_object_list ut_varchar2_list := null
152+
) return ut_varchar2_rows pipelined is
153+
l_reporter ut_reporter_base := coalesce(a_reporter, ut_documentation_reporter());
154+
l_paths ut_varchar2_list := ut_varchar2_list(sys_context('userenv', 'current_schema'));
155+
l_lines sys_refcursor;
156+
l_line varchar2(4000);
157+
begin
158+
run_autonomous(
159+
l_paths, l_reporter, a_color_console, a_project_files, a_test_files,
160+
a_include_object_list, a_exclude_object_list
161+
);
162+
l_lines := ut_output_buffer.get_lines_cursor(l_reporter.reporter_id);
163+
loop
164+
fetch l_lines into l_line;
165+
exit when l_lines%notfound;
166+
pipe row(l_line);
167+
end loop;
168+
close l_lines;
169+
end;
170+
171+
function run(
172+
a_paths ut_varchar2_list, a_reporter ut_reporter_base := null, a_color_console integer := 0,
173+
a_project_file_mappings ut_file_mappings := null, a_test_file_mappings ut_file_mappings := null,
174+
a_include_object_list ut_varchar2_list := null, a_exclude_object_list ut_varchar2_list := null
175+
) return ut_varchar2_rows pipelined is
176+
l_reporter ut_reporter_base := coalesce(a_reporter, ut_documentation_reporter());
177+
l_lines sys_refcursor;
178+
l_line varchar2(4000);
179+
begin
180+
run_autonomous(
181+
a_paths, l_reporter, a_color_console, a_project_file_mappings, a_test_file_mappings,
182+
a_include_object_list, a_exclude_object_list
183+
);
111184
l_lines := ut_output_buffer.get_lines_cursor(l_reporter.reporter_id);
112185
loop
113186
fetch l_lines into l_line;
@@ -117,12 +190,19 @@ create or replace package body ut is
117190
close l_lines;
118191
end;
119192

120-
function run(a_paths ut_varchar2_list, a_reporter ut_reporter_base := ut_documentation_reporter(), a_color_console integer := 0) return ut_varchar2_rows pipelined is
193+
function run(
194+
a_paths ut_varchar2_list, a_reporter ut_reporter_base := null, a_color_console integer := 0,
195+
a_project_files ut_varchar2_list, a_test_files ut_varchar2_list,
196+
a_include_object_list ut_varchar2_list := null, a_exclude_object_list ut_varchar2_list := null
197+
) return ut_varchar2_rows pipelined is
121198
l_reporter ut_reporter_base := coalesce(a_reporter, ut_documentation_reporter());
122199
l_lines sys_refcursor;
123200
l_line varchar2(4000);
124201
begin
125-
run_autonomous(a_paths, l_reporter, a_color_console);
202+
run_autonomous(
203+
a_paths, l_reporter, a_color_console, a_project_files, a_test_files,
204+
a_include_object_list, a_exclude_object_list
205+
);
126206
l_lines := ut_output_buffer.get_lines_cursor(l_reporter.reporter_id);
127207
loop
128208
fetch l_lines into l_line;
@@ -132,13 +212,20 @@ create or replace package body ut is
132212
close l_lines;
133213
end;
134214

135-
function run(a_path varchar2, a_reporter ut_reporter_base := ut_documentation_reporter(), a_color_console integer := 0) return ut_varchar2_rows pipelined is
215+
function run(
216+
a_path varchar2, a_reporter ut_reporter_base := null, a_color_console integer := 0,
217+
a_project_file_mappings ut_file_mappings := null, a_test_file_mappings ut_file_mappings := null,
218+
a_include_object_list ut_varchar2_list := null, a_exclude_object_list ut_varchar2_list := null
219+
) return ut_varchar2_rows pipelined is
136220
l_reporter ut_reporter_base := coalesce(a_reporter, ut_documentation_reporter());
137221
l_paths ut_varchar2_list := ut_varchar2_list(coalesce(a_path, sys_context('userenv', 'current_schema')));
138222
l_lines sys_refcursor;
139223
l_line varchar2(4000);
140224
begin
141-
run_autonomous(l_paths, a_reporter, a_color_console );
225+
run_autonomous(
226+
l_paths, l_reporter, a_color_console, a_project_file_mappings, a_test_file_mappings,
227+
a_include_object_list, a_exclude_object_list
228+
);
142229
l_lines := ut_output_buffer.get_lines_cursor(l_reporter.reporter_id);
143230
loop
144231
fetch l_lines into l_line;
@@ -148,22 +235,105 @@ create or replace package body ut is
148235
close l_lines;
149236
end;
150237

151-
procedure run(a_reporter ut_reporter_base := ut_documentation_reporter(), a_color_console boolean := false) is
238+
function run(
239+
a_path varchar2, a_reporter ut_reporter_base := null, a_color_console integer := 0,
240+
a_project_files ut_varchar2_list, a_test_files ut_varchar2_list,
241+
a_include_object_list ut_varchar2_list := null, a_exclude_object_list ut_varchar2_list := null
242+
) return ut_varchar2_rows pipelined is
243+
l_reporter ut_reporter_base := coalesce(a_reporter, ut_documentation_reporter());
244+
l_paths ut_varchar2_list := ut_varchar2_list(coalesce(a_path, sys_context('userenv', 'current_schema')));
245+
l_lines sys_refcursor;
246+
l_line varchar2(4000);
152247
begin
153-
ut.run(ut_varchar2_list(sys_context('userenv', 'current_schema')), a_reporter, a_color_console);
248+
run_autonomous(
249+
l_paths, l_reporter, a_color_console, a_project_files, a_test_files,
250+
a_include_object_list, a_exclude_object_list
251+
);
252+
l_lines := ut_output_buffer.get_lines_cursor(l_reporter.reporter_id);
253+
loop
254+
fetch l_lines into l_line;
255+
exit when l_lines%notfound;
256+
pipe row(l_line);
257+
end loop;
258+
close l_lines;
154259
end;
155260

156-
procedure run(a_paths ut_varchar2_list, a_reporter ut_reporter_base := ut_documentation_reporter(), a_color_console boolean := false) is
261+
procedure run(
262+
a_reporter ut_reporter_base := null, a_color_console boolean := false,
263+
a_project_file_mappings ut_file_mappings := null, a_test_file_mappings ut_file_mappings := null,
264+
a_include_object_list ut_varchar2_list := null, a_exclude_object_list ut_varchar2_list := null
265+
) is
266+
begin
267+
ut.run(
268+
ut_varchar2_list(sys_context('userenv', 'current_schema')), a_reporter, a_color_console,
269+
a_project_file_mappings, a_test_file_mappings, a_include_object_list, a_exclude_object_list
270+
);
271+
end;
272+
273+
procedure run(
274+
a_reporter ut_reporter_base := null, a_color_console boolean := false,
275+
a_project_files ut_varchar2_list, a_test_files ut_varchar2_list,
276+
a_include_object_list ut_varchar2_list := null, a_exclude_object_list ut_varchar2_list := null
277+
) is
278+
begin
279+
ut.run(
280+
ut_varchar2_list(sys_context('userenv', 'current_schema')), a_reporter, a_color_console,
281+
a_project_files, a_test_files, a_include_object_list, a_exclude_object_list
282+
);
283+
end;
284+
285+
procedure run(
286+
a_paths ut_varchar2_list, a_reporter ut_reporter_base := null, a_color_console boolean := false,
287+
a_project_file_mappings ut_file_mappings := null, a_test_file_mappings ut_file_mappings := null,
288+
a_include_object_list ut_varchar2_list := null, a_exclude_object_list ut_varchar2_list := null
289+
) is
290+
l_reporter ut_reporter_base := coalesce(a_reporter, ut_documentation_reporter());
291+
begin
292+
ut_runner.run(
293+
a_paths, l_reporter, a_color_console, a_project_file_mappings, a_test_file_mappings,
294+
a_include_object_list, a_exclude_object_list
295+
);
296+
ut_output_buffer.lines_to_dbms_output(l_reporter.reporter_id);
297+
end;
298+
299+
procedure run(
300+
a_paths ut_varchar2_list, a_reporter ut_reporter_base := null, a_color_console boolean := false,
301+
a_project_files ut_varchar2_list, a_test_files ut_varchar2_list,
302+
a_include_object_list ut_varchar2_list := null, a_exclude_object_list ut_varchar2_list := null
303+
) is
157304
l_reporter ut_reporter_base := coalesce(a_reporter, ut_documentation_reporter());
158305
begin
159-
ut_runner.run(a_paths, l_reporter, a_color_console);
306+
ut_runner.run(
307+
a_paths, l_reporter, a_color_console, a_project_files, a_test_files,
308+
a_include_object_list, a_exclude_object_list
309+
);
160310
ut_output_buffer.lines_to_dbms_output(l_reporter.reporter_id);
161311
end;
162312

163-
procedure run(a_path varchar2, a_reporter ut_reporter_base := ut_documentation_reporter(), a_color_console boolean := false) is
313+
procedure run(
314+
a_path varchar2, a_reporter ut_reporter_base := null, a_color_console boolean := false,
315+
a_project_file_mappings ut_file_mappings := null, a_test_file_mappings ut_file_mappings := null,
316+
a_include_object_list ut_varchar2_list := null, a_exclude_object_list ut_varchar2_list := null
317+
) is
318+
l_paths ut_varchar2_list := ut_varchar2_list(coalesce(a_path, sys_context('userenv', 'current_schema')));
319+
begin
320+
ut.run(
321+
l_paths, a_reporter, a_color_console, a_project_file_mappings, a_test_file_mappings,
322+
a_include_object_list, a_exclude_object_list
323+
);
324+
end;
325+
326+
procedure run(
327+
a_path varchar2, a_reporter ut_reporter_base := null, a_color_console boolean := false,
328+
a_project_files ut_varchar2_list, a_test_files ut_varchar2_list,
329+
a_include_object_list ut_varchar2_list := null, a_exclude_object_list ut_varchar2_list := null
330+
) is
164331
l_paths ut_varchar2_list := ut_varchar2_list(coalesce(a_path, sys_context('userenv', 'current_schema')));
165332
begin
166-
ut.run(l_paths, a_reporter, a_color_console);
333+
ut.run(
334+
l_paths, a_reporter, a_color_console, a_project_files, a_test_files,
335+
a_include_object_list, a_exclude_object_list
336+
);
167337
end;
168338

169339
procedure set_nls is

source/api/ut.pks

Lines changed: 71 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,77 @@ create or replace package ut authid current_user as
4747

4848
procedure fail(a_message in varchar2);
4949

50-
function run(a_reporter ut_reporter_base := ut_documentation_reporter(), a_color_console integer := 0) return ut_varchar2_rows pipelined;
51-
52-
function run(a_paths ut_varchar2_list, a_reporter ut_reporter_base := ut_documentation_reporter(), a_color_console integer := 0) return ut_varchar2_rows pipelined;
53-
54-
function run(a_path varchar2, a_reporter ut_reporter_base := ut_documentation_reporter(), a_color_console integer := 0) return ut_varchar2_rows pipelined;
55-
56-
procedure run(a_reporter ut_reporter_base := ut_documentation_reporter(), a_color_console boolean := false);
57-
58-
procedure run(a_paths ut_varchar2_list, a_reporter ut_reporter_base := ut_documentation_reporter(), a_color_console boolean := false);
59-
60-
procedure run(a_path varchar2, a_reporter ut_reporter_base := ut_documentation_reporter(), a_color_console boolean := false);
50+
function run(
51+
a_reporter ut_reporter_base := null, a_color_console integer := 0,
52+
a_project_file_mappings ut_file_mappings := null, a_test_file_mappings ut_file_mappings := null,
53+
a_include_object_list ut_varchar2_list := null, a_exclude_object_list ut_varchar2_list := null
54+
) return ut_varchar2_rows pipelined;
55+
56+
function run(
57+
a_reporter ut_reporter_base := null, a_color_console integer := 0,
58+
a_project_files ut_varchar2_list, a_test_files ut_varchar2_list,
59+
a_include_object_list ut_varchar2_list := null, a_exclude_object_list ut_varchar2_list := null
60+
) return ut_varchar2_rows pipelined;
61+
62+
function run(
63+
a_paths ut_varchar2_list, a_reporter ut_reporter_base := null, a_color_console integer := 0,
64+
a_project_file_mappings ut_file_mappings := null, a_test_file_mappings ut_file_mappings := null,
65+
a_include_object_list ut_varchar2_list := null, a_exclude_object_list ut_varchar2_list := null
66+
) return ut_varchar2_rows pipelined;
67+
68+
function run(
69+
a_paths ut_varchar2_list, a_reporter ut_reporter_base := null, a_color_console integer := 0,
70+
a_project_files ut_varchar2_list, a_test_files ut_varchar2_list,
71+
a_include_object_list ut_varchar2_list := null, a_exclude_object_list ut_varchar2_list := null
72+
) return ut_varchar2_rows pipelined;
73+
74+
function run(
75+
a_path varchar2, a_reporter ut_reporter_base := null, a_color_console integer := 0,
76+
a_project_file_mappings ut_file_mappings := null, a_test_file_mappings ut_file_mappings := null,
77+
a_include_object_list ut_varchar2_list := null, a_exclude_object_list ut_varchar2_list := null
78+
) return ut_varchar2_rows pipelined;
79+
80+
function run(
81+
a_path varchar2, a_reporter ut_reporter_base := null, a_color_console integer := 0,
82+
a_project_files ut_varchar2_list, a_test_files ut_varchar2_list,
83+
a_include_object_list ut_varchar2_list := null, a_exclude_object_list ut_varchar2_list := null
84+
) return ut_varchar2_rows pipelined;
85+
86+
procedure run(
87+
a_reporter ut_reporter_base := null, a_color_console boolean := false,
88+
a_project_file_mappings ut_file_mappings := null, a_test_file_mappings ut_file_mappings := null,
89+
a_include_object_list ut_varchar2_list := null, a_exclude_object_list ut_varchar2_list := null
90+
);
91+
92+
procedure run(
93+
a_reporter ut_reporter_base := null, a_color_console boolean := false,
94+
a_project_files ut_varchar2_list, a_test_files ut_varchar2_list,
95+
a_include_object_list ut_varchar2_list := null, a_exclude_object_list ut_varchar2_list := null
96+
);
97+
98+
procedure run(
99+
a_paths ut_varchar2_list, a_reporter ut_reporter_base := null, a_color_console boolean := false,
100+
a_project_file_mappings ut_file_mappings := null, a_test_file_mappings ut_file_mappings := null,
101+
a_include_object_list ut_varchar2_list := null, a_exclude_object_list ut_varchar2_list := null
102+
);
103+
104+
procedure run(
105+
a_paths ut_varchar2_list, a_reporter ut_reporter_base := null, a_color_console boolean := false,
106+
a_project_files ut_varchar2_list, a_test_files ut_varchar2_list,
107+
a_include_object_list ut_varchar2_list := null, a_exclude_object_list ut_varchar2_list := null
108+
);
109+
110+
procedure run(
111+
a_path varchar2, a_reporter ut_reporter_base := null, a_color_console boolean := false,
112+
a_project_file_mappings ut_file_mappings := null, a_test_file_mappings ut_file_mappings := null,
113+
a_include_object_list ut_varchar2_list := null, a_exclude_object_list ut_varchar2_list := null
114+
);
115+
116+
procedure run(
117+
a_path varchar2, a_reporter ut_reporter_base := null, a_color_console boolean := false,
118+
a_project_files ut_varchar2_list, a_test_files ut_varchar2_list,
119+
a_include_object_list ut_varchar2_list := null, a_exclude_object_list ut_varchar2_list := null
120+
);
61121

62122
/*
63123
Helper procedure to set NLS session parameter for date processing in refcursor.

0 commit comments

Comments
 (0)