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

Skip to content

Commit 5565427

Browse files
committed
Cleanup of obsolete reporter code.
Removed: - ut_reporter_decorator - ut_dbms_output_suite_reporter Updated examples and install/uninstall.
1 parent 11728f1 commit 5565427

48 files changed

Lines changed: 1113 additions & 208 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.travis/create_utplsql_user.sql

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ create user &ut3_user identified by &ut3_password default tablespace &ut3_tables
1313

1414
grant create session, create procedure, create type, create table to &ut3_user;
1515

16+
grant execute on dbms_pipe to &ut3_user;
17+
grant create job to &ut3_user;
18+
1619
grant alter session to &ut3_user;
1720

21+
--only needed to run unit tests for utplsql v3, not required to run utplsql v3 itself
22+
grant select any dictionary to &ut3_user;
23+
1824
exit success

build/utplsql_style_check.sql

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
ALTER SESSION SET PLSCOPE_SETTINGS= 'IDENTIFIERS:ALL';
1+
alter session set plscope_settings= 'identifiers:all';
2+
set linesize 300
23

34
--install or comple all code here
45
exec dbms_utility.compile_schema(USER,compile_all => TRUE,reuse_settings => FALSE);
@@ -12,39 +13,44 @@ column errcnt_c noprint new_value errcnt_c
1213

1314
--find parameters that donot begin with A_
1415
prompt parameters should start with A_
15-
select NAME,TYPE,OBJECT_NAME,OBJECT_TYPE,USAGE,LINE,COL , count(*) over() errcnt_a
16-
from user_identifiers
17-
where type like 'FORMAL%' and usage = 'DECLARATION'
18-
and name != 'SELF'
19-
and name not like 'A#_%' escape '#'
20-
order by object_name, object_type, line, col
16+
select name, type, object_name, object_type, usage, line, col, count(*) over() errcnt_a
17+
from user_identifiers
18+
where type like 'FORMAL%' and usage = 'DECLARATION'
19+
and name != 'SELF'
20+
and name not like 'A#_%' escape '#'
21+
order by object_name, object_type, line, col
2122
;
2223

2324
prompt variables should start with L_
2425
--variables start with l_ or g_
25-
select NAME,TYPE,OBJECT_NAME,OBJECT_TYPE,USAGE,LINE,COL , count(*) over() errcnt_l
26-
from user_identifiers
27-
where type like 'VARIABLE' and usage = 'DECLARATION'
28-
and object_type not in ('TYPE')
29-
and (name not like 'L#_%' escape '#'
30-
and name not like 'G#_%' escape '#' --TODO: only valid on package level
31-
)
32-
order by object_name, object_type, line, col
26+
select i.name, i.type, i.object_name, i.object_type, i.usage, i.line, i.col, count(*) over() errcnt_l
27+
from user_identifiers i
28+
join user_identifiers p
29+
on p.object_name = i.object_name and p.object_type = i.object_type
30+
and i.usage_context_id = p.usage_id
31+
where i.type like 'VARIABLE' and i.usage = 'DECLARATION'
32+
and i.object_type not in ('TYPE')
33+
and (i.name not like 'L#_%' escape '#' and p.type in ('PROCEDURE','FUNCTION','ITERATOR')
34+
or i.name not like 'G#_%' escape '#' and p.type not in ('PROCEDURE','FUNCTION','ITERATOR'))
35+
and p.type != 'RECORD'
36+
order by object_name, object_type, line, col;
3337
;
3438

3539
--constants start with c_ or gc_
3640
prompt constants should start with C_
37-
select NAME,TYPE,OBJECT_NAME,OBJECT_TYPE,USAGE,LINE,COL , count(*) over() errcnt_c
38-
from user_identifiers
39-
where type like 'CONSTANT' and usage = 'DECLARATION'
40-
and (name not like 'C#_%' escape '#'
41-
and name not like 'GC#_%' escape '#'
42-
)
43-
order by object_name, object_type, line, col
41+
select i.name, i.type, i.object_name, i.object_type, i.usage, i.line, i.col, count(*) over() errcnt_c
42+
from user_identifiers i
43+
join user_identifiers p
44+
on p.object_name = i.object_name and p.object_type = i.object_type
45+
and i.usage_context_id = p.usage_id
46+
where i.type like 'CONSTANT' and i.usage = 'DECLARATION'
47+
and (i.name not like 'C#_%' escape '#' and p.type in ('PROCEDURE','FUNCTION','ITERATOR')
48+
or i.name not like 'GC#_%' escape '#' and p.type not in ('PROCEDURE','FUNCTION','ITERATOR'))
49+
order by object_name, object_type, line, col
4450
;
4551

