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

Skip to content

Commit 4f91b64

Browse files
committed
Merge branch 'version3' into feature/running_with_many_reporters
# Conflicts: # source/core/ut_suite_manager.pkb
2 parents 00e7dce + 5a99775 commit 4f91b64

7 files changed

Lines changed: 78 additions & 59 deletions

source/core/annotations/ut_annotations.pkb

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,13 @@ create or replace package body ut_annotations as
146146
end;
147147
end;
148148

149-
function get_procedure_annotations(a_source clob, a_comments tt_comment_list) return tt_procedure_annotations is
149+
function get_procedure_list(a_source clob, a_comments tt_comment_list) return tt_procedure_list is
150150
l_proc_comments varchar2(32767);
151151
l_proc_name t_annotation_name;
152152
l_annot_proc_ind number;
153153
l_annot_proc_block varchar2(32767);
154154
l_procedure_annotations tt_procedure_annotations;
155+
l_procedure_list tt_procedure_list;
155156
begin
156157
-- loop through procedures and functions of the package and get all the comment blocks just before it's declaration
157158
l_annot_proc_ind := 1;
@@ -183,15 +184,18 @@ create or replace package body ut_annotations as
183184
,subexpression => 5));
184185

185186
-- parse the comment block for the syntactically correct annotations and store them as an array
186-
l_procedure_annotations(l_proc_name) := get_annotations(l_proc_comments, a_comments);
187+
l_procedure_annotations.name := l_proc_name;
188+
l_procedure_annotations.annotations := get_annotations(l_proc_comments, a_comments);
189+
190+
l_procedure_list(l_procedure_list.count+1) := l_procedure_annotations;
187191

188192
--l_annot_proc_ind := l_annot_proc_ind + length(l_annot_proc_block);
189193
l_annot_proc_ind := regexp_instr(srcstr => a_source
190194
,pattern => ';'
191195
,occurrence => 1
192196
,position => l_annot_proc_ind + length(l_annot_proc_block));
193197
end loop;
194-
return l_procedure_annotations;
198+
return l_procedure_list;
195199
end;
196200

197201
function extract_and_replace_comments(a_source in out nocopy clob) return tt_comment_list is
@@ -307,7 +311,7 @@ create or replace package body ut_annotations as
307311

308312
l_annotated_pkg.package_annotations := get_package_annotations(l_source, l_comments);
309313

310-
l_annotated_pkg.procedure_annotations := get_procedure_annotations(l_source, l_comments);
314+
l_annotated_pkg.procedure_annotations := get_procedure_list(l_source, l_comments);
311315

312316
-- printing out parsed structure for debugging
313317
$if $$ut_trace $then

source/core/annotations/ut_annotations.pks

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,17 @@ create or replace package ut_annotations authid definer as
3939
type: tt_procedure_annotations
4040
a list of tt_annotations index by the procedure name
4141
*/
42-
type tt_procedure_annotations is table of tt_annotations index by t_procedure_name;
42+
type tt_procedure_annotations is record(name t_procedure_name, annotations tt_annotations);
43+
44+
type tt_procedure_list is table of tt_procedure_annotations index by pls_integer;
4345

4446
/*
4547
type: typ_annotated_package
4648
a structure containing a list of package level annotations and a list of procedure level annotations
4749

4850
*/
4951
type typ_annotated_package is record(
50-
procedure_annotations tt_procedure_annotations
52+
procedure_annotations tt_procedure_list
5153
,package_annotations tt_annotations);
5254

