|
1 | 1 | create or replace package body ut_runner is |
2 | 2 |
|
3 | | - g_run_params t_run_params; |
4 | | - |
5 | 3 | procedure run(a_paths ut_varchar2_list, a_reporters ut_reporters, a_color_console boolean := false) is |
6 | 4 | l_items_to_run ut_run; |
7 | 5 | l_listener ut_event_listener; |
@@ -46,104 +44,19 @@ create or replace package body ut_runner is |
46 | 44 | run(ut_varchar2_list(coalesce(a_path, sys_context('userenv', 'current_schema'))), a_reporters, a_color_console); |
47 | 45 | end run; |
48 | 46 |
|
49 | | - function parse_reporting_params(a_params ut_varchar2_list) return tt_call_params is |
50 | | - l_default_call_param t_call_param; |
51 | | - l_call_params tt_call_params := tt_call_params(); |
52 | | - l_force_out_to_screen boolean; |
53 | | - begin |
54 | | - for param in( |
55 | | - with |
56 | | - param_vals as( |
57 | | - select regexp_substr(column_value,'-([fos])\=?(.*)',1,1,'c',1) param_type, |
58 | | - regexp_substr(column_value,'-([fos])\=(.*)',1,1,'c',2) param_value |
59 | | - from table(a_params) |
60 | | - where column_value is not null) |
61 | | - select param_type, param_value |
62 | | - from param_vals |
63 | | - where param_type is not null |
64 | | - ) loop |
65 | | - if param.param_type = 'f' or l_call_params.last is null then |
66 | | - l_call_params.extend; |
67 | | - l_call_params(l_call_params.last) := l_default_call_param; |
68 | | - if param.param_type = 'f' then |
69 | | - l_call_params(l_call_params.last).ut_reporter_name := param.param_value; |
70 | | - end if; |
71 | | - l_force_out_to_screen := false; |
72 | | - end if; |
73 | | - if param.param_type = 'o' then |
74 | | - l_call_params(l_call_params.last).output_file_name := param.param_value; |
75 | | - if not l_force_out_to_screen then |
76 | | - l_call_params(l_call_params.last).output_to_screen := 'off'; |
77 | | - end if; |
78 | | - elsif param.param_type = 's' then |
79 | | - l_call_params(l_call_params.last).output_to_screen := 'on'; |
80 | | - l_force_out_to_screen := true; |
81 | | - end if; |
82 | | - end loop; |
83 | | - if l_call_params.count = 0 then |
84 | | - l_call_params.extend; |
85 | | - l_call_params(1) := l_default_call_param; |
86 | | - end if; |
87 | | - return l_call_params; |
88 | | - end; |
89 | | - |
90 | | - function parse_paths_param(a_params ut_varchar2_list) return varchar2 is |
91 | | - l_paths varchar2(4000); |
92 | | - begin |
93 | | - begin |
94 | | - select ''''||replace(ut_paths,',',''',''')||'''' |
95 | | - into l_paths |
96 | | - from (select regexp_substr(column_value,'-p\=(.*)',1,1,'c',1) as ut_paths from table(a_params) ) |
97 | | - where ut_paths is not null; |
98 | | - exception |
99 | | - when no_data_found then |
100 | | - l_paths := 'user'; |
101 | | - when too_many_rows then |
102 | | - raise_application_error(-20000, 'Parameter "-p=ut_path(s)" defined more than once. Only one "-p=ut_path(s)" parameter can be used.'); |
103 | | - end; |
104 | | - return l_paths; |
105 | | - end; |
106 | | - |
107 | | - procedure setup_reporting_output_ids(a_call_params in out nocopy tt_call_params) is |
108 | | - begin |
109 | | - for i in 1 .. cardinality(a_call_params) loop |
110 | | - execute immediate 'begin :l_output_id := '||get_streamed_output_type_name()||'().generate_output_id(); end;' |
111 | | - using out a_call_params(i).output_id; |
112 | | - end loop; |
113 | | - end; |
114 | | - |
115 | | - function is_color_enabled(a_params ut_varchar2_list) return boolean is |
116 | | - begin |
117 | | - for i in 1 .. cardinality(a_params) loop |
118 | | - if a_params(i) = '-c' then |
119 | | - return true; |
120 | | - end if; |
121 | | - end loop; |
122 | | - return false; |
123 | | - end; |
124 | | - |
125 | 47 | procedure set_run_params(a_params ut_varchar2_list) is |
126 | | - l_call_params tt_call_params := tt_call_params(); |
127 | 48 | begin |
128 | | - l_call_params := parse_reporting_params(a_params); |
129 | | - g_run_params.ut_paths := parse_paths_param(a_params); |
130 | | - g_run_params.color_enabled := is_color_enabled(a_params); |
131 | | - setup_reporting_output_ids(l_call_params); |
132 | | - g_run_params.call_params := l_call_params; |
| 49 | + ut_runner_helper.set_run_params(a_params); |
133 | 50 | end set_run_params; |
134 | 51 |
|
135 | 52 | function get_run_params return t_run_params is |
136 | 53 | begin |
137 | | - return g_run_params; |
| 54 | + return ut_runner_helper.get_run_params(); |
138 | 55 | end; |
139 | 56 |
|
140 | 57 | function get_streamed_output_type_name return varchar2 is |
141 | | - l_result varchar2(255); |
142 | 58 | begin |
143 | | - select type_name |
144 | | - into l_result |
145 | | - from user_types where supertype_name = 'UT_OUTPUT_STREAM'; |
146 | | - return lower(l_result); |
| 59 | + return ut_runner_helper.get_streamed_output_type_name(); |
147 | 60 | end; |
148 | 61 |
|
149 | 62 | end ut_runner; |
|
0 commit comments