Skip to content

Commit fccc966

Browse files
Merge pull request #964 from utPLSQL/feature/add_package_keyword_to_warnings
Added `package` to annotation warnings.
2 parents 2cc0d05 + e2ff899 commit fccc966

File tree

2 files changed

+31
-24
lines changed

2 files changed

+31
-24
lines changed

source/core/ut_suite_builder.pkb

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,27 @@ create or replace package body ut_suite_builder is
9595
by_name tt_annotations_by_name
9696
);
9797

98+
function get_qualified_object_name(
99+
a_suite ut_suite_item, a_procedure_name t_object_name
100+
) return varchar2 is
101+
l_result varchar2(1000);
102+
begin
103+
if a_suite is not null then
104+
l_result := upper( a_suite.object_owner || '.' || a_suite.object_name );
105+
if a_procedure_name is not null then
106+
l_result := l_result || upper( '.' || a_procedure_name );
107+
end if;
108+
end if;
109+
return l_result;
110+
end;
111+
112+
function get_object_reference(
113+
a_suite ut_suite_item, a_procedure_name t_object_name, a_line_no binary_integer
114+
) return varchar2 is
115+
begin
116+
return chr( 10 ) || 'at package "' || get_qualified_object_name(a_suite, a_procedure_name) || '", line ' || a_line_no;
117+
end;
118+
98119
procedure delete_annotations_range(
99120
a_annotations in out nocopy t_annotations_info,
100121
a_start_pos t_annotation_position,
@@ -131,20 +152,6 @@ create or replace package body ut_suite_builder is
131152
-- Processing annotations
132153
-----------------------------------------------
133154

134-
function get_qualified_object_name(
135-
a_suite ut_suite_item, a_procedure_name t_object_name
136-
) return varchar2 is
137-
l_result varchar2(1000);
138-
begin
139-
if a_suite is not null then
140-
l_result := upper( a_suite.object_owner || '.' || a_suite.object_name );
141-
if a_procedure_name is not null then
142-
l_result := l_result || upper( '.' || a_procedure_name );
143-
end if;
144-
end if;
145-
return l_result;
146-
end;
147-
148155
procedure add_annotation_ignored_warning(
149156
a_suite in out nocopy ut_suite_item,
150157
a_annotation t_annotation_name,
@@ -154,8 +161,8 @@ create or replace package body ut_suite_builder is
154161
) is
155162
begin
156163
a_suite.put_warning(
157-
replace(a_message,'%%%','"--%'||a_annotation||'"') || ' Annotation ignored.'
158-
|| chr( 10 ) || 'at "' || get_qualified_object_name(a_suite, a_procedure_name) || '", line ' || a_line_no
164+
replace(a_message,'%%%','"--%'||a_annotation||'"')
165+
|| ' Annotation ignored.' || get_object_reference( a_suite, a_procedure_name, a_line_no )
159166
);
160167
end;
161168

@@ -271,8 +278,8 @@ create or replace package body ut_suite_builder is
271278

272279
if l_exception_number is null then
273280
a_suite.put_warning(
274-
'Invalid parameter value "'||l_throws_list(i)||'" for "--%throws" annotation. Parameter ignored.'
275-
|| chr( 10 ) || 'at "' || get_qualified_object_name(a_suite, a_procedure_name) || '", line ' || a_line_no
281+
'Invalid parameter value "'||l_throws_list(i)
282+
||'" for "--%throws" annotation. Parameter ignored.'||get_object_reference( a_suite, a_procedure_name, a_line_no )
276283
);
277284
else
278285
l_exception_number_list.extend;
@@ -291,7 +298,7 @@ create or replace package body ut_suite_builder is
291298
if a_throws_ann_text(l_annotation_pos) is null then
292299
a_suite.put_warning(
293300
'"--%throws" annotation requires a parameter. Annotation ignored.'
294-
|| chr( 10 ) || 'at "' || get_qualified_object_name(a_suite, a_procedure_name) || '", line ' || l_annotation_pos
301+
|| get_object_reference( a_suite, a_procedure_name, l_annotation_pos )
295302
);
296303
else
297304
a_list :=
@@ -321,7 +328,7 @@ create or replace package body ut_suite_builder is
321328
if a_tags_ann_text(l_annotation_pos) is null then
322329
a_suite.put_warning(
323330
'"--%tags" annotation requires a tag value populated. Annotation ignored.'
324-
|| chr( 10 ) || 'at "' || get_qualified_object_name(a_suite, a_procedure_name) || '", line ' || l_annotation_pos
331+
|| get_object_reference( a_suite, a_procedure_name, l_annotation_pos )
325332
);
326333
else
327334
l_tag_list := l_tag_list multiset union distinct ut_utils.trim_list_elements(

test/ut3_tester/core/test_suite_builder.pkb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ create or replace package body test_suite_builder is
619619
ut.expect(l_actual).to_match('(.*)(<WARNINGS>)(.*)(Annotation &quot;--%beforeeach&quot;)(.*)(line 3)(.*)(</WARNINGS>)(.*)', 'n');
620620
ut.expect(l_actual).to_match('(.*)(<WARNINGS>)(.*)(Annotation &quot;--%aftereach&quot;)(.*)(line 4)(.*)(</WARNINGS>)(.*)', 'n');
621621
ut.expect(l_actual).to_match('(.*)(<WARNINGS>)(.*)(Annotation &quot;--%afterall&quot; cannot be used with &quot;--%test&quot;. Annotation ignored.)'
622-
||'(.*)(at &quot;UT3_TESTER.SOME_PACKAGE.DO_STUFF&quot;, line 5)(.*)(</WARNINGS>)(.*)', 'n');
622+
||'(.*)(at package &quot;UT3_TESTER.SOME_PACKAGE.DO_STUFF&quot;, line 5)(.*)(</WARNINGS>)(.*)', 'n');
623623
ut.expect(l_actual).not_to_be_like('%<BEFORE_EACH_LIST>%');
624624
ut.expect(l_actual).not_to_be_like('%<AFTER_EACH_LIST>%');
625625
ut.expect(l_actual).not_to_be_like('%<BEFORE_ALL_LIST>%');
@@ -791,7 +791,7 @@ create or replace package body test_suite_builder is
791791
l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE');
792792
--Assert
793793
ut.expect(l_actual).to_be_like(
794-
'%<WARNINGS><VARCHAR2>Invalid annotation &quot;--\%context&quot;. Cannot find following &quot;--\%endcontext&quot;. Annotation ignored.%at &quot;UT3_TESTER.SOME_PACKAGE&quot;, line 4</VARCHAR2></WARNINGS>%'
794+
'%<WARNINGS><VARCHAR2>Invalid annotation &quot;--\%context&quot;. Cannot find following &quot;--\%endcontext&quot;. Annotation ignored.%at package &quot;UT3_TESTER.SOME_PACKAGE&quot;, line 4</VARCHAR2></WARNINGS>%'
795795
,'\'
796796
);
797797
ut.expect(l_actual).to_be_like(
@@ -835,7 +835,7 @@ create or replace package body test_suite_builder is
835835
l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE');
836836
--Assert
837837
ut.expect(l_actual).to_be_like(
838-
'%<WARNINGS><VARCHAR2>Invalid annotation &quot;--\%endcontext&quot;. Cannot find preceding &quot;--\%context&quot;. Annotation ignored.%at &quot;UT3_TESTER.SOME_PACKAGE&quot;, line 9</VARCHAR2></WARNINGS>%'
838+
'%<WARNINGS><VARCHAR2>Invalid annotation &quot;--\%endcontext&quot;. Cannot find preceding &quot;--\%context&quot;. Annotation ignored.%at package &quot;UT3_TESTER.SOME_PACKAGE&quot;, line 9</VARCHAR2></WARNINGS>%'
839839
,'\'
840840
);
841841
ut.expect(l_actual).to_be_like(
@@ -892,7 +892,7 @@ create or replace package body test_suite_builder is
892892
l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE');
893893
--Assert
894894
ut.expect(l_actual).to_be_like(
895-
'%<WARNINGS><VARCHAR2>Context name must be unique in a suite. Context and all of it&apos;s content ignored.%at &quot;UT3_TESTER.SOME_PACKAGE&quot;, line 9</VARCHAR2></WARNINGS>%'
895+
'%<WARNINGS><VARCHAR2>Context name must be unique in a suite. Context and all of it&apos;s content ignored.%at package &quot;UT3_TESTER.SOME_PACKAGE&quot;, line 9</VARCHAR2></WARNINGS>%'
896896
,'\'
897897
);
898898
ut.expect(l_actual).to_be_like(

0 commit comments

Comments
 (0)