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

Skip to content

Commit 3d9e7e4

Browse files
committed
Initial commit of ut_debug_reporter
1 parent 5cd30b3 commit 3d9e7e4

16 files changed

Lines changed: 244 additions & 23 deletions

source/api/ut_runner.pkb

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,17 @@ create or replace package body ut_runner is
9696
l_paths ut_varchar2_list := ut_varchar2_list();
9797
begin
9898
ut_event_manager.initialize();
99+
if a_reporters is not empty then
100+
for i in 1 .. a_reporters.count loop
101+
ut_event_manager.add_listener( a_reporters(i) );
102+
end loop;
103+
else
104+
ut_event_manager.add_listener( ut_documentation_reporter() );
105+
end if;
106+
107+
ut_event_manager.trigger_event(ut_event_manager.gc_initialize);
108+
ut_event_manager.trigger_event(ut_event_manager.gc_debug, ut_run_info());
109+
99110
if a_paths is null or a_paths is empty or a_paths.count = 1 and a_paths(1) is null then
100111
l_paths := ut_varchar2_list(sys_context('userenv', 'current_schema'));
101112
else
@@ -109,13 +120,6 @@ create or replace package body ut_runner is
109120
ut_utils.save_dbms_output_to_cache();
110121

111122
ut_console_reporter_base.set_color_enabled(a_color_console);
112-
if a_reporters is null or a_reporters.count = 0 then
113-
ut_event_manager.add_listener(ut_documentation_reporter());
114-
else
115-
for i in 1 .. a_reporters.count loop
116-
ut_event_manager.add_listener(a_reporters(i));
117-
end loop;
118-
end if;
119123

120124
if a_coverage_schemes is not empty then
121125
l_coverage_schema_names := ut_utils.convert_collection(a_coverage_schemes);
@@ -142,8 +146,6 @@ create or replace package body ut_runner is
142146
a_client_character_set
143147
);
144148

145-
ut_event_manager.trigger_event(ut_event_manager.gc_initialize, l_run);
146-
147149
ut_suite_manager.configure_execution_by_path(l_paths, l_run.items);
148150
if a_force_manual_rollback then
149151
l_run.set_rollback_type( a_rollback_type => ut_utils.gc_rollback_manual, a_force => true );
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
create or replace type body ut_event_item is
2+
/*
3+
utPLSQL - Version 3
4+
Copyright 2016 - 2018 utPLSQL Project
5+
6+
Licensed under the Apache License, Version 2.0 (the "License"):
7+
you may not use this file except in compliance with the License.
8+
You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
*/
18+
19+
member function to_clob return clob is
20+
l_clob clob;
21+
begin
22+
select xmlserialize( content deletexml(xmltype(self),'/*/ITEMS') as clob indent size = 2 ) into l_clob from dual;
23+
return l_clob;
24+
end;
25+
end;
26+
/

source/core/events/ut_event_item.tps

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ create or replace type ut_event_item authid current_user as object (
2020
* Object type is a pre-declaration to be referenced by ut_event_listener_base
2121
* The true abstract type is ut_suite_item
2222
*/
23-
self_type varchar2(250 byte)
24-
23+
self_type varchar2(250 byte),
24+
member function to_clob return clob
2525
) not final not instantiable
2626
/

source/core/events/ut_event_manager.pkb

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,26 @@ create or replace package body ut_event_manager as
5757
end if;
5858
end;
5959

