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

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion source/core/ut_annotations.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -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)||']*(\(.*?\)$)?';
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we use \s* rather than chr(9)?
We should also enhance the pattern to allow \s at the end I think.
So how about:

gc_annotation_qualifier || c_rgexp_identifier || '\s*(\(.*?\)\s*$)?';

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

\s contains new line character which is not allowed

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make the regexp work with trailing spaces?
'[ '||chr(9)||]((.?)[ '||chr(9)||']*$)?'



function delete_multiline_comments(a_source in clob) return clob is
Expand Down
2 changes: 1 addition & 1 deletion source/core/ut_suite_manager.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that the trim should be done on the text of annotation param inside the annotation parser.

l_suite_path := l_annotation_data.package_annotations('suitepath').text || '.' || lower(l_object_name);
end if;

Expand Down
2 changes: 2 additions & 0 deletions tests/RunAll.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 24 and 25 are not used I think

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;
/
33 changes: 33 additions & 0 deletions tests/ut_suite_manager/ut_suite_manager.emptySuitePath.sql
Original file line number Diff line number Diff line change
@@ -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
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand how will this test ever fail, as there is no expectation executed before status is checked.

:test_result := ut_utils.tr_success;
end if;

end;
/

drop package tst_empty_suite_path
/