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

Skip to content

Commit 0d5a873

Browse files
authored
Merge branch 'develop' into issue-364
2 parents 4b63eb4 + eab7ad9 commit 0d5a873

16 files changed

Lines changed: 286 additions & 37 deletions

.travis/install.sh

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,18 @@ pwd
88
set feedback off
99
set verify off
1010
11-
@../source/create_utplsql_owner.sql $UT3_OWNER $UT3_OWNER_PASSWORD $UT3_TABLESPACE
11+
--@../source/create_utplsql_owner.sql $UT3_OWNER $UT3_OWNER_PASSWORD $UT3_TABLESPACE
12+
@../source/install_headless.sql
13+
14+
set feedback on
15+
--change the deafult password
16+
alter user $UT3_OWNER identified by $UT3_OWNER_PASSWORD;
1217
--needed for Mystats script to work
1318
grant select any dictionary to $UT3_OWNER;
1419
--Needed for testing a coverage outside ut3_owner.
1520
grant create any procedure, execute any procedure to $UT3_OWNER;
1621
22+
set feedback off
1723
@../source/create_utplsql_owner.sql $UT3_USER $UT3_USER_PASSWORD $UT3_TABLESPACE
1824
1925
cd ..
@@ -23,10 +29,10 @@ cd ..
2329
--@ut_debug_enable.sql
2430
--cd ..
2531
26-
cd source
27-
@install.sql $UT3_OWNER
28-
@create_synonyms_and_grants_for_user.sql $UT3_OWNER $UT3_USER
29-
cd ..
32+
--cd source
33+
--@install.sql $UT3_OWNER
34+
--@create_synonyms_and_grants_for_user.sql $UT3_OWNER $UT3_USER
35+
--cd ..
3036
3137
cd development
3238
conn $UT3_OWNER/$UT3_OWNER_PASSWORD@//$CONNECTION_STR

source/core/coverage/proftab.sql

Lines changed: 61 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
create table plsql_profiler_runs
1+
declare
2+
l_tab_exist number;
3+
begin
4+
select count(*) into l_tab_exist from
5+
(select table_name from all_tables where table_name = 'PLSQL_PROFILER_RUNS' and owner = sys_context('USERENV','CURRENT_SCHEMA')
6+
union all
7+
select synonym_name from all_synonyms where synonym_name = 'PLSQL_PROFILER_RUNS' and owner = sys_context('USERENV','CURRENT_SCHEMA'));
8+
if l_tab_exist = 0 then
9+
execute immediate q'[create table plsql_profiler_runs
210
(
311
runid number primary key, -- unique run identifier,
412
-- from plsql_profiler_runnumber
@@ -11,12 +19,23 @@ create table plsql_profiler_runs
1119
run_system_info varchar2(2047), -- currently unused
1220
run_comment1 varchar2(2047), -- additional comment
1321
spare1 varchar2(256) -- unused
14-
);
22+
)]';
23+
execute immediate q'[comment on table plsql_profiler_runs is
24+
'Run-specific information for the PL/SQL profiler']';
25+
dbms_output.put_line('PLSQL_PROFILER_RUNS table created');
26+
end if;
27+
end;
28+
/
1529

16-
comment on table plsql_profiler_runs is
17-
'Run-specific information for the PL/SQL profiler';
18-
19-
create table plsql_profiler_units
30+
declare
31+
l_tab_exist number;
32+
begin
33+
select count(*) into l_tab_exist from
34+
(select table_name from all_tables where table_name = 'PLSQL_PROFILER_UNITS' and owner = sys_context('USERENV','CURRENT_SCHEMA')
35+
union all
36+
select synonym_name from all_synonyms where synonym_name = 'PLSQL_PROFILER_UNITS' and owner = sys_context('USERENV','CURRENT_SCHEMA'));
37+
if l_tab_exist = 0 then
38+
execute immediate q'[create table plsql_profiler_units
2039
(
2140
runid number references plsql_profiler_runs,
2241
unit_number number, -- internally generated library unit #
@@ -31,12 +50,23 @@ create table plsql_profiler_units
3150
spare2 number, -- unused
3251
--
3352
primary key (runid, unit_number)
34-
);
35-
36-
comment on table plsql_profiler_units is
37-
'Information about each library unit in a run';
53+
)]';
54+
execute immediate q'[comment on table plsql_profiler_units is
55+
'Information about each library unit in a run']';
56+
dbms_output.put_line('PLSQL_PROFILER_UNITS table created');
57+
end if;
58+
end;
59+
/
3860

