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

Skip to content

Commit b33aaae

Browse files
committed
Added additional test for display of parser warnings.
Fixed issue with warnings not getting shown.
1 parent 48aa338 commit b33aaae

3 files changed

Lines changed: 148 additions & 101 deletions

File tree

source/core/ut_suite_manager.pkb

Lines changed: 102 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -174,91 +174,112 @@ create or replace package body ut_suite_manager is
174174
a_level pls_integer,
175175
a_prev_level pls_integer,
176176
a_items_at_level t_item_levels
177-
) return ut_logical_suite is
177+
) return ut_suite_item is
178+
l_result ut_suite_item;
178179
begin
179-
return
180180
case a_rows( a_idx ).self_type
181181
when 'UT_SUITE' then
182-
case when a_prev_level > a_level then
183-
ut_suite(
184-
self_type => a_rows( a_idx ).self_type,
185-
object_owner => a_rows( a_idx ).object_owner, object_name => lower( a_rows( a_idx ).object_name),
186-
name => lower( a_rows( a_idx ).name), description => a_rows( a_idx ).description, path => a_rows( a_idx ).path,
187-
rollback_type => a_rows( a_idx ).rollback_type, disabled_flag => a_rows( a_idx ).disabled_flag,
188-
line_no => a_rows( a_idx ).line_no, parse_time => a_rows( a_idx ).parse_time,
189-
start_time => null, end_time => null, result => null, warnings => a_rows( a_idx ).warnings,
190-
results_count => ut_results_counter(), transaction_invalidators => ut_varchar2_list(),
191-
items => a_items_at_level(a_prev_level),
192-
before_all_list => sort_by_seq_no( a_rows( a_idx ).before_all_list), after_all_list => sort_by_seq_no(
193-
a_rows( a_idx ).after_all_list)
194-
)
195-
else
196-
ut_suite(
197-
self_type => a_rows( a_idx ).self_type,
198-
object_owner => a_rows( a_idx ).object_owner, object_name => lower( a_rows( a_idx ).object_name),
199-
name => lower( a_rows( a_idx ).name), description => a_rows( a_idx ).description, path => a_rows( a_idx ).path,
200-
rollback_type => a_rows( a_idx ).rollback_type, disabled_flag => a_rows( a_idx ).disabled_flag,
201-
line_no => a_rows( a_idx ).line_no, parse_time => a_rows( a_idx ).parse_time,
202-
start_time => null, end_time => null, result => null, warnings => a_rows( a_idx ).warnings,
203-
results_count => ut_results_counter(), transaction_invalidators => ut_varchar2_list(),
204-
items => ut_suite_items(),
205-
before_all_list => sort_by_seq_no( a_rows( a_idx ).before_all_list), after_all_list => sort_by_seq_no(
206-
a_rows( a_idx ).after_all_list)
207-
)
208-
end
182+
l_result :=
183+
case when a_prev_level > a_level then
184+
ut_suite(
185+
self_type => a_rows( a_idx ).self_type,
186+
object_owner => a_rows( a_idx ).object_owner, object_name => lower( a_rows( a_idx ).object_name),
187+
name => lower( a_rows( a_idx ).name), description => a_rows( a_idx ).description, path => a_rows( a_idx ).path,
188+
rollback_type => a_rows( a_idx ).rollback_type, disabled_flag => a_rows( a_idx ).disabled_flag,
189+
line_no => a_rows( a_idx ).line_no, parse_time => a_rows( a_idx ).parse_time,
190+
start_time => null, end_time => null, result => null, warnings => a_rows( a_idx ).warnings,
191+
results_count => ut_results_counter(), transaction_invalidators => ut_varchar2_list(),
192+
items => a_items_at_level(a_prev_level),
193+
before_all_list => sort_by_seq_no( a_rows( a_idx ).before_all_list), after_all_list => sort_by_seq_no(
194+
a_rows( a_idx ).after_all_list)
195+
)
196+
else
197+
ut_suite(
198+
self_type => a_rows( a_idx ).self_type,
199+
object_owner => a_rows( a_idx ).object_owner, object_name => lower( a_rows( a_idx ).object_name),
200+
name => lower( a_rows( a_idx ).name), description => a_rows( a_idx ).description, path => a_rows( a_idx ).path,
201+
rollback_type => a_rows( a_idx ).rollback_type, disabled_flag => a_rows( a_idx ).disabled_flag,
202+
line_no => a_rows( a_idx ).line_no, parse_time => a_rows( a_idx ).parse_time,
203+
start_time => null, end_time => null, result => null, warnings => a_rows( a_idx ).warnings,
204+
results_count => ut_results_counter(), transaction_invalidators => ut_varchar2_list(),
205+
items => ut_suite_items(),
206+
before_all_list => sort_by_seq_no( a_rows( a_idx ).before_all_list), after_all_list => sort_by_seq_no(
207+
a_rows( a_idx ).after_all_list)
208+
)
209+
end;
209210
when 'UT_SUITE_CONTEXT' then
210-
case when a_prev_level > a_level then
211-
ut_suite_context(
212-
self_type => a_rows( a_idx ).self_type,
213-
object_owner => a_rows( a_idx ).object_owner, object_name => lower( a_rows( a_idx ).object_name),
214-
name => lower( a_rows( a_idx ).name), description => a_rows( a_idx ).description, path => a_rows( a_idx ).path,
215-
rollback_type => a_rows( a_idx ).rollback_type, disabled_flag => a_rows( a_idx ).disabled_flag,
216-
line_no => a_rows( a_idx ).line_no, parse_time => a_rows( a_idx ).parse_time,
217-
start_time => null, end_time => null, result => null, warnings => a_rows( a_idx ).warnings,
218-
results_count => ut_results_counter(), transaction_invalidators => ut_varchar2_list(),
219-
items => a_items_at_level(a_prev_level),
220-
before_all_list => sort_by_seq_no( a_rows( a_idx ).before_all_list), after_all_list => sort_by_seq_no(
221-
a_rows( a_idx ).after_all_list)
222-
)
223-
else
224-
ut_suite_context(
225-
self_type => a_rows( a_idx ).self_type,
226-
object_owner => a_rows( a_idx ).object_owner, object_name => lower( a_rows( a_idx ).object_name),
227-
name => lower( a_rows( a_idx ).name), description => a_rows( a_idx ).description, path => a_rows( a_idx ).path,
228-
rollback_type => a_rows( a_idx ).rollback_type, disabled_flag => a_rows( a_idx ).disabled_flag,
229-
line_no => a_rows( a_idx ).line_no, parse_time => a_rows( a_idx ).parse_time,
230-
start_time => null, end_time => null, result => null, warnings => a_rows( a_idx ).warnings,
231-
results_count => ut_results_counter(), transaction_invalidators => ut_varchar2_list(),
232-
items => ut_suite_items(),
233-
before_all_list => sort_by_seq_no( a_rows( a_idx ).before_all_list), after_all_list => sort_by_seq_no(
234-
a_rows( a_idx ).after_all_list)
235-
)
236-
end
211+
l_result :=
212+
case when a_prev_level > a_level then
213+
ut_suite_context(
214+
self_type => a_rows( a_idx ).self_type,
215+
object_owner => a_rows( a_idx ).object_owner, object_name => lower( a_rows( a_idx ).object_name),
216+
name => lower( a_rows( a_idx ).name), description => a_rows( a_idx ).description, path => a_rows( a_idx ).path,
217+
rollback_type => a_rows( a_idx ).rollback_type, disabled_flag => a_rows( a_idx ).disabled_flag,
218+
line_no => a_rows( a_idx ).line_no, parse_time => a_rows( a_idx ).parse_time,
219+
start_time => null, end_time => null, result => null, warnings => a_rows( a_idx ).warnings,
220+
results_count => ut_results_counter(), transaction_invalidators => ut_varchar2_list(),
221+
items => a_items_at_level(a_prev_level),
222+
before_all_list => sort_by_seq_no( a_rows( a_idx ).before_all_list), after_all_list => sort_by_seq_no(
223+
a_rows( a_idx ).after_all_list)
224+
)
225+
else
226+
ut_suite_context(
227+
self_type => a_rows( a_idx ).self_type,
228+
object_owner => a_rows( a_idx ).object_owner, object_name => lower( a_rows( a_idx ).object_name),
229+
name => lower( a_rows( a_idx ).name), description => a_rows( a_idx ).description, path => a_rows( a_idx ).path,
230+
rollback_type => a_rows( a_idx ).rollback_type, disabled_flag => a_rows( a_idx ).disabled_flag,
231+
line_no => a_rows( a_idx ).line_no, parse_time => a_rows( a_idx ).parse_time,
232+
start_time => null, end_time => null, result => null, warnings => a_rows( a_idx ).warnings,
233+
results_count => ut_results_counter(), transaction_invalidators => ut_varchar2_list(),
234+
items => ut_suite_items(),
235+
before_all_list => sort_by_seq_no( a_rows( a_idx ).before_all_list), after_all_list => sort_by_seq_no(
236+
a_rows( a_idx ).after_all_list)
237+
)
238+
end;
237239
when 'UT_LOGICAL_SUITE' then
238-
case when a_prev_level > a_level then
239-
ut_logical_suite(
240-
self_type => a_rows( a_idx ).self_type,
241-
object_owner => a_rows( a_idx ).object_owner, object_name => lower( a_rows( a_idx ).object_name),
242-
name => lower( a_rows( a_idx ).name), description => a_rows( a_idx ).description, path => a_rows( a_idx ).path,
243-
rollback_type => a_rows( a_idx ).rollback_type, disabled_flag => a_rows( a_idx ).disabled_flag,
244-
line_no => a_rows( a_idx ).line_no, parse_time => a_rows( a_idx ).parse_time,
245-
start_time => null, end_time => null, result => null, warnings => a_rows( a_idx ).warnings,
246-
results_count => ut_results_counter(), transaction_invalidators => ut_varchar2_list(),
247-
items => a_items_at_level(a_prev_level)
248-
)
249-
else
250-
ut_logical_suite(
251-
self_type => a_rows( a_idx ).self_type,
252-
object_owner => a_rows( a_idx ).object_owner, object_name => lower( a_rows( a_idx ).object_name),
253-
name => lower( a_rows( a_idx ).name), description => a_rows( a_idx ).description, path => a_rows( a_idx ).path,
254-
rollback_type => a_rows( a_idx ).rollback_type, disabled_flag => a_rows( a_idx ).disabled_flag,
255-
line_no => a_rows( a_idx ).line_no, parse_time => a_rows( a_idx ).parse_time,
256-
start_time => null, end_time => null, result => null, warnings => a_rows( a_idx ).warnings,
240+
l_result :=
241+
case when a_prev_level > a_level then
242+
ut_logical_suite(
243+
self_type => a_rows( a_idx ).self_type,
244+
object_owner => a_rows( a_idx ).object_owner, object_name => lower( a_rows( a_idx ).object_name),
245+
name => lower( a_rows( a_idx ).name), description => a_rows( a_idx ).description, path => a_rows( a_idx ).path,
246+
rollback_type => a_rows( a_idx ).rollback_type, disabled_flag => a_rows( a_idx ).disabled_flag,
247+
line_no => a_rows( a_idx ).line_no, parse_time => a_rows( a_idx ).parse_time,
248+
start_time => null, end_time => null, result => null, warnings => a_rows( a_idx ).warnings,
249+
results_count => ut_results_counter(), transaction_invalidators => ut_varchar2_list(),
250+
items => a_items_at_level(a_prev_level)
251+
)
252+
else
253+
ut_logical_suite(
254+
self_type => a_rows( a_idx ).self_type,
255+
object_owner => a_rows( a_idx ).object_owner, object_name => lower( a_rows( a_idx ).object_name),
256+
name => lower( a_rows( a_idx ).name), description => a_rows( a_idx ).description, path => a_rows( a_idx ).path,
257+
rollback_type => a_rows( a_idx ).rollback_type, disabled_flag => a_rows( a_idx ).disabled_flag,
258+
line_no => a_rows( a_idx ).line_no, parse_time => a_rows( a_idx ).parse_time,
259+
start_time => null, end_time => null, result => null, warnings => a_rows( a_idx ).warnings,
260+
results_count => ut_results_counter(), transaction_invalidators => ut_varchar2_list(),
261+
items => ut_suite_items()
262+
)
263+
end;
264+
when 'UT_TEST' then
265+
l_result :=
266+
ut_test(
267+
self_type => a_rows(a_idx).self_type,
268+
object_owner => a_rows(a_idx).object_owner, object_name => lower(a_rows(a_idx).object_name),
269+
name => lower(a_rows(a_idx).name), description => a_rows(a_idx).description, path => a_rows(a_idx).path,
270+
rollback_type => a_rows(a_idx).rollback_type, disabled_flag => a_rows(a_idx).disabled_flag,
271+
line_no => a_rows(a_idx).line_no, parse_time => a_rows(a_idx).parse_time,
272+
start_time => null, end_time => null, result => null, warnings => a_rows(a_idx).warnings,
257273
results_count => ut_results_counter(), transaction_invalidators => ut_varchar2_list(),
258-
items => ut_suite_items()
259-
)
260-
end
261-
end;
274+
before_each_list => sort_by_seq_no(a_rows(a_idx).before_each_list), before_test_list => sort_by_seq_no(a_rows(a_idx).before_test_list),
275+
item => a_rows(a_idx).item,
276+
after_test_list => sort_by_seq_no(a_rows(a_idx).after_test_list), after_each_list => sort_by_seq_no(a_rows(a_idx).after_each_list),
277+
all_expectations => ut_expectation_results(), failed_expectations => ut_expectation_results(),
278+
parent_error_stack_trace => null, expected_error_codes => a_rows(a_idx).expected_error_codes
279+
);
280+
end case;
281+
l_result.results_count.warnings_count := l_result.warnings.count;
282+
return l_result;
262283
end;
263284

