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

Skip to content

Commit 6d140a3

Browse files
authored
Merge pull request #609 from utPLSQL/feature/warnings_reporting_fix
Deprecation warnings are now showing in `ut_documentation_reporter` output.
2 parents 73c6869 + c377250 commit 6d140a3

11 files changed

Lines changed: 64 additions & 73 deletions

File tree

source/core/types/ut_results_counter.tpb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ create or replace type body ut_results_counter as
4242
self.warnings_count := self.warnings_count + a_item.warnings_count;
4343
end;
4444

45-
member procedure increase_warning_count(self in out nocopy ut_results_counter) is
45+
member procedure increase_warning_count(self in out nocopy ut_results_counter, a_count integer := 1) is
4646
begin
47-
self.warnings_count := self.warnings_count + 1;
47+
self.warnings_count := self.warnings_count + nvl(a_count,0);
4848
end;
4949

5050
member function total_count return integer is

source/core/types/ut_results_counter.tps

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ create or replace type ut_results_counter as object(
2323
constructor function ut_results_counter(self in out nocopy ut_results_counter) return self as result,
2424
member procedure set_counter_values(self in out nocopy ut_results_counter, a_status integer),
2525
member procedure sum_counter_values(self in out nocopy ut_results_counter, a_item ut_results_counter),
26-
member procedure increase_warning_count(self in out nocopy ut_results_counter),
26+
member procedure increase_warning_count(self in out nocopy ut_results_counter, a_count integer := 1),
2727
member function total_count return integer,
2828
member function result_status return integer
2929
)

source/core/types/ut_test.tpb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ create or replace type body ut_test as
113113
end;
114114

115115
overriding member procedure calc_execution_result(self in out nocopy ut_test) is
116+
l_warnings ut_varchar2_list;
116117
begin
117118
if self.get_error_stack_traces().count = 0 then
118119
self.result := ut_expectation_processor.get_status();
@@ -122,9 +123,11 @@ create or replace type body ut_test as
122123
--expectation results need to be part of test results
123124
self.all_expectations := ut_expectation_processor.get_all_expectations();
124125
self.failed_expectations := ut_expectation_processor.get_failed_expectations();
125-
self.warnings := self.warnings multiset union all ut_expectation_processor.get_warnings();
126-
ut_expectation_processor.clear_expectations();
126+
l_warnings := coalesce( ut_expectation_processor.get_warnings(), ut_varchar2_list() );
127+
self.warnings := self.warnings multiset union all l_warnings;
128+
self.results_count.increase_warning_count( cardinality(l_warnings) );
127129
self.results_count.set_counter_values(self.result);
130+
ut_expectation_processor.clear_expectations();
128131
end;
129132

130133
overriding member procedure mark_as_errored(self in out nocopy ut_test, a_listener in out nocopy ut_event_listener_base, a_error_stack_trace varchar2) is

source/core/ut_expectation_processor.pkb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,14 @@ create or replace package body ut_expectation_processor as
168168
g_warnings(g_warnings.last) := a_messsage;
169169
end;
170170

171+
procedure add_depreciation_warning(a_deprecated_syntax varchar2, a_new_syntax varchar2) is
172+
begin
173+
add_warning(
174+
ut_utils.build_depreciation_warning( a_deprecated_syntax, a_new_syntax ) || chr(10)
175+
|| ut_expectation_processor.who_called_expectation(dbms_utility.format_call_stack())
176+
);
177+
end;
178+
171179
function get_warnings return ut_varchar2_list is
172180
begin
173181
return g_warnings;

source/core/ut_expectation_processor.pks

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ create or replace package ut_expectation_processor authid current_user as
5050

5151
procedure add_warning(a_messsage varchar2);
5252

53+
procedure add_depreciation_warning(a_deprecated_syntax varchar2, a_new_syntax varchar2);
54+
5355
function get_warnings return ut_varchar2_list;
5456

5557
function invalidation_exception_found return boolean;

