Skip to content

Bugfix/test description with comma #347

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
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
22 changes: 12 additions & 10 deletions source/core/ut_annotations.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
/
9 changes: 7 additions & 2 deletions source/core/ut_annotations.pks
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
/
24 changes: 11 additions & 13 deletions source/core/ut_suite_manager.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions tests/RunAll.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/helpers/check_annotation_parsing.prc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
/