39-
create table plsql_profiler_data
61+
declare
62+
l_tab_exist number;
63+
begin
64+
select count(*) into l_tab_exist from
65+
(select table_name from all_tables where table_name = 'PLSQL_PROFILER_DATA' and owner = sys_context('USERENV','CURRENT_SCHEMA')
66+
union all
67+
select synonym_name from all_synonyms where synonym_name = 'PLSQL_PROFILER_DATA' and owner = sys_context('USERENV','CURRENT_SCHEMA'));
68+
if l_tab_exist = 0 then
69+
execute immediate q'[create table plsql_profiler_data
4070
(
4171
runid number, -- unique (generated) run identifier
4272
unit_number number, -- internally generated library unit #
@@ -52,10 +82,25 @@ create table plsql_profiler_data
5282
--
5383
primary key (runid, unit_number, line#),
5484
foreign key (runid, unit_number) references plsql_profiler_units
55-
);
56-
57-
comment on table plsql_profiler_data is
58-
'Accumulated data from all profiler runs';
85+
)]';
86+
execute immediate q'[comment on table plsql_profiler_data is
87+
'Accumulated data from all profiler runs']';
88+
dbms_output.put_line('PLSQL_PROFILER_DATA table created');
89+
end if;
90+
end;
91+
/
5992

60-
create sequence plsql_profiler_runnumber start with 1 nocache;
93+
declare
94+
l_seq_exist number;
95+
begin
96+
select count(*) into l_seq_exist from
97+
(select sequence_name from all_sequences where sequence_name = 'PLSQL_PROFILER_RUNNUMBER' and sequence_owner = sys_context('USERENV','CURRENT_SCHEMA')
98+
union all
99+
select synonym_name from all_synonyms where synonym_name = 'PLSQL_PROFILER_RUNNUMBER' and owner = sys_context('USERENV','CURRENT_SCHEMA'));
100+
if l_seq_exist = 0 then
101+
execute immediate q'[create sequence plsql_profiler_runnumber start with 1 nocache]';
102+
dbms_output.put_line('Sequence PLSQL_PROFILER_RUNNUMBER created');
103+
end if;
104+
end;
105+
/
61106

source/core/ut_annotations.pkb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ create or replace package body ut_annotations as
3030
c_rgexp_identifier constant varchar2(50) := '[a-z][a-z0-9#_$]*';
3131
c_annotation_block_pattern constant varchar2(200) := '(({COMMENT#.+}'||chr(10)||')+)( |'||chr(09)||')*(procedure|function)\s+(' ||
3232
c_rgexp_identifier || ')';
33-
c_annotation_pattern constant varchar2(50) := gc_annotation_qualifier || c_rgexp_identifier || '(\(.*?\)$)?';
33+
c_annotation_pattern constant varchar2(50) := gc_annotation_qualifier || c_rgexp_identifier || '[ '||chr(9)||']*(\(.*?\)\s*?$)?';
3434

3535

3636
function delete_multiline_comments(a_source in clob) return clob is