4652

4753
exec :errcnt := nvl('&errcnt_a',0) + nvl('&errcnt_l',0) + nvl('&errcnt_c',0);
4854

4955
--quit :errcnt
50-
exit success
56+
exit success

examples/RunExampleTestSuiteWithCompositeReporter.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ begin
3333
suite.add_item(testtoexecute);
3434

3535
-- provide a reporter to process results
36-
reporter := ut_composite_reporter(ut_reporters_list(ut_dbms_output_suite_reporter, ut_dbms_output_suite_reporter));
36+
reporter := ut_composite_reporter(ut_reporters_list(ut_documentation_reporter, ut_teamcity_reporter));
3737
suite.do_execute(reporter);
3838
end;
3939
/

examples/RunExampleTestSuiteWithDBMSOutputReporter.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ begin
3232
suite.add_item(testtoexecute);
3333

3434
-- provide a reporter to process results
35-
reporter := ut_dbms_output_suite_reporter;
35+
reporter := ut_documentation_reporter;
3636
suite.do_execute(reporter);
3737
end;
3838
/

examples/RunExampleTestThroughBaseClass.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ begin
1919
,a_setup_procedure => 'setup'
2020
,a_teardown_procedure => 'teardown');
2121

22-
reporter := ut_dbms_output_suite_reporter;
22+
reporter := ut_documentation_reporter;
2323
simple_test.do_execute(reporter);
2424
end;
2525
/

examples/ut_custom_reporter.tpb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,47 +9,47 @@ create or replace type body ut_custom_reporter is
99
return;
1010
end;
1111

12-
member function tab(self in ut_custom_reporter) return varchar2 is
12+
overriding member function tab(self in ut_custom_reporter) return varchar2 is
1313
tab_str varchar2(255);
1414
begin
1515
tab_str := rpad(' ', lvl * tab_size);
1616
return tab_str;
1717
end tab;
1818

19-
overriding member procedure print(a_text varchar2) is
19+
overriding member procedure print_text(a_text varchar2) is
2020
begin
21-
(self as ut_dbms_output_suite_reporter).print(tab || a_text);
22-
end print;
21+
(self as ut_documentation_reporter).print_text(tab || a_text);
22+
end;
2323

2424
overriding member procedure before_suite(self in out nocopy ut_custom_reporter, a_suite ut_object) as
2525
begin
26-
(self as ut_dbms_output_suite_reporter).before_suite(a_suite);
26+
(self as ut_documentation_reporter).before_suite(a_suite);
2727
lvl := lvl + 1;
2828
end;
2929

3030
overriding member procedure before_test(self in out nocopy ut_custom_reporter, a_test ut_object) as
3131
begin
32-
(self as ut_dbms_output_suite_reporter).before_test(a_test);
32+
(self as ut_documentation_reporter).before_test(a_test);
3333
lvl := lvl + 1;
3434
end;
3535

3636
overriding member procedure on_assert_process(self in out nocopy ut_custom_reporter, a_assert ut_object) is
3737
begin
3838
lvl := lvl + 1;
39-
(self as ut_dbms_output_suite_reporter).on_assert_process(a_assert);
39+
(self as ut_documentation_reporter).on_assert_process(a_assert);
4040
lvl := lvl - 1;
4141
end;
4242

4343
overriding member procedure after_test(self in out nocopy ut_custom_reporter, a_test ut_object) as
4444
begin
4545
lvl := lvl - 1;
46-
(self as ut_dbms_output_suite_reporter).after_test(a_test);
46+
(self as ut_documentation_reporter).after_test(a_test);
4747
end;
4848

4949
overriding member procedure after_suite(self in out nocopy ut_custom_reporter, a_suite ut_object) as
5050
begin
5151
lvl := lvl - 1;
52-
(self as ut_dbms_output_suite_reporter).after_suite(a_suite);
52+
(self as ut_documentation_reporter).after_suite(a_suite);
5353
end;
5454

5555
end;

