From 64cab8e655bda967563059658ef5e4bccd1cd782 Mon Sep 17 00:00:00 2001 From: Pazus Date: Wed, 28 Jun 2017 08:55:05 +0300 Subject: [PATCH 1/3] fix error with space before annotation params --- source/core/ut_annotations.pkb | 2 +- source/core/ut_suite_manager.pkb | 2 +- tests/RunAll.sql | 2 + ...nnotations.spaceBeforeAnnotationParams.sql | 39 +++++++++++++++++++ .../ut_suite_manager.emptySuitePath.sql | 33 ++++++++++++++++ 5 files changed, 76 insertions(+), 2 deletions(-) create mode 100644 tests/ut_annotations/ut_annotations.parse_package_annotations.spaceBeforeAnnotationParams.sql create mode 100644 tests/ut_suite_manager/ut_suite_manager.emptySuitePath.sql diff --git a/source/core/ut_annotations.pkb b/source/core/ut_annotations.pkb index 6f48ed5b6..8be529d56 100644 --- a/source/core/ut_annotations.pkb +++ b/source/core/ut_annotations.pkb @@ -30,7 +30,7 @@ create or replace package body ut_annotations as c_rgexp_identifier constant varchar2(50) := '[a-z][a-z0-9#_$]*'; c_annotation_block_pattern constant varchar2(200) := '(({COMMENT#.+}'||chr(10)||')+)( |'||chr(09)||')*(procedure|function)\s+(' || c_rgexp_identifier || ')'; - c_annotation_pattern constant varchar2(50) := gc_annotation_qualifier || c_rgexp_identifier || '(\(.*?\)$)?'; + c_annotation_pattern constant varchar2(50) := gc_annotation_qualifier || c_rgexp_identifier || '[ '||chr(9)||']*(\(.*?\)$)?'; function delete_multiline_comments(a_source in clob) return clob is diff --git a/source/core/ut_suite_manager.pkb b/source/core/ut_suite_manager.pkb index f97bde768..7534c0a86 100644 --- a/source/core/ut_suite_manager.pkb +++ b/source/core/ut_suite_manager.pkb @@ -84,7 +84,7 @@ create or replace package body ut_suite_manager is l_suite_name := l_annotation_data.package_annotations('suite').text; end if; - if l_annotation_data.package_annotations.exists('suitepath') then + if l_annotation_data.package_annotations.exists('suitepath') and trim(l_annotation_data.package_annotations('suitepath').text) is not null then l_suite_path := l_annotation_data.package_annotations('suitepath').text || '.' || lower(l_object_name); end if; diff --git a/tests/RunAll.sql b/tests/RunAll.sql index 1aa98db16..e1ad8b728 100644 --- a/tests/RunAll.sql +++ b/tests/RunAll.sql @@ -44,6 +44,7 @@ exec ut_coverage.coverage_start_develop(); @@lib/RunTest.sql ut_annotations/ut_annotations.parse_package_annotations.ParsePackageLevelAnnotationMultilineDeclare.sql @@lib/RunTest.sql ut_annotations/ut_annotations.parse_package_annotations.ParsePackageLevelAnnotationWithKeyValue.sql @@lib/RunTest.sql ut_annotations/ut_annotations.parse_package_annotations.ParsePackageLevelAnnotationWithMultilineComment.sql +@@lib/RunTest.sql ut_annotations/ut_annotations.parse_package_annotations.spaceBeforeAnnotationParams.sql @@ut_expectations/ut.expect.not_to_be_null.sql @@lib/RunTest.sql ut_expectations/ut.expect.to_be_false.GivesFailureWhenExpessionIsNotBoolean.sql @@lib/RunTest.sql ut_expectations/ut.expect.to_be_false.GivesFailureWhenExpessionIsNull.sql @@ -183,6 +184,7 @@ exec ut_coverage.coverage_start_develop(); @@lib/RunTest.sql ut_suite_manager/ut_suite_manager.TestWithDollarSign.sql @@lib/RunTest.sql ut_suite_manager/ut_suite_manager.PackageWithHash.sql @@lib/RunTest.sql ut_suite_manager/ut_suite_manager.TestWithHashSign.sql +@@lib/RunTest.sql ut_suite_manager/ut_suite_manager.emptySuitePath.sql @@lib/RunTest.sql ut_test/ut_test.DisabledFlagSkipTest.sql diff --git a/tests/ut_annotations/ut_annotations.parse_package_annotations.spaceBeforeAnnotationParams.sql b/tests/ut_annotations/ut_annotations.parse_package_annotations.spaceBeforeAnnotationParams.sql new file mode 100644 index 000000000..3e87df527 --- /dev/null +++ b/tests/ut_annotations/ut_annotations.parse_package_annotations.spaceBeforeAnnotationParams.sql @@ -0,0 +1,39 @@ +--Arrange +declare + l_source clob; + l_parsing_result ut_annotations.typ_annotated_package; + l_expected ut_annotations.typ_annotated_package; + l_ann_param ut_annotations.typ_annotation_param; + +begin + l_source := 'PACKAGE test_tt AS + /* + Some comment + -- inlined + */ + -- %suite + -- %suitepath (all.globaltests) + + procedure foo; +END;'; + +--Act + l_parsing_result := ut_annotations.parse_package_annotations(l_source); + +--Assert + l_ann_param := null; + l_ann_param.val := 'Name of suite'; + l_expected.package_annotations('suite').params := cast( null as ut_annotations.tt_annotation_params); + + l_ann_param := null; + l_ann_param.val := 'all.globaltests'; + l_expected.package_annotations('suitepath').params(1) := l_ann_param; + + check_annotation_parsing(l_expected, l_parsing_result); + + if ut_expectation_processor.get_status = ut_utils.tr_success then + :test_result := ut_utils.tr_success; + end if; + +end; +/ diff --git a/tests/ut_suite_manager/ut_suite_manager.emptySuitePath.sql b/tests/ut_suite_manager/ut_suite_manager.emptySuitePath.sql new file mode 100644 index 000000000..4b9cd35f2 --- /dev/null +++ b/tests/ut_suite_manager/ut_suite_manager.emptySuitePath.sql @@ -0,0 +1,33 @@ +set termout off +create or replace package tst_empty_suite_path as + --%suite + --%suitepath + + --%test + procedure test#1; +end; +/ + +create or replace package body tst_empty_suite_path as + procedure test#1 is begin ut.expect(1).to_equal(1); end; +end; +/ + +set termout on + +declare + l_objects_to_run ut_suite_items; +begin + + --act + l_objects_to_run := ut_suite_manager.configure_execution_by_path(ut_varchar2_list('tst_empty_suite_path')); + + if ut_expectation_processor.get_status = ut_utils.tr_success then + :test_result := ut_utils.tr_success; + end if; + +end; +/ + +drop package tst_empty_suite_path +/ From f2ca323ad13c530df22e7410e4beaff3e68ec7b5 Mon Sep 17 00:00:00 2001 From: Pazus Date: Sat, 1 Jul 2017 22:20:33 +0300 Subject: [PATCH 2/3] addressed comments fixed additional recent tests --- source/core/ut_suite_manager.pkb | 2 +- ...ge_annotations.spaceBeforeAnnotationParams.sql | 2 -- .../ut_suite_manager.PackageWithDollarSign.sql | 7 +++++++ .../ut_suite_manager.PackageWithHash.sql | 7 +++++++ .../ut_suite_manager.TestWithDollarSign.sql | 15 ++++++++++++++- .../ut_suite_manager.TestWithHashSign.sql | 15 ++++++++++++++- .../ut_suite_manager.emptySuitePath.sql | 12 ++++++++++-- 7 files changed, 53 insertions(+), 7 deletions(-) diff --git a/source/core/ut_suite_manager.pkb b/source/core/ut_suite_manager.pkb index 7534c0a86..ec70af29e 100644 --- a/source/core/ut_suite_manager.pkb +++ b/source/core/ut_suite_manager.pkb @@ -84,7 +84,7 @@ create or replace package body ut_suite_manager is l_suite_name := l_annotation_data.package_annotations('suite').text; end if; - if l_annotation_data.package_annotations.exists('suitepath') and trim(l_annotation_data.package_annotations('suitepath').text) is not null then + if l_annotation_data.package_annotations.exists('suitepath') and l_annotation_data.package_annotations('suitepath').text is not null then l_suite_path := l_annotation_data.package_annotations('suitepath').text || '.' || lower(l_object_name); end if; diff --git a/tests/ut_annotations/ut_annotations.parse_package_annotations.spaceBeforeAnnotationParams.sql b/tests/ut_annotations/ut_annotations.parse_package_annotations.spaceBeforeAnnotationParams.sql index 3e87df527..0b2c423bf 100644 --- a/tests/ut_annotations/ut_annotations.parse_package_annotations.spaceBeforeAnnotationParams.sql +++ b/tests/ut_annotations/ut_annotations.parse_package_annotations.spaceBeforeAnnotationParams.sql @@ -21,8 +21,6 @@ END;'; l_parsing_result := ut_annotations.parse_package_annotations(l_source); --Assert - l_ann_param := null; - l_ann_param.val := 'Name of suite'; l_expected.package_annotations('suite').params := cast( null as ut_annotations.tt_annotation_params); l_ann_param := null; diff --git a/tests/ut_suite_manager/ut_suite_manager.PackageWithDollarSign.sql b/tests/ut_suite_manager/ut_suite_manager.PackageWithDollarSign.sql index 0d913a949..9aab210f3 100644 --- a/tests/ut_suite_manager/ut_suite_manager.PackageWithDollarSign.sql +++ b/tests/ut_suite_manager/ut_suite_manager.PackageWithDollarSign.sql @@ -17,9 +17,16 @@ set termout on declare l_objects_to_run ut_suite_items; + l_suite ut_suite; begin --act l_objects_to_run := ut_suite_manager.configure_execution_by_path(ut_varchar2_list('tst_package_with$dollar')); + + --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_with$dollar'); if ut_expectation_processor.get_status = ut_utils.tr_success then :test_result := ut_utils.tr_success; diff --git a/tests/ut_suite_manager/ut_suite_manager.PackageWithHash.sql b/tests/ut_suite_manager/ut_suite_manager.PackageWithHash.sql index 3e43232fa..b6628e377 100644 --- a/tests/ut_suite_manager/ut_suite_manager.PackageWithHash.sql +++ b/tests/ut_suite_manager/ut_suite_manager.PackageWithHash.sql @@ -17,11 +17,18 @@ set termout on declare l_objects_to_run ut_suite_items; + l_suite ut_suite; begin --act l_objects_to_run := ut_suite_manager.configure_execution_by_path(ut_varchar2_list('tst_package_with#hash')); + --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_with#hash'); + if ut_expectation_processor.get_status = ut_utils.tr_success then :test_result := ut_utils.tr_success; end if; diff --git a/tests/ut_suite_manager/ut_suite_manager.TestWithDollarSign.sql b/tests/ut_suite_manager/ut_suite_manager.TestWithDollarSign.sql index f6cbd6c88..a7e109a3c 100644 --- a/tests/ut_suite_manager/ut_suite_manager.TestWithDollarSign.sql +++ b/tests/ut_suite_manager/ut_suite_manager.TestWithDollarSign.sql @@ -9,7 +9,6 @@ end; create or replace package body tst_package_with_dollar_test as procedure test$1 is begin ut.expect(1).to_equal(1); end; - procedure test$2 is begin ut.expect(1).to_equal(1); end; end; / @@ -17,9 +16,23 @@ set termout on declare l_objects_to_run ut_suite_items; + l_suite ut_suite; + l_test ut_test; begin --act l_objects_to_run := ut_suite_manager.configure_execution_by_path(ut_varchar2_list('tst_package_with_dollar_test.test$1')); + + --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_with_dollar_test'); + ut.expect(l_suite.items.count).to_equal(1); + + l_test := treat(l_suite.items(1) as ut_test); + + ut.expect(l_test.name).to_equal('test$1'); if ut_expectation_processor.get_status = ut_utils.tr_success then :test_result := ut_utils.tr_success; diff --git a/tests/ut_suite_manager/ut_suite_manager.TestWithHashSign.sql b/tests/ut_suite_manager/ut_suite_manager.TestWithHashSign.sql index e7a18ffe8..0d3d3265d 100644 --- a/tests/ut_suite_manager/ut_suite_manager.TestWithHashSign.sql +++ b/tests/ut_suite_manager/ut_suite_manager.TestWithHashSign.sql @@ -9,7 +9,6 @@ end; create or replace package body tst_package_with_hash_test as procedure test#1 is begin ut.expect(1).to_equal(1); end; - procedure test#2 is begin ut.expect(1).to_equal(1); end; end; / @@ -17,10 +16,24 @@ set termout on declare l_objects_to_run ut_suite_items; + l_suite ut_suite; + l_test ut_test; begin --act l_objects_to_run := ut_suite_manager.configure_execution_by_path(ut_varchar2_list('tst_package_with_hash_test.test#1')); + + --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_with_hash_test'); + ut.expect(l_suite.items.count).to_equal(1); + + l_test := treat(l_suite.items(1) as ut_test); + + ut.expect(l_test.name).to_equal('test#1'); if ut_expectation_processor.get_status = ut_utils.tr_success then :test_result := ut_utils.tr_success; diff --git a/tests/ut_suite_manager/ut_suite_manager.emptySuitePath.sql b/tests/ut_suite_manager/ut_suite_manager.emptySuitePath.sql index 4b9cd35f2..7d348da9f 100644 --- a/tests/ut_suite_manager/ut_suite_manager.emptySuitePath.sql +++ b/tests/ut_suite_manager/ut_suite_manager.emptySuitePath.sql @@ -4,12 +4,12 @@ create or replace package tst_empty_suite_path as --%suitepath --%test - procedure test#1; + procedure test1; end; / create or replace package body tst_empty_suite_path as - procedure test#1 is begin ut.expect(1).to_equal(1); end; + procedure test1 is begin ut.expect(1).to_equal(1); end; end; / @@ -17,10 +17,18 @@ set termout on declare l_objects_to_run ut_suite_items; + l_suite ut_suite; begin --act l_objects_to_run := ut_suite_manager.configure_execution_by_path(ut_varchar2_list('tst_empty_suite_path')); + + --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_empty_suite_path'); if ut_expectation_processor.get_status = ut_utils.tr_success then :test_result := ut_utils.tr_success; From 413e63f328663e46032b62dcf9593feeafd4f8bc Mon Sep 17 00:00:00 2001 From: Pazus Date: Mon, 3 Jul 2017 10:41:13 +0300 Subject: [PATCH 3/3] added trailing spaces processing --- source/core/ut_annotations.pkb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/core/ut_annotations.pkb b/source/core/ut_annotations.pkb index 8be529d56..ccf8bda66 100644 --- a/source/core/ut_annotations.pkb +++ b/source/core/ut_annotations.pkb @@ -30,7 +30,7 @@ create or replace package body ut_annotations as c_rgexp_identifier constant varchar2(50) := '[a-z][a-z0-9#_$]*'; c_annotation_block_pattern constant varchar2(200) := '(({COMMENT#.+}'||chr(10)||')+)( |'||chr(09)||')*(procedure|function)\s+(' || c_rgexp_identifier || ')'; - c_annotation_pattern constant varchar2(50) := gc_annotation_qualifier || c_rgexp_identifier || '[ '||chr(9)||']*(\(.*?\)$)?'; + c_annotation_pattern constant varchar2(50) := gc_annotation_qualifier || c_rgexp_identifier || '[ '||chr(9)||']*(\(.*?\)\s*?$)?'; function delete_multiline_comments(a_source in clob) return clob is