source/core/ut_expectation_processor.pkb

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,14 +129,15 @@ create or replace package body ut_expectation_processor as
129129
l_object_name varchar2(1000);
130130
-- in 12.2 format_call_stack reportes not only package name, but also the procedure name
131131
-- when 11g and 12c reports only package name
132-
c_expectation_search_pattern constant varchar2(500) := '(.*\.UT_EXPECTATION_RESULT\s+)(.*\.UT_EXPECTATION[A-Z0-9#_$]*(\.[A-Za-z0-9$#_]+)?.*\s+)+(.*)\s';
132+
c_expectation_search_pattern constant varchar2(500) :=
133+
'(.*\.(UT_EXPECTATION[A-Z0-9#_$]*|UT|UTASSERT2?)(\.[A-Z0-9#_$]+)?\s+)+(.*)';
133134
begin
134135
l_caller_stack_line := regexp_substr( c_call_stack, c_expectation_search_pattern, 1, 1, 'm', 4);
135-
l_line_no := to_number( regexp_substr(l_caller_stack_line,'^\dx[0-9a-f]+\s+(\d+)',subexpression => 1) );
136-
l_caller_type_and_name := substr( l_caller_stack_line, 23 );
136+
l_line_no := to_number( regexp_substr(l_caller_stack_line,'0x[0-9a-f]+\s+(\d+)',subexpression => 1) );
137+
l_caller_type_and_name := trim(regexp_substr(l_caller_stack_line,'0x[0-9a-f]+\s+\d+\s+(.+)',subexpression => 1));
137138
if l_caller_stack_line like '%.%' then
138-
l_owner := regexp_substr(l_caller_stack_line,'\s([A-Za-z0-9$#_]+)\.([A-Za-z0-9$#_]|\.)+$',subexpression => 1);
139-
l_object_name := regexp_substr(l_caller_stack_line,'\s([A-Za-z0-9$#_]+)\.(([A-Za-z0-9$#_]|\.)+)$',subexpression => 2);
139+
l_owner := regexp_substr(l_caller_stack_line,'([A-Za-z0-9$#_]+)\.([A-Za-z0-9$#_]|\.)+',subexpression => 1);
140+
l_object_name := regexp_substr(l_caller_stack_line,'([A-Za-z0-9$#_]+)\.(([A-Za-z0-9$#_]|\.)+)',subexpression => 2);
140141
end if;
141142
return
142143
case when l_owner is not null and l_object_name is not null and l_line_no is not null then

source/core/ut_suite_manager.pkb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ create or replace package body ut_suite_manager is
8484
l_suite_name := l_annotation_data.package_annotations('suite').text;
8585
end if;
8686

87-
if l_annotation_data.package_annotations.exists('suitepath') then
87+
if l_annotation_data.package_annotations.exists('suitepath') and l_annotation_data.package_annotations('suitepath').text is not null then
8888
l_suite_path := l_annotation_data.package_annotations('suitepath').text || '.' || lower(l_object_name);
8989
end if;
9090

source/install.sql

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,7 @@ alter session set plsql_warnings = 'ENABLE:ALL', 'DISABLE:(5004,5018,6000,6001,6
8787
@@install_component.sql 'core/ut_expectation_processor.pkb'
8888

8989
prompt Installing PLSQL profiler objects into &&ut3_owner schema
90-
prompt You will see "ORA-00955" errors if they already exist
91-
prompt &&line_separator
92-
whenever sqlerror continue
93-
set feedback on
9490
@@core/coverage/proftab.sql
95-
whenever sqlerror exit failure rollback
9691

9792
@@install_component.sql 'core/ut_file_mapper.pks'
9893
@@install_component.sql 'core/ut_file_mapper.pkb'

source/install_headless.sql

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,3 @@ define ut3_tablespace = users
2121
@@create_utplsql_owner.sql &&ut3_owner &&ut3_password &&ut3_tablespace
2222
@@install.sql &&ut3_owner
2323
@@create_synonyms_and_grants_for_public.sql &&ut3_owner
24-
25-
exit

