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
Next Next commit
Fix problem with identifying annotations on windows machines when win…
…dows newline is used
  • Loading branch information
pesse authored and Samuel Nitsche committed Aug 2, 2017
commit 050c4a12c23ff18016c4d74b96c1aa4a3142ff79
2 changes: 1 addition & 1 deletion source/core/ut_annotations.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ create or replace package body ut_annotations as
l_comment := a_comments(l_comment_index);

-- strip everything except the annotation itself (spaces and others)
l_annotation_str := regexp_substr(l_comment, c_annotation_pattern, 1, 1, modifier => 'i');
l_annotation_str := regexp_substr(trim(translate(l_comment, chr(10)||chr(13), ' ')), c_annotation_pattern, 1, 1, modifier => 'i');
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 it would be better to put the fix into: ut_metadata.get_package_spec_source so that the whole source that we parse have Unix-style end of line.

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.

Agreed and fixed. Thanks for the hint.

if l_annotation_str is not null then

l_annotation_params.delete;
Expand Down
3 changes: 2 additions & 1 deletion tests/RunAll.sql
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ 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
@@lib/RunTest.sql ut_annotations/ut_annotations.parse_package_annotations.spaceBeforeAnnotationParams.SQL
@@lib/RunTest.sql ut_annotations/ut_annotations.parse_package_annotations.ParseAnnotationWithWindowsNewline.sql
@@lib/RunTest.sql ut_expectation_processor/who_called_expectation.parseStackTrace.sql
@@lib/RunTest.sql ut_expectation_processor/who_called_expectation.parseStackTraceWith0x.sql
@@ut_expectations/ut.expect.not_to_be_null.sql
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
PROMPT Parse package level annotations with windows newline

--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
-- %suite
-- %displayname(Name of suite)' || chr(13) || chr(10)
|| ' -- %suitepath(all.globaltests)
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_expected.package_annotations('displayname').params(1) := l_ann_param;

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;
/