From 72c4fa710b8a31c94e01f60924b4bcc8cc163db0 Mon Sep 17 00:00:00 2001 From: Pazus Date: Sat, 26 Aug 2017 20:26:34 +0300 Subject: [PATCH 1/2] fixed bug when both suites are executed if they only differ by with a suffix --- source/core/ut_suite_manager.pkb | 5 +- test/ut_suite_manager/test_suite_manager.pkb | 56 ++++++++++++++++++++ test/ut_suite_manager/test_suite_manager.pks | 7 +++ 3 files changed, 66 insertions(+), 2 deletions(-) diff --git a/source/core/ut_suite_manager.pkb b/source/core/ut_suite_manager.pkb index 5bf5a4c30..30c298cdd 100644 --- a/source/core/ut_suite_manager.pkb +++ b/source/core/ut_suite_manager.pkb @@ -424,7 +424,8 @@ create or replace package body ut_suite_manager is end clean_paths; procedure skip_by_path(a_suite in out nocopy ut_suite_item, a_path varchar2) is - c_root constant varchar2(32767) := replace(regexp_substr(a_path, '[A-Za-z0-9$#_]+'), '$', '\$'); + --c_root constant varchar2(32767) := replace(regexp_substr(a_path, '[A-Za-z0-9$#_]+'), '$', '\$'); + c_root constant varchar2(32767) := upper(regexp_substr(a_path, '[A-Za-z0-9$#_]+')); c_rest_path constant varchar2(32767) := regexp_substr(a_path, '\.(.+)', subexpression => 1); l_suite ut_logical_suite; l_item ut_suite_item; @@ -441,7 +442,7 @@ create or replace package body ut_suite_manager is l_item_name := l_item.name; --l_item_name := regexp_substr(l_item_name,'[A-Za-z0-9$#_]+$'); -- temporary fix. seems like suite have suitepath in object_name - if regexp_like(l_item_name, c_root, modifier => 'i') then + if upper(l_item_name) = c_root then skip_by_path(l_item, c_rest_path); l_items.extend; diff --git a/test/ut_suite_manager/test_suite_manager.pkb b/test/ut_suite_manager/test_suite_manager.pkb index f20e0401b..dcd7344f9 100644 --- a/test/ut_suite_manager/test_suite_manager.pkb +++ b/test/ut_suite_manager/test_suite_manager.pkb @@ -1208,5 +1208,61 @@ end test_package_3;]'; execute immediate 'drop package test_package_3'; end; + procedure test_pck_with_same_path is + l_objects_to_run ut3.ut_suite_items; + l_suite1 ut3.ut_logical_suite; + l_suite2 ut3.ut_logical_suite; + l_suite3 ut3.ut_suite; + begin + l_objects_to_run := ut3.ut_suite_manager.configure_execution_by_path(ut3.ut_varchar2_list(':test1.test2$.test_package_same_1')); + + --Assert + ut.expect(l_objects_to_run.count).to_equal(1); + + l_suite1 := treat(l_objects_to_run(1) as ut3.ut_logical_suite); + ut.expect(l_suite1.name).to_equal('test1'); + ut.expect(l_suite1.items.count).to_equal(1); + + l_suite2 := treat(l_suite1.items(1) as ut3.ut_logical_suite); + ut.expect(l_suite2.name).to_equal('test2$'); + ut.expect(l_suite2.items.count).to_equal(1); + + l_suite3 := treat(l_suite2.items(1) as ut3.ut_suite); + ut.expect(l_suite3.name).to_equal('test_package_same_1'); + end; + + procedure setup_pck_with_same_path is + pragma autonomous_transaction; + begin + execute immediate 'create or replace package test_package_same_1 as + --%suite + --%suitepath(test1.test2$) + + --%test + procedure test1; +end;'; + execute immediate 'create or replace package body test_package_same_1 as + procedure test1 is begin null; end; +end;'; + execute immediate 'create or replace package test_package_same_1_a as + --%suite + --%suitepath(test1.test2$) + + --%test + procedure test1; +end;'; + execute immediate 'create or replace package body test_package_same_1_a as + procedure test1 is begin null; end; +end;'; + end; + + procedure clean_pck_with_same_path is + pragma autonomous_transaction; + begin + execute immediate 'drop package test_package_same_1'; + execute immediate 'drop package test_package_same_1_a'; + null; + end; + end test_suite_manager; / diff --git a/test/ut_suite_manager/test_suite_manager.pks b/test/ut_suite_manager/test_suite_manager.pks index 6e9322214..1a9f64c3a 100644 --- a/test/ut_suite_manager/test_suite_manager.pks +++ b/test/ut_suite_manager/test_suite_manager.pks @@ -132,6 +132,13 @@ create or replace package test_suite_manager is --%test --%disabled --procedure IncludesPackagesWithSutePath; + + --%test + --%beforetest(setup_pck_with_same_path) + --%aftertest(clean_pck_with_same_path) + procedure test_pck_with_same_path; + procedure setup_pck_with_same_path; + procedure clean_pck_with_same_path; end test_suite_manager; / From ff4ede86c3b90208fe682709708f83df6100e6da Mon Sep 17 00:00:00 2001 From: Pazus Date: Sun, 27 Aug 2017 12:02:13 +0300 Subject: [PATCH 2/2] addressed the reviewer comments --- source/core/ut_suite_manager.pkb | 7 +------ test/ut_suite_manager/test_suite_manager.pks | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/source/core/ut_suite_manager.pkb b/source/core/ut_suite_manager.pkb index 30c298cdd..605be5d61 100644 --- a/source/core/ut_suite_manager.pkb +++ b/source/core/ut_suite_manager.pkb @@ -424,14 +424,11 @@ create or replace package body ut_suite_manager is end clean_paths; procedure skip_by_path(a_suite in out nocopy ut_suite_item, a_path varchar2) is - --c_root constant varchar2(32767) := replace(regexp_substr(a_path, '[A-Za-z0-9$#_]+'), '$', '\$'); c_root constant varchar2(32767) := upper(regexp_substr(a_path, '[A-Za-z0-9$#_]+')); c_rest_path constant varchar2(32767) := regexp_substr(a_path, '\.(.+)', subexpression => 1); l_suite ut_logical_suite; l_item ut_suite_item; l_items ut_suite_items := ut_suite_items(); - l_item_name varchar2(32767); - begin if a_path is not null and a_suite is not null and a_suite is of (ut_logical_suite) then l_suite := treat(a_suite as ut_logical_suite); @@ -440,9 +437,7 @@ create or replace package body ut_suite_manager is l_item := l_suite.items(i); - l_item_name := l_item.name; - --l_item_name := regexp_substr(l_item_name,'[A-Za-z0-9$#_]+$'); -- temporary fix. seems like suite have suitepath in object_name - if upper(l_item_name) = c_root then + if upper(l_item.name) = c_root then skip_by_path(l_item, c_rest_path); l_items.extend; diff --git a/test/ut_suite_manager/test_suite_manager.pks b/test/ut_suite_manager/test_suite_manager.pks index 1a9f64c3a..c27173974 100644 --- a/test/ut_suite_manager/test_suite_manager.pks +++ b/test/ut_suite_manager/test_suite_manager.pks @@ -133,7 +133,7 @@ create or replace package test_suite_manager is --%disabled --procedure IncludesPackagesWithSutePath; - --%test + --%test(only the defined in suitepath suite/test is executed if multiple similarly named test suites exist in the context differed only by comment) --%beforetest(setup_pck_with_same_path) --%aftertest(clean_pck_with_same_path) procedure test_pck_with_same_path;