11create or replace package body ut_suite_manager is
22
33 type tt_schema_suites is table of ut_test_suite index by varchar2(4000 char);
4- type t_schema_cache is record (schema_suites tt_schema_suites, changed_at date);
4+ type t_schema_cache is record(
5+ schema_suites tt_schema_suites
6+ ,changed_at date);
57 type tt_schena_suites_list is table of t_schema_cache index by varchar2(32 char);
68
79 g_schema_suites tt_schena_suites_list;
@@ -14,7 +16,7 @@ create or replace package body ut_suite_manager is
1416 function get_schema_max_ddl(a_owner_name varchar2) return date is
1517 l_date date;
1618 begin
17- select nvl(max(t.LAST_DDL_TIME ), date'4999-12-31')
19+ select nvl(max(t.last_ddl_time ), date '4999-12-31')
1820 into l_date
1921 from all_objects t
2022 where t.owner = a_owner_name
@@ -84,10 +86,10 @@ create or replace package body ut_suite_manager is
8486 l_suite.set_ignore_flag(true);
8587 end if;
8688
87- l_proc_name := l_annotation_data.procedure_annotations.first;
88- while ( l_default_setup_proc is null or l_default_teardown_proc is null or l_suite_setup_proc is null or
89- l_suite_teardown_proc is null) and l_proc_name is not null loop
90- l_proc_annotations := l_annotation_data.procedure_annotations(l_proc_name) ;
89+ for i in 1 .. l_annotation_data.procedure_annotations.count loop
90+ exit when l_default_setup_proc is not null and l_default_teardown_proc is not null and l_suite_setup_proc is not null and l_suite_teardown_proc is not null;
91+ l_proc_name := l_annotation_data.procedure_annotations(i).name;
92+ l_proc_annotations := l_annotation_data.procedure_annotations(i).annotations ;
9193
9294 if l_proc_annotations.exists('setup') and l_default_setup_proc is null then
9395 l_default_setup_proc := l_proc_name;
@@ -99,7 +101,6 @@ create or replace package body ut_suite_manager is
99101 l_suite_teardown_proc := l_proc_name;
100102 end if;
101103
102- l_proc_name := l_annotation_data.procedure_annotations.next(l_proc_name);
103104 end loop;
104105
105106 if l_suite_setup_proc is not null then
@@ -114,16 +115,15 @@ create or replace package body ut_suite_manager is
114115 ,a_owner_name => l_owner_name);
115116 end if;
116117
117- l_proc_name := l_annotation_data.procedure_annotations.first;
118- while l_proc_name is not null loop
119-
120- l_proc_annotations := l_annotation_data.procedure_annotations(l_proc_name);
118+ for i in 1 .. l_annotation_data.procedure_annotations.count loop
119+ l_proc_name := l_annotation_data.procedure_annotations(i).name;
120+ l_proc_annotations := l_annotation_data.procedure_annotations(i).annotations;
121121 if l_proc_annotations.exists('test') then
122122 declare
123123 l_setup_procedure varchar2(30 char);
124124 l_teardown_procedure varchar2(30 char);
125125 l_rollback_annotation varchar2(4000);
126- l_rollback_type integer := ut_utils.gc_rollback_auto ;
126+ l_rollback_type integer := l_suite_rollback ;
127127 begin
128128 if l_proc_annotations.exists('testsetup') then
129129 l_setup_procedure := ut_annotations.get_annotation_param(l_proc_annotations('testsetup'), 1);
@@ -164,13 +164,12 @@ create or replace package body ut_suite_manager is
164164 end;
165165 end if;
166166
167- l_proc_name := l_annotation_data.procedure_annotations.next(l_proc_name);
168167 end loop;
169168 end if;
170169 return l_suite;
171170
172171 end config_package;
173-
172+
174173 procedure actualize_cache(a_owner_name varchar2, a_schema_suites tt_schema_suites) is
175174 begin
176175 if a_schema_suites.count > 0 then
@@ -194,22 +193,20 @@ create or replace package body ut_suite_manager is
194193
195194 procedure put(a_root_suite in out nocopy ut_test_suite, a_path varchar2, a_suite ut_test_suite, a_parent_path varchar2 default null) is
196195 l_temp_root varchar2(4000 char);
197- l_path varchar2(4000 char);
196+ l_path varchar2(4000 char);
198197 l_cur_item ut_test_suite;
199198 l_ind pls_integer;
200199 begin
201200 if a_path like '%.%' then
202201 l_temp_root := regexp_substr(a_path, '^[^.]+');
203- l_path := ltrim(a_parent_path|| '.'|| l_temp_root,'.');
202+ l_path := ltrim(a_parent_path || '.' || l_temp_root, '.');
204203
205204 if a_root_suite is not null then
206205
207206 l_ind := a_root_suite.item_index(l_temp_root);
208207
209208 if l_ind is null then
210- l_cur_item := ut_test_suite(a_suite_name => null
211- ,a_object_name => l_temp_root
212- ,a_object_path => l_path);
209+ l_cur_item := ut_test_suite(a_suite_name => null, a_object_name => l_temp_root, a_object_path => l_path);
213210 else
214211 l_cur_item := treat(a_root_suite.items(l_ind) as ut_test_suite);
215212 end if;
@@ -223,9 +220,7 @@ create or replace package body ut_suite_manager is
223220 end if;
224221
225222 else
226- a_root_suite := ut_test_suite(a_suite_name => null
227- ,a_object_name => l_temp_root
228- ,a_object_path => l_path);
223+ a_root_suite := ut_test_suite(a_suite_name => null, a_object_name => l_temp_root, a_object_path => l_path);
229224 put(a_root_suite, trim_path(a_path, l_temp_root || '.'), a_suite, l_path);
230225 end if;
231226 else
@@ -241,15 +236,16 @@ create or replace package body ut_suite_manager is
241236 procedure print(a_suite ut_test_suite, a_pad pls_integer) is
242237 l_test ut_test;
243238 begin
244- dbms_output.put_line(lpad(' ', a_pad, ' ') || 'Suite: ' || a_suite.object_name|| '('|| a_suite.object_path|| ')');
239+ dbms_output.put_line(lpad(' ', a_pad, ' ') || 'Suite: ' || a_suite.object_name || '(' || a_suite.object_path || ')');
245240 dbms_output.put_line(lpad(' ', a_pad, ' ') || 'Items: ');
246241 for i in 1 .. a_suite.items.count loop
247242 if a_suite.items(i) is of(ut_test_suite) then
248243 print(treat(a_suite.items(i) as ut_test_suite), a_pad + 2);
249244 else
250245
251246 l_test := treat(a_suite.items(i) as ut_test);
252- dbms_output.put_line(lpad(' ', a_pad + 2, ' ') || 'Test: ' || l_test.object_name||'('||l_test.object_path||')');
247+ dbms_output.put_line(lpad(' ', a_pad + 2, ' ') || 'Test: ' || l_test.object_name || '(' ||
248+ l_test.object_path || ')');
253249 end if;
254250 end loop;
255251 end print;
@@ -311,8 +307,8 @@ create or replace package body ut_suite_manager is
311307 function get_schema_suites(a_schema_name in varchar2) return tt_schema_suites is
312308 begin
313309 -- Currently cache invalidation on DDL is not implemented so schema is rescaned each time
314- if not g_schema_suites.exists(a_schema_name)
315- or g_schema_suites(a_schema_name) .changed_at <= get_schema_max_ddl(a_schema_name) then
310+ if not g_schema_suites.exists(a_schema_name) or g_schema_suites(a_schema_name)
311+ .changed_at <= get_schema_max_ddl(a_schema_name) then
316312 ut_utils.debug_log('Rescanning schema ' || a_schema_name);
317313 config_schema(a_schema_name);
318314 end if;
@@ -360,8 +356,8 @@ create or replace package body ut_suite_manager is
360356 procedure skip_by_path(a_suite in out nocopy ut_test_object, a_path varchar2) is
361357 l_root constant varchar2(32767) := regexp_substr(a_path, '\w+');
362358 l_rest_path constant varchar2(32767) := regexp_substr(a_path, '\.(.+)', subexpression => 1);
363- l_item ut_test_object;
364- l_items ut_objects_list := ut_objects_list();
359+ l_item ut_test_object;
360+ l_items ut_objects_list := ut_objects_list();
365361 l_object_name varchar2(32767);
366362
367363 begin
@@ -387,7 +383,8 @@ create or replace package body ut_suite_manager is
387383
388384 a_suite.items := l_items;
389385
390- if l_items.count = 0 then--not l_found then
386+ if l_items.count = 0 then
387+ --not l_found then
391388 raise_application_error(-20203, 'Suite note found');
392389 end if;
393390 end if;
@@ -439,8 +436,9 @@ create or replace package body ut_suite_manager is
439436
440437 begin
441438 l_suite := l_schema_suites(l_root_suite_name);
442- exception when no_data_found then
443- raise_application_error(-20203, 'Suite ' || l_root_suite_name || ' note found');
439+ exception
440+ when no_data_found then
441+ raise_application_error(-20203, 'Suite ' || l_root_suite_name || ' note found');
444442 end;
445443
446444 skip_by_path(l_suite, regexp_substr(l_suite_path, '\.(.+)', subexpression => 1));
0 commit comments