60-
procedure trigger_event( a_event_name t_event_name, a_event_object ut_event_item ) is
61-
begin
62-
if a_event_name is not null and g_event_listeners_index.exists(a_event_name)
63-
then
64-
for listener_number in 1 .. g_event_listeners_index(a_event_name).count loop
65-
g_listeners(listener_number).on_event(a_event_name, a_event_object);
60+
procedure trigger_event( a_event_name t_event_name, a_event_object ut_event_item := null ) is
61+
procedure trigger_listener_event( a_listener_numbers t_listener_numbers, a_event_name t_event_name, a_event_object ut_event_item ) is
62+
l_listener_number t_listener_number;
63+
begin
64+
l_listener_number := a_listener_numbers.first;
65+
while l_listener_number is not null loop
66+
g_listeners(l_listener_number).on_event(a_event_name, a_event_object);
67+
l_listener_number := a_listener_numbers.next(l_listener_number);
6668
end loop;
69+
end;
70+
begin
71+
if a_event_name is not null then
72+
if g_event_listeners_index.exists(gc_all) then
73+
trigger_listener_event( g_event_listeners_index(gc_all), a_event_name, a_event_object );
74+
end if;
75+
if g_event_listeners_index.exists(a_event_name) then
76+
trigger_listener_event( g_event_listeners_index(a_event_name), a_event_name, a_event_object );
77+
end if;
6778
if a_event_name = ut_event_manager.gc_finalize then
68-
dispose_listeners;
79+
dispose_listeners();
6980
end if;
7081
end if;
7182
end;
@@ -78,7 +89,7 @@ create or replace package body ut_event_manager as
7889
procedure add_events( a_event_names ut_varchar2_list, a_listener_pos binary_integer ) is
7990
begin
8091
for i in 1 .. a_event_names.count loop
81-
add_event(a_event_names(i), a_listener_pos);
92+
add_event( a_event_names(i), a_listener_pos );
8293
end loop;
8394
end;
8495

@@ -98,10 +109,9 @@ create or replace package body ut_event_manager as
98109
if a_listener is not null then
99110
l_event_names := a_listener.get_supported_events();
100111
if l_event_names is not empty then
101-
add_events( l_event_names, add_listener(a_listener ) );
112+
add_events( l_event_names, add_listener( a_listener ) );
102113
end if;
103114
end if;
104-
105115
end;
106116

107117
end;

source/core/events/ut_event_manager.pks

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ create or replace package ut_event_manager authid current_user as
1818
/* Constants: Event names */
1919
subtype t_event_name is varchar2(250);
2020

21+
--capture all events
22+
gc_all constant t_event_name := 'all';
23+
24+
gc_debug constant t_event_name := 'debug';
25+
2126
gc_initialize constant t_event_name := 'initialize';
2227

2328
gc_before_run constant t_event_name := 'before_run';
@@ -51,7 +56,7 @@ create or replace package ut_event_manager authid current_user as
5156

5257
gc_finalize constant t_event_name := 'finalize';
5358

54-
procedure trigger_event( a_event_name t_event_name, a_event_object ut_event_item );
59+
procedure trigger_event( a_event_name t_event_name, a_event_object ut_event_item := null );
5560

5661
procedure initialize;
5762

source/core/types/ut_reporter_base.tpb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ create or replace type body ut_reporter_base is
211211
then self.after_calling_after_all(treat(a_event_item as ut_executable));
212212
when ut_event_manager.gc_finalize
213213
then self.on_finalize(treat(a_event_item as ut_run));
214+
else null;
214215
end case;
215216
end;
216217

