Skip to content

Commit d00a0f7

Browse files
committed
Updates to PR.
Switch to common add tags to suite item
1 parent b636830 commit d00a0f7

File tree

9 files changed

+42
-113
lines changed

9 files changed

+42
-113
lines changed

docs/userguide/annotations.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1250,40 +1250,40 @@ When a suite gets tagged all of its children will automatically inherit a tag an
12501250
Sample tag package.
12511251

12521252
```sql
1253-
create or replace PACKAGE ut_sample_test IS
1253+
create or replace package ut_sample_test IS
12541254

12551255
--%suite(Sample Test Suite)
12561256
--%tag(suite1)
12571257

12581258
--%test(Compare Ref Cursors)
12591259
--%tag(test1,sample)
1260-
PROCEDURE ut_refcursors1;
1260+
procedure ut_refcursors1;
12611261

12621262
--%test(Run equality test)
12631263
--%tag(test2,sample)
1264-
PROCEDURE ut_test;
1264+
procedure ut_test;
12651265

1266-
END ut_sample_test;
1266+
end ut_sample_test;
12671267
/
12681268

1269-
create or replace PACKAGE BODY ut_sample_test IS
1269+
create or replace package body ut_sample_test is
12701270

1271-
PROCEDURE ut_refcursors1 IS
1272-
v_actual SYS_REFCURSOR;
1273-
v_expected SYS_REFCURSOR;
1274-
BEGIN
1271+
procedure ut_refcursors1 is
1272+
v_actual sys_refcursor;
1273+
v_expected sys_refcursor;
1274+
begin
12751275
open v_expected for select 1 as test from dual;
12761276
open v_actual for select 2 as test from dual;
12771277

12781278
ut.expect(v_actual).to_equal(v_expected);
1279-
END;
1279+
end;
12801280

1281-
PROCEDURE ut_test IS
1282-
BEGIN
1281+
procedure ut_test is
1282+
begin
12831283
ut.expect(1).to_equal(0);
1284-
END;
1284+
end;
12851285

1286-
END ut_sample_test;
1286+
end ut_sample_test;
12871287
/
12881288
```
12891289

source/api/ut_runner.pkb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ create or replace package body ut_runner is
143143

144144
if a_tags is not null then
145145
l_tags := l_tags multiset union distinct ut_utils.convert_collection(
146-
ut_utils.filter_list(ut_utils.string_to_table(a_tags,','),'^(\w|\S)+$')
146+
ut_utils.trim_list_elements(ut_utils.filter_list(ut_utils.string_to_table(a_tags,','),ut_utils.gc_word_no_space))
147147
);
148148
end if;
149149
l_exclude_object_names := l_exclude_object_names multiset union all ut_suite_manager.get_schema_ut_packages(l_coverage_schema_names);

source/core/ut_suite_builder.pkb

Lines changed: 10 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,6 @@ create or replace package body ut_suite_builder is
1515
See the License for the specific language governing permissions and
1616
limitations under the License.
1717
*/
18-
19-
/**
20-
* Regexp to validate tag
21-
*/
22-
gc_word_no_space constant varchar2(50) := '^(\w|\S)+$';
2318

2419
subtype t_annotation_text is varchar2(4000);
2520
subtype t_annotation_name is varchar2(4000);
@@ -311,13 +306,13 @@ create or replace package body ut_suite_builder is
311306
l_annotation_pos := a_throws_ann_text.next(l_annotation_pos);
312307
end loop;
313308
end;
314-
315-
procedure add_tags_to_test(
309+
310+
procedure add_tags_to_suite_item(
316311
a_suite in out nocopy ut_suite,
312+
a_tags_ann_text tt_annotation_texts,
317313
a_list in out nocopy ut_varchar2_rows,
318-
a_procedure_name t_object_name,
319-
a_tags_ann_text tt_annotation_texts
320-
) is
314+
a_procedure_name t_object_name := null
315+
) is
321316
l_annotation_pos binary_integer;
322317
l_tag_list ut_varchar2_list := ut_varchar2_list();
323318
begin
@@ -333,14 +328,12 @@ create or replace package body ut_suite_builder is
333328
ut_utils.string_to_table(a_tags_ann_text(l_annotation_pos),',')
334329
);
335330
end if;
336-
--remove empty strings from table list e.g. tag1,,tag2 and conver to rows
337-
a_list := ut_utils.convert_collection( ut_utils.filter_list(l_tag_list,gc_word_no_space) );
338331
l_annotation_pos := a_tags_ann_text.next(l_annotation_pos);
339332
end loop;
340-
333+
--remove empty strings from table list e.g. tag1,,tag2 and conver to rows
334+
a_list := ut_utils.convert_collection( ut_utils.filter_list(l_tag_list,ut_utils.gc_word_no_space) );
341335
end;
342-
343-
336+
344337
procedure set_seq_no(
345338
a_list in out nocopy ut_executables
346339
) is
@@ -521,7 +514,7 @@ create or replace package body ut_suite_builder is
521514
end if;
522515