source/core/ut_utils.pkb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -496,9 +496,9 @@ procedure append_to_clob(a_src_clob in out nocopy clob, a_clob_table t_clob_tab,
496496

497497
function build_depreciation_warning(a_old_syntax varchar2, a_new_syntax varchar2) return varchar2 is
498498
begin
499-
return 'The syntax: "'||a_old_syntax||'" is depreciated.' ||chr(10)||
499+
return 'The syntax: "'||a_old_syntax||'" is deprecated.' ||chr(10)||
500500
'Please use the new syntax: "'||a_new_syntax||'".' ||chr(10)||
501-
'The depreciated syntax will not be supported in future releases.';
501+
'The deprecated syntax will not be supported in future releases.';
502502
end;
503503

504504
function to_xml_number_format(a_value number) return varchar2 is

source/expectations/matchers/ut_equal.tpb

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,11 @@ create or replace type body ut_equal as
3838
end;
3939

4040
constructor function ut_equal(self in out nocopy ut_equal, a_expected anydata, a_exclude varchar2, a_nulls_are_equal boolean := null) return self as result is
41-
l_depreciated integer;
41+
l_deprecated integer;
4242
begin
43-
ut_expectation_processor.add_warning(
44-
ut_utils.build_depreciation_warning(
45-
'equal( a_expected anydata, a_exclude varchar2 )',
46-
'equal( a_expected anydata ).exclude( a_exclude varchar2 )'
47-
)
43+
ut_expectation_processor.add_depreciation_warning(
44+
'equal( a_expected anydata, a_exclude varchar2 )',
45+
'equal( a_expected anydata ).exclude( a_exclude varchar2 )'
4846
);
4947
init(ut_data_value_anydata.get_instance(a_expected), a_nulls_are_equal);
5048
exclude_list := ut_varchar2_list(a_exclude);
@@ -53,11 +51,9 @@ create or replace type body ut_equal as
5351

5452
constructor function ut_equal(self in out nocopy ut_equal, a_expected anydata, a_exclude ut_varchar2_list, a_nulls_are_equal boolean := null) return self as result is
5553
begin
56-
ut_expectation_processor.add_warning(
57-
ut_utils.build_depreciation_warning(
58-
'equal( a_expected anydata, a_exclude ut_varchar2_list )',
59-
'equal( a_expected anydata ).exclude( a_exclude ut_varchar2_list )'
60-
)
54+
ut_expectation_processor.add_depreciation_warning(
55+
'equal( a_expected anydata, a_exclude ut_varchar2_list )',
56+
'equal( a_expected anydata ).exclude( a_exclude ut_varchar2_list )'
6157
);
6258
init(ut_data_value_anydata.get_instance(a_expected), a_nulls_are_equal);
6359
exclude_list := coalesce(a_exclude, ut_varchar2_list());
@@ -102,11 +98,9 @@ create or replace type body ut_equal as
10298

10399
constructor function ut_equal(self in out nocopy ut_equal, a_expected sys_refcursor, a_exclude varchar2, a_nulls_are_equal boolean := null) return self as result is
104100
begin
105-
ut_expectation_processor.add_warning(
106-
ut_utils.build_depreciation_warning(
107-
'equal( a_expected sys_refcursor, a_exclude varchar2 )',
108-
'equal( a_expected sys_refcursor ).exclude( a_exclude varchar2 )'
109-
)
101+
ut_expectation_processor.add_depreciation_warning(
102+
'equal( a_expected sys_refcursor, a_exclude varchar2 )',
103+
'equal( a_expected sys_refcursor ).exclude( a_exclude varchar2 )'
110104
);
111105
init(ut_data_value_refcursor(a_expected), a_nulls_are_equal);
112106
exclude_list := ut_varchar2_list(a_exclude);
@@ -115,11 +109,9 @@ create or replace type body ut_equal as
115109

116110
constructor function ut_equal(self in out nocopy ut_equal, a_expected sys_refcursor, a_exclude ut_varchar2_list, a_nulls_are_equal boolean := null) return self as result is
117111
begin
118-
ut_expectation_processor.add_warning(
119-
ut_utils.build_depreciation_warning(
120-
'equal( a_expected sys_refcursor, a_exclude ut_varchar2_list )',
121-
'equal( a_expected sys_refcursor ).exclude( a_exclude ut_varchar2_list )'
122-
)
112+
ut_expectation_processor.add_depreciation_warning(
113+
'equal( a_expected sys_refcursor, a_exclude ut_varchar2_list )',
114+
'equal( a_expected sys_refcursor ).exclude( a_exclude ut_varchar2_list )'
123115
);
124116
init(ut_data_value_refcursor(a_expected), a_nulls_are_equal);
125117
exclude_list := coalesce(a_exclude, ut_varchar2_list());

source/expectations/ut_expectation.tpb

Lines changed: 18 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -138,22 +138,18 @@ create or replace type body ut_expectation as
138138

139139
member procedure to_equal(self in ut_expectation, a_expected sys_refcursor, a_exclude varchar2, a_nulls_are_equal boolean := null) is
140140
begin
141-
ut_expectation_processor.add_warning(
142-
ut_utils.build_depreciation_warning(
143-
'to_equal( a_expected sys_refcursor, a_exclude varchar2 )',
144-
'to_equal( a_expected sys_refcursor ).exclude( a_exclude varchar2 )'
145-
)
141+
ut_expectation_processor.add_depreciation_warning(
142+
'to_equal( a_expected sys_refcursor, a_exclude varchar2 )',
143+
'to_equal( a_expected sys_refcursor ).exclude( a_exclude varchar2 )'
146144
);
147145
self.to_( ut_equal(a_expected, a_nulls_are_equal).exclude(a_exclude) );
148146
end;
149147

150148
member procedure to_equal(self in ut_expectation, a_expected sys_refcursor, a_exclude ut_varchar2_list, a_nulls_are_equal boolean := null) is
151149
begin
152-
ut_expectation_processor.add_warning(
153-
ut_utils.build_depreciation_warning(
154-
'to_equal( a_expected sys_refcursor, a_exclude ut_varchar2_list )',
155-
'to_equal( a_expected sys_refcursor ).exclude( a_exclude ut_varchar2_list )'
156-
)
150+
ut_expectation_processor.add_depreciation_warning(
151+
'to_equal( a_expected sys_refcursor, a_exclude ut_varchar2_list )',
152+
'to_equal( a_expected sys_refcursor ).exclude( a_exclude ut_varchar2_list )'
157153
);
158154
self.to_( ut_equal(a_expected, a_nulls_are_equal).exclude(a_exclude) );
159155
end;
@@ -196,22 +192,18 @@ create or replace type body ut_expectation as
196192

197193
member procedure not_to_equal(self in ut_expectation, a_expected anydata, a_exclude varchar2, a_nulls_are_equal boolean := null) is
198194
begin
199-
ut_expectation_processor.add_warning(
200-
ut_utils.build_depreciation_warning(
201-
'not_to_equal( a_expected anydata, a_exclude varchar2 )',
202-
'not_to_equal( a_expected anydata ).exclude( a_exclude varchar2 )'
203-
)
195+
ut_expectation_processor.add_depreciation_warning(
196+
'not_to_equal( a_expected anydata, a_exclude varchar2 )',
197+
'not_to_equal( a_expected anydata ).exclude( a_exclude varchar2 )'
204198
);
205199
self.not_to( ut_equal(a_expected, a_nulls_are_equal).exclude(a_exclude) );
206200
end;
207201

208202
member procedure not_to_equal(self in ut_expectation, a_expected anydata, a_exclude ut_varchar2_list, a_nulls_are_equal boolean := null) is
209203
begin
210-
ut_expectation_processor.add_warning(
211-
ut_utils.build_depreciation_warning(
212-
'not_to_equal( a_expected anydata, a_exclude ut_varchar2_list )',
213-
'not_to_equal( a_expected anydata ).exclude( a_exclude ut_varchar2_list )'
214-
)
204+
ut_expectation_processor.add_depreciation_warning(
205+
'not_to_equal( a_expected anydata, a_exclude ut_varchar2_list )',
206+
'not_to_equal( a_expected anydata ).exclude( a_exclude ut_varchar2_list )'
215207
);
216208
self.not_to( ut_equal(a_expected, a_nulls_are_equal).exclude(a_exclude) );
217209
end;
@@ -248,22 +240,18 @@ create or replace type body ut_expectation as
248240

249241
member procedure not_to_equal(self in ut_expectation, a_expected sys_refcursor, a_exclude varchar2, a_nulls_are_equal boolean := null) is
250242
begin
251-
ut_expectation_processor.add_warning(
252-
ut_utils.build_depreciation_warning(
253-
'not_to_equal( a_expected sys_refcursor, a_exclude varchar2 )',
254-
'not_to_equal( a_expected sys_refcursor ).exclude( a_exclude varchar2 )'
255-
)
243+
ut_expectation_processor.add_depreciation_warning(
244+
'not_to_equal( a_expected sys_refcursor, a_exclude varchar2 )',
245+
'not_to_equal( a_expected sys_refcursor ).exclude( a_exclude varchar2 )'
256246
);
257247
self.not_to( ut_equal(a_expected, a_nulls_are_equal).exclude(a_exclude) );
258248
end;
259249

260250
member procedure not_to_equal(self in ut_expectation, a_expected sys_refcursor, a_exclude ut_varchar2_list, a_nulls_are_equal boolean := null) is
261251
begin
262-
ut_expectation_processor.add_warning(
263-
ut_utils.build_depreciation_warning(
264-
'not_to_equal( a_expected sys_refcursor, a_exclude ut_varchar2_list )',
265-
'not_to_equal( a_expected sys_refcursor ).exclude( a_exclude ut_varchar2_list )'
266-
)
252+
ut_expectation_processor.add_depreciation_warning(
253+
'not_to_equal( a_expected sys_refcursor, a_exclude ut_varchar2_list )',
254+
'not_to_equal( a_expected sys_refcursor ).exclude( a_exclude ut_varchar2_list )'
267255
);
268256
self.not_to( ut_equal(a_expected, a_nulls_are_equal).exclude(a_exclude) );
269257
end;

source/reporters/ut_documentation_reporter.tpb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,7 @@ create or replace type body ut_documentation_reporter is
148148
if a_item is of (ut_logical_suite) then
149149
l_items := treat(a_item as ut_logical_suite).items;
150150
for i in 1 .. l_items.count loop
151-
if l_items(i) is of(ut_suite_item) then
152-
print_item_warnings(l_items(i));
153-
end if;
151+
print_item_warnings(l_items(i));
154152
end loop;
155153
end if;
156154

test/core/expectations/compound_data/test_expectation_anydata.pkb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ Rows: [ 1 differences ]
401401
ut3.ut.expect(get_anydata()).to_equal(get_anydata(), a_exclude => 'A_COLUMN,Some_Col');
402402
--Assert
403403
ut.expect(cardinality(ut3.ut_expectation_processor.get_warnings())).to_equal(1);
404-
ut.expect(ut3.ut_expectation_processor.get_warnings()(1)).to_be_like('The syntax: "%" is depreciated.%');
404+
ut.expect(ut3.ut_expectation_processor.get_warnings()(1)).to_be_like('The syntax: "%" is deprecated.%');
405405
end;
406406

407407
procedure deprec_to_equal_excl_list is
@@ -410,7 +410,7 @@ Rows: [ 1 differences ]
410410
ut3.ut.expect(get_anydata()).to_equal(get_anydata(), a_exclude => ut3.ut_varchar2_list('A_COLUMN','Some_Col'));
411411
--Assert
412412
ut.expect(cardinality(ut3.ut_expectation_processor.get_warnings())).to_equal(1);
413-
ut.expect(ut3.ut_expectation_processor.get_warnings()(1)).to_be_like('The syntax: "%" is depreciated.%');
413+
ut.expect(ut3.ut_expectation_processor.get_warnings()(1)).to_be_like('The syntax: "%" is deprecated.%');
414414
end;
415415

416416
procedure deprec_not_to_equal_excl_varch is
@@ -419,7 +419,7 @@ Rows: [ 1 differences ]
419419
ut3.ut.expect(get_anydata()).not_to_equal(get_anydata(), a_exclude => 'A_COLUMN,Some_Col');
420420
--Assert
421421
ut.expect(cardinality(ut3.ut_expectation_processor.get_warnings())).to_equal(1);
422-
ut.expect(ut3.ut_expectation_processor.get_warnings()(1)).to_be_like('The syntax: "%" is depreciated.%');
422+
ut.expect(ut3.ut_expectation_processor.get_warnings()(1)).to_be_like('The syntax: "%" is deprecated.%');
423423
end;
424424

425425
procedure deprec_not_to_equal_excl_list is
@@ -428,7 +428,7 @@ Rows: [ 1 differences ]
428428
ut3.ut.expect(get_anydata()).not_to_equal(get_anydata(), a_exclude => ut3.ut_varchar2_list('A_COLUMN','Some_Col'));
429429
--Assert
430430
ut.expect(cardinality(ut3.ut_expectation_processor.get_warnings())).to_equal(1);
431-
ut.expect(ut3.ut_expectation_processor.get_warnings()(1)).to_be_like('The syntax: "%" is depreciated.%');
431+
ut.expect(ut3.ut_expectation_processor.get_warnings()(1)).to_be_like('The syntax: "%" is deprecated.%');
432432
end;
433433

434434
procedure deprec_equal_excl_varch is
@@ -437,7 +437,7 @@ Rows: [ 1 differences ]
437437
ut3.ut.expect(get_anydata()).to_(ut3.equal(get_anydata(), a_exclude => 'A_COLUMN,Some_Col'));
438438
--Assert
439439
ut.expect(cardinality(ut3.ut_expectation_processor.get_warnings())).to_equal(1);
440-
ut.expect(ut3.ut_expectation_processor.get_warnings()(1)).to_be_like('The syntax: "%" is depreciated.%');
440+
ut.expect(ut3.ut_expectation_processor.get_warnings()(1)).to_be_like('The syntax: "%" is deprecated.%');
441441
end;
442442

443443
procedure deprec_equal_excl_list is
@@ -446,7 +446,7 @@ Rows: [ 1 differences ]
446446
ut3.ut.expect(get_anydata()).to_(ut3.equal(get_anydata(), a_exclude => ut3.ut_varchar2_list('A_COLUMN','Some_Col')));
447447
--Assert
448448
ut.expect(cardinality(ut3.ut_expectation_processor.get_warnings())).to_equal(1);
449-
ut.expect(ut3.ut_expectation_processor.get_warnings()(1)).to_be_like('The syntax: "%" is depreciated.%');
449+
ut.expect(ut3.ut_expectation_processor.get_warnings()(1)).to_be_like('The syntax: "%" is deprecated.%');
450450
end;
451451

452452
--%test(Reports only mismatched columns on column data mismatch)

0 commit comments

Comments
 (0)