@@ -2,22 +2,27 @@ create or replace package body ut_runner is
22
33 g_run_params t_run_params;
44
5- procedure run(a_paths in ut_varchar2_list, a_reporters in ut_reporters) is
5+ procedure run(a_paths ut_varchar2_list, a_reporters ut_reporters) is
66 l_items_to_run ut_run;
7- l_listener ut_execution_listener := ut_execution_listener(a_reporters) ;
7+ l_listener ut_execution_listener;
88 l_current_suite ut_suite;
99 begin
10+ if a_reporters is null or a_reporters.count = 0 then
11+ l_listener := ut_execution_listener(ut_reporters(ut_documentation_reporter()));
12+ else
13+ l_listener := ut_execution_listener(a_reporters);
14+ end if;
1015 l_items_to_run := ut_run( ut_suite_manager.configure_execution_by_path(a_paths) );
1116 l_items_to_run.do_execute(l_listener);
1217 end;
1318
14- procedure run(a_paths in ut_varchar2_list, a_reporter in ut_reporter) is
19+ procedure run(a_paths ut_varchar2_list, a_reporter ut_reporter := ut_documentation_reporter() ) is
1520 begin
16- run(a_paths, ut_reporters(a_reporter));
21+ run(a_paths, ut_reporters(coalesce( a_reporter,ut_documentation_reporter()) ));
1722 end;
1823
1924
20- procedure run(a_path in varchar2, a_reporter in ut_reporter) is
25+ procedure run(a_path in varchar2, a_reporter ut_reporter := ut_documentation_reporter() ) is
2126 begin
2227 run(ut_varchar2_list(coalesce(a_path, sys_context('userenv', 'current_schema'))), a_reporter);
2328 end run;
@@ -27,56 +32,80 @@ create or replace package body ut_runner is
2732 run(ut_varchar2_list(coalesce(a_path, sys_context('userenv', 'current_schema'))), a_reporters);
2833 end run;
2934
30- procedure set_run_params(a_params ut_varchar2_list) is
31- l_call_param t_call_param;
35+
36+
37+ function parse_reporting_params(a_params ut_varchar2_list) return tt_call_params is
38+ l_default_call_param t_call_param;
3239 l_call_params tt_call_params := tt_call_params();
33- l_ut_paths varchar2(4000);
3440 l_force_out_to_screen boolean;
3541 begin
36- for param in
37- ( with
38- param_vals as(
39- select regexp_substr(column_value,'-([fos])\=?(.*)',1,1,'c',1) param_type,
40- regexp_substr(column_value,'-([fos])\=(.*)',1,1,'c',2) param_value
41- from table(a_params)
42- where column_value is not null)
43- select param_type, param_value
44- from param_vals
45- where param_type is not null)
46- loop
47- if param.param_type = 'f' then
42+ for param in(
43+ with
44+ param_vals as(
45+ select regexp_substr(column_value,'-([fos])\=?(.*)',1,1,'c',1) param_type,
46+ regexp_substr(column_value,'-([fos])\=(.*)',1,1,'c',2) param_value
47+ from table(a_params)
48+ where column_value is not null)
49+ select param_type, param_value
50+ from param_vals
51+ where param_type is not null
52+ ) loop
53+ if param.param_type = 'f' or l_call_params.last is null then
4854 l_call_params.extend;
49- l_call_params(l_call_params.last) := l_call_param;
50- l_call_params(l_call_params.last).ut_reporter_name := param.param_value;
55+ l_call_params(l_call_params.last) := l_default_call_param;
56+ if param.param_type = 'f' then
57+ l_call_params(l_call_params.last).ut_reporter_name := param.param_value;
58+ end if;
5159 l_force_out_to_screen := false;
52- elsif l_call_params.last is not null then
53- if param.param_type = 'o' then
54- l_call_params(l_call_params.last).output_file_name := param.param_value;
55- if not l_force_out_to_screen then
56- l_call_params(l_call_params.last).output_to_screen := 'off';
57- end if;
58- elsif param.param_type = 's' then
59- l_call_params(l_call_params.last).output_to_screen := 'on';
60- l_force_out_to_screen := true;
60+ end if;
61+ if param.param_type = 'o' then
62+ l_call_params(l_call_params.last).output_file_name := param.param_value;
63+ if not l_force_out_to_screen then
64+ l_call_params(l_call_params.last).output_to_screen := 'off';
6165 end if;
66+ elsif param.param_type = 's' then
67+ l_call_params(l_call_params.last).output_to_screen := 'on';
68+ l_force_out_to_screen := true;
6269 end if;
6370 end loop;
71+ if l_call_params.count = 0 then
72+ l_call_params.extend;
73+ l_call_params(1) := l_default_call_param;
74+ end if;
75+ return l_call_params;
76+ end;
6477
78+ function parse_paths_param(a_params ut_varchar2_list) return varchar2 is
79+ l_paths varchar2(4000);
80+ begin
6581 begin
6682 select ''''||replace(ut_paths,',',''',''')||''''
67- into g_run_params.ut_paths
83+ into l_paths
6884 from (select regexp_substr(column_value,'-p\=(.*)',1,1,'c',1) as ut_paths from table(a_params) )
6985 where ut_paths is not null;
7086 exception
7187 when no_data_found then
72- g_run_params.ut_paths := 'user';
88+ l_paths := 'user';
7389 when too_many_rows then
74- raise_application_error(-20000, 'Parameter "-p=ut_paths " defined more than once. Only one "-p=ut_paths " parameter can be used.');
90+ raise_application_error(-20000, 'Parameter "-p=ut_path(s) " defined more than once. Only one "-p=ut_path(s) " parameter can be used.');
7591 end;
76- for i in 1 .. cardinality(l_call_params) loop
92+ return l_paths;
93+ end;
94+
95+ procedure setup_reporting_output_ids(a_call_params in out nocopy tt_call_params) is
96+ begin
97+ for i in 1 .. cardinality(a_call_params) loop
7798 execute immediate 'begin :l_output_id := '||get_streamed_output_type_name()||'().generate_output_id(); end;'
78- using out l_call_params (i).output_id;
99+ using out a_call_params (i).output_id;
79100 end loop;
101+ end;
102+
103+ procedure set_run_params(a_params ut_varchar2_list) is
104+ l_call_params tt_call_params := tt_call_params();
105+ begin
106+ l_call_params := parse_reporting_params(a_params);
107+ g_run_params.ut_paths := parse_paths_param(a_params);
108+ setup_reporting_output_ids(l_call_params);
80109 g_run_params.call_params := l_call_params;
81110 end set_run_params;
82111
@@ -87,12 +116,12 @@ create or replace package body ut_runner is
87116
88117 function get_streamed_output_type_name return varchar2 is
89118 l_result varchar2(255);
90- begin
91- select type_name
92- into l_result
93- from user_types where supertype_name = 'UT_OUTPUT_STREAM';
94- return lower(l_result);
95- end;
119+ begin
120+ select type_name
121+ into l_result
122+ from user_types where supertype_name = 'UT_OUTPUT_STREAM';
123+ return lower(l_result);
124+ end;
96125
97126end ut_runner;
98127/
0 commit comments