examples/ut_custom_reporter.tps

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
create or replace type ut_custom_reporter under ut_dbms_output_suite_reporter
1+
create or replace type ut_custom_reporter under ut_documentation_reporter
22
(
3-
lvl integer,
43
tab_size integer,
54

65
-- Member functions and procedures
76
constructor function ut_custom_reporter(a_tab_size integer default 4, a_output ut_output default ut_output_dbms_output() ) return self as result,
8-
member function tab(self in ut_custom_reporter) return varchar2,
9-
overriding member procedure print(a_text varchar2),
7+
overriding member function tab(self in ut_custom_reporter) return varchar2,
8+
overriding member procedure print_text(a_text varchar2),
109
overriding member procedure before_suite(self in out nocopy ut_custom_reporter, a_suite ut_object),
1110
overriding member procedure before_test(self in out nocopy ut_custom_reporter, a_test ut_object),
1211
overriding member procedure on_assert_process(self in out nocopy ut_custom_reporter, a_assert ut_object),

source/core/types/ut_clob_list.tps

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
create or replace type ut_clob_list as table of clob
2+
/

source/core/types/ut_output.tps

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ create or replace type ut_output as object (
33
output_id varchar2(128),
44
final member function generate_output_id return varchar2,
55
not instantiable member procedure open(self in out nocopy ut_output),
6-
not instantiable member procedure send(self in out nocopy ut_output, a_text clob),
7-
not instantiable member procedure close(self in out nocopy ut_output)
6+
not instantiable member procedure send_line(self in out nocopy ut_output, a_text varchar2),
7+
not instantiable member procedure send_clob(self in out nocopy ut_output, a_text clob),
8+
not instantiable member procedure close(self in out nocopy ut_output),
9+
not instantiable member function get_lines(a_output_id varchar2) return ut_varchar2_list pipelined,
10+
not instantiable member function get_clob_lines(a_output_id varchar2) return ut_clob_list pipelined
811
) not final not instantiable
912
/

source/core/types/ut_output_dbms_output.tpb

Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,17 @@ create or replace type body ut_output_dbms_output as
1212
null;
1313
end;
1414

15-
overriding member procedure send(self in out nocopy ut_output_dbms_output, a_text clob) is
16-
l_text_part varchar2(32767 byte);
17-
--we're assuming max of 2 bytes per char
18-
c_size_limit_chars constant integer := (32767/2);
19-
i integer := 0;
15+
overriding member procedure send_line(self in out nocopy ut_output_dbms_output, a_text varchar2) is
2016
begin
21-
while i < length(a_text) loop
22-
l_text_part := substr( a_text, i + 1, c_size_limit_chars );
23-
dbms_output.put_line(l_text_part);
24-
i := i + c_size_limit_chars;
17+
dbms_output.put_line(a_text);
18+
end;
19+
20+
overriding member procedure send_clob(self in out nocopy ut_output_dbms_output, a_text clob) is
21+
l_buffer ut_varchar2_list;
22+
begin
23+
l_buffer := ut_utils.clob_to_table(a_text);
24+
for i in 1 .. l_buffer.count loop
25+
dbms_output.put_line(l_buffer(i));
2526
end loop;
2627
end;
2728

@@ -30,5 +31,35 @@ create or replace type body ut_output_dbms_output as
3031
null;
3132
end;
3233

34+
overriding final member function get_lines(a_output_id varchar2) return ut_varchar2_list pipelined is
35+
l_buffer varchar2(32767);
36+
l_status integer;
37+
c_max_line_length constant integer := 4000;
38+
l_results_tab ut_varchar2_list;
39+
begin
40+
loop
41+
dbms_output.get_line (l_buffer, l_status);
42+
exit when l_status != 0;
43+
l_results_tab := ut_utils.clob_to_table(l_buffer, c_max_line_length);
44+
--pipe results one by one
45+
for i in 1 .. l_results_tab.count loop
46+
pipe row( l_results_tab(i) );
47+
end loop;
48+
end loop;
49+
return;
50+
end;
51+
52+
overriding final member function get_clob_lines(a_output_id varchar2) return ut_clob_list pipelined is
53+
l_buffer varchar2(32767);
54+
l_status integer;
55+
begin
56+
loop
57+
dbms_output.get_line (l_buffer, l_status);
58+
exit when l_status != 0;
59+
pipe row(l_buffer);
60+
end loop;
61+
return;
62+
end;
63+
3364
end;
3465
/

0 commit comments

Comments
 (0)