Skip to content

Commit aa400a4

Browse files
committed
Creating a list of annotations allowed.
Current issues is that any comment matching annotation --% is pushed into ut cache packages which causes exclusion from coverage reports.
1 parent 31604c6 commit aa400a4

4 files changed

Lines changed: 84 additions & 35 deletions

File tree

source/core/annotations/ut_annotation_manager.pkb

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,18 +99,32 @@ create or replace package body ut_annotation_manager as
9999
return l_result;
100100
end;
101101

102+
function get_annotations_list return ut_varchar2_list pipelined is
103+
begin
104+
for i in 1 .. ut_utils.gc_supported_annotations.count loop
105+
pipe row( ut_utils.gc_supported_annotations(i) );
106+
end loop;
107+
end get_annotations_list;
108+
102109
function get_sources_to_annotate(a_object_owner varchar2, a_object_type varchar2, a_objects_to_refresh ut_annotation_objs_cache_info) return sys_refcursor is
103110
l_result sys_refcursor;
104111
l_sources_view varchar2(200) := ut_metadata.get_source_view_name();
105112
l_card natural;
113+
l_allowed_annotations varchar2(32767) := 'suite';
106114
begin
115+
116+
select listagg(column_value,'|') within group (order by column_value)
117+
into l_allowed_annotations
118+
from table(get_annotations_list);
119+
120+
107121
l_card := ut_utils.scale_cardinality(cardinality(a_objects_to_refresh));
108122
open l_result for
109123
q'[select /*+ no_parallel */ x.name, x.text
110124
from (select /*+ cardinality( r ]'||l_card||q'[ )*/
111125
s.name, s.text, s.line,
112126
max(case when s.text like '%--%\%%' escape '\'
113-
and regexp_like(s.text,'^\s*--\s*%')
127+
and regexp_like(s.text,'^\s*--\s*]'||l_allowed_annotations||q'[%')
114128
then 'Y' else 'N' end
115129
)
116130
over(partition by s.name) is_annotated
@@ -125,7 +139,24 @@ create or replace package body ut_annotation_manager as
125139
where x.is_annotated = 'Y'
126140
order by x.name, x.line]'
127141
using a_objects_to_refresh;
128-
142+
raise_application_error(-20001, q'[select /*+ no_parallel */ x.name, x.text
143+
from (select /*+ cardinality( r ]'||l_card||q'[ )*/
144+
s.name, s.text, s.line,
145+
max(case when s.text like '%--%\%%' escape '\'
146+
and regexp_like(s.text,'^\s*--\s*]'||l_allowed_annotations||q'[%')
147+
then 'Y' else 'N' end
148+
)
149+
over(partition by s.name) is_annotated
150+
from table(:a_objects_to_refresh) r
151+
join ]'||l_sources_view||q'[ s
152+
on s.name = r.object_name
153+
and s.owner = r.object_owner
154+
and s.type = r.object_type
155+
where s.owner = ']'||ut_utils.qualified_sql_name(a_object_owner)||q'['
156+
and s.type = ']'||ut_utils.qualified_sql_name(a_object_type)||q'['
157+
) x
158+
where x.is_annotated = 'Y'
159+
order by x.name, x.line]');
129160
return l_result;
130161
end;
131162

source/core/annotations/ut_annotation_manager.pks

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ create or replace package ut_annotation_manager authid current_user as
2020
* Builds annotations out of database source code by reading it from cache
2121
*/
2222

