diff --git a/source/core/ut_annotations.pkb b/source/core/ut_annotations.pkb index c4fbf41dc..6f48ed5b6 100644 --- a/source/core/ut_annotations.pkb +++ b/source/core/ut_annotations.pkb @@ -48,6 +48,7 @@ create or replace package body ut_annotations as l_annotation_params_str varchar2(32767); l_annotation_name varchar2(1000); l_annotation_params tt_annotation_params; + l_annotation t_annotation; l_annotations_list tt_annotations; begin -- loop while there are unprocessed comment blocks @@ -102,8 +103,9 @@ create or replace package body ut_annotations as end; end loop; end if; - - l_annotations_list(l_annotation_name) := l_annotation_params; + l_annotation.text := l_annotation_params_str; + l_annotation.params := l_annotation_params; + l_annotations_list(l_annotation_name) := l_annotation; end if; l_loop_index := l_loop_index + 1; end loop; @@ -324,14 +326,14 @@ create or replace package body ut_annotations as end if; end; - function get_annotation_param(a_param_list tt_annotation_params, a_def_index pls_integer) return varchar2 is - l_result varchar2(32767); - begin - if a_param_list.exists(a_def_index) then - l_result := a_param_list(a_def_index).val; - end if; - return l_result; - end get_annotation_param; +-- function get_annotation_param(a_param_list tt_annotation_params, a_def_index pls_integer) return varchar2 is +-- l_result varchar2(32767); +-- begin +-- if a_param_list.exists(a_def_index) then +-- l_result := a_param_list(a_def_index).val; +-- end if; +-- return l_result; +-- end get_annotation_param; end ut_annotations; / diff --git a/source/core/ut_annotations.pks b/source/core/ut_annotations.pks index 133a8e5b4..e1f5764ac 100644 --- a/source/core/ut_annotations.pks +++ b/source/core/ut_annotations.pks @@ -46,11 +46,16 @@ create or replace package ut_annotations authid current_user as */ type tt_annotation_params is table of typ_annotation_param index by pls_integer; + type t_annotation is record( + text varchar2(4000), + params tt_annotation_params + ); + /* type: tt_annotations a list of tt_annotation_params index by the annotation name */ - type tt_annotations is table of tt_annotation_params index by t_annotation_name; + type tt_annotations is table of t_annotation index by t_annotation_name; /* type: tt_procedure_annotations @@ -87,7 +92,7 @@ create or replace package ut_annotations authid current_user as get annotation parameter on a specified index position */ - function get_annotation_param(a_param_list tt_annotation_params, a_def_index pls_integer) return varchar2; +-- function get_annotation_param(a_param_list tt_annotation_params, a_def_index pls_integer) return varchar2; end ut_annotations; / diff --git a/source/core/ut_suite_manager.pkb b/source/core/ut_suite_manager.pkb index 4e007817d..f97bde768 100644 --- a/source/core/ut_suite_manager.pkb +++ b/source/core/ut_suite_manager.pkb @@ -79,19 +79,17 @@ create or replace package body ut_suite_manager is if l_annotation_data.package_annotations.exists('suite') then if l_annotation_data.package_annotations.exists('displayname') then - l_suite_name := ut_annotations.get_annotation_param(l_annotation_data.package_annotations('displayname'), 1); - elsif l_annotation_data.package_annotations('suite').count>0 then - l_suite_name := ut_annotations.get_annotation_param(l_annotation_data.package_annotations('suite'), 1); + l_suite_name := l_annotation_data.package_annotations('displayname').text; + else + l_suite_name := l_annotation_data.package_annotations('suite').text; end if; if l_annotation_data.package_annotations.exists('suitepath') then - l_suite_path := ut_annotations.get_annotation_param(l_annotation_data.package_annotations('suitepath'), 1) || '.' || - lower(l_object_name); + l_suite_path := l_annotation_data.package_annotations('suitepath').text || '.' || lower(l_object_name); end if; if l_annotation_data.package_annotations.exists('rollback') then - l_suite_rollback_annotation := ut_annotations.get_annotation_param(l_annotation_data.package_annotations('rollback') - ,1); + l_suite_rollback_annotation := l_annotation_data.package_annotations('rollback').text; l_suite_rollback := case lower(l_suite_rollback_annotation) when 'manual' then ut_utils.gc_rollback_manual @@ -145,21 +143,21 @@ create or replace package body ut_suite_manager is l_displayname varchar2(4000); begin if l_proc_annotations.exists('beforetest') then - l_beforetest_procedure := ut_annotations.get_annotation_param(l_proc_annotations('beforetest'), 1); + l_beforetest_procedure := l_proc_annotations('beforetest').text; end if; if l_proc_annotations.exists('aftertest') then - l_aftertest_procedure := ut_annotations.get_annotation_param(l_proc_annotations('aftertest'), 1); + l_aftertest_procedure := l_proc_annotations('aftertest').text; end if; if l_proc_annotations.exists('displayname') then - l_displayname := ut_annotations.get_annotation_param(l_proc_annotations('displayname'), 1); - elsif l_proc_annotations('test').count > 0 then - l_displayname := ut_annotations.get_annotation_param(l_proc_annotations('test'), 1); + l_displayname := l_proc_annotations('displayname').text; + else + l_displayname := l_proc_annotations('test').text; end if; if l_proc_annotations.exists('rollback') then - l_rollback_annotation := ut_annotations.get_annotation_param(l_proc_annotations('rollback'), 1); + l_rollback_annotation := l_proc_annotations('rollback').text; l_rollback_type := case lower(l_rollback_annotation) when 'manual' then ut_utils.gc_rollback_manual diff --git a/tests/RunAll.sql b/tests/RunAll.sql index 734d7c2a5..0fac9d3ac 100644 --- a/tests/RunAll.sql +++ b/tests/RunAll.sql @@ -156,6 +156,7 @@ exec ut_coverage.coverage_start_develop(); @@lib/RunTest.sql ut/ut.run.WithSuitePath.ExecutesAllFromGivenPath.sql @@lib/RunTest.sql ut/ut.version.sql +@@lib/RunTest.sql ut_suite_manager/ut_suite_manager.AllowsDescriptionsWithComma.sql @@lib/RunTest.sql ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheSchema.sql @@lib/RunTest.sql ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageByPath.sql @@lib/RunTest.sql ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageByPathCurUser.sql diff --git a/tests/helpers/check_annotation_parsing.prc b/tests/helpers/check_annotation_parsing.prc index eb75c6996..d47e02f67 100644 --- a/tests/helpers/check_annotation_parsing.prc +++ b/tests/helpers/check_annotation_parsing.prc @@ -31,7 +31,7 @@ create or replace procedure check_annotation_parsing(a_expected ut_annotations.t ut.expect(a_actual.exists(l_ind),('['||a_msg||']Check annotation exists')).to_be_true; if a_actual.exists(l_ind) then - check_annotation_params(a_msg||'.'||l_ind,a_expected(l_ind),a_actual(l_ind)); + check_annotation_params(a_msg||'.'||l_ind,a_expected(l_ind).params,a_actual(l_ind).params); end if; l_ind := a_expected.next(l_ind); end loop; diff --git a/tests/ut_annotations/ut_annotations.parse_package_annotations.ParseAnnotationMixedWithWrongBeforeProcedure.sql b/tests/ut_annotations/ut_annotations.parse_package_annotations.ParseAnnotationMixedWithWrongBeforeProcedure.sql index 95a864c62..26dd340f9 100644 --- a/tests/ut_annotations/ut_annotations.parse_package_annotations.ParseAnnotationMixedWithWrongBeforeProcedure.sql +++ b/tests/ut_annotations/ut_annotations.parse_package_annotations.ParseAnnotationMixedWithWrongBeforeProcedure.sql @@ -25,17 +25,17 @@ END;'; --Assert l_ann_param := null; l_ann_param.val := 'Name of suite'; - l_expected.package_annotations('suite') := cast( null as ut_annotations.tt_annotation_params); - l_expected.package_annotations('displayname')(1) := l_ann_param; + l_expected.package_annotations('suite').params := cast( null as ut_annotations.tt_annotation_params); + l_expected.package_annotations('displayname').params(1) := l_ann_param; l_ann_param := null; l_ann_param.val := 'all.globaltests'; - l_expected.package_annotations('suitepath')(1) := l_ann_param; + l_expected.package_annotations('suitepath').params(1) := l_ann_param; l_ann_param := null; l_ann_param.val := 'some_value'; l_expected.procedure_annotations(1).name :='foo'; - l_expected.procedure_annotations(1).annotations('ann2')(1) := l_ann_param; + l_expected.procedure_annotations(1).annotations('ann2').params(1) := l_ann_param; check_annotation_parsing(l_expected, l_parsing_result); diff --git a/tests/ut_annotations/ut_annotations.parse_package_annotations.ParseAnnotationNotBeforeProcedure.sql b/tests/ut_annotations/ut_annotations.parse_package_annotations.ParseAnnotationNotBeforeProcedure.sql index 5f80c17fb..b7315726a 100644 --- a/tests/ut_annotations/ut_annotations.parse_package_annotations.ParseAnnotationNotBeforeProcedure.sql +++ b/tests/ut_annotations/ut_annotations.parse_package_annotations.ParseAnnotationNotBeforeProcedure.sql @@ -25,12 +25,12 @@ END;'; --Assert l_ann_param := null; l_ann_param.val := 'Name of suite'; - l_expected.package_annotations('suite') := cast( null as ut_annotations.tt_annotation_params); - l_expected.package_annotations('displayname')(1) := l_ann_param; + l_expected.package_annotations('suite').params := cast( null as ut_annotations.tt_annotation_params); + l_expected.package_annotations('displayname').params(1) := l_ann_param; l_ann_param := null; l_ann_param.val := 'all.globaltests'; - l_expected.package_annotations('suitepath')(1) := l_ann_param; + l_expected.package_annotations('suitepath').params(1) := l_ann_param; check_annotation_parsing(l_expected, l_parsing_result); diff --git a/tests/ut_annotations/ut_annotations.parse_package_annotations.ParseAnnotationParamsWithBrackets.sql b/tests/ut_annotations/ut_annotations.parse_package_annotations.ParseAnnotationParamsWithBrackets.sql index 8bd91642e..4a8f5cbef 100644 --- a/tests/ut_annotations/ut_annotations.parse_package_annotations.ParseAnnotationParamsWithBrackets.sql +++ b/tests/ut_annotations/ut_annotations.parse_package_annotations.ParseAnnotationParamsWithBrackets.sql @@ -17,7 +17,7 @@ END;'; --Assert l_ann_param.val := 'Name of suite (including some brackets) and some more text'; - l_expected.package_annotations('suite')(1) := l_ann_param; + l_expected.package_annotations('suite').params(1) := l_ann_param; check_annotation_parsing(l_expected, l_parsing_result); diff --git a/tests/ut_annotations/ut_annotations.parse_package_annotations.ParseComplexPackage.sql b/tests/ut_annotations/ut_annotations.parse_package_annotations.ParseComplexPackage.sql index eac0dcec7..2854e5337 100644 --- a/tests/ut_annotations/ut_annotations.parse_package_annotations.ParseComplexPackage.sql +++ b/tests/ut_annotations/ut_annotations.parse_package_annotations.ParseComplexPackage.sql @@ -40,18 +40,18 @@ END;'; --Assert l_ann_param := null; l_ann_param.val := 'Name of suite'; - l_expected.package_annotations('suite') := cast( null as ut_annotations.tt_annotation_params); - l_expected.package_annotations('displayname')(1) := l_ann_param; + l_expected.package_annotations('suite').params := cast( null as ut_annotations.tt_annotation_params); + l_expected.package_annotations('displayname').params(1) := l_ann_param; l_ann_param := null; l_ann_param.val := 'all.globaltests'; - l_expected.package_annotations('suitepath')(1) := l_ann_param; + l_expected.package_annotations('suitepath').params(1) := l_ann_param; l_expected.procedure_annotations(1).name := 'foo'; - l_expected.procedure_annotations(1).annotations('test') := cast( null as ut_annotations.tt_annotation_params); + l_expected.procedure_annotations(1).annotations('test').params := cast( null as ut_annotations.tt_annotation_params); l_expected.procedure_annotations(2).name := 'foo2'; - l_expected.procedure_annotations(2).annotations('beforeeach') := cast( null as ut_annotations.tt_annotation_params); + l_expected.procedure_annotations(2).annotations('beforeeach').params := cast( null as ut_annotations.tt_annotation_params); l_ann_param := null; l_ann_param.key := 'key'; diff --git a/tests/ut_annotations/ut_annotations.parse_package_annotations.ParsePackageAndProcedureLevelAnnotations.sql b/tests/ut_annotations/ut_annotations.parse_package_annotations.ParsePackageAndProcedureLevelAnnotations.sql index 885a99bc4..a418629e1 100644 --- a/tests/ut_annotations/ut_annotations.parse_package_annotations.ParsePackageAndProcedureLevelAnnotations.sql +++ b/tests/ut_annotations/ut_annotations.parse_package_annotations.ParsePackageAndProcedureLevelAnnotations.sql @@ -23,15 +23,15 @@ END;'; --Assert l_ann_param := null; l_ann_param.val := 'Name of suite'; - l_expected.package_annotations('suite') := cast( null as ut_annotations.tt_annotation_params); - l_expected.package_annotations('displayname')(1) := l_ann_param; + l_expected.package_annotations('suite').params := cast( null as ut_annotations.tt_annotation_params); + l_expected.package_annotations('displayname').params(1) := l_ann_param; l_ann_param := null; l_ann_param.val := 'all.globaltests'; - l_expected.package_annotations('suitepath')(1) := l_ann_param; + l_expected.package_annotations('suitepath').params(1) := l_ann_param; l_expected.procedure_annotations(1).name := 'foo'; - l_expected.procedure_annotations(1).annotations('test') := cast( null as ut_annotations.tt_annotation_params); + l_expected.procedure_annotations(1).annotations('test').params := cast( null as ut_annotations.tt_annotation_params); check_annotation_parsing(l_expected, l_parsing_result); diff --git a/tests/ut_annotations/ut_annotations.parse_package_annotations.ParsePackageLevelAnnotation.sql b/tests/ut_annotations/ut_annotations.parse_package_annotations.ParsePackageLevelAnnotation.sql index facad5832..49d1c6e68 100644 --- a/tests/ut_annotations/ut_annotations.parse_package_annotations.ParsePackageLevelAnnotation.sql +++ b/tests/ut_annotations/ut_annotations.parse_package_annotations.ParsePackageLevelAnnotation.sql @@ -22,12 +22,12 @@ END;'; --Assert l_ann_param := null; l_ann_param.val := 'Name of suite'; - l_expected.package_annotations('suite') := cast( null as ut_annotations.tt_annotation_params); - l_expected.package_annotations('displayname')(1) := l_ann_param; + l_expected.package_annotations('suite').params := cast( null as ut_annotations.tt_annotation_params); + l_expected.package_annotations('displayname').params(1) := l_ann_param; l_ann_param := null; l_ann_param.val := 'all.globaltests'; - l_expected.package_annotations('suitepath')(1) := l_ann_param; + l_expected.package_annotations('suitepath').params(1) := l_ann_param; check_annotation_parsing(l_expected, l_parsing_result); diff --git a/tests/ut_annotations/ut_annotations.parse_package_annotations.ParsePackageLevelAnnotationAccessibleBy.sql b/tests/ut_annotations/ut_annotations.parse_package_annotations.ParsePackageLevelAnnotationAccessibleBy.sql index f78f73baf..282a7d313 100644 --- a/tests/ut_annotations/ut_annotations.parse_package_annotations.ParsePackageLevelAnnotationAccessibleBy.sql +++ b/tests/ut_annotations/ut_annotations.parse_package_annotations.ParsePackageLevelAnnotationAccessibleBy.sql @@ -22,12 +22,12 @@ END;'; --Assert l_ann_param := null; l_ann_param.val := 'Name of suite'; - l_expected.package_annotations('suite') := cast( null as ut_annotations.tt_annotation_params); - l_expected.package_annotations('displayname')(1) := l_ann_param; + l_expected.package_annotations('suite').params := cast( null as ut_annotations.tt_annotation_params); + l_expected.package_annotations('displayname').params(1) := l_ann_param; l_ann_param := null; l_ann_param.val := 'all.globaltests'; - l_expected.package_annotations('suitepath')(1) := l_ann_param; + l_expected.package_annotations('suitepath').params(1) := l_ann_param; check_annotation_parsing(l_expected, l_parsing_result); diff --git a/tests/ut_annotations/ut_annotations.parse_package_annotations.ParsePackageLevelAnnotationMultilineDeclare.sql b/tests/ut_annotations/ut_annotations.parse_package_annotations.ParsePackageLevelAnnotationMultilineDeclare.sql index 8525af5f6..6b735a618 100644 --- a/tests/ut_annotations/ut_annotations.parse_package_annotations.ParsePackageLevelAnnotationMultilineDeclare.sql +++ b/tests/ut_annotations/ut_annotations.parse_package_annotations.ParsePackageLevelAnnotationMultilineDeclare.sql @@ -25,12 +25,12 @@ END;'; --Assert l_ann_param := null; l_ann_param.val := 'Name of suite'; - l_expected.package_annotations('suite') := cast( null as ut_annotations.tt_annotation_params); - l_expected.package_annotations('displayname')(1) := l_ann_param; + l_expected.package_annotations('suite').params := cast( null as ut_annotations.tt_annotation_params); + l_expected.package_annotations('displayname').params(1) := l_ann_param; l_ann_param := null; l_ann_param.val := 'all.globaltests'; - l_expected.package_annotations('suitepath')(1) := l_ann_param; + l_expected.package_annotations('suitepath').params(1) := l_ann_param; check_annotation_parsing(l_expected, l_parsing_result); diff --git a/tests/ut_annotations/ut_annotations.parse_package_annotations.ParsePackageLevelAnnotationWithKeyValue.sql b/tests/ut_annotations/ut_annotations.parse_package_annotations.ParsePackageLevelAnnotationWithKeyValue.sql index 4ab405e77..d87a504d7 100644 --- a/tests/ut_annotations/ut_annotations.parse_package_annotations.ParsePackageLevelAnnotationWithKeyValue.sql +++ b/tests/ut_annotations/ut_annotations.parse_package_annotations.ParsePackageLevelAnnotationWithKeyValue.sql @@ -23,18 +23,18 @@ END;'; l_ann_param := null; l_ann_param.key := 'name'; l_ann_param.val := 'Name of suite'; - l_expected.package_annotations('suite') := cast( null as ut_annotations.tt_annotation_params); - l_expected.package_annotations('displayname')(1) := l_ann_param; + l_expected.package_annotations('suite').params := cast( null as ut_annotations.tt_annotation_params); + l_expected.package_annotations('displayname').params(1) := l_ann_param; l_ann_param := null; l_ann_param.key := 'key'; l_ann_param.val := 'all.globaltests'; - l_expected.package_annotations('suitepath')(1) := l_ann_param; + l_expected.package_annotations('suitepath').params(1) := l_ann_param; l_ann_param := null; l_ann_param.key := 'key2'; l_ann_param.val := 'foo'; - l_expected.package_annotations('suitepath')(2) := l_ann_param; + l_expected.package_annotations('suitepath').params(2) := l_ann_param; check_annotation_parsing(l_expected, l_parsing_result); diff --git a/tests/ut_annotations/ut_annotations.parse_package_annotations.ParsePackageLevelAnnotationWithMultilineComment.sql b/tests/ut_annotations/ut_annotations.parse_package_annotations.ParsePackageLevelAnnotationWithMultilineComment.sql index 74e750455..7173cac3f 100644 --- a/tests/ut_annotations/ut_annotations.parse_package_annotations.ParsePackageLevelAnnotationWithMultilineComment.sql +++ b/tests/ut_annotations/ut_annotations.parse_package_annotations.ParsePackageLevelAnnotationWithMultilineComment.sql @@ -26,12 +26,12 @@ END;'; --Assert l_ann_param := null; l_ann_param.val := 'Name of suite'; - l_expected.package_annotations('suite') := cast( null as ut_annotations.tt_annotation_params); - l_expected.package_annotations('displayname')(1) := l_ann_param; + l_expected.package_annotations('suite').params := cast( null as ut_annotations.tt_annotation_params); + l_expected.package_annotations('displayname').params(1) := l_ann_param; l_ann_param := null; l_ann_param.val := 'all.globaltests'; - l_expected.package_annotations('suitepath')(1) := l_ann_param; + l_expected.package_annotations('suitepath').params(1) := l_ann_param; check_annotation_parsing(l_expected, l_parsing_result); diff --git a/tests/ut_suite_manager/ut_suite_manager.AllowsDescriptionsWithComma.sql b/tests/ut_suite_manager/ut_suite_manager.AllowsDescriptionsWithComma.sql new file mode 100644 index 000000000..3ee8321a0 --- /dev/null +++ b/tests/ut_suite_manager/ut_suite_manager.AllowsDescriptionsWithComma.sql @@ -0,0 +1,62 @@ +set termout off +create or replace package tst_package_to_be_dropped as + --%suite(A suite description, though with comma, is assigned by suite_manager) + + --%test(A test description, though with comma, is assigned by suite_manager) + procedure test1; + + --%test + --%displayname(A test description, though with comma, is assigned by suite_manager) + procedure test2; +end; +/ + +create or replace package body tst_package_to_be_dropped as + procedure test1 is begin ut.expect(1).to_equal(1); end; + procedure test2 is begin ut.expect(1).to_equal(1); end; +end; +/ + +set termout on + +set termout on + +declare + l_objects_to_run ut_suite_items; + l_suite ut_suite; + l_test ut_test; + l_results ut_expectation_results; +begin + l_objects_to_run := ut_suite_manager.configure_execution_by_path(ut_varchar2_list('tst_package_to_be_dropped')); + + --Assert + ut.expect(l_objects_to_run.count).to_equal(1); + + l_suite := treat(l_objects_to_run(1) as ut_suite); + + ut.expect(l_suite.name).to_equal('tst_package_to_be_dropped'); + ut.expect(l_suite.description).to_equal('A suite description, though with comma, is assigned by suite_manager'); + ut.expect(l_suite.items.count).to_equal(2); + + l_test := treat(l_suite.items(1) as ut_test); + + ut.expect(l_test.name).to_equal('test1'); + ut.expect(l_test.description).to_equal('A test description, though with comma, is assigned by suite_manager'); + + l_test := treat(l_suite.items(2) as ut_test); + + ut.expect(l_test.name).to_equal('test2'); + ut.expect(l_test.description).to_equal('A test description, though with comma, is assigned by suite_manager'); + + + l_results := ut_expectation_processor.get_expectations_results(); + + :test_result := ut_utils.tr_success; + for i in 1 .. l_results.count loop + :test_result := greatest(:test_result, l_results(i).status); + if l_results(i).status != ut_utils.tr_success then + dbms_output.put_line(l_results(i).get_result_clob); + end if; + end loop; +end; +/