11create or replace package body ut_runner is
22
3- g_run_params t_run_params;
4-
5- procedure run(a_paths ut_varchar2_list, a_reporters ut_reporters) is
3+ procedure run(a_paths ut_varchar2_list, a_reporters ut_reporters, a_color_console boolean := false) is
64 l_items_to_run ut_run;
75 l_listener ut_event_listener;
86 l_current_suite ut_logical_suite;
97 begin
8+ ut_console_reporter_base.set_color_enabled(a_color_console);
109 if a_reporters is null or a_reporters.count = 0 then
1110 l_listener := ut_event_listener(ut_reporters(ut_documentation_reporter()));
1211 else
@@ -29,109 +28,35 @@ create or replace package body ut_runner is
2928 raise;
3029 end;
3130
32- procedure run(a_paths ut_varchar2_list, a_reporter ut_reporter_base := ut_documentation_reporter()) is
31+ procedure run(a_paths ut_varchar2_list, a_reporter ut_reporter_base := ut_documentation_reporter(), a_color_console boolean := false ) is
3332 begin
34- run(a_paths, ut_reporters(coalesce(a_reporter,ut_documentation_reporter())));
33+ run(a_paths, ut_reporters(coalesce(a_reporter,ut_documentation_reporter())), a_color_console );
3534 end;
3635
3736
38- procedure run(a_path in varchar2, a_reporter ut_reporter_base := ut_documentation_reporter()) is
37+ procedure run(a_path in varchar2, a_reporter ut_reporter_base := ut_documentation_reporter(), a_color_console boolean := false ) is
3938 begin
40- run(ut_varchar2_list(coalesce(a_path, sys_context('userenv', 'current_schema'))), a_reporter);
39+ run(ut_varchar2_list(coalesce(a_path, sys_context('userenv', 'current_schema'))), a_reporter, a_color_console );
4140 end run;
4241
43- procedure run(a_path in varchar2, a_reporters in ut_reporters) is
42+ procedure run(a_path in varchar2, a_reporters in ut_reporters, a_color_console boolean := false ) is
4443 begin
45- run(ut_varchar2_list(coalesce(a_path, sys_context('userenv', 'current_schema'))), a_reporters);
44+ run(ut_varchar2_list(coalesce(a_path, sys_context('userenv', 'current_schema'))), a_reporters, a_color_console );
4645 end run;
4746
48- function parse_reporting_params(a_params ut_varchar2_list) return tt_call_params is
49- l_default_call_param t_call_param;
50- l_call_params tt_call_params := tt_call_params();
51- l_force_out_to_screen boolean;
52- begin
53- for param in(
54- with
55- param_vals as(
56- select regexp_substr(column_value,'-([fos])\=?(.*)',1,1,'c',1) param_type,
57- regexp_substr(column_value,'-([fos])\=(.*)',1,1,'c',2) param_value
58- from table(a_params)
59- where column_value is not null)
60- select param_type, param_value
61- from param_vals
62- where param_type is not null
63- ) loop
64- if param.param_type = 'f' or l_call_params.last is null then
65- l_call_params.extend;
66- l_call_params(l_call_params.last) := l_default_call_param;
67- if param.param_type = 'f' then
68- l_call_params(l_call_params.last).ut_reporter_name := param.param_value;
69- end if;
70- l_force_out_to_screen := false;
71- end if;
72- if param.param_type = 'o' then
73- l_call_params(l_call_params.last).output_file_name := param.param_value;
74- if not l_force_out_to_screen then
75- l_call_params(l_call_params.last).output_to_screen := 'off';
76- end if;
77- elsif param.param_type = 's' then
78- l_call_params(l_call_params.last).output_to_screen := 'on';
79- l_force_out_to_screen := true;
80- end if;
81- end loop;
82- if l_call_params.count = 0 then
83- l_call_params.extend;
84- l_call_params(1) := l_default_call_param;
85- end if;
86- return l_call_params;
87- end;
88-
89- function parse_paths_param(a_params ut_varchar2_list) return varchar2 is
90- l_paths varchar2(4000);
91- begin
92- begin
93- select ''''||replace(ut_paths,',',''',''')||''''
94- into l_paths
95- from (select regexp_substr(column_value,'-p\=(.*)',1,1,'c',1) as ut_paths from table(a_params) )
96- where ut_paths is not null;
97- exception
98- when no_data_found then
99- l_paths := 'user';
100- when too_many_rows then
101- raise_application_error(-20000, 'Parameter "-p=ut_path(s)" defined more than once. Only one "-p=ut_path(s)" parameter can be used.');
102- end;
103- return l_paths;
104- end;
105-
106- procedure setup_reporting_output_ids(a_call_params in out nocopy tt_call_params) is
107- begin
108- for i in 1 .. cardinality(a_call_params) loop
109- execute immediate 'begin :l_output_id := '||get_streamed_output_type_name()||'().generate_output_id(); end;'
110- using out a_call_params(i).output_id;
111- end loop;
112- end;
113-
11447 procedure set_run_params(a_params ut_varchar2_list) is
115- l_call_params tt_call_params := tt_call_params();
11648 begin
117- l_call_params := parse_reporting_params(a_params);
118- g_run_params.ut_paths := parse_paths_param(a_params);
119- setup_reporting_output_ids(l_call_params);
120- g_run_params.call_params := l_call_params;
49+ ut_runner_helper.set_run_params(a_params);
12150 end set_run_params;
12251
12352 function get_run_params return t_run_params is
12453 begin
125- return g_run_params ;
54+ return ut_runner_helper.get_run_params() ;
12655 end;
12756
12857 function get_streamed_output_type_name return varchar2 is
129- l_result varchar2(255);
13058 begin
131- select type_name
132- into l_result
133- from user_types where supertype_name = 'UT_OUTPUT_STREAM';
134- return lower(l_result);
59+ return ut_runner_helper.get_streamed_output_type_name();
13560 end;
13661
13762end ut_runner;
0 commit comments