23+
function get_annotations_list return ut_varchar2_list pipelined;
24+
2325
/**
2426
* Gets annotations for all objects of a specified type for database schema.
2527
* Annotations that are stale or missing are parsed and placed in persistent cache.

source/core/ut_suite_builder.pkb

Lines changed: 14 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -21,46 +21,27 @@ create or replace package body ut_suite_builder is
2121
subtype t_object_name is varchar2(500);
2222
subtype t_annotation_position is binary_integer;
2323

24-
gc_suite constant t_annotation_name := 'suite';
25-
gc_suitepath constant t_annotation_name := 'suitepath';
26-
gc_tags constant t_annotation_name := 'tags';
24+
gc_suite constant t_annotation_name := ut_utils.gc_suite;
25+
gc_suitepath constant t_annotation_name := ut_utils.gc_suitepath;
26+
gc_tags constant t_annotation_name := ut_utils.gc_tags;
2727
gc_test constant t_annotation_name := ut_utils.gc_test_execute;
28-
gc_disabled constant t_annotation_name := 'disabled';
29-
gc_displayname constant t_annotation_name := 'displayname';
28+
gc_disabled constant t_annotation_name := ut_utils.gc_disabled_ann;
29+
gc_displayname constant t_annotation_name := ut_utils.gc_displayname;
3030
gc_beforeall constant t_annotation_name := ut_utils.gc_before_all;
3131
gc_beforeeach constant t_annotation_name := ut_utils.gc_before_each;
3232
gc_beforetest constant t_annotation_name := ut_utils.gc_before_test;
3333
gc_afterall constant t_annotation_name := ut_utils.gc_after_all;
3434
gc_aftereach constant t_annotation_name := ut_utils.gc_after_each;
3535
gc_aftertest constant t_annotation_name := ut_utils.gc_after_test;
36-
gc_throws constant t_annotation_name := 'throws';
37-
gc_rollback constant t_annotation_name := 'rollback';
38-
gc_context constant t_annotation_name := 'context';
39-
gc_name constant t_annotation_name := 'name';
40-
gc_endcontext constant t_annotation_name := 'endcontext';
41-
42-
type tt_annotations is table of t_annotation_name;
43-
44-
gc_supported_annotations constant tt_annotations
45-
:= tt_annotations(
46-
gc_suite,
47-
gc_suitepath,
48-
gc_tags,
49-
gc_test,
50-
gc_disabled,
51-
gc_displayname,
52-
gc_beforeall,
53-
gc_beforeeach,
54-
gc_beforetest,
55-
gc_afterall,
56-
gc_aftereach,
57-
gc_aftertest,
58-
gc_throws,
59-
gc_rollback,
60-
gc_context,
61-
gc_name,
62-
gc_endcontext
63-
);
36+
gc_throws constant t_annotation_name := ut_utils.gc_throws;
37+
gc_rollback constant t_annotation_name := ut_utils.gc_rollback;
38+
gc_context constant t_annotation_name := ut_utils.gc_context;
39+
gc_name constant t_annotation_name := ut_utils.gc_name;
40+
gc_endcontext constant t_annotation_name := ut_utils.gc_endcontext;
41+
42+
43+
gc_supported_annotations constant ut_utils.tt_annotations
44+
:= ut_utils.gc_supported_annotations;
6445

6546
type tt_executables is table of ut_executables index by t_annotation_position;
6647

source/core/ut_utils.pks

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,48 @@ create or replace package ut_utils authid definer is
2424
gc_version constant varchar2(50) := 'v3.1.14.4206-develop';
2525

2626
subtype t_executable_type is varchar2(30);
27+
subtype t_annotation_name is varchar2(4000);
28+
gc_suite constant t_annotation_name := 'suite';
29+
gc_suitepath constant t_annotation_name := 'suitepath';
30+
gc_tags constant t_annotation_name := 'tags';
2731
gc_before_all constant t_executable_type := 'beforeall';
2832
gc_before_each constant t_executable_type := 'beforeeach';
2933
gc_before_test constant t_executable_type := 'beforetest';
3034
gc_test_execute constant t_executable_type := 'test';
3135
gc_after_test constant t_executable_type := 'aftertest';
3236
gc_after_each constant t_executable_type := 'aftereach';
3337
gc_after_all constant t_executable_type := 'afterall';
38+
gc_disabled_ann constant t_annotation_name := 'disabled';
39+
gc_displayname constant t_annotation_name := 'displayname';
40+
gc_throws constant t_annotation_name := 'throws';
41+
gc_rollback constant t_annotation_name := 'rollback';
42+
gc_context constant t_annotation_name := 'context';
43+
gc_name constant t_annotation_name := 'name';
44+
gc_endcontext constant t_annotation_name := 'endcontext';
45+
46+
type tt_annotations is table of t_annotation_name;
47+
48+
49+
gc_supported_annotations constant tt_annotations
50+
:= tt_annotations(
51+
gc_suite,
52+
gc_suitepath,
53+
gc_tags,
54+
gc_before_all,
55+
gc_before_each,
56+
gc_before_test,
57+
gc_test_execute,
58+
gc_after_test,
59+
gc_after_each,
60+
gc_after_all,
61+
gc_disabled_ann,
62+
gc_displayname,
63+
gc_throws,
64+
gc_rollback,
65+
gc_context,
66+
gc_name ,
67+
gc_endcontext
68+
);
3469

3570
/* Constants: Test Results */
3671
subtype t_test_result is binary_integer range 0 .. 3;

0 commit comments

Comments
 (0)