Skip to content

Commit 2689052

Browse files
authored
Merge pull request #1061 from utPLSQL/bugfix/suitepath_with_nlssort
Resolves issue #1060 with suites not properly built with GERMAN (non-…
2 parents ea4c9fb + b8c0287 commit 2689052

File tree

4 files changed

+88
-11
lines changed

4 files changed

+88
-11
lines changed

source/core/ut_suite_cache_manager.pkb

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -161,13 +161,16 @@ create or replace package body ut_suite_cache_manager is
161161
begin
162162
return case
163163
when a_random_seed is null then q'[
164-
replace(
165-
--suite path until objects name (excluding contexts and test path) with trailing dot (full stop)
166-
substr( c.obj.path, 1, instr( c.obj.path, lower(c.obj.object_name), -1 ) + length(c.obj.object_name) ),
167-
'.',
168-
--'.' replaced with chr(0) to assure that child elements come before parent when sorting in descending oder
169-
chr(0)
170-
) desc nulls last,
164+
nlssort(
165+
replace(
166+
/*suite path until objects name (excluding contexts and test path) with trailing dot (full stop)*/
167+
substr( c.obj.path, 1, instr( c.obj.path, lower(c.obj.object_name), -1 ) + length(c.obj.object_name) ),
168+
'.',
169+
/*'.' replaced with chr(0) to assure that child elements come before parent when sorting in descending order*/
170+
chr(0)
171+
),
172+
'nls_sort=binary'
173+
)desc nulls last,
171174
case when c.obj.self_type = 'UT_SUITE_CONTEXT' then
172175
( select max( x.line_no ) + 1
173176
from ut_suite_cache x
@@ -178,7 +181,7 @@ create or replace package body ut_suite_cache_manager is
178181
else
179182
c.obj.line_no
180183
end,
181-
--assures that child contexts come before parent contexts
184+
/*assures that child contexts come before parent contexts*/
182185
regexp_count(c.obj.path,'\.') desc,
183186
:a_random_seed]'
184187
else

test/ut3_tester/core/test_suite_manager.pks

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@ create or replace package test_suite_manager is
33
--%suite(suite_manager)
44
--%suitepath(utplsql.ut3_tester.core)
55

6-
procedure create_dummy_long_test_package;
7-
8-
procedure drop_dummy_long_test_package;
96

107
--%beforeall
118
procedure compile_dummy_packages;
@@ -170,6 +167,8 @@ create or replace package test_suite_manager is
170167
--%beforetest(create_dummy_long_test_package)
171168
--%aftertest(drop_dummy_long_test_package)
172169
procedure add_new_long_test_package;
170+
procedure create_dummy_long_test_package;
171+
procedure drop_dummy_long_test_package;
173172

174173
end test_suite_manager;
175174
/

test/ut3_user/api/test_ut_run.pkb

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -780,6 +780,74 @@ Failures:%
780780
execute immediate 'drop package '||gc_owner||'.'||gc_owner;
781781
end;
782782

783+
procedure create_suites_with_path is
784+
pragma autonomous_transaction;
785+
begin
786+
execute immediate q'[create or replace package ut_abc is
787+
-- %suite
788+
-- %suitepath(main.abc)
789+
790+
-- %test
791+
procedure ut_test_01;
792+
end ut_abc;]';
793+
794+
execute immediate q'[create or replace package body ut_abc
795+
is
796+
procedure ut_test_01 as begin ut.expect(true).to_be_true(); end;
797+
end;]';
798+
799+
execute immediate q'[create or replace package ut_abc_def
800+
is
801+
-- %suite
802+
-- %suitepath(main.abc_def)
803+
804+
-- %test
805+
procedure ut_test_01;
806+
end ut_abc_def;]';
807+
808+
execute immediate q'[create or replace package body ut_abc_def
809+
is
810+
procedure ut_test_01 as begin ut.expect(true).to_be_true(); end;
811+
end;]';
812+
813+
end;
814+
815+
procedure drop_suites_with_path is
816+
pragma autonomous_transaction;
817+
begin
818+
execute immediate q'[drop package ut_abc]';
819+
execute immediate q'[drop package ut_abc_def]';
820+
end;
821+
822+
procedure run_suite_with_nls_sort is
823+
L_current_sort varchar2(2000);
824+
l_results ut3_develop.ut_varchar2_list;
825+
l_expected clob;
826+
begin
827+
--Arrange
828+
select value
829+
into l_current_sort
830+
from nls_session_parameters where parameter = 'NLS_SORT';
831+
832+
execute immediate 'alter session set nls_sort=GERMAN';
833+
834+
--Act
835+
select *
836+
bulk collect into l_results
837+
from table ( ut3_develop.ut.run( gc_owner||':main' ) );
838+
--Assert
839+
l_expected := q'[main%
840+
abc_def%
841+
ut_abc_def%
842+
ut_test_01%
843+
abc%
844+
ut_abc%
845+
ut_test_01%]';
846+
ut.expect(ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( l_expected );
847+
848+
execute immediate 'alter session set nls_sort='||l_current_sort;
849+
end;
850+
783851
procedure run_with_random_order is
784852
l_random_results ut3_develop.ut_varchar2_list;
785853
l_results ut3_develop.ut_varchar2_list;

test/ut3_user/api/test_ut_run.pks

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,13 @@ create or replace package test_ut_run is
155155
procedure create_schema_name_package;
156156
procedure drop_schema_name_package;
157157

158+
--%test(Runs properly formed suite hierarchy regardless of NLS_SORT settings - Issue #1060)
159+
--%beforetest(create_suites_with_path)
160+
--%aftertest(drop_suites_with_path)
161+
procedure run_suite_with_nls_sort;
162+
procedure create_suites_with_path;
163+
procedure drop_suites_with_path;
164+
158165
--%endcontext
159166

160167
--%context(random_order)

0 commit comments

Comments
 (0)