5355
/*

source/core/ut_suite_manager.pkb

Lines changed: 29 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
create 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));

tests/helpers/check_annotation_parsing.prc

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ create or replace procedure check_annotation_parsing(a_expected ut_annotations.t
22
procedure check_annotation_params(a_msg varchar2, a_expected ut_annotations.tt_annotation_params, a_actual ut_annotations.tt_annotation_params) is
33
begin
44
ut_assert.are_equal('['||a_msg||']Check number of annotation params', a_expected.count, a_actual.count);
5-
5+
66
if a_expected.count = a_actual.count and a_expected.count > 0 then
77
for i in 1..a_expected.count loop
88
if a_expected(i).key is not null then
99
ut_assert.are_equal('['||a_msg||'('||i||')]Check annotation param key',a_expected(i).key,a_actual(i).key);
1010
else
1111
ut_assert.is_null('['||a_msg||'('||i||')]Check annotation param key',a_actual(i).key);
1212
end if;
13-
13+
1414
if a_expected(i).val is not null then
1515
ut_assert.are_equal('['||a_msg||'('||i||')]Check annotation param value',a_expected(i).val,a_actual(i).val);
1616
else
@@ -19,16 +19,16 @@ create or replace procedure check_annotation_parsing(a_expected ut_annotations.t
1919
end loop;
2020
end if;
2121
end;
22-
22+
2323
procedure check_annotations(a_msg varchar2, a_expected ut_annotations.tt_annotations, a_actual ut_annotations.tt_annotations) is
2424
l_ind varchar2(500);
2525
begin
2626
ut_assert.are_equal('['||a_msg||']Check number of annotations parsed',a_expected.count,a_actual.count);
27-
27+
2828
if a_expected.count = a_actual.count and a_expected.count > 0 then
2929
l_ind := a_expected.first;
3030
while l_ind is not null loop
31-
31+
3232
ut_assert.this('['||a_msg||']Check annotation exists', a_actual.exists(l_ind));
3333
if a_actual.exists(l_ind) then
3434
check_annotation_params(a_msg||'.'||l_ind,a_expected(l_ind),a_actual(l_ind));
@@ -37,21 +37,29 @@ create or replace procedure check_annotation_parsing(a_expected ut_annotations.t
3737
end loop;
3838
end if;
3939
end;
40-
41-
procedure check_procedures(a_msg varchar2, a_expected ut_annotations.tt_procedure_annotations, a_actual ut_annotations.tt_procedure_annotations) is
42-
l_ind varchar2(500);
40+
41+
procedure check_procedures(a_msg varchar2, a_expected ut_annotations.tt_procedure_list, a_actual ut_annotations.tt_procedure_list) is
42+
l_found boolean := false;
43+
l_index pls_integer;
4344
begin
4445
ut_assert.are_equal('['||a_msg||']Check number of procedures parsed',a_expected.count,a_actual.count);
45-
46+
4647
if a_expected.count = a_actual.count and a_expected.count > 0 then
47-
l_ind := a_expected.first;
48-
while l_ind is not null loop
49-
50-
ut_assert.this('['||a_msg||']Check procedure exists', a_actual.exists(l_ind));
51-
if a_actual.exists(l_ind) then
52-
check_annotations(a_msg||'.'||l_ind,a_expected(l_ind),a_actual(l_ind));
48+
for i in 1..a_expected.count loop
49+
l_found := false;
50+
l_index := null;
51+
for j in 1..a_actual.count loop
52+
if a_expected(i).name = a_actual(j).name then
53+
l_found:=true;
54+
l_index := j;
55+
exit;
56+
end if;
57+
end loop;
58+
59+
ut.expect(l_found,'['||a_msg||']Check procedure exists').to_be_true;
60+
if l_found then
61+
check_annotations(a_msg||'.'||a_expected(i).name,a_expected(i).annotations,a_actual(l_index).annotations);
5362
end if;
54-
l_ind := a_expected.next(l_ind);
5563
end loop;
5664
end if;
5765
end;

tests/ut_annotations/ut_annotations.parse_package_annotations.ParseAnnotationMixedWithWrongBeforeProcedure.sql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ END;';
3232

3333
l_ann_param := null;
3434
l_ann_param.val := 'some_value';
35-
l_expected.procedure_annotations('foo')('ann2')(1) := l_ann_param;
35+
l_expected.procedure_annotations(1).name :='foo';
36+
l_expected.procedure_annotations(1).annotations('ann2')(1) := l_ann_param;
3637

3738
check_annotation_parsing(l_expected, l_parsing_result);
3839

tests/ut_annotations/ut_annotations.parse_package_annotations.ParseComplexPackage.sql

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,18 @@ END;';
4545
l_ann_param.val := 'all.globaltests';
4646
l_expected.package_annotations('suitepackage')(1) := l_ann_param;
4747

48-
l_expected.procedure_annotations('foo')('test') := cast( null as ut_annotations.tt_annotation_params);
49-
l_expected.procedure_annotations('foo2')('setup') := cast( null as ut_annotations.tt_annotation_params);
48+
l_expected.procedure_annotations(1).name := 'foo';
49+
l_expected.procedure_annotations(1).annotations('test') := cast( null as ut_annotations.tt_annotation_params);
50+
51+
l_expected.procedure_annotations(2).name := 'foo2';
52+
l_expected.procedure_annotations(2).annotations('setup') := cast( null as ut_annotations.tt_annotation_params);
5053

5154
l_ann_param := null;
5255
l_ann_param.key := 'key';
53-
l_ann_param.val := 'testval';
54-
l_expected.procedure_annotations('foo3')('setup')(1) := l_ann_param;
56+
l_ann_param.val := 'testval';
57+
58+
l_expected.procedure_annotations(3).name := 'foo3';
59+
l_expected.procedure_annotations(3).annotations('setup')(1) := l_ann_param;
5560

5661
check_annotation_parsing(l_expected, l_parsing_result);
5762

tests/ut_annotations/ut_annotations.parse_package_annotations.ParsePackageAndProcedureLevelAnnotations.sql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ END;';
2828
l_ann_param.val := 'all.globaltests';
2929
l_expected.package_annotations('suitepackage')(1) := l_ann_param;
3030

31-
l_expected.procedure_annotations('foo')('test') := cast( null as ut_annotations.tt_annotation_params);
31+
l_expected.procedure_annotations(1).name := 'foo';
32+
l_expected.procedure_annotations(1).annotations('test') := cast( null as ut_annotations.tt_annotation_params);
3233

3334
check_annotation_parsing(l_expected, l_parsing_result);
3435

0 commit comments

Comments
 (0)