523516
if l_proc_annotations.exists( gc_tag) then
524-
add_tags_to_test(a_suite, l_test.tags, a_procedure_name, l_proc_annotations( gc_tag));
517+
add_tags_to_suite_item(a_suite, l_proc_annotations( gc_tag), l_test.tags, a_procedure_name);
525518
end if;
526519

527520
if l_proc_annotations.exists( gc_throws) then
@@ -625,30 +618,6 @@ create or replace package body ut_suite_builder is
625618
a_suite.path := lower(coalesce(a_suite.path, a_suite.object_name));
626619
end;
627620

628-
procedure add_tags_to_suite(
629-
a_suite in out nocopy ut_suite,
630-
a_tags_ann_text tt_annotation_texts
631-
) is
632-
l_annotation_pos binary_integer;
633-
l_tag_list ut_varchar2_list := ut_varchar2_list();
634-
begin
635-
l_annotation_pos := a_tags_ann_text.first;
636-
while l_annotation_pos is not null loop
637-
if a_tags_ann_text(l_annotation_pos) is null then
638-
a_suite.put_warning(
639-
'"--%tags" annotation requires a tag value populated. Annotation ignored, line ' || l_annotation_pos
640-
);
641-
else
642-
l_tag_list := l_tag_list multiset union distinct ut_utils.trim_list_elements(
643-
ut_utils.string_to_table(a_tags_ann_text(l_annotation_pos),',')
644-
);
645-
end if;
646-
l_annotation_pos := a_tags_ann_text.next(l_annotation_pos);
647-
end loop;
648-
--remove empty strings from table list e.g. tag1,,tag2
649-
a_suite.tags := ut_utils.convert_collection(ut_utils.filter_list(l_tag_list,gc_word_no_space));
650-
end;
651-
652621
procedure add_suite_tests(
653622
a_suite in out nocopy ut_suite,
654623
a_annotations t_annotations_info,
@@ -699,7 +668,7 @@ create or replace package body ut_suite_builder is
699668
end if;
700669

701670
if a_annotations.by_name.exists(gc_tag) then
702-
add_tags_to_suite(a_suite, a_annotations.by_name(gc_tag));
671+
add_tags_to_suite_item(a_suite, a_annotations.by_name(gc_tag),a_suite.tags);
703672
end if;
704673
a_suite.disabled_flag := ut_utils.boolean_to_int(a_annotations.by_name.exists(gc_disabled));
705674

source/core/ut_suite_manager.pkb

Lines changed: 8 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ create or replace package body ut_suite_manager is
1717
*/
1818

1919
gc_suitpath_error_message constant varchar2(100) := 'Suitepath exceeds 1000 CHAR on: ';
20-
gc_tag_errmsg constant number := 450;
20+
gc_tag_errmsg constant integer := 450;
2121

2222
type t_path_item is record (
2323
object_name varchar2(250),
@@ -687,35 +687,6 @@ create or replace package body ut_suite_manager is
687687
return l_suites;
688688
end;
689689

690-
function build_no_test_error_msg(
691-
a_schema_name in varchar2,
692-
a_suite_path in varchar2,
693-
a_procedure_name in varchar2,
694-
a_object_name in varchar2,
695-
a_tags in ut_varchar2_rows := ut_varchar2_rows()
696-
) return varchar2 is
697-
l_error_msg varchar2(500);
698-
l_tags clob:= ut_utils.table_to_clob(coalesce(a_tags,ut_varchar2_rows()),',');
699-
begin
700-
if a_suite_path is not null then
701-
l_error_msg := 'No suite packages found for path '||a_schema_name||':'||a_suite_path;
702-
elsif a_procedure_name is not null then
703-
l_error_msg := 'Suite test '||a_schema_name||'.'||a_object_name|| '.'||a_procedure_name||' does not exists';
704-
elsif a_object_name is not null then
705-
l_error_msg := 'Suite package '||a_schema_name||'.'||a_object_name|| ' does not exists';
706-
end if;
707-
708-
if l_error_msg is null and a_tags.count > 0 then
709-
l_error_msg := 'No tests found for tags: '||ut_utils.to_string(l_tags,a_max_output_len => gc_tag_errmsg);
710-
elsif l_error_msg is not null and a_tags.count > 0 then
711-
l_error_msg := l_error_msg||' with tags: '||ut_utils.to_string(l_tags,a_max_output_len => gc_tag_errmsg);
712-
end if;
713-
714-
l_error_msg := l_error_msg ||'.';
715-
716-
return l_error_msg;
717-
end;
718-
719690
procedure configure_execution_by_path(
720691
a_paths in ut_varchar2_list,
721692
a_suites out nocopy ut_suite_items,
@@ -751,9 +722,13 @@ create or replace package body ut_suite_manager is
751722
a_tags
752723
);
753724
if a_suites.count = l_suites_count then
754-
raise_application_error(ut_utils.gc_suite_package_not_found,build_no_test_error_msg(
755-
l_schema,l_path_item.suite_path,l_path_item.procedure_name,
756-
l_path_item.object_name,a_tags));
725+
if l_path_item.suite_path is not null then
726+
raise_application_error(ut_utils.gc_suite_package_not_found,'No suite packages found for path '||l_schema||':'||l_path_item.suite_path|| '.');
727+
elsif l_path_item.procedure_name is not null then
728+
raise_application_error(ut_utils.gc_suite_package_not_found,'Suite test '||l_schema||'.'||l_path_item.object_name|| '.'||l_path_item.procedure_name||' does not exist');
729+
elsif l_path_item.object_name is not null then
730+
raise_application_error(ut_utils.gc_suite_package_not_found,'Suite package '||l_schema||'.'||l_path_item.object_name|| ' does not exist');
731+
end if;
757732
end if;
758733
l_index := a_suites.first;
759734
l_suites_count := a_suites.count;

source/core/ut_utils.pks

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,11 @@ create or replace package ut_utils authid definer is
131131
gc_bc_fetch_limit constant integer := 1000;
132132
gc_diff_max_rows constant integer := 20;
133133

134+
/**
135+
* Regexp to validate tag
136+
*/
137+
gc_word_no_space constant varchar2(50) := '^(\w|\S)+$';
138+
134139
type t_version is record(
135140
major natural,
136141
minor natural,

test/ut3_tester/core/test_suite_builder.pkb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1296,7 +1296,7 @@ create or replace package body test_suite_builder is
12961296
l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE');
12971297
--Assert
12981298
ut.expect(l_actual).to_be_like(
1299-
'%<WARNINGS><VARCHAR2>&quot;--%tags&quot; annotation requires a tag value populated. Annotation ignored, line 3</VARCHAR2></WARNINGS>%'||
1299+
'%<WARNINGS><VARCHAR2>&quot;--%tags&quot; annotation requires a tag value populated. Annotation ignored.%</VARCHAR2></WARNINGS>%'||
13001300
'%<TAGS/>%'
13011301
);
13021302

test/ut3_user/api/test_ut_run.pkb

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -875,14 +875,11 @@ Failures:%
875875
l_results clob;
876876
l_exp_message varchar2(4000);
877877
begin
878-
l_exp_message :=q'[ORA-20204: No tests found for tags: 'nonexisting'.]';
879878
ut3_tester_helper.run_helper.run(a_tags => 'nonexisting');
880879
l_results := ut3_tester_helper.main_helper.get_dbms_output_as_clob();
881-
ut.fail('Expecte test to fail');
882-
--Assert
883-
exception
884-
when others then
885-
ut.expect( sqlerrm ).to_be_like( l_exp_message );
880+
ut.expect( l_results ).not_to_be_like( '%test_package_1%' );
881+
ut.expect( l_results ).not_to_be_like( '%test_package_2%' );
882+
ut.expect( l_results ).not_to_be_like( '%test_package_3%' );
886883
end;
887884

888885
procedure test_duplicate_tag is
@@ -906,19 +903,6 @@ Failures:%
906903
ut.expect( l_results ).to_be_like( '%test_package_2%' );
907904
ut.expect( l_results ).not_to_be_like( '%test_package_3%' );
908905
end;
909-
910-
procedure run_proc_pkg_name_no_tag is
911-
l_results clob;
912-
l_exp_message varchar2(4000);
913-
begin
914-
l_exp_message :=q'[ORA-20204: Suite package ut3_tester_helper.test_package_1 does not exists with tags: 'nonexists'.]';
915-
ut3.ut.run('ut3_tester_helper.test_package_1',a_tags => 'nonexists');
916-
l_results := ut3_tester_helper.main_helper.get_dbms_output_as_clob();
917-
ut.fail('Expecte test to fail');
918-
exception
919-
when others then
920-
ut.expect( sqlerrm ).to_be_like( l_exp_message );
921-
end;
922906

923907
procedure run_proc_pkg_name_tag is
924908
l_results clob;

test/ut3_user/api/test_ut_run.pks

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,6 @@ create or replace package test_ut_run is
198198
--%test(Execute suite test for duplicate list tags)
199199
procedure suite_duplicate_tag;
200200

201-
--%test(Run a package by name with non existing tag)
202-
procedure run_proc_pkg_name_no_tag;
203-
204201
--%test(Runs given package only with package name given as path and filter by tag)
205202
procedure run_proc_pkg_name_tag;
206203

test/ut3_user/api/test_ut_runner.pkb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,6 @@ end;';
270270
ut.expect(l_actual).to_equal(l_expected);
271271
end;
272272

273-
--TODO : Apostro?????
274273
procedure test_get_suites_info_tag is
275274
l_expected sys_refcursor;
276275
l_actual sys_refcursor;

0 commit comments

Comments
 (0)