source/core/types/ut_run_info.tpb

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
create or replace type body ut_run_info as
2+
/*
3+
utPLSQL - Version 3
4+
Copyright 2016 - 2018 utPLSQL Project
5+
6+
Licensed under the Apache License, Version 2.0 (the "License"):
7+
you may not use this file except in compliance with the License.
8+
You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions andTEST_GET_REPORTERS_LIST
16+
limitations under the License.
17+
*/
18+
constructor function ut_run_info(self in out nocopy ut_run_info) return self as result is
19+
l_ut_owner varchar2(250) := ut_utils.ut_owner;
20+
begin
21+
self.self_type := $$plsql_unit;
22+
execute immediate
23+
'select '||l_ut_owner||'.ut.version() from dual'
24+
into self.ut_version;
25+
26+
dbms_utility.db_version( self.db_version, self.db_compatibility );
27+
db_os_type := dbms_utility.port_string();
28+
29+
execute immediate
30+
'select '||l_ut_owner||'.ut_key_value_pair(x.product, x.version) from product_component_version x'
31+
bulk collect into self.db_component_version;
32+
33+
execute immediate
34+
'select '||l_ut_owner||'.ut_key_value_pair(x.parameter, x.value)
35+
from nls_session_parameters x'
36+
bulk collect into self.nls_session_params;
37+
38+
execute immediate
39+
'select '||l_ut_owner||'.ut_key_value_pair(x.parameter, x.value) from nls_instance_parameters x'
40+
bulk collect into self.nls_instance_params;
41+
42+
execute immediate
43+
'select '||l_ut_owner||'.ut_key_value_pair(x.parameter, x.value) from nls_database_parameters x'
44+
bulk collect into self.nls_db_params;
45+
return;
46+
end;
47+
end;
48+
/

source/core/types/ut_run_info.tps

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
create or replace type ut_run_info under ut_event_item (
2+
/*
3+
utPLSQL - Version 3
4+
Copyright 2016 - 2018 utPLSQL Project
5+
6+
Licensed under the Apache License, Version 2.0 (the "License"):
7+
you may not use this file except in compliance with the License.
8+
You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
*/
18+
ut_version varchar2(4000),
19+
db_version varchar2(4000),
20+
db_compatibility varchar2(4000),
21+
db_os_type varchar2(4000),
22+
db_component_version ut_key_value_pairs,
23+
nls_session_params ut_key_value_pairs,
24+
nls_instance_params ut_key_value_pairs,
25+
nls_db_params ut_key_value_pairs,
26+
constructor function ut_run_info(self in out nocopy ut_run_info) return self as result
27+
);
28+
/

source/create_synonyms_and_grants_for_public.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ grant execute on &&ut3_owner..ut_have_count to public;
4949
grant execute on &&ut3_owner..ut_match to public;
5050
grant execute on &&ut3_owner..ut to public;
5151
grant execute on &&ut3_owner..ut_runner to public;
52+
grant execute on &&ut3_owner..ut_debug_reporter to public;
5253
grant execute on &&ut3_owner..ut_teamcity_reporter to public;
5354
grant execute on &&ut3_owner..ut_xunit_reporter to public;
5455
grant execute on &&ut3_owner..ut_junit_reporter to public;
@@ -124,6 +125,7 @@ create public synonym have_count for &&ut3_owner..have_count;
124125
create public synonym match for &&ut3_owner..ut_match;
125126
create public synonym ut for &&ut3_owner..ut;
126127
create public synonym ut_runner for &&ut3_owner..ut_runner;
128+
create public synonym ut_debug_reporter for &&ut3_owner..ut_debug_reporter;
127129
create public synonym ut_teamcity_reporter for &&ut3_owner..ut_teamcity_reporter;
128130
create public synonym ut_xunit_reporter for &&ut3_owner..ut_xunit_reporter;
129131
create public synonym ut_junit_reporter for &&ut3_owner..ut_junit_reporter;

source/create_user_grants.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ grant execute on &&ut3_owner..ut_have_count to &ut3_user;
6969
grant execute on &&ut3_owner..ut_match to &ut3_user;
7070
grant execute on &&ut3_owner..ut to &ut3_user;
7171
grant execute on &&ut3_owner..ut_runner to &ut3_user;
72+
grant execute on &&ut3_owner..ut_debug_reporter to &ut3_user;
7273
grant execute on &&ut3_owner..ut_teamcity_reporter to &ut3_user;
7374
grant execute on &&ut3_owner..ut_xunit_reporter to &ut3_user;
7475
grant execute on &&ut3_owner..ut_junit_reporter to &ut3_user;

0 commit comments

Comments
 (0)