264285
procedure reconstruct_from_cache(
@@ -283,26 +304,8 @@ create or replace package body ut_suite_manager is
283304
l_items_at_level(l_level) := ut_suite_items();
284305
end if;
285306
l_items_at_level(l_level).extend;
286-
if l_rows(l_idx).self_type = 'UT_TEST' then
287-
l_items_at_level(l_level)(l_items_at_level(l_level).last) :=
288-
ut_test(
289-
self_type => l_rows(l_idx).self_type,
290-
object_owner => l_rows(l_idx).object_owner, object_name => lower(l_rows(l_idx).object_name),
291-
name => lower(l_rows(l_idx).name), description => l_rows(l_idx).description, path => l_rows(l_idx).path,
292-
rollback_type => l_rows(l_idx).rollback_type, disabled_flag => l_rows(l_idx).disabled_flag,
293-
line_no => l_rows(l_idx).line_no, parse_time => l_rows(l_idx).parse_time,
294-
start_time => null, end_time => null, result => null, warnings => l_rows(l_idx).warnings,
295-
results_count => ut_results_counter(), transaction_invalidators => ut_varchar2_list(),
296-
before_each_list => sort_by_seq_no(l_rows(l_idx).before_each_list), before_test_list => sort_by_seq_no(l_rows(l_idx).before_test_list),
297-
item => l_rows(l_idx).item,
298-
after_test_list => sort_by_seq_no(l_rows(l_idx).after_test_list), after_each_list => sort_by_seq_no(l_rows(l_idx).after_each_list),
299-
all_expectations => ut_expectation_results(), failed_expectations => ut_expectation_results(),
300-
parent_error_stack_trace => null, expected_error_codes => l_rows(l_idx).expected_error_codes
301-
);
302-
else
303-
pragma inline(get_logical_suite, 'YES');
304-
l_items_at_level(l_level)(l_items_at_level(l_level).last) := get_logical_suite(l_rows, l_idx, l_level,l_prev_level, l_items_at_level );
305-
end if;
307+
pragma inline(get_logical_suite, 'YES');
308+
l_items_at_level(l_level)(l_items_at_level(l_level).last) := get_logical_suite(l_rows, l_idx, l_level,l_prev_level, l_items_at_level );
306309
else
307310
a_suites.extend;
308311
pragma inline(get_logical_suite, 'YES');

test/api/test_ut_run.pkb

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,45 @@ Failures:%
806806
begin
807807
execute immediate 'drop package invalid_pckag_that_revalidates';
808808
execute immediate 'drop package parent_specs';
809-
end;
810-
809+
end;
810+
811+
procedure run_and_report_warnings is
812+
l_results ut3.ut_varchar2_list;
813+
l_actual clob;
814+
begin
815+
816+
select * bulk collect into l_results from table(ut3.ut.run('bad_annotations'));
817+
l_actual := ut3.ut_utils.table_to_clob(l_results);
818+
819+
ut.expect(l_actual).to_be_like('%Invalid annotation "--%context". Cannot find following "--%endcontext". Annotation ignored.%
820+
%1 tests, 0 failed, 0 errored, 0 disabled, 1 warning(s)%');
821+
822+
end;
823+
824+
procedure create_bad_annot is
825+
pragma autonomous_transaction;
826+
begin
827+
execute immediate q'[
828+
create or replace package bad_annotations as
829+
--%suite
830+
831+
--%context
832+
833+
--%test(invalidspecs)
834+
procedure test1;
835+
836+
end;]';
837+
838+
execute immediate q'[
839+
create or replace package body bad_annotations as
840+
procedure test1 is begin ut.expect(1).to_equal(1); end;
841+
end;]';
842+
843+
end;
844+
procedure drop_bad_annot is
845+
pragma autonomous_transaction;
846+
begin
847+
execute immediate 'drop package bad_annotations';
848+
end;
811849
end;
812850
/

test/api/test_ut_run.pks

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,12 @@ create or replace package test_ut_run is
114114
procedure generate_invalid_spec;
115115
procedure drop_invalid_spec;
116116

117+
--%test(Provides warnings on invalid annotations)
118+
--%beforetest(create_bad_annot)
119+
--%aftertest(drop_bad_annot)
120+
procedure run_and_report_warnings;
121+
procedure create_bad_annot;
122+
procedure drop_bad_annot;
117123
--%endcontext
118124

119125
end;

0 commit comments

Comments
 (0)