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

Skip to content

Commit 2a50990

Browse files
committed
Changed data-type used for schema_names filtering.
Resolves #368 Refactored ut_runner and ut_run, so that the ut_coverage_options are built in ut_run. The previous implementation was confusing. Changed data-type of send_line to avoid similar issue.
1 parent 625232c commit 2a50990

13 files changed

Lines changed: 67 additions & 42 deletions

source/api/ut_runner.pkb

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ create or replace package body ut_runner is
5757
) is
5858
l_items_to_run ut_run;
5959
l_listener ut_event_listener;
60-
l_coverage_options ut_coverage_options;
6160
begin
6261
ut_output_buffer.cleanup_buffer();
6362

@@ -67,13 +66,15 @@ create or replace package body ut_runner is
6766
else
6867
l_listener := ut_event_listener(a_reporters);
6968
end if;
70-
l_coverage_options := ut_coverage_options(
71-
schema_names => a_coverage_schemes,
72-
exclude_objects => to_ut_object_list(a_exclude_objects),
73-
include_objects => to_ut_object_list(a_include_objects),
74-
file_mappings => set(a_source_file_mappings)
69+
l_items_to_run := ut_run(
70+
ut_suite_manager.configure_execution_by_path(a_paths),
71+
a_paths,
72+
ut_utils.convert_collection(a_coverage_schemes),
73+
to_ut_object_list(a_exclude_objects),
74+
to_ut_object_list(a_include_objects),
75+
set(a_source_file_mappings),
76+
set(a_test_file_mappings)
7577
);
76-
l_items_to_run := ut_run( ut_suite_manager.configure_execution_by_path(a_paths), a_paths, l_coverage_options, set(a_test_file_mappings) );
7778
l_items_to_run.do_execute(l_listener);
7879

7980
cleanup_temp_tables;

source/core/coverage/ut_coverage.pkb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,10 @@ create or replace package body ut_coverage is
149149
type t_source_lines is table of binary_integer;
150150
l_source_lines t_source_lines;
151151
line_no binary_integer;
152-
l_schema_names ut_varchar2_list;
152+
l_schema_names ut_varchar2_rows;
153153
l_query varchar2(32767);
154154
begin
155-
l_schema_names := coalesce(a_coverage_options.schema_names, ut_varchar2_list(sys_context('USERENV','CURRENT_SCHEMA')));
155+
l_schema_names := coalesce(a_coverage_options.schema_names, ut_varchar2_rows(sys_context('USERENV','CURRENT_SCHEMA')));
156156

157157
if not ut_coverage_helper.is_develop_mode() then
158158
--skip all the utplsql framework objects and all the unit test packages that could potentially be reported by coverage.

source/core/coverage/ut_coverage_reporter_base.tpb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ create or replace type body ut_coverage_reporter_base is
1717
*/
1818

1919
overriding final member procedure before_calling_run(self in out nocopy ut_coverage_reporter_base, a_run ut_run) as
20-
l_schema_names ut_varchar2_list := a_run.get_run_schemes();
2120
begin
2221
(self as ut_reporter_base).before_calling_run(a_run);
2322
ut_coverage.coverage_start();

source/core/types/ut_coverage_options.tps

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ create or replace type ut_coverage_options as object (
1616
limitations under the License.
1717
*/
1818

19-
schema_names ut_varchar2_list,
19+
schema_names ut_varchar2_rows,
2020
exclude_objects ut_object_names,
2121
include_objects ut_object_names,
2222
file_mappings ut_file_mappings

source/core/types/ut_run.tpb

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,29 +17,33 @@ create or replace type body ut_run as
1717
*/
1818

1919
constructor function ut_run(
20-
self in out nocopy ut_run, a_items ut_suite_items, a_run_paths ut_varchar2_list := null,
21-
a_coverage_options ut_coverage_options := null, a_test_file_mappings ut_file_mappings := null
20+
self in out nocopy ut_run,
21+
a_items ut_suite_items,
22+
a_run_paths ut_varchar2_list := null,
23+
a_schema_names ut_varchar2_rows := null,
24+
a_exclude_objects ut_object_names := null,
25+
a_include_objects ut_object_names := null,
26+
a_project_file_mappings ut_file_mappings := null,
27+
a_test_file_mappings ut_file_mappings := null
2228
) return self as result is
23-
l_coverage_schema_names ut_varchar2_list;
29+
l_coverage_schema_names ut_varchar2_rows;
30+
l_coverage_options ut_coverage_options;
31+
l_exclude_objects ut_object_names;
2432
begin
33+
l_coverage_schema_names := coalesce(a_schema_names, get_run_schemes());
34+
l_exclude_objects := coalesce(a_exclude_objects,ut_object_names());
35+
2536
self.run_paths := a_run_paths;
2637
self.self_type := $$plsql_unit;
2738
self.items := a_items;
2839
self.results_count := ut_results_counter();
29-
self.coverage_options := a_coverage_options;
3040
self.test_file_mappings := coalesce(a_test_file_mappings, ut_file_mappings());
31-
if self.coverage_options is not null then
32-
l_coverage_schema_names := coalesce(coverage_options.schema_names, get_run_schemes());
33-
coverage_options.schema_names := l_coverage_schema_names;
34-
if coverage_options.exclude_objects is not null then
35-
coverage_options.exclude_objects :=
36-
coverage_options.exclude_objects
37-
multiset union all
38-
ut_suite_manager.get_schema_ut_packages(l_coverage_schema_names);
39-
else
40-
coverage_options.exclude_objects := ut_suite_manager.get_schema_ut_packages(l_coverage_schema_names);
41-
end if;
42-
end if;
41+
self.coverage_options := ut_coverage_options(
42+
l_coverage_schema_names,
43+
l_exclude_objects multiset union all ut_suite_manager.get_schema_ut_packages(l_coverage_schema_names),
44+
a_include_objects,
45+
a_project_file_mappings
46+
);
4347
return;
4448
end;
4549

@@ -101,14 +105,14 @@ create or replace type body ut_run as
101105
a_listener.fire_after_event(ut_utils.gc_run, self);
102106
end;
103107

104-
member function get_run_schemes return ut_varchar2_list is
108+
member function get_run_schemes return ut_varchar2_rows is
105109
l_schema varchar2(128);
106110
c_current_schema constant varchar2(128) := sys_context('USERENV','CURRENT_SCHEMA');
107111
l_path varchar2(32767);
108-
l_schemes ut_varchar2_list;
112+
l_schemes ut_varchar2_rows;
109113
begin
110114
if run_paths is not null then
111-
l_schemes := ut_varchar2_list();
115+
l_schemes := ut_varchar2_rows();
112116
for i in 1 .. self.run_paths.count loop
113117
l_path := self.run_paths(i);
114118
if regexp_like(l_path, '^([A-Za-z0-9$#_]+)?:') then
@@ -131,7 +135,7 @@ create or replace type body ut_run as
131135
l_schemes(l_schemes.last) := l_schema;
132136
end loop;
133137
else
134-
l_schemes := ut_varchar2_list(c_current_schema);
138+
l_schemes := ut_varchar2_rows(c_current_schema);
135139
end if;
136140
return l_schemes;
137141

source/core/types/ut_run.tps

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,19 @@ create or replace type ut_run under ut_suite_item (
2424
coverage_options ut_coverage_options,
2525
test_file_mappings ut_file_mappings,
2626
constructor function ut_run(
27-
self in out nocopy ut_run, a_items ut_suite_items, a_run_paths ut_varchar2_list := null,
28-
a_coverage_options ut_coverage_options := null, a_test_file_mappings ut_file_mappings := null
27+
self in out nocopy ut_run,
28+
a_items ut_suite_items,
29+
a_run_paths ut_varchar2_list := null,
30+
a_schema_names ut_varchar2_rows := null,
31+
a_exclude_objects ut_object_names := null,
32+
a_include_objects ut_object_names := null,
33+
a_project_file_mappings ut_file_mappings := null,
34+
a_test_file_mappings ut_file_mappings := null
2935
) return self as result,
3036
overriding member function do_execute(self in out nocopy ut_run, a_listener in out nocopy ut_event_listener_base) return boolean,
3137
overriding member procedure calc_execution_result(self in out nocopy ut_run),
3238
overriding member procedure mark_as_errored(self in out nocopy ut_run, a_listener in out nocopy ut_event_listener_base, a_error_stack_trace varchar2),
33-
member function get_run_schemes return ut_varchar2_list,
39+
member function get_run_schemes return ut_varchar2_rows,
3440
overriding member function get_error_stack_traces return ut_varchar2_list,
3541
overriding member function get_serveroutputs return clob
3642
)

source/core/ut_output_buffer.pkb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ create or replace package body ut_output_buffer is
1717
*/
1818

1919
procedure send_line(a_reporter ut_reporter_base, a_text varchar2) is
20-
l_text_list ut_varchar2_list;
20+
l_text_list ut_varchar2_rows;
2121
pragma autonomous_transaction;
2222
begin
2323
if a_reporter is not null and a_reporter.reporter_id is not null and a_reporter.start_date is not null and a_text is not null then
2424
if length(a_text) > ut_utils.gc_max_storage_varchar2_len then
25-
l_text_list := ut_utils.clob_to_table(a_text, ut_utils.gc_max_storage_varchar2_len);
25+
l_text_list := ut_utils.convert_collection(ut_utils.clob_to_table(a_text, ut_utils.gc_max_storage_varchar2_len));
2626
insert /*+ append */
2727
into ut_output_buffer_tmp(start_date, reporter_id, message_id, text)
2828
select a_reporter.start_date, a_reporter.reporter_id, ut_message_id_seq.nextval, t.column_value

source/core/ut_suite_manager.pkb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ create or replace package body ut_suite_manager is
340340
end if;
341341
end get_schema_suites;
342342

343-
function get_schema_ut_packages(a_schema_names ut_varchar2_list) return ut_object_names is
343+
function get_schema_ut_packages(a_schema_names ut_varchar2_rows) return ut_object_names is
344344
l_schema_ut_packages ut_object_names := ut_object_names();
345345
l_schema_suites tt_schema_suites;
346346
l_iter varchar2(4000);

source/core/ut_suite_manager.pks

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ create or replace package ut_suite_manager authid current_user is
2020

2121
procedure config_schema(a_owner_name varchar2);
2222

23-
function get_schema_ut_packages(a_schema_names ut_varchar2_list) return ut_object_names;
23+
function get_schema_ut_packages(a_schema_names ut_varchar2_rows) return ut_object_names;
2424

2525
--INTERNAL USE
2626
function configure_execution_by_path(a_paths in ut_varchar2_list) return ut_suite_items;

source/core/ut_utils.pkb

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,5 +328,18 @@ create or replace package body ut_utils is
328328
end if;
329329
end;
330330

331+
function convert_collection(a_collection ut_varchar2_list) return ut_varchar2_rows is
332+
l_result ut_varchar2_rows;
333+
begin
334+
if a_collection is not null then
335+
l_result := ut_varchar2_rows();
336+
for i in 1 .. a_collection.count loop
337+
l_result.extend();
338+
l_result(i) := substr(a_collection(i),1,gc_max_storage_varchar2_len);
339+
end loop;
340+
end if;
341+
return l_result;
342+
end;
343+
331344
end ut_utils;
332-
/
345+
/

0 commit comments

Comments
 (0)