tests/RunAll.sql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ exec ut_coverage.coverage_start_develop();
4444
@@lib/RunTest.sql ut_annotations/ut_annotations.parse_package_annotations.ParsePackageLevelAnnotationMultilineDeclare.sql
4545
@@lib/RunTest.sql ut_annotations/ut_annotations.parse_package_annotations.ParsePackageLevelAnnotationWithKeyValue.sql
4646
@@lib/RunTest.sql ut_annotations/ut_annotations.parse_package_annotations.ParsePackageLevelAnnotationWithMultilineComment.sql
47+
@@lib/RunTest.sql ut_annotations/ut_annotations.parse_package_annotations.spaceBeforeAnnotationParams.sql
4748
@@ut_expectations/ut.expect.not_to_be_null.sql
4849
@@lib/RunTest.sql ut_expectations/ut.expect.to_be_false.GivesFailureWhenExpessionIsNotBoolean.sql
4950
@@lib/RunTest.sql ut_expectations/ut.expect.to_be_false.GivesFailureWhenExpessionIsNull.sql
@@ -101,6 +102,8 @@ exec ut_coverage.coverage_start_develop();
101102
@@lib/RunTest.sql ut_expectations/ut.expect.to_match.FailsForUnsupportedDatatype.sql
102103
@@lib/RunTest.sql ut_expectations/ut_data_value_object.compare.Gives0WhenComparingIdenticalObjects.sql
103104
@@lib/RunTest.sql ut_expectations/ut_expectation_processor.nulls_are_equal.raisesExceptionWhenTryingToSetNullValue.sql
105+
@@lib/RunTest.sql ut_expectations/ut_expectation_processor.stackOnFailedTest.sql
106+
@@lib/RunTest.sql ut_expectations/ut_expectation_processor.stackOnUtFail.sql
104107

105108
@@ut_matchers/be_between.sql
106109
@@ut_matchers/be_empty.sql
@@ -185,6 +188,7 @@ exec ut_coverage.coverage_start_develop();
185188
@@lib/RunTest.sql ut_suite_manager/ut_suite_manager.TestWithDollarSign.sql
186189
@@lib/RunTest.sql ut_suite_manager/ut_suite_manager.PackageWithHash.sql
187190
@@lib/RunTest.sql ut_suite_manager/ut_suite_manager.TestWithHashSign.sql
191+
@@lib/RunTest.sql ut_suite_manager/ut_suite_manager.emptySuitePath.sql
188192

189193

190194
@@lib/RunTest.sql ut_test/ut_test.DisabledFlagSkipTest.sql
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
--Arrange
2+
declare
3+
l_source clob;
4+
l_parsing_result ut_annotations.typ_annotated_package;
5+
l_expected ut_annotations.typ_annotated_package;
6+
l_ann_param ut_annotations.typ_annotation_param;
7+
8+
begin
9+
l_source := 'PACKAGE test_tt AS
10+
/*
11+
Some comment
12+
-- inlined
13+
*/
14+
-- %suite
15+
-- %suitepath (all.globaltests)
16+
17+
procedure foo;
18+
END;';
19+
20+
--Act
21+
l_parsing_result := ut_annotations.parse_package_annotations(l_source);
22+
23+
--Assert
24+
l_expected.package_annotations('suite').params := cast( null as ut_annotations.tt_annotation_params);
25+
26+
l_ann_param := null;
27+
l_ann_param.val := 'all.globaltests';
28+
l_expected.package_annotations('suitepath').params(1) := l_ann_param;
29+
30+
check_annotation_parsing(l_expected, l_parsing_result);
31+
32+
if ut_expectation_processor.get_status = ut_utils.tr_success then
33+
:test_result := ut_utils.tr_success;
34+
end if;
35+
36+
end;
37+
/
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
set termout off
2+
create or replace package tst_stack_on_failed_test as
3+
--%suite
4+
5+
--%test
6+
procedure test;
7+
end;
8+
/
9+
10+
create or replace package body tst_stack_on_failed_test as
11+
procedure test is begin ut.expect(1).to_equal(2); end;
12+
end;
13+
/
14+
15+
set termout on
16+
17+
declare
18+
l_test_report ut_varchar2_list;
19+
l_output_data ut_varchar2_list;
20+
l_output varchar2(32767);
21+
l_expected varchar2(32767);
22+
begin
23+
l_expected := q'[%Failures:%at "UT3.TST_STACK_ON_FAIL%", line 2%]';
24+
25+
--act
26+
select *
27+
bulk collect into l_output_data
28+
from table(ut.run('tst_stack_on_failed_test',ut_documentation_reporter()));
29+
30+
l_output := ut_utils.table_to_clob(l_output_data);
31+
32+
--assert
33+
if l_output like l_expected then
34+
:test_result := ut_utils.tr_success;
35+
else
36+
dbms_output.put_line('Actual:"'||l_output||'"');
37+
end if;
38+
end;
39+
/
40+
41+
drop package tst_stack_on_failed_test;

0 commit comments

Comments
 (0)