All files (95.04% lines covered at 588 hits/line)
102 files in total.
4741 relevant lines. 4506 lines covered (including 20 lines partially covered ) and 235 lines missed.
UT3.UT
93.2 % lines covered
103 relevant lines. 96 lines covered and 7 lines missed
package body ut is
/*
utPLSQL - Version 3
Copyright 2016 - 2019 utPLSQL Project
Licensed under the Apache License, Version 2.0 (the "License"):
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
g_nls_date_format varchar2(4000);
- 1
gc_fail_on_errors constant boolean := false;
g_result_line_no binary_integer;
- 1
g_result_lines ut_varchar2_list := ut_varchar2_list();
function version return varchar2 is
begin
- 117
return ut_runner.version();
end;
function expect(a_actual in anydata, a_message varchar2 := null) return ut_expectation_compound is
begin
- 109
return ut_expectation_compound(ut_data_value_anydata(a_actual), a_message);
end;
function expect(a_actual in blob, a_message varchar2 := null) return ut_expectation is
begin
- 23
return ut_expectation(ut_data_value_blob(a_actual), a_message);
end;
function expect(a_actual in boolean, a_message varchar2 := null) return ut_expectation is
begin
- 29
return ut_expectation(ut_data_value_boolean(a_actual), a_message);
end;
function expect(a_actual in clob, a_message varchar2 := null) return ut_expectation is
begin
- 48
return ut_expectation(ut_data_value_clob(a_actual), a_message);
end;
function expect(a_actual in date, a_message varchar2 := null) return ut_expectation is
begin
- 42
return ut_expectation(ut_data_value_date(a_actual), a_message);
end;
function expect(a_actual in number, a_message varchar2 := null) return ut_expectation is
begin
- 122
return ut_expectation(ut_data_value_number(a_actual), a_message);
end;
function expect(a_actual in timestamp_unconstrained, a_message varchar2 := null) return ut_expectation is
begin
- 42
return ut_expectation(ut_data_value_timestamp(a_actual), a_message);
end;
function expect(a_actual in timestamp_ltz_unconstrained, a_message varchar2 := null) return ut_expectation is
begin
- 44
return ut_expectation(ut_data_value_timestamp_ltz(a_actual), a_message);
end;
function expect(a_actual in timestamp_tz_unconstrained, a_message varchar2 := null) return ut_expectation is
begin
- 40
return ut_expectation(ut_data_value_timestamp_tz(a_actual), a_message);
end;
function expect(a_actual in varchar2, a_message varchar2 := null) return ut_expectation is
begin
- 57
return ut_expectation(ut_data_value_varchar2(a_actual), a_message);
end;
function expect(a_actual in sys_refcursor, a_message varchar2 := null) return ut_expectation_compound is
begin
- 153
return ut_expectation_compound(ut_data_value_refcursor(a_actual), a_message);
end;
function expect(a_actual in yminterval_unconstrained, a_message varchar2 := null) return ut_expectation is
begin
- 34
return ut_expectation(ut_data_value_yminterval(a_actual), a_message);
end;
function expect(a_actual in dsinterval_unconstrained, a_message varchar2 := null) return ut_expectation is
begin
- 34
return ut_expectation(ut_data_value_dsinterval(a_actual), a_message);
end;
function expect(a_actual in json_element_t , a_message varchar2 := null) return ut_expectation_json is
begin
- 23
return ut_expectation_json(ut_data_value_json(a_actual), a_message);
end;
procedure fail(a_message in varchar2) is
begin
- 1
ut_expectation_processor.report_failure(a_message);
end;
procedure raise_if_packages_invalidated is
e_package_invalidated exception;
pragma exception_init (e_package_invalidated, -04068);
begin
- 113
if ut_expectation_processor.invalidation_exception_found() then
- 1
ut_expectation_processor.reset_invalidation_exception();
- 1
raise e_package_invalidated;
end if;
end;
procedure run_autonomous(
a_paths ut_varchar2_list,
a_reporter in out nocopy ut_reporter_base,
a_color_console integer,
a_coverage_schemes ut_varchar2_list,
a_source_file_mappings ut_file_mappings,
a_test_file_mappings ut_file_mappings,
a_include_objects ut_varchar2_list,
a_exclude_objects ut_varchar2_list,
a_client_character_set varchar2,
a_random_test_order integer,
a_random_test_order_seed positive,
a_tags varchar2 := null
) is
pragma autonomous_transaction;
begin
- 102
a_reporter := coalesce(a_reporter,ut_documentation_reporter());
- 102
ut_runner.run(
a_paths,
ut_reporters(a_reporter),
ut_utils.int_to_boolean(a_color_console),
a_coverage_schemes,
a_source_file_mappings,
a_test_file_mappings,
a_include_objects,
a_exclude_objects,
gc_fail_on_errors,
a_client_character_set,
false,
ut_utils.int_to_boolean(a_random_test_order),
a_random_test_order_seed,
a_tags
);
- 101
rollback;
end;
procedure run_autonomous(
a_paths ut_varchar2_list,
a_reporter in out nocopy ut_reporter_base,
a_color_console integer,
a_coverage_schemes ut_varchar2_list,
a_source_files ut_varchar2_list,
a_test_files ut_varchar2_list,
a_include_objects ut_varchar2_list,
a_exclude_objects ut_varchar2_list,
a_client_character_set varchar2,
a_random_test_order integer,
a_random_test_order_seed positive,
a_tags varchar2 := null
) is
pragma autonomous_transaction;
begin
- 10
a_reporter := coalesce(a_reporter,ut_documentation_reporter());
- 10
ut_runner.run(
a_paths,
ut_reporters(a_reporter),
ut_utils.int_to_boolean(a_color_console),
a_coverage_schemes,
ut_file_mapper.build_file_mappings(a_source_files),
ut_file_mapper.build_file_mappings(a_test_files),
a_include_objects,
a_exclude_objects,
gc_fail_on_errors,
a_client_character_set,
false,
ut_utils.int_to_boolean(a_random_test_order),
a_random_test_order_seed,
a_tags
);
- 10
rollback;
end;
function get_report_outputs( a_cursor sys_refcursor ) return varchar2 is
l_clob clob;
l_item_type varchar2(32767);
l_result varchar2(4000);
begin
- 18750
if g_result_line_no is null then
- 16627
fetch a_cursor into l_clob, l_item_type;
- 16627
if a_cursor%notfound then
- 81
close a_cursor;
- 81
g_result_line_no := null;
- 81
g_result_lines := ut_varchar2_list();
- 81
raise_if_packages_invalidated();
- 80
raise no_data_found;
end if;
- 16546
g_result_lines := ut_utils.clob_to_table(l_clob, ut_utils.gc_max_storage_varchar2_len);
- 16546
g_result_line_no := g_result_lines.first;
end if;
- 18669
if g_result_line_no is not null then
- 18669
l_result := g_result_lines(g_result_line_no);
- 18669
g_result_line_no := g_result_lines.next(g_result_line_no);
end if;
- 18669
return l_result;
end;
function run(
a_reporter ut_reporter_base := null,
a_color_console integer := 0,
a_coverage_schemes ut_varchar2_list := null,
a_source_file_mappings ut_file_mappings := null,
a_test_file_mappings ut_file_mappings := null,
a_include_objects ut_varchar2_list := null,
a_exclude_objects ut_varchar2_list := null,
a_client_character_set varchar2 := null,
a_random_test_order integer := 0,
a_random_test_order_seed positive := null,
a_tags varchar2 := null
) return ut_varchar2_rows pipelined is
- 3
l_reporter ut_reporter_base := a_reporter;
l_results sys_refcursor;
begin
- 3
run_autonomous(
ut_varchar2_list(),
l_reporter,
a_color_console,
a_coverage_schemes,
a_source_file_mappings,
a_test_file_mappings,
a_include_objects,
a_exclude_objects,
a_client_character_set,
a_random_test_order,
a_random_test_order_seed,
a_tags
);
- 3
if l_reporter is of (ut_output_reporter_base) then
- 3
l_results := treat(l_reporter as ut_output_reporter_base).get_lines_cursor();
- 90
loop
- 90
pipe row( get_report_outputs( l_results ) );
end loop;
end if;
return;
end;
function run(
a_reporter ut_reporter_base := null,
a_color_console integer := 0,
a_coverage_schemes ut_varchar2_list := null,
a_source_files ut_varchar2_list,
a_test_files ut_varchar2_list,
a_include_objects ut_varchar2_list := null,
a_exclude_objects ut_varchar2_list := null,
a_client_character_set varchar2 := null,
a_random_test_order integer := 0,
a_random_test_order_seed positive := null,
a_tags varchar2 := null
) return ut_varchar2_rows pipelined is
- 1
l_reporter ut_reporter_base := a_reporter;
l_results sys_refcursor;
begin
- 1
run_autonomous(
ut_varchar2_list(),
l_reporter,
a_color_console,
a_coverage_schemes,
a_source_files,
a_test_files,
a_include_objects,
a_exclude_objects,
a_client_character_set,
a_random_test_order,
a_random_test_order_seed,
a_tags
);
- 1
if l_reporter is of (ut_output_reporter_base) then
- 1
l_results := treat(l_reporter as ut_output_reporter_base).get_lines_cursor();
- 30
loop
- 30
pipe row( get_report_outputs( l_results ) );
end loop;
end if;
return;
end;
function run(
a_paths ut_varchar2_list,
a_reporter ut_reporter_base := null,
a_color_console integer := 0,
a_coverage_schemes ut_varchar2_list := null,
a_source_file_mappings ut_file_mappings := null,
a_test_file_mappings ut_file_mappings := null,
a_include_objects ut_varchar2_list := null,
a_exclude_objects ut_varchar2_list := null,
a_client_character_set varchar2 := null,
a_random_test_order integer := 0,
a_random_test_order_seed positive := null,
a_tags varchar2 := null
) return ut_varchar2_rows pipelined is
- 6
l_reporter ut_reporter_base := a_reporter;
l_results sys_refcursor;
begin
- 6
run_autonomous(
a_paths,
l_reporter,
a_color_console,
a_coverage_schemes,
a_source_file_mappings,
a_test_file_mappings,
a_include_objects,
a_exclude_objects,
a_client_character_set,
a_random_test_order,
a_random_test_order_seed,
a_tags
);
- 6
if l_reporter is of (ut_output_reporter_base) then
- 6
l_results := treat(l_reporter as ut_output_reporter_base).get_lines_cursor();
- 158
loop
- 158
pipe row( get_report_outputs( l_results ) );
end loop;
end if;
return;
end;
function run(
a_paths ut_varchar2_list,
a_reporter ut_reporter_base := null,
a_color_console integer := 0,
a_coverage_schemes ut_varchar2_list := null,
a_source_files ut_varchar2_list,
a_test_files ut_varchar2_list,
a_include_objects ut_varchar2_list := null,
a_exclude_objects ut_varchar2_list := null,
a_client_character_set varchar2 := null,
a_random_test_order integer := 0,
a_random_test_order_seed positive := null,
a_tags varchar2 := null
) return ut_varchar2_rows pipelined is
- 1
l_reporter ut_reporter_base := a_reporter;
l_results sys_refcursor;
begin
- 1
run_autonomous(
a_paths,
l_reporter,
a_color_console,
a_coverage_schemes,
a_source_files,
a_test_files,
a_include_objects,
a_exclude_objects,
a_client_character_set,
a_random_test_order,
a_random_test_order_seed,
a_tags
);
- 1
if l_reporter is of (ut_output_reporter_base) then
- 1
l_results := treat(l_reporter as ut_output_reporter_base).get_lines_cursor();
- 44
loop
- 44
pipe row( get_report_outputs( l_results ) );
end loop;
end if;
return;
end;
function run(
a_path varchar2,
a_reporter ut_reporter_base := null,
a_color_console integer := 0,
a_coverage_schemes ut_varchar2_list := null,
a_source_file_mappings ut_file_mappings := null,
a_test_file_mappings ut_file_mappings := null,
a_include_objects ut_varchar2_list := null,
a_exclude_objects ut_varchar2_list := null,
a_client_character_set varchar2 := null,
a_random_test_order integer := 0,
a_random_test_order_seed positive := null,
a_tags varchar2 := null
) return ut_varchar2_rows pipelined is
- 63
l_reporter ut_reporter_base := a_reporter;
l_results sys_refcursor;
begin
- 63
run_autonomous(
ut_varchar2_list(a_path),
l_reporter,
a_color_console,
a_coverage_schemes,
a_source_file_mappings,
a_test_file_mappings,
a_include_objects,
a_exclude_objects,
a_client_character_set,
a_random_test_order,
a_random_test_order_seed,
a_tags
);
- 62
if l_reporter is of (ut_output_reporter_base) then
- 62
l_results := treat(l_reporter as ut_output_reporter_base).get_lines_cursor();
- 18260
loop
- 18260
pipe row( get_report_outputs( l_results ) );
end loop;
end if;
return;
end;
function run(
a_path varchar2,
a_reporter ut_reporter_base := null,
a_color_console integer := 0,
a_coverage_schemes ut_varchar2_list := null,
a_source_files ut_varchar2_list,
a_test_files ut_varchar2_list,
a_include_objects ut_varchar2_list := null,
a_exclude_objects ut_varchar2_list := null,
a_client_character_set varchar2 := null,
a_random_test_order integer := 0,
a_random_test_order_seed positive := null,
a_tags varchar2 := null
) return ut_varchar2_rows pipelined is
- 8
l_reporter ut_reporter_base := a_reporter;
l_results sys_refcursor;
begin
- 8
run_autonomous(
ut_varchar2_list(a_path),
l_reporter,
a_color_console,
a_coverage_schemes,
a_source_files,
a_test_files,
a_include_objects,
a_exclude_objects,
a_client_character_set,
a_random_test_order,
a_random_test_order_seed,
a_tags
);
- 8
if l_reporter is of (ut_output_reporter_base) then
- 8
l_results := treat(l_reporter as ut_output_reporter_base).get_lines_cursor();
- 168
loop
- 168
pipe row( get_report_outputs( l_results ) );
end loop;
end if;
return;
end;
procedure run(
a_paths ut_varchar2_list,
a_reporter ut_reporter_base := null,
a_color_console boolean := false,
a_coverage_schemes ut_varchar2_list := null,
a_source_file_mappings ut_file_mappings := null,
a_test_file_mappings ut_file_mappings := null,
a_include_objects ut_varchar2_list := null,
a_exclude_objects ut_varchar2_list := null,
a_client_character_set varchar2 := null,
a_force_manual_rollback boolean := false,
a_random_test_order boolean := false,
a_random_test_order_seed positive := null,
a_tags varchar2 := null
) is
- 32
l_reporter ut_reporter_base := a_reporter;
begin
- 32
if a_force_manual_rollback then
- 2
l_reporter := coalesce(l_reporter,ut_documentation_reporter());
- 2
ut_runner.run(
a_paths,
ut_reporters(l_reporter),
a_color_console,
a_coverage_schemes,
a_source_file_mappings,
a_test_file_mappings,
a_include_objects,
a_exclude_objects,
gc_fail_on_errors,
a_client_character_set,
a_force_manual_rollback,
a_random_test_order,
a_random_test_order_seed,
a_tags
);
else
- 30
run_autonomous(
a_paths,
l_reporter,
ut_utils.boolean_to_int(a_color_console),
a_coverage_schemes,
a_source_file_mappings,
a_test_file_mappings,
a_include_objects,
a_exclude_objects,
a_client_character_set,
ut_utils.boolean_to_int(a_random_test_order),
a_random_test_order_seed,
a_tags
);
end if;
- 32
if l_reporter is of (ut_output_reporter_base) then
- 32
treat(l_reporter as ut_output_reporter_base).lines_to_dbms_output();
end if;
- 32
raise_if_packages_invalidated();
end;
procedure run(
a_paths ut_varchar2_list,
a_reporter ut_reporter_base := null,
a_color_console boolean := false,
a_coverage_schemes ut_varchar2_list := null,
a_source_files ut_varchar2_list,
a_test_files ut_varchar2_list,
a_include_objects ut_varchar2_list := null,
a_exclude_objects ut_varchar2_list := null,
a_client_character_set varchar2 := null,
a_force_manual_rollback boolean := false,
a_random_test_order boolean := false,
a_random_test_order_seed positive := null,
a_tags varchar2 := null
) is
- 4
l_reporter ut_reporter_base := a_reporter;
begin
- 4
ut.run(
a_paths,
l_reporter,
a_color_console,
a_coverage_schemes,
ut_file_mapper.build_file_mappings(a_source_files),
ut_file_mapper.build_file_mappings(a_test_files),
a_include_objects,
a_exclude_objects,
a_client_character_set,
a_force_manual_rollback,
a_random_test_order,
a_random_test_order_seed,
a_tags
);
end;
procedure run(
a_reporter ut_reporter_base := null,
a_color_console boolean := false,
a_coverage_schemes ut_varchar2_list := null,
a_source_file_mappings ut_file_mappings := null,
a_test_file_mappings ut_file_mappings := null,
a_include_objects ut_varchar2_list := null,
a_exclude_objects ut_varchar2_list := null,
a_client_character_set varchar2 := null,
a_force_manual_rollback boolean := false,
a_random_test_order boolean := false,
a_random_test_order_seed positive := null,
a_tags varchar2 := null
) is
begin
- 11
ut.run(
ut_varchar2_list(),
a_reporter,
a_color_console,
a_coverage_schemes,
a_source_file_mappings,
a_test_file_mappings,
a_include_objects,
a_exclude_objects,
a_client_character_set,
a_force_manual_rollback,
a_random_test_order,
a_random_test_order_seed,
a_tags
);
end;
procedure run(
a_reporter ut_reporter_base := null,
a_color_console boolean := false,
a_coverage_schemes ut_varchar2_list := null,
a_source_files ut_varchar2_list,
a_test_files ut_varchar2_list,
a_include_objects ut_varchar2_list := null,
a_exclude_objects ut_varchar2_list := null,
a_client_character_set varchar2 := null,
a_force_manual_rollback boolean := false,
a_random_test_order boolean := false,
a_random_test_order_seed positive := null,
a_tags varchar2 := null
) is
begin
ut.run(
ut_varchar2_list(),
a_reporter,
a_color_console,
a_coverage_schemes,
a_source_files,
a_test_files,
a_include_objects,
a_exclude_objects,
a_client_character_set,
a_force_manual_rollback,
a_random_test_order,
a_random_test_order_seed,
a_tags
);
end;
procedure run(
a_path varchar2,
a_reporter ut_reporter_base := null,
a_color_console boolean := false,
a_coverage_schemes ut_varchar2_list := null,
a_source_file_mappings ut_file_mappings := null,
a_test_file_mappings ut_file_mappings := null,
a_include_objects ut_varchar2_list := null,
a_exclude_objects ut_varchar2_list := null,
a_client_character_set varchar2 := null,
a_force_manual_rollback boolean := false,
a_random_test_order boolean := false,
a_random_test_order_seed positive := null,
a_tags varchar2 := null
) is
begin
- 14
ut.run(
ut_varchar2_list(a_path),
a_reporter,
a_color_console,
a_coverage_schemes,
a_source_file_mappings,
a_test_file_mappings,
a_include_objects,
a_exclude_objects,
a_client_character_set,
a_force_manual_rollback,
a_random_test_order,
a_random_test_order_seed,
a_tags
);
end;
procedure run(
a_path varchar2,
a_reporter ut_reporter_base := null,
a_color_console boolean := false,
a_coverage_schemes ut_varchar2_list := null,
a_source_files ut_varchar2_list,
a_test_files ut_varchar2_list,
a_include_objects ut_varchar2_list := null,
a_exclude_objects ut_varchar2_list := null,
a_client_character_set varchar2 := null,
a_force_manual_rollback boolean := false,
a_random_test_order boolean := false,
a_random_test_order_seed positive := null,
a_tags varchar2 := null
) is
begin
- 3
ut.run(
ut_varchar2_list(a_path),
a_reporter,
a_color_console,
a_coverage_schemes,
a_source_files,
a_test_files,
a_include_objects,
a_exclude_objects,
a_client_character_set,
a_force_manual_rollback,
a_random_test_order,
a_random_test_order_seed,
a_tags
);
end;
procedure set_nls is
begin
- 4
if g_nls_date_format is null then
- 4
select nsp.value
into g_nls_date_format
from nls_session_parameters nsp
where parameter = 'NLS_DATE_FORMAT';
end if;
- 4
execute immediate 'alter session set nls_date_format = '''||ut_utils.gc_date_format||'''';
end;
procedure reset_nls is
begin
- 4
if g_nls_date_format is not null then
- 4
execute immediate 'alter session set nls_date_format = '''||g_nls_date_format||'''';
end if;
- 4
g_nls_date_format := null;
end;
end ut;
UT3.UT_RUNNER
93.5 % lines covered
123 relevant lines. 115 lines covered (including 1 lines partially covered ) and 8 lines missed
package body ut_runner is
/*
utPLSQL - Version 3
Copyright 2016 - 2019 utPLSQL Project
Licensed under the Apache License, Version 2.0 (the "License"):
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/**
* Private functions
*/
function to_ut_object_list(a_names ut_varchar2_list, a_schema_names ut_varchar2_rows) return ut_object_names is
l_result ut_object_names;
l_object_name ut_object_name;
begin
- 116
if a_names is not empty then
- 3
l_result := ut_object_names();
- 6
for i in 1 .. a_names.count loop
- 3
l_object_name := ut_object_name(a_names(i));
- 3
if l_object_name.owner is null then
for i in 1 .. cardinality(a_schema_names) loop
l_result.extend;
l_result(l_result.last) := ut_object_name(a_schema_names(i)||'.'||l_object_name.name);
end loop;
else
- 3
l_result.extend;
- 3
l_result(l_result.last) := l_object_name;
end if;
end loop;
end if;
- 116
return l_result;
end;
procedure finish_run(a_run ut_run, a_force_manual_rollback boolean) is
begin
- 116
ut_event_manager.trigger_event(ut_event_manager.gc_finalize, a_run);
- 117
ut_metadata.reset_source_definition_cache;
- 116
ut_utils.read_cache_to_dbms_output();
- 222
ut_coverage_helper.cleanup_tmp_table();
- 232
ut_compound_data_helper.cleanup_diff();
- 116
if not a_force_manual_rollback then
- 114
rollback;
- 114
ut_utils.cleanup_session_temp_tables;
end if;
end;
/**
* Public functions
*/
function version return varchar2 is
begin
- 118
return ut_utils.gc_version;
end;
function version_compatibility_check( a_requested varchar2, a_current varchar2 := null ) return integer is
- 16
l_result boolean := false;
- 16
l_requested ut_utils.t_version := ut_utils.to_version(a_requested);
- 15
l_current ut_utils.t_version := ut_utils.to_version(coalesce(a_current,version()));
begin
- 14
if l_requested.major = l_current.major
- 1
and (l_requested.minor < l_current.minor or l_requested.minor is null
- 1
or l_requested.minor = l_current.minor and (l_requested.bugfix <= l_current.bugfix or l_requested.bugfix is null)) then
- 10
l_result := true;
end if;
- 14
return ut_utils.boolean_to_int(l_result);
end;
procedure run(
a_paths ut_varchar2_list,
a_reporters ut_reporters,
a_color_console boolean := false,
a_coverage_schemes ut_varchar2_list := null,
a_source_file_mappings ut_file_mappings := null,
a_test_file_mappings ut_file_mappings := null,
a_include_objects ut_varchar2_list := null,
a_exclude_objects ut_varchar2_list := null,
a_fail_on_errors boolean := false,
a_client_character_set varchar2 := null,
a_force_manual_rollback boolean := false,
a_random_test_order boolean := false,
a_random_test_order_seed positive := null,
a_tags varchar2 := null
) is
l_run ut_run;
l_coverage_schema_names ut_varchar2_rows;
- 116
l_exclude_object_names ut_object_names := ut_object_names();
l_include_object_names ut_object_names;
- 116
l_paths ut_varchar2_list := ut_varchar2_list();
l_random_test_order_seed positive;
- 116
l_tags ut_varchar2_rows := ut_varchar2_rows();
begin
- 232
ut_event_manager.initialize();
- 116
if a_reporters is not empty then
- 232
for i in 1 .. a_reporters.count loop
- 116
ut_event_manager.add_listener( a_reporters(i) );
end loop;
else
ut_event_manager.add_listener( ut_documentation_reporter() );
end if;
- 116
ut_event_manager.add_listener( ut_session_info() );
- 116
ut_event_manager.trigger_event(ut_event_manager.gc_initialize);
- 116
ut_event_manager.trigger_event(ut_event_manager.gc_debug, ut_run_info());
- 116
if a_random_test_order_seed is not null then
- 4
l_random_test_order_seed := a_random_test_order_seed;
- 112
elsif a_random_test_order then
dbms_random.seed( to_char(systimestamp,'yyyyddmmhh24missffff') );
l_random_test_order_seed := trunc(dbms_random.value(1, 1000000000));
end if;
- 116
if a_paths is null or a_paths is empty or a_paths.count = 1 and a_paths(1) is null then
- 21
l_paths := ut_varchar2_list(sys_context('userenv', 'current_schema'));
else
- 196
for i in 1..a_paths.count loop
- 101
l_paths := l_paths multiset union ut_utils.string_to_table(a_string => a_paths(i),a_delimiter => ',');
end loop;
end if;
begin
- 232
ut_expectation_processor.reset_invalidation_exception();
- 116
ut_utils.save_dbms_output_to_cache();
- 116
ut_console_reporter_base.set_color_enabled(a_color_console);
- 116
if a_coverage_schemes is not empty then
- 1
l_coverage_schema_names := ut_utils.convert_collection(a_coverage_schemes);
else
- 115
l_coverage_schema_names := ut_suite_manager.get_schema_names(l_paths);
end if;
- 116
if a_exclude_objects is not empty then
l_exclude_object_names := to_ut_object_list(a_exclude_objects, l_coverage_schema_names);
end if;
- 116
if a_tags is not null then
- 16
l_tags := l_tags multiset union distinct ut_utils.convert_collection(
ut_utils.trim_list_elements(ut_utils.filter_list(ut_utils.string_to_table(a_tags,','),ut_utils.gc_word_no_space))
);
end if;
- 116
l_exclude_object_names := l_exclude_object_names multiset union all ut_suite_manager.get_schema_ut_packages(l_coverage_schema_names);
- 116
l_include_object_names := to_ut_object_list(a_include_objects, l_coverage_schema_names);
- 116
l_run := ut_run(
null,
l_paths,
l_coverage_schema_names,
l_exclude_object_names,
l_include_object_names,
set(a_source_file_mappings),
set(a_test_file_mappings),
a_client_character_set,
l_random_test_order_seed,
l_tags
);
- 116
ut_suite_manager.configure_execution_by_path(l_paths, l_run.items, l_random_test_order_seed, l_tags);
- 115
if a_force_manual_rollback then
- 2
l_run.set_rollback_type( a_rollback_type => ut_utils.gc_rollback_manual, a_force => true );
end if;
- 115
l_run.do_execute();
- 115
finish_run(l_run, a_force_manual_rollback);
exception
- 2
when others then
- 1
finish_run(l_run, a_force_manual_rollback);
- 1
dbms_output.put_line(dbms_utility.format_error_backtrace);
- 1
dbms_output.put_line(dbms_utility.format_error_stack);
- 1
raise;
end;
- 1/2 115
if a_fail_on_errors and l_run.result in (ut_utils.gc_failure, ut_utils.gc_error) then
- 1
raise_application_error(ut_utils.gc_some_tests_failed, 'Some tests failed');
end if;
end;
procedure rebuild_annotation_cache(a_object_owner varchar2, a_object_type varchar2 := null) is
begin
- 2
ut_annotation_manager.rebuild_annotation_cache(a_object_owner, coalesce(a_object_type,'PACKAGE'));
end;
procedure purge_cache(a_object_owner varchar2 := null, a_object_type varchar2 := null) is
begin
- 1
ut_annotation_manager.purge_cache(a_object_owner, a_object_type);
end;
function get_suites_info(a_owner varchar2 := null, a_package_name varchar2 := null) return ut_suite_items_info pipelined is
l_cursor sys_refcursor;
l_results ut_suite_items_info;
- 3
c_bulk_limit constant integer := 100;
begin
- 3
l_cursor := ut_suite_manager.get_suites_info( nvl(a_owner,sys_context('userenv', 'current_schema')), a_package_name );
- 3
loop
- 3
fetch l_cursor bulk collect into l_results limit c_bulk_limit;
- 13
for i in 1 .. l_results.count loop
- 10
pipe row (l_results(i));
end loop;
- 3
exit when l_cursor%notfound;
end loop;
- 3
close l_cursor;
- 3
return;
end;
function is_test(a_owner varchar2, a_package_name varchar2, a_procedure_name varchar2) return boolean is
- 7
l_result boolean := false;
begin
- 7
if a_owner is not null and a_package_name is not null and a_procedure_name is not null then
- 4
l_result := ut_suite_manager.suite_item_exists( a_owner, a_package_name, a_procedure_name );
end if;
- 7
return l_result;
end;
function is_suite(a_owner varchar2, a_package_name varchar2) return boolean is
- 6
l_result boolean := false;
begin
- 6
if a_owner is not null and a_package_name is not null then
- 4
l_result := ut_suite_manager.suite_item_exists( a_owner, a_package_name );
end if;
- 6
return l_result;
end;
function has_suites(a_owner varchar2) return boolean is
- 5
l_result boolean := false;
begin
- 5
if a_owner is not null then
- 4
l_result := ut_suite_manager.suite_item_exists( a_owner );
end if;
- 5
return l_result;
end;
function get_reporters_list return tt_reporters_info pipelined is
- 1
l_owner varchar2(128) := upper(ut_utils.ut_owner());
l_reporters ut_reporters_info;
l_result t_reporter_rec;
begin
- 4
loop
- 4
l_reporters := ut_utils.get_child_reporters( l_reporters );
- 4
exit when l_reporters is null or l_reporters.count = 0;
- 18
for i in 1 .. l_reporters.count loop
- 15
if l_reporters(i).is_instantiable = 'Y' then
- 12
l_result.reporter_object_name := l_owner||'.'||l_reporters(i).object_name;
- 12
l_result.is_output_reporter := l_reporters(i).is_output_reporter;
- 12
pipe row( l_result );
end if;
end loop;
end loop;
end;
function hash_suite_path(a_path varchar2, a_random_seed positiven) return varchar2 is
- 16
l_start_pos pls_integer := 1;
- 16
l_end_pos pls_integer := 1;
l_result varchar2(4000);
l_item varchar2(4000);
- 16
l_at_end boolean := false;
begin
- 16
if a_random_seed is null then
l_result := a_path;
end if;
- 16
if a_path is not null then
- 36
loop
- 36
l_end_pos := instr(a_path,'.',l_start_pos);
- 36
if l_end_pos = 0 then
- 16
l_end_pos := length(a_path)+1;
- 16
l_at_end := true;
end if;
- 36
l_item := substr(a_path,l_start_pos,l_end_pos-l_start_pos);
- 36
if l_item is not null then
- 36
l_result :=
l_result ||
ut_utils.get_hash( to_char( dbms_utility.get_hash_value( l_item, 1, a_random_seed ) ) );
end if;
- 36
exit when l_at_end;
- 20
l_result := l_result || chr(0);
- 20
l_start_pos := l_end_pos + 1;
end loop;
end if;
- 16
return l_result;
end;
end ut_runner;
UT3.UT_SUITE_ITEM_INFO
100 % lines covered
12 relevant lines. 12 lines covered and 0 lines missed
type body ut_suite_item_info is
/*
utPLSQL - Version 3
Copyright 2016 - 2019 utPLSQL Project
Licensed under the Apache License, Version 2.0 (the "License"):
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
constructor function ut_suite_item_info(a_object_owner varchar2, a_object_name varchar2, a_item_name varchar2,
a_item_description varchar2, a_item_type varchar2, a_item_line_no integer, a_path varchar2, a_disabled_flag integer,
a_tags ut_varchar2_rows) return self as result is
begin
- 10
self.object_owner := a_object_owner;
- 10
self.object_name := a_object_name;
- 10
self.item_name := a_item_name;
- 10
self.item_description := a_item_description;
- 10
self.item_type := a_item_type;
- 10
self.item_line_no := a_item_line_no;
- 10
self.path := a_path;
- 10
self.disabled_flag := a_disabled_flag;
- 10
self.tags := case
- 1
when a_tags is null then null
- 1
when a_tags.count = 0 then null
else ut_utils.to_string(ut_utils.table_to_clob(a_tags,',') ,a_quote_char => null)
end;
- 10
return;
end;
end;
UT3.UT_ANNOTATION_CACHE_MANAGER
95.12 % lines covered
41 relevant lines. 39 lines covered and 2 lines missed
package body ut_annotation_cache_manager as
/*
utPLSQL - Version 3
Copyright 2016 - 2019 utPLSQL Project
Licensed under the Apache License, Version 2.0 (the "License"):
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
procedure update_cache(a_object ut_annotated_object) is
l_cache_id integer;
- 415
l_timestamp timestamp := systimestamp;
pragma autonomous_transaction;
begin
- 415
update ut_annotation_cache_schema s
set s.max_parse_time = l_timestamp
where s.object_type = a_object.object_type and s.object_owner = a_object.object_owner;
- 415
if sql%rowcount = 0 then
- 5
insert into ut_annotation_cache_schema s
(object_owner, object_type, max_parse_time)
values (a_object.object_owner, a_object.object_type, l_timestamp);
end if;
-- if not in trigger, or object has annotations
- 415
if ora_sysevent is null or a_object.annotations is not null and a_object.annotations.count > 0 then
- 376
update ut_annotation_cache_info i
set i.parse_time = l_timestamp,
i.is_annotated = case when a_object.annotations is not empty then 'Y' else 'N' end
where (i.object_owner, i.object_name, i.object_type)
in ((a_object.object_owner, a_object.object_name, a_object.object_type))
returning cache_id into l_cache_id;
- 376
if sql%rowcount = 0 then
- 85
insert into ut_annotation_cache_info
(cache_id, object_owner, object_name, object_type, parse_time, is_annotated)
values (ut_annotation_cache_seq.nextval, a_object.object_owner, a_object.object_name, a_object.object_type, l_timestamp,
case when a_object.annotations is not empty then 'Y' else 'N' end
)
returning cache_id into l_cache_id;
end if;
end if;
- 415
delete from ut_annotation_cache c where cache_id = l_cache_id;
- 415
if a_object.annotations is not null and a_object.annotations.count > 0 then
- 376
insert into ut_annotation_cache
(cache_id, annotation_position, annotation_name, annotation_text, subobject_name)
select l_cache_id, a.position, a.name, a.text, a.subobject_name
from table(a_object.annotations) a;
end if;
- 415
commit;
end;
procedure reset_objects_cache(a_objects ut_annotation_objs_cache_info) is
- 85
l_timestamp timestamp := systimestamp;
pragma autonomous_transaction;
begin
- 85
delete from ut_annotation_cache c
where c.cache_id
in (select i.cache_id
from ut_annotation_cache_info i
join table (a_objects) o
on o.object_name = i.object_name
and o.object_type = i.object_type
and o.object_owner = i.object_owner
);
- 85
update ut_annotation_cache_schema s
set s.max_parse_time = l_timestamp
where (s.object_owner, s.object_type)
in (
select o.object_owner, o.object_type
from table(a_objects) o
);
- 85
if sql%rowcount = 0 then
- 1
insert into ut_annotation_cache_schema s
(object_owner, object_type, max_parse_time)
select distinct o.object_owner, o.object_type, l_timestamp
from table(a_objects) o;
end if;
- 85
merge into ut_annotation_cache_info i
using (select o.object_name, o.object_type, o.object_owner
from table(a_objects) o ) o
on (o.object_name = i.object_name
and o.object_type = i.object_type
and o.object_owner = i.object_owner)
when matched then
update
set parse_time = l_timestamp,
is_annotated = 'N'
when not matched then insert
(cache_id, object_owner, object_name, object_type, parse_time, is_annotated)
values (ut_annotation_cache_seq.nextval, o.object_owner, o.object_name, o.object_type, l_timestamp, 'N');
- 85
commit;
end;
function get_cached_objects_list(a_object_owner varchar2, a_object_type varchar2, a_parsed_after timestamp := null) return ut_annotation_objs_cache_info is
l_result ut_annotation_objs_cache_info;
begin
- 893
select ut_annotation_obj_cache_info(
object_owner => i.object_owner,
object_name => i.object_name,
object_type => i.object_type,
needs_refresh => 'N',
parse_time => i.parse_time
)
bulk collect into l_result
from ut_annotation_cache_info i
where i.object_owner = a_object_owner
and i.object_type = a_object_type
and (i.parse_time > a_parsed_after or a_parsed_after is null);
- 893
return l_result;
end;
function get_cache_schema_info(a_object_owner varchar2, a_object_type varchar2) return t_cache_schema_info is
l_result t_cache_schema_info;
begin
begin
- 327
select *
into l_result
from ut_annotation_cache_schema s
where s.object_type = a_object_type and s.object_owner = a_object_owner;
exception
- 6
when no_data_found then
- 3
null;
end;
- 327
return l_result;
end;
procedure set_fully_refreshed(a_object_owner varchar2, a_object_type varchar2) is
pragma autonomous_transaction;
begin
- 13
update ut_annotation_cache_schema s
set s.full_refresh_time = s.max_parse_time
where s.object_owner = a_object_owner
and s.object_type = a_object_type;
- 13
commit;
end;
procedure remove_from_cache(a_objects ut_annotation_objs_cache_info) is
pragma autonomous_transaction;
begin
- 388
delete from ut_annotation_cache_info i
where exists (
select 1 from table (a_objects) o
where o.object_name = i.object_name
and o.object_type = i.object_type
and o.object_owner = i.object_owner
);
- 388
commit;
end;
function get_annotations_parsed_since(a_object_owner varchar2, a_object_type varchar2, a_parsed_after timestamp) return sys_refcursor is
l_results sys_refcursor;
begin
- 317
open l_results for
select ut_annotated_object(
i.object_owner, i.object_name, i.object_type, i.parse_time,
cast(
collect(
ut_annotation(
c.annotation_position, c.annotation_name, c.annotation_text, c.subobject_name
) order by c.annotation_position
) as ut_annotations
)
) as annotated_object
from ut_annotation_cache_info i
join ut_annotation_cache c on i.cache_id = c.cache_id
where i.object_owner = a_object_owner and i.object_type = a_object_type
and (i.parse_time > a_parsed_after or a_parsed_after is null)
group by i.object_owner, i.object_type, i.object_name, i.parse_time;
- 317
return l_results;
end;
procedure purge_cache(a_object_owner varchar2, a_object_type varchar2) is
l_filter varchar2(32767);
l_cache_filter varchar2(32767);
pragma autonomous_transaction;
begin
- 2
if a_object_owner is null and a_object_type is null then
l_filter := ':a_object_owner is null and :a_object_type is null';
l_cache_filter := l_filter;
else
- 2
l_filter := case when a_object_owner is null then ':a_object_owner is null' else 'object_owner = :a_object_owner' end;
- 2
l_filter := l_filter || ' and ' || case when a_object_type is null then ':a_object_type is null' else 'object_type = :a_object_type' end;
- 2
l_cache_filter := ' c.cache_id in (select i.cache_id from ut_annotation_cache_info i where ' || l_filter || ' )';
end if;
- 2
execute immediate 'delete from ut_annotation_cache c where ' || l_cache_filter
using a_object_owner, a_object_type;
- 2
execute immediate ' delete from ut_annotation_cache_info i where ' || l_filter
using a_object_owner, a_object_type;
- 2
execute immediate ' delete from ut_annotation_cache_schema s where ' || l_filter
using a_object_owner, a_object_type;
- 2
commit;
end;
end;
UT3.UT_ANNOTATION_MANAGER
98.86 % lines covered
88 relevant lines. 87 lines covered and 1 lines missed
package body ut_annotation_manager as
/*
utPLSQL - Version 3
Copyright 2016 - 2019 utPLSQL Project
Licensed under the Apache License, Version 2.0 (the "License"):
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
------------------------------
--private definitions
function user_can_see_whole_schema( a_schema_name varchar2 ) return boolean is
begin
- 345
return sys_context('userenv','current_schema') = a_schema_name
- 1
or ut_metadata.user_has_execute_any_proc()
- 1
or ut_metadata.is_object_visible('dba_objects');
end;
function get_non_existing_objects( a_object_owner varchar2, a_object_type varchar2 ) return ut_annotation_objs_cache_info is
- 265
l_objects_view varchar2(200) := ut_metadata.get_objects_view_name();
- 265
l_object_to_delete ut_annotation_objs_cache_info := ut_annotation_objs_cache_info();
l_cached_objects ut_annotation_objs_cache_info;
begin
- 265
l_cached_objects := ut_annotation_cache_manager.get_cached_objects_list( a_object_owner, a_object_type );
- 265
if l_cached_objects is not empty then
- 262
execute immediate 'select /*+ cardinality(i '||ut_utils.scale_cardinality(cardinality(l_cached_objects))||') */
value(i)
from table( :l_data ) i
where
not exists (
select 1 from '||l_objects_view||q'[ o
where o.owner = i.object_owner
and o.object_name = i.object_name
and o.object_type = i.object_type
and o.owner = ']'||ut_utils.qualified_sql_name(a_object_owner)||q'['
and o.object_type = ']'||ut_utils.qualified_sql_name(a_object_type)||q'['
)]'
bulk collect into l_object_to_delete
using l_cached_objects;
end if;
- 265
return l_object_to_delete;
end;
function get_objects_to_refresh(
a_object_owner varchar2,
a_object_type varchar2,
a_modified_after timestamp
) return ut_annotation_objs_cache_info is
- 327
l_ut_owner varchar2(250) := ut_utils.ut_owner;
l_refresh_needed boolean;
- 327
l_objects_view varchar2(200) := ut_metadata.get_objects_view_name();
l_cached_objects ut_annotation_objs_cache_info;
l_result ut_annotation_objs_cache_info;
begin
- 327
ut_event_manager.trigger_event( 'get_objects_to_refresh - start' );
- 327
l_refresh_needed := ( ut_trigger_check.is_alive() = false ) or a_modified_after is null;
- 327
l_cached_objects := ut_annotation_cache_manager.get_cached_objects_list( a_object_owner, a_object_type, a_modified_after );
- 327
if l_refresh_needed then
--limit the list to objects that exist and are visible to the invoking user
--enrich the list by info about cache validity
- 29
execute immediate
'select /*+ cardinality(i '||ut_utils.scale_cardinality(cardinality(l_cached_objects))||') */
'||l_ut_owner||q'[.ut_annotation_obj_cache_info(
object_owner => o.owner,
object_name => o.object_name,
object_type => o.object_type,
needs_refresh => 'Y',
parse_time => c.parse_time
)
from ]'||l_objects_view||' o
left join table( cast(:l_cached_objects as '||l_ut_owner||q'[.ut_annotation_objs_cache_info ) ) c
on o.owner = c.object_owner
and o.object_name = c.object_name
and o.object_type = c.object_type
where o.owner = ']'||ut_utils.qualified_sql_name(a_object_owner)||q'['
and o.object_type = ']'||ut_utils.qualified_sql_name(a_object_type)||q'['
and case when o.last_ddl_time < cast(c.parse_time as date) then 'N' else 'Y' end = 'Y'
and ]'
- 1
|| case
- 1
when a_modified_after is null
then ':a_modified_after is null'
else 'o.last_ddl_time >= cast(:a_modified_after as date)'
end
bulk collect into l_result using l_cached_objects, a_modified_after;
else
- 298
l_result := l_cached_objects;
end if;
- 327
ut_event_manager.trigger_event('get_objects_to_refresh - end (count='||l_result.count||')');
- 327
return l_result;
end;
function get_sources_to_annotate(a_object_owner varchar2, a_object_type varchar2, a_objects_to_refresh ut_annotation_objs_cache_info) return sys_refcursor is
l_result sys_refcursor;
- 85
l_sources_view varchar2(200) := ut_metadata.get_source_view_name();
l_card natural;
begin
- 85
l_card := ut_utils.scale_cardinality(cardinality(a_objects_to_refresh));
- 85
open l_result for
q'[select x.name, x.text
from (select /*+ cardinality( r ]'||l_card||q'[ )*/
s.name, s.text, s.line,
max(case when s.text like '%--%\%%' escape '\'
and regexp_like(s.text,'^\s*--\s*%')
then 'Y' else 'N' end
)
over(partition by s.name) is_annotated
from table(:a_objects_to_refresh) r
join ]'||l_sources_view||q'[ s
on s.name = r.object_name
and s.owner = r.object_owner
and s.type = r.object_type
where s.owner = ']'||ut_utils.qualified_sql_name(a_object_owner)||q'['
and s.type = ']'||ut_utils.qualified_sql_name(a_object_type)||q'['
) x
where x.is_annotated = 'Y'
order by x.name, x.line]'
using a_objects_to_refresh;
- 85
return l_result;
end;
procedure build_annot_cache_for_sources(
a_object_owner varchar2,
a_object_type varchar2,
a_sources_cursor sys_refcursor
) is
l_annotations ut_annotations;
- 216
c_lines_fetch_limit constant integer := 10000;
l_lines dbms_preprocessor.source_lines_t;
l_names dbms_preprocessor.source_lines_t;
l_name varchar2(250);
l_object_lines dbms_preprocessor.source_lines_t;
- 216
l_parse_time date := sysdate;
pragma autonomous_transaction;
begin
- 216
loop
- 216
fetch a_sources_cursor bulk collect into l_names, l_lines limit c_lines_fetch_limit;
- 16196
for i in 1 .. l_names.count loop
- 15980
if l_names(i) != l_name then
- 211
l_annotations := ut_annotation_parser.parse_object_annotations(l_object_lines, a_object_type);
- 211
ut_annotation_cache_manager.update_cache(
ut_annotated_object(a_object_owner, l_name, a_object_type, l_parse_time, l_annotations)
);
- 211
l_object_lines.delete;
end if;
- 15980
l_name := l_names(i);
- 15980
l_object_lines(l_object_lines.count+1) := l_lines(i);
end loop;
- 216
exit when a_sources_cursor%notfound;
end loop;
- 216
if a_sources_cursor%rowcount > 0 then
- 204
l_annotations := ut_annotation_parser.parse_object_annotations(l_object_lines, a_object_type);
- 204
ut_annotation_cache_manager.update_cache(
ut_annotated_object(a_object_owner, l_name, a_object_type, l_parse_time, l_annotations)
);
- 204
l_object_lines.delete;
end if;
- 216
close a_sources_cursor;
end;
procedure validate_annotation_cache(
a_object_owner varchar2,
a_object_type varchar2,
a_modified_after timestamp := null
) is
l_objects_to_refresh ut_annotation_objs_cache_info;
- 327
l_modified_after timestamp := a_modified_after;
begin
- 327
if ut_annotation_cache_manager.get_cache_schema_info(a_object_owner, a_object_type).full_refresh_time is null then
- 10
l_modified_after := null;
end if;
- 327
l_objects_to_refresh := get_objects_to_refresh(a_object_owner, a_object_type, l_modified_after);
- 327
ut_event_manager.trigger_event('validate_annotation_cache - start (l_objects_to_refresh.count = '||l_objects_to_refresh.count||')');
- 327
if user_can_see_whole_schema( a_object_owner ) then
--Remove non existing objects from cache only when user can see whole schema
- 265
ut_annotation_cache_manager.remove_from_cache( get_non_existing_objects( a_object_owner, a_object_type ) );
end if;
--if some source needs parsing and putting into cache
- 327
if l_objects_to_refresh.count > 0 then
--Delete annotations for objects that are to be refreshed
- 85
ut_annotation_cache_manager.reset_objects_cache(l_objects_to_refresh);
--Rebuild cache from objects source
- 85
build_annot_cache_for_sources(
a_object_owner, a_object_type,
get_sources_to_annotate(a_object_owner, a_object_type, l_objects_to_refresh)
);
end if;
- 327
if l_modified_after is null then
- 18
if user_can_see_whole_schema( a_object_owner ) then
- 13
ut_annotation_cache_manager.set_fully_refreshed( a_object_owner, a_object_type );
else
-- if user cannot see full schema - we dont mark it as fully refreshed
-- it will get refreshed each time until someone with proper privs will refresh it
- 5
null;
end if;
end if;
- 327
ut_event_manager.trigger_event('validate_annotation_cache - end');
end;
------------------------------------------------------------
--public definitions
------------------------------------------------------------
procedure rebuild_annotation_cache(a_object_owner varchar2, a_object_type varchar2) is
begin
- 10
validate_annotation_cache( a_object_owner, a_object_type );
end;
procedure trigger_obj_annotation_rebuild is
l_sql_text ora_name_list_t;
l_parts binary_integer;
l_restricted_users ora_name_list_t;
function get_source_from_sql_text(a_object_name varchar2, a_sql_text ora_name_list_t, a_parts binary_integer) return sys_refcursor is
l_sql_clob clob;
- 128
l_sql_lines ut_varchar2_rows := ut_varchar2_rows();
l_result sys_refcursor;
begin
- 128
if a_parts > 0 then
- 747
for i in 1..a_parts loop
- 619
ut_utils.append_to_clob(l_sql_clob, a_sql_text(i));
end loop;
- 128
l_sql_clob := ut_utils.replace_multiline_comments(l_sql_clob);
-- replace comment lines that contain "-- create or replace"
- 128
l_sql_clob := regexp_replace(l_sql_clob, '^.*[-]{2,}\s*create(\s+or\s+replace).*$', modifier => 'mi');
-- remove the "create [or replace] [[non]editionable] " so that we have only "type|package" for parsing
-- needed for dbms_preprocessor
- 128
l_sql_clob := regexp_replace(l_sql_clob, '^(.*?\s*create(\s+or\s+replace)?(\s+(editionable|noneditionable))?\s+?)((package|type).*)', '\5', 1, 1, 'ni');
- 128
l_sql_lines := ut_utils.convert_collection( ut_utils.clob_to_table(l_sql_clob) );
end if;
- 128
open l_result for
select a_object_name as name, column_value||chr(10) as text from table(l_sql_lines);
- 128
return l_result;
end;
function get_source_for_object(a_object_owner varchar2, a_object_name varchar2, a_object_type varchar2) return sys_refcursor is
l_result sys_refcursor;
- 3
l_sources_view varchar2(200) := ut_metadata.get_source_view_name();
begin
- 3
open l_result for
q'[select :a_object_name, s.text
from ]'||l_sources_view||q'[ s
where s.type = :a_object_type
and s.owner = :a_object_owner
and s.name = :a_object_name
order by s.line]'
using a_object_name, a_object_type, a_object_owner, a_object_name;
- 3
return l_result;
end;
begin
- 254
if ora_dict_obj_type in ('PACKAGE','PROCEDURE','FUNCTION','TYPE') then
$if dbms_db_version.version < 12 $then
l_restricted_users := ora_name_list_t(
'ANONYMOUS','APPQOSSYS','AUDSYS','DBSFWUSER','DBSNMP','DIP','GGSYS','GSMADMIN_INTERNAL',
'GSMCATUSER','GSMUSER','ORACLE_OCM','OUTLN','REMOTE_SCHEDULER_AGENT','SYS','SYS$UMF',
'SYSBACKUP','SYSDG','SYSKM','SYSRAC','SYSTEM','WMSYS','XDB','XS$NULL');
$else
- 254
select username bulk collect into l_restricted_users
from all_users where oracle_maintained = 'Y';
$end
- 254
if ora_dict_obj_owner member of l_restricted_users then
return;
end if;
- 254
if ora_sysevent = 'CREATE' then
- 128
l_parts := ORA_SQL_TXT(l_sql_text);
- 128
build_annot_cache_for_sources(
ora_dict_obj_owner, ora_dict_obj_type,
get_source_from_sql_text(ora_dict_obj_name, l_sql_text, l_parts)
);
- 126
elsif ora_sysevent = 'ALTER' then
- 3
build_annot_cache_for_sources(
ora_dict_obj_owner, ora_dict_obj_type,
get_source_for_object(ora_dict_obj_owner, ora_dict_obj_name, ora_dict_obj_type)
);
- 123
elsif ora_sysevent = 'DROP' then
- 123
ut_annotation_cache_manager.remove_from_cache(
ut_annotation_objs_cache_info(
ut_annotation_obj_cache_info(ora_dict_obj_owner, ora_dict_obj_name, ora_dict_obj_type, 'Y', null)
)
);
end if;
end if;
end;
function get_annotated_objects(a_object_owner varchar2, a_object_type varchar2, a_modified_after timestamp) return sys_refcursor is
l_cursor sys_refcursor;
begin
- 317
ut_event_manager.trigger_event('get_annotated_objects - start: a_modified_after='||ut_utils.to_string(a_modified_after));
- 317
validate_annotation_cache(a_object_owner, a_object_type, a_modified_after);
--pipe annotations from cache
- 317
l_cursor := ut_annotation_cache_manager.get_annotations_parsed_since(a_object_owner, a_object_type, a_modified_after);
- 317
ut_event_manager.trigger_event('get_annotated_objects - end');
- 317
return l_cursor;
end;
procedure purge_cache(a_object_owner varchar2, a_object_type varchar2) is
begin
- 2
ut_annotation_cache_manager.purge_cache(a_object_owner, a_object_type);
end;
end;
UT3.UT_ANNOTATION_PARSER
97.26 % lines covered
73 relevant lines. 71 lines covered and 2 lines missed
package body ut_annotation_parser as
/*
utPLSQL - Version 3
Copyright 2016 - 2019 utPLSQL Project
Licensed under the Apache License, Version 2.0 (the "License"):
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
------------------------------
--private definitions
type tt_comment_list is table of varchar2(32767) index by binary_integer;
- 1
gc_annotation_qualifier constant varchar2(1) := '%';
- 1
gc_annot_comment_pattern constant varchar2(30) := '^( |'||chr(09)||')*-- *('||gc_annotation_qualifier||'.*?)$'; -- chr(09) is a tab character
- 1
gc_comment_replacer_patter constant varchar2(50) := '{COMMENT#%N%}';
- 1
gc_comment_replacer_regex_ptrn constant varchar2(25) := '{COMMENT#(\d+)}';
- 1
gc_regexp_identifier constant varchar2(50) := '[a-zA-Z][a-zA-Z0-9#_$]*';
- 1
gc_annotation_block_pattern constant varchar2(200) := '(({COMMENT#.+}'||chr(10)||')+)( |'||chr(09)||')*(procedure|function)\s+(' ||
gc_regexp_identifier || ')';
- 1
gc_annotation_pattern constant varchar2(50) := gc_annotation_qualifier || gc_regexp_identifier || '[ '||chr(9)||']*(\(.*?\)\s*?$)?';
procedure add_annotation(
a_annotations in out nocopy ut_annotations,
a_position positiven,
a_comment varchar2,
a_subobject_name varchar2 := null
) is
l_annotation_str varchar2(32767);
l_annotation_text varchar2(32767);
l_annotation_name varchar2(1000);
begin
-- strip everything except the annotation itself (spaces and others)
- 6031
l_annotation_str := regexp_substr(a_comment, gc_annotation_pattern, 1, 1, modifier => 'i');
- 6031
if l_annotation_str is not null then
-- get the annotation name and it's parameters if present
- 6031
l_annotation_name := lower(regexp_substr(l_annotation_str ,'%(' || gc_regexp_identifier || ')', subexpression => 1));
- 6031
l_annotation_text := trim(regexp_substr(l_annotation_str, '\((.*?)\)\s*$', subexpression => 1));
- 6031
a_annotations.extend;
- 6031
a_annotations( a_annotations.last) :=
ut_annotation(a_position, l_annotation_name, l_annotation_text, a_subobject_name);
end if;
end;
procedure delete_processed_comments( a_comments in out nocopy tt_comment_list, a_annotations ut_annotations ) is
- 429
l_loop_index binary_integer := 1;
begin
- 429
l_loop_index := a_annotations.first;
- 4929
while l_loop_index is not null loop
- 4500
a_comments.delete( a_annotations(l_loop_index).position );
- 4500
l_loop_index := a_annotations.next( l_loop_index );
end loop;
end;
procedure add_annotations(
a_annotations in out nocopy ut_annotations,
a_source varchar2,
a_comments tt_comment_list,
a_subobject_name varchar2 := null
) is
- 3705
l_loop_index binary_integer := 1;
l_annotation_index binary_integer;
begin
-- loop while there are unprocessed comment blocks
- 8205
while 0 != nvl(regexp_instr(srcstr => a_source
,pattern => gc_comment_replacer_regex_ptrn
,occurrence => l_loop_index
,subexpression => 1)
,0) loop
-- define index of the comment block and get it's content from cache
- 4500
l_annotation_index := regexp_substr( a_source ,gc_comment_replacer_regex_ptrn ,1 ,l_loop_index ,subexpression => 1);
- 4500
add_annotation( a_annotations, l_annotation_index, a_comments( l_annotation_index ), a_subobject_name );
- 4500
l_loop_index := l_loop_index + 1;
end loop;
end add_annotations;
procedure add_procedure_annotations(a_annotations in out nocopy ut_annotations, a_source clob, a_comments in out nocopy tt_comment_list) is
l_proc_comments varchar2(32767);
l_proc_name varchar2(250);
l_annot_proc_ind number;
l_annot_proc_block varchar2(32767);
begin
-- loop through procedures and functions of the package and get all the comment blocks just before it's declaration
- 429
l_annot_proc_ind := 1;
- 4134
loop
--find annotated procedure index
- 4134
l_annot_proc_ind := regexp_instr(srcstr => a_source
,pattern => gc_annotation_block_pattern
,occurrence => 1
,modifier => 'i'
,position => l_annot_proc_ind);
- 4134
exit when l_annot_proc_ind = 0;
--get the annotations with procedure name
- 3705
l_annot_proc_block := regexp_substr(srcstr => a_source
,pattern => gc_annotation_block_pattern
,position => l_annot_proc_ind
,occurrence => 1
,modifier => 'i');
--extract the annotations
- 3705
l_proc_comments := trim(regexp_substr(srcstr => l_annot_proc_block
,pattern => gc_annotation_block_pattern
,modifier => 'i'
,subexpression => 1));
--extract the procedure name
- 3705
l_proc_name := trim(regexp_substr(srcstr => l_annot_proc_block
,pattern => gc_annotation_block_pattern
,modifier => 'i'
,subexpression => 5));
-- parse the comment block for the syntactically correct annotations and store them as an array
- 3705
add_annotations(a_annotations, l_proc_comments, a_comments, l_proc_name);
- 3705
l_annot_proc_ind := instr(a_source, ';', l_annot_proc_ind + length(l_annot_proc_block) );
end loop;
end add_procedure_annotations;
function extract_and_replace_comments(a_source in out nocopy clob) return tt_comment_list is
l_comments tt_comment_list;
l_comment_pos binary_integer;
l_comment_line binary_integer;
l_comment_replacer varchar2(50);
- 429
l_source clob := a_source;
begin
- 429
l_comment_pos := 1;
- 6460
loop
- 6460
l_comment_pos := regexp_instr(srcstr => a_source
,pattern => gc_annot_comment_pattern
,occurrence => 1
,modifier => 'm'
,position => l_comment_pos);
- 6460
exit when l_comment_pos = 0;
-- position index is shifted by 1 because gc_annot_comment_pattern contains ^ as first sign
-- but after instr index already points to the char on that line
- 6031
l_comment_pos := l_comment_pos-1;
- 6031
l_comment_line := length(substr(a_source,1,l_comment_pos))-length(replace(substr(a_source,1,l_comment_pos),chr(10)))+1;
- 6031
l_comments(l_comment_line) := trim(regexp_substr(srcstr => a_source
,pattern => gc_annot_comment_pattern
,occurrence => 1
,position => l_comment_pos
,modifier => 'm'
,subexpression => 2));
- 6031
l_comment_replacer := replace(gc_comment_replacer_patter, '%N%', l_comment_line);
- 6031
l_source := regexp_replace(srcstr => a_source
,pattern => gc_annot_comment_pattern
,replacestr => l_comment_replacer
,position => l_comment_pos
,occurrence => 1
,modifier => 'm');
- 6031
dbms_lob.freetemporary(a_source);
- 6031
a_source := l_source;
- 6031
dbms_lob.freetemporary(l_source);
- 6031
l_comment_pos := l_comment_pos + length(l_comment_replacer);
end loop;
- 429
ut_utils.debug_log(a_source);
- 429
return l_comments;
end extract_and_replace_comments;
------------------------------------------------------------
--public definitions
------------------------------------------------------------
function parse_object_annotations(a_source clob) return ut_annotations is
- 429
l_source clob := a_source;
l_comments tt_comment_list;
- 429
l_annotations ut_annotations := ut_annotations();
l_result ut_annotations;
l_comment_index positive;
begin
- 429
l_source := ut_utils.replace_multiline_comments(l_source);
-- replace all single line comments with {COMMENT#12} element and store it's content for easier processing
-- this call modifies l_source
- 429
l_comments := extract_and_replace_comments(l_source);
- 429
add_procedure_annotations(l_annotations, l_source, l_comments);
- 429
delete_processed_comments(l_comments, l_annotations);
--at this point, only the comments not related to procedures are left, so we process them all as top-level
- 429
l_comment_index := l_comments.first;
- 1960
while l_comment_index is not null loop
- 1531
add_annotation( l_annotations, l_comment_index, l_comments( l_comment_index ) );
- 1531
l_comment_index := l_comments.next(l_comment_index);
end loop;
- 429
dbms_lob.freetemporary(l_source);
- 429
select value(x) bulk collect into l_result from table(l_annotations) x order by x.position;
- 429
return l_result;
end parse_object_annotations;
function parse_object_annotations(a_source_lines dbms_preprocessor.source_lines_t, a_object_type varchar2) return ut_annotations is
l_processed_lines dbms_preprocessor.source_lines_t;
l_source clob;
- 416
l_annotations ut_annotations := ut_annotations();
ex_package_is_wrapped exception;
pragma exception_init(ex_package_is_wrapped, -24241);
source_text_is_empty exception;
pragma exception_init(source_text_is_empty, -24236);
begin
- 416
if a_source_lines.count > 0 then
--convert to post-processed source clob
begin
--get post-processed source
- 416
if a_object_type = 'TYPE' then
- 10
l_processed_lines := a_source_lines;
else
- 406
l_processed_lines := sys.dbms_preprocessor.get_post_processed_source(a_source_lines);
end if;
--convert to clob
- 16678
for i in 1..l_processed_lines.count loop
- 16262
ut_utils.append_to_clob(l_source, replace(l_processed_lines(i), chr(13)||chr(10), chr(10)));
end loop;
--parse annotations
- 416
l_annotations := parse_object_annotations(l_source);
- 416
dbms_lob.freetemporary(l_source);
exception
when ex_package_is_wrapped or source_text_is_empty then
null;
end;
end if;
- 416
return l_annotations;
end;
end;
UT3.UT_TRIGGER_CHECK
100 % lines covered
7 relevant lines. 7 lines covered and 0 lines missed
package body ut_trigger_check is
/*
utPLSQL - Version 3
Copyright 2016 - 2019 utPLSQL Project
Licensed under the Apache License, Version 2.0 (the "License"):
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
- 1
gc_check_object_name constant varchar2(128) := 'UT3_TRIGGER_ALIVE';
- 1
g_is_trigger_live boolean := false;
function is_alive return boolean is
pragma autonomous_transaction;
begin
- 418
execute immediate 'create or replace synonym '||ut_utils.ut_owner||'.'||gc_check_object_name||' for no_object';
- 418
return g_is_trigger_live;
end;
procedure is_alive is
begin
- 404
if ora_dict_obj_owner is not null and ora_dict_obj_name is not null and ora_dict_obj_type is not null then
- 400
g_is_trigger_live := true;
else
- 4
g_is_trigger_live := false;
end if;
end;
end;
UT3.UT_COVERAGE
88.1 % lines covered
84 relevant lines. 74 lines covered and 10 lines missed
package body ut_coverage is
/*
utPLSQL - Version 3
Copyright 2016 - 2019 utPLSQL Project
Licensed under the Apache License, Version 2.0 (the "License"):
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
g_coverage_id tt_coverage_id_arr;
- 1
g_develop_mode boolean not null := false;
- 1
g_is_started boolean not null := false;
procedure set_develop_mode(a_develop_mode in boolean) is
begin
- 2
g_develop_mode := a_develop_mode;
end;
function get_coverage_id(a_coverage_type in varchar2) return integer is
begin
- 20
return g_coverage_id(a_coverage_type);
end;
function is_develop_mode return boolean is
begin
- 52
return g_develop_mode;
end;
function get_cov_sources_sql(a_coverage_options ut_coverage_options, a_skip_objects ut_object_names) return varchar2 is
l_result varchar2(32767);
l_full_name varchar2(32767);
l_join_mappings varchar2(32767);
l_filters varchar2(32767);
- 10
l_mappings_cardinality integer := 0;
begin
- 10
l_result := q'[
with
trigger_source_offsets as (
select min(s.line) - 1 offset, s.owner, s.name, s.type
from {sources_view} s
where s.type = 'TRIGGER'
{filters}
and (lower(s.text) like '%begin%' or lower(s.text) like '%declare%' or lower(s.text) like '%compound%')
group by s.owner, s.name, s.type
),
sources as (
select /*+ cardinality(f {mappings_cardinality}) */
{l_full_name} as full_name, s.owner, s.name,
s.line - case when s.type = 'TRIGGER' then o.offset else 0 end as line,
s.text
from {sources_view} s {join_file_mappings}
left join trigger_source_offsets o
on (s.owner = o.owner and s.name = o.name and s.type = o.type)
where s.type in ('PACKAGE BODY', 'TYPE BODY', 'PROCEDURE', 'FUNCTION', 'TRIGGER')
{filters}
),
coverage_sources as (
select full_name, owner, name, line, text,
case
when
-- to avoid execution of regexp_like on every line
-- first do a rough check for existence of search pattern keyword
(lower(s.text) like '%procedure%'
or lower(s.text) like '%function%'
or lower(s.text) like '%begin%'
or lower(s.text) like '%end%'
or lower(s.text) like '%package%'
) and
regexp_like(
s.text,
'^([\t ]*(((not)?\s*(overriding|final|instantiable)[\t ]*)*(static|constructor|member)?[\t ]*(procedure|function)|package([\t ]+body)|begin|end([\t ]+\S+)*[ \t]*;))', 'i'
)
then 'Y'
end as to_be_skipped
from sources s
)
select full_name, owner, name, line, to_be_skipped, text
from coverage_sources s
-- Exclude calls to utPLSQL framework, Unit Test packages and objects from a_exclude_list parameter of coverage reporter
where (s.owner, s.name) not in ( select /*+ cardinality(el {skipped_objects_cardinality})*/el.owner, el.name from table(:l_skipped_objects) el )
and line > 0
]';
- 10
if a_coverage_options.file_mappings is not empty then
- 5
l_mappings_cardinality := ut_utils.scale_cardinality(cardinality(a_coverage_options.file_mappings));
- 5
l_full_name := 'f.file_name';
- 5
l_join_mappings := '
join table(:file_mappings) f
on s.name = f.object_name
and s.type = f.object_type
and s.owner = f.object_owner';
else
- 5
l_full_name := q'[lower(s.owner||'.'||s.name)]';
- 5
l_filters := case
- 1
when a_coverage_options.include_objects is not empty then '
and (s.owner, s.name) in (
select /*+ cardinality(il '||ut_utils.scale_cardinality(cardinality(a_coverage_options.include_objects))||') */
il.owner, il.name
from table(:include_objects) il
)'
else '
and s.owner in (
select /*+ cardinality(t '||ut_utils.scale_cardinality(cardinality(a_coverage_options.schema_names))||') */
upper(t.column_value)
from table(:l_schema_names) t)'
end;
end if;
- 10
l_result := replace(l_result, '{sources_view}', ut_metadata.get_source_view_name());
- 10
l_result := replace(l_result, '{l_full_name}', l_full_name);
- 10
l_result := replace(l_result, '{join_file_mappings}', l_join_mappings);
- 10
l_result := replace(l_result, '{filters}', l_filters);
- 10
l_result := replace(l_result, '{mappings_cardinality}', l_mappings_cardinality);
- 10
l_result := replace(l_result, '{skipped_objects_cardinality}', ut_utils.scale_cardinality(cardinality(a_skip_objects)));
- 10
return l_result;
end;
function get_cov_sources_cursor(a_coverage_options in ut_coverage_options) return sys_refcursor is
l_cursor sys_refcursor;
l_skip_objects ut_object_names;
l_sql varchar2(32767);
begin
- 10
if not is_develop_mode() then
--skip all the utplsql framework objects and all the unit test packages that could potentially be reported by coverage.
l_skip_objects := ut_utils.get_utplsql_objects_list() multiset union all coalesce(a_coverage_options.exclude_objects, ut_object_names());
end if;
- 10
l_sql := get_cov_sources_sql(a_coverage_options, l_skip_objects);
- 10
ut_event_manager.trigger_event(ut_event_manager.gc_debug, ut_key_anyvalues().put('l_sql',l_sql) );
- 10
if a_coverage_options.file_mappings is not empty then
- 5
open l_cursor for l_sql using a_coverage_options.file_mappings, l_skip_objects;
- 5
elsif a_coverage_options.include_objects is not empty then
- 3
open l_cursor for l_sql using a_coverage_options.include_objects, a_coverage_options.include_objects, l_skip_objects;
else
- 2
open l_cursor for l_sql using a_coverage_options.schema_names, a_coverage_options.schema_names, l_skip_objects;
end if;
- 10
return l_cursor;
end;
procedure populate_tmp_table(a_coverage_options ut_coverage_options) is
pragma autonomous_transaction;
l_cov_sources_crsr sys_refcursor;
l_cov_sources_data ut_coverage_helper.t_coverage_sources_tmp_rows;
begin
- 10
if not ut_coverage_helper.is_tmp_table_populated() or is_develop_mode() then
- 10
ut_coverage_helper.cleanup_tmp_table();
- 10
l_cov_sources_crsr := get_cov_sources_cursor(a_coverage_options);
- 11
loop
- 11
fetch l_cov_sources_crsr bulk collect into l_cov_sources_data limit 10000;
- 11
ut_coverage_helper.insert_into_tmp_table(l_cov_sources_data);
- 11
exit when l_cov_sources_crsr%notfound;
end loop;
- 10
close l_cov_sources_crsr;
end if;
- 10
commit;
end;
/**
* Public functions
*/
procedure coverage_start(a_coverage_options ut_coverage_options default null) is
- 10
l_run_comment varchar2(200) := 'utPLSQL Code coverage run '||ut_utils.to_string(systimestamp);
begin
- 10
if not is_develop_mode() and not g_is_started then
ut_coverage_helper_block.coverage_start( l_run_comment, g_coverage_id(gc_block_coverage) );
ut_coverage_helper_profiler.coverage_start( l_run_comment, g_coverage_id(gc_proftab_coverage) );
coverage_pause();
g_is_started := true;
end if;
end;
procedure coverage_pause is
begin
- 22
if not is_develop_mode() then
ut_coverage_helper_profiler.coverage_pause();
end if;
end;
procedure coverage_resume is
begin
- 32
ut_coverage_helper_profiler.coverage_resume();
end;
procedure mock_coverage_id(a_coverage_id integer,a_coverage_type in varchar2) is
begin
- 3
g_develop_mode := true;
- 3
g_is_started := true;
- 3
g_coverage_id(a_coverage_type) := a_coverage_id;
end;
procedure mock_coverage_id(a_coverage_id tt_coverage_id_arr) is
begin
- 1
g_develop_mode := true;
- 1
g_is_started := true;
- 1
g_coverage_id := a_coverage_id;
end;
procedure coverage_stop is
begin
- 10
if not is_develop_mode() then
g_is_started := false;
ut_coverage_helper_block.coverage_stop();
ut_coverage_helper_profiler.coverage_stop();
g_is_started := false;
end if;
end;
function get_coverage_data(a_coverage_options ut_coverage_options) return t_coverage is
- 10
l_result_block ut_coverage.t_coverage;
- 10
l_result_profiler_enrich ut_coverage.t_coverage;
l_object ut_coverage.t_full_name;
l_line_no binary_integer;
begin
--prepare global temp table with sources
- 10
ut_event_manager.trigger_event('about to populate coverage temp table');
- 10
populate_tmp_table(a_coverage_options);
- 10
ut_event_manager.trigger_event('coverage temp table populated');
-- Get raw data for both reporters, order is important as tmp table will skip headers and dont populate
-- tmp table for block again.
- 10
l_result_profiler_enrich:= ut_coverage_profiler.get_coverage_data( a_coverage_options, get_coverage_id(gc_proftab_coverage) );
- 10
ut_event_manager.trigger_event('profiler coverage data retrieved');
-- If block coverage available we will use it.
$if dbms_db_version.version = 12 and dbms_db_version.release >= 2 or dbms_db_version.version > 12 $then
- 10
l_result_block := ut_coverage_block.get_coverage_data( a_coverage_options, get_coverage_id(gc_block_coverage) );
- 10
ut_event_manager.trigger_event('block coverage data retrieved');
-- Enrich profiler results with some of the block results
- 10
l_object := l_result_profiler_enrich.objects.first;
- 56
while (l_object is not null) loop
- 46
l_line_no := l_result_profiler_enrich.objects(l_object).lines.first;
-- to avoid no data found check if we got object in profiler
- 46
if l_result_block.objects.exists(l_object) then
- 59
while (l_line_no is not null) loop
-- To avoid no data check for object line
- 16
if l_result_block.objects(l_object).lines.exists(l_line_no) then
-- enrich line level stats
- 12
l_result_profiler_enrich.objects(l_object).lines(l_line_no).partcove := l_result_block.objects(l_object).lines(l_line_no).partcove;
- 12
l_result_profiler_enrich.objects(l_object).lines(l_line_no).covered_blocks := l_result_block.objects(l_object).lines(l_line_no).covered_blocks;
- 12
l_result_profiler_enrich.objects(l_object).lines(l_line_no).no_blocks := l_result_block.objects(l_object).lines(l_line_no).no_blocks;
-- enrich object level stats
- 12
l_result_profiler_enrich.objects(l_object).partcovered_lines := nvl(l_result_profiler_enrich.objects(l_object).partcovered_lines,0) + l_result_block.objects(l_object).lines(l_line_no).partcove;
end if;
--At the end go to next line
- 16
l_line_no := l_result_profiler_enrich.objects(l_object).lines.next(l_line_no);
end loop;
--total level stats enrich
- 43
l_result_profiler_enrich.partcovered_lines := nvl(l_result_profiler_enrich.partcovered_lines,0) + l_result_profiler_enrich.objects(l_object).partcovered_lines;
-- At the end go to next object
end if;
- 46
l_object := l_result_profiler_enrich.objects.next(l_object);
end loop;
- 10
ut_event_manager.trigger_event('coverage data combined');
$end
- 10
return l_result_profiler_enrich;
end get_coverage_data;
end;
UT3.UT_COVERAGE_BLOCK
92.31 % lines covered
52 relevant lines. 48 lines covered and 4 lines missed
package body ut_coverage_block is
/*
utPLSQL - Version 3
Copyright 2016 - 2019 utPLSQL Project
Licensed under the Apache License, Version 2.0 (the "License"):
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
type t_source_lines is table of binary_integer;
/**
* Public functions
*/
function get_coverage_data(a_coverage_options ut_coverage_options, a_coverage_id integer) return ut_coverage.t_coverage is
l_line_calls ut_coverage_helper.t_unit_line_calls;
- 10
l_result ut_coverage.t_coverage;
- 10
l_new_unit ut_coverage.t_unit_coverage;
l_line_no binary_integer;
l_source_objects_crsr ut_coverage_helper.t_tmp_table_objects_crsr;
l_source_object ut_coverage_helper.t_tmp_table_object;
begin
$if dbms_db_version.version = 12 and dbms_db_version.release >= 2 or dbms_db_version.version > 12 $then
- 10
l_source_objects_crsr := ut_coverage_helper.get_tmp_table_objects_cursor();
- 56
loop
- 56
fetch l_source_objects_crsr
into l_source_object;
- 56
exit when l_source_objects_crsr%notfound;
--get coverage data
- 46
l_line_calls := ut_coverage_helper_block.get_raw_coverage_data(l_source_object.owner, l_source_object.name, a_coverage_id);
--if there is coverage, we need to filter out the garbage (badly indicated data)
- 46
if l_line_calls.count > 0 then
--remove lines that should not be indicted as meaningful
- 40
for i in 1 .. l_source_object.to_be_skipped_list.count loop
- 36
if l_source_object.to_be_skipped_list(i) is not null then
- 36
l_line_calls.delete(l_source_object.to_be_skipped_list(i));
end if;
end loop;
end if;
--if there are no file mappings or object was actually captured by profiler
- 46
if a_coverage_options.file_mappings is null or l_line_calls.count > 0 then
--populate total stats
- 43
l_result.total_lines := nvl(l_result.total_lines,0) + l_source_object.lines_count;
--populate object level coverage stats
- 43
if not l_result.objects.exists(l_source_object.full_name) then
- 43
l_result.objects(l_source_object.full_name) := l_new_unit;
- 43
l_result.objects(l_source_object.full_name).owner := l_source_object.owner;
- 43
l_result.objects(l_source_object.full_name).name := l_source_object.name;
- 43
l_result.objects(l_source_object.full_name).total_lines := l_source_object.lines_count;
end if;
--map to results
- 43
l_line_no := l_line_calls.first;
- 43
if l_line_no is null then
- 39
l_result.uncovered_lines := l_result.uncovered_lines + l_source_object.lines_count;
- 39
l_result.objects(l_source_object.full_name).uncovered_lines := l_source_object.lines_count;
- 1
else
- 16
loop
- 16
exit when l_line_no is null;
--turn the block coverage into a line coverage format to allow for reading.
--whenever the linst is a part covered treat that line as a hit and execution but only part covered
--total stats
--Get total blocks ,blocks covered, blocks not covered this will be used for PCT calc
- 12
l_result.total_blocks := nvl(l_result.total_blocks, 0) + l_line_calls(l_line_no).blocks;
- 12
l_result.covered_blocks := nvl(l_result.covered_blocks, 0) + l_line_calls(l_line_no).covered_blocks;
- 12
l_result.uncovered_blocks := nvl(l_result.uncovered_blocks, 0) +
(l_line_calls(l_line_no).blocks - l_line_calls(l_line_no).covered_blocks);
--If line is partially covered add as part line cover and covered for line reporter
- 12
if l_line_calls(l_line_no).partcovered = 1 then
- 4
l_result.partcovered_lines := l_result.partcovered_lines + 1;
end if;
- 12
if l_line_calls(l_line_no).covered_blocks > 0 then
- 12
l_result.covered_lines := l_result.covered_lines + 1;
end if;
-- Use nvl as be default is null and screw the calcs
--Increase total blocks
- 12
l_result.objects(l_source_object.full_name).lines(l_line_no).no_blocks := l_line_calls(l_line_no).blocks;
- 12
l_result.objects(l_source_object.full_name).lines(l_line_no).covered_blocks := l_line_calls(l_line_no).covered_blocks;
- 12
l_result.objects(l_source_object.full_name).total_blocks := nvl(l_result.objects(l_source_object.full_name)
.total_blocks
,0) + l_line_calls(l_line_no).blocks;
--Total uncovered blocks is a line blocks minus covered blocsk
- 12
l_result.objects(l_source_object.full_name).uncovered_blocks := nvl(l_result.objects(l_source_object.full_name)
.uncovered_blocks
,0) +
(l_line_calls(l_line_no).blocks - l_line_calls(l_line_no)
.covered_blocks);
--If we have any covered blocks in line
- 12
if l_line_calls(l_line_no).covered_blocks > 0 then
--If any block is covered then we have a hit on that line
- 12
l_result.executions := l_result.executions + 1;
--object level stats
--If its part covered then mark it else treat as full cov
- 12
if l_line_calls(l_line_no).partcovered = 1 then
- 4
l_result.objects(l_source_object.full_name).partcovered_lines := l_result.objects(l_source_object.full_name)
.partcovered_lines + 1;
end if;
- 12
l_result.objects(l_source_object.full_name).covered_lines := l_result.objects(l_source_object.full_name)
.covered_lines + 1;
--How many blocks we covered
- 12
l_result.objects(l_source_object.full_name).covered_blocks := nvl(l_result.objects(l_source_object.full_name)
.covered_blocks
,0) + l_line_calls(l_line_no)
.covered_blocks;
--Object line executions
- 12
l_result.objects(l_source_object.full_name).executions := nvl(l_result.objects(l_source_object.full_name)
.executions
,0) + 1;
- 12
l_result.objects(l_source_object.full_name).lines(l_line_no).executions := 1;
--Whenever there is no covered block treat as uncovered (query returns only lines where the blocks are in code so we
--dont have a false results here when there is no blocks
elsif l_line_calls(l_line_no).covered_blocks = 0 then
l_result.uncovered_lines := l_result.uncovered_lines + 1;
l_result.objects(l_source_object.full_name).uncovered_lines := l_result.objects(l_source_object.full_name)
.uncovered_lines + 1;
l_result.objects(l_source_object.full_name).lines(l_line_no).executions := 0;
end if;
--increase part covered counter (+ 1/0)
- 12
l_result.objects(l_source_object.full_name).lines(l_line_no).partcove := l_line_calls(l_line_no).partcovered;
- 12
l_line_no := l_line_calls.next(l_line_no);
end loop;
end if;
end if;
end loop;
- 10
close l_source_objects_crsr;
$end
- 10
return l_result;
end get_coverage_data;
end;
UT3.UT_COVERAGE_HELPER
90 % lines covered
10 relevant lines. 9 lines covered and 1 lines missed
package body ut_coverage_helper is
/*
utPLSQL - Version 3
Copyright 2016 - 2019 utPLSQL Project
Licensed under the Apache License, Version 2.0 (the "License"):
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
type t_proftab_row is record (
line binary_integer,
calls number(38,0)
);
type t_proftab_rows is table of t_proftab_row;
type t_block_row is record(
line binary_integer
,blocks binary_integer
,covered_blocks binary_integer);
type t_block_rows is table of t_block_row;
procedure insert_into_tmp_table(a_data t_coverage_sources_tmp_rows) is
begin
- 11
forall i in 1 .. a_data.count
insert into ut_coverage_sources_tmp
(full_name,owner,name,line,text, to_be_skipped)
values(a_data(i).full_name,a_data(i).owner,a_data(i).name,a_data(i).line,a_data(i).text,a_data(i).to_be_skipped);
end;
procedure cleanup_tmp_table is
pragma autonomous_transaction;
begin
- 126
execute immediate 'truncate table ut_coverage_sources_tmp';
end;
function is_tmp_table_populated return boolean is
l_result integer;
begin
- 10
select 1 into l_result from ut_coverage_sources_tmp where rownum = 1;
return (l_result = 1);
exception
- 20
when no_data_found then
- 10
return false;
end;
function get_tmp_table_objects_cursor return t_tmp_table_objects_crsr is
l_result t_tmp_table_objects_crsr;
begin
- 20
open l_result for
select o.owner, o.name, o.full_name, max(o.line) lines_count,
cast(
collect(decode(to_be_skipped, 'Y', to_char(line))) as ut_varchar2_list
) to_be_skipped_list
from ut_coverage_sources_tmp o
group by o.owner, o.name, o.full_name;
- 20
return l_result;
end;
function get_tmp_table_object_lines(a_owner varchar2, a_object_name varchar2) return ut_varchar2_list is
l_result ut_varchar2_list;
begin
- 1
select rtrim(s.text,chr(10)) text
bulk collect into l_result
from ut_coverage_sources_tmp s
where s.owner = a_owner
and s.name = a_object_name
order by s.line;
- 1
return l_result;
end;
end;
UT3.UT_COVERAGE_HELPER_BLOCK
83.33 % lines covered
12 relevant lines. 10 lines covered (including 1 lines partially covered ) and 2 lines missed
package body ut_coverage_helper_block is
/*
utPLSQL - Version 3
Copyright 2016 - 2019 utPLSQL Project
Licensed under the Apache License, Version 2.0 (the "License"):
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
type t_proftab_row is record (
line binary_integer,
calls number(38,0)
);
type t_proftab_rows is table of t_proftab_row;
type t_block_row is record(
line binary_integer
,blocks binary_integer
,covered_blocks binary_integer);
type t_block_rows is table of t_block_row;
procedure coverage_start(a_run_comment varchar2, a_coverage_id out integer) is
begin
$if dbms_db_version.version = 12 and dbms_db_version.release >= 2 or dbms_db_version.version > 12 $then
a_coverage_id := dbms_plsql_code_coverage.start_coverage(run_comment => a_run_comment);
$else
null;
$end
end;
procedure coverage_stop is
begin
$if dbms_db_version.version = 12 and dbms_db_version.release >= 2 or dbms_db_version.version > 12 $then
dbms_plsql_code_coverage.stop_coverage();
$else
null;
$end
end;
function block_results(a_object_owner varchar2, a_object_name varchar2, a_coverage_id integer) return t_block_rows is
l_coverage_rows t_block_rows;
begin
- 46
select ccb.line as line,
count(ccb.block) as blocks,
sum(ccb.covered) as covered_blocks
bulk collect into l_coverage_rows
from dbmspcc_units ccu
left outer join dbmspcc_blocks ccb
on ccu.run_id = ccb.run_id
and ccu.object_id = ccb.object_id
where ccu.run_id = a_coverage_id
and ccu.owner = a_object_owner
and ccu.name = a_object_name
group by ccb.line
order by 1;
- 46
return l_coverage_rows;
end;
function get_raw_coverage_data(a_object_owner varchar2, a_object_name varchar2, a_coverage_id integer) return ut_coverage_helper.t_unit_line_calls is
l_tmp_data t_block_rows;
l_results ut_coverage_helper.t_unit_line_calls;
begin
$if dbms_db_version.version = 12 and dbms_db_version.release >= 2 or dbms_db_version.version > 12 $then
- 46
l_tmp_data := block_results(a_object_owner, a_object_name, a_coverage_id);
- 58
for i in 1 .. l_tmp_data.count loop
- 12
l_results(l_tmp_data(i).line).blocks := l_tmp_data(i).blocks;
- 12
l_results(l_tmp_data(i).line).covered_blocks := l_tmp_data(i).covered_blocks;
- 12
l_results(l_tmp_data(i).line).partcovered := case
- 1/2 1
when (l_tmp_data(i).covered_blocks > 0) and
- 1
(l_tmp_data(i).blocks > l_tmp_data(i).covered_blocks) then
1
else
0
end;
end loop;
$end
- 46
return l_results;
end;
end;
UT3.UT_COVERAGE_HELPER_PROFILER
70 % lines covered
10 relevant lines. 7 lines covered and 3 lines missed
package body ut_coverage_helper_profiler is
/*
utPLSQL - Version 3
Copyright 2016 - 2019 utPLSQL Project
Licensed under the Apache License, Version 2.0 (the "License"):
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
type t_proftab_row is record (
line binary_integer,
calls number(38,0)
);
type t_proftab_rows is table of t_proftab_row;
type t_block_row is record(
line binary_integer
,blocks binary_integer
,covered_blocks binary_integer);
type t_block_rows is table of t_block_row;
procedure coverage_start(a_run_comment varchar2,a_coverage_id out integer) is
begin
dbms_profiler.start_profiler(run_comment => a_run_comment, run_number => a_coverage_id);
end;
procedure coverage_pause is
l_return_code binary_integer;
begin
l_return_code := dbms_profiler.pause_profiler();
end;
procedure coverage_resume is
l_return_code binary_integer;
begin
- 22
l_return_code := dbms_profiler.resume_profiler();
end;
procedure coverage_stop is
begin
dbms_profiler.stop_profiler();
end;
function proftab_results(a_object_owner varchar2, a_object_name varchar2, a_coverage_id integer) return t_proftab_rows is
l_coverage_rows t_proftab_rows;
begin
- 46
select
d.line#,
case when sum(d.total_occur) = 0 and sum(d.total_time) > 0 then 1 else sum(d.total_occur) end total_occur
bulk collect into l_coverage_rows
from plsql_profiler_units u
join plsql_profiler_data d
on u.runid = d.runid
and u.unit_number = d.unit_number
where u.runid = a_coverage_id
and u.unit_owner = a_object_owner
and u.unit_name = a_object_name
and u.unit_type in ('PACKAGE BODY', 'TYPE BODY', 'PROCEDURE', 'FUNCTION', 'TRIGGER')
group by d.line#;
- 46
return l_coverage_rows;
end;
function get_raw_coverage_data(a_object_owner varchar2, a_object_name varchar2, a_coverage_id integer) return ut_coverage_helper.t_unit_line_calls is
l_tmp_data t_proftab_rows;
l_results ut_coverage_helper.t_unit_line_calls;
begin
- 46
l_tmp_data := proftab_results(a_object_owner, a_object_name, a_coverage_id);
- 71
for i in 1 .. l_tmp_data.count loop
- 25
l_results(l_tmp_data(i).line).calls := l_tmp_data(i).calls;
end loop;
- 46
return l_results;
end;
end;
UT3.UT_COVERAGE_PROFILER
100 % lines covered
37 relevant lines. 37 lines covered and 0 lines missed
package body ut_coverage_profiler is
/*
utPLSQL - Version 3
Copyright 2016 - 2019 utPLSQL Project
Licensed under the Apache License, Version 2.0 (the "License"):
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/**
* Public functions
*/
function get_coverage_data(a_coverage_options ut_coverage_options, a_coverage_id integer) return ut_coverage.t_coverage is
l_line_calls ut_coverage_helper.t_unit_line_calls;
- 10
l_result ut_coverage.t_coverage;
- 10
l_new_unit ut_coverage.t_unit_coverage;
l_line_no binary_integer;
l_source_objects_crsr ut_coverage_helper.t_tmp_table_objects_crsr;
l_source_object ut_coverage_helper.t_tmp_table_object;
begin
- 10
l_source_objects_crsr := ut_coverage_helper.get_tmp_table_objects_cursor();
- 56
loop
- 56
fetch l_source_objects_crsr into l_source_object;
- 56
exit when l_source_objects_crsr%notfound;
--get coverage data
- 46
l_line_calls := ut_coverage_helper_profiler.get_raw_coverage_data( l_source_object.owner, l_source_object.name, a_coverage_id);
--if there is coverage, we need to filter out the garbage (badly indicated data from dbms_profiler)
- 46
if l_line_calls.count > 0 then
--remove lines that should not be indicted as meaningful
- 70
for i in 1 .. l_source_object.to_be_skipped_list.count loop
- 63
if l_source_object.to_be_skipped_list(i) is not null then
- 63
l_line_calls.delete(l_source_object.to_be_skipped_list(i));
end if;
end loop;
end if;
--if there are no file mappings or object was actually captured by profiler
- 46
if a_coverage_options.file_mappings is null or l_line_calls.count > 0 then
--populate total stats
- 46
l_result.total_lines := nvl(l_result.total_lines,0) + l_source_object.lines_count;
--populate object level coverage stats
- 46
if not l_result.objects.exists(l_source_object.full_name) then
- 46
l_result.objects(l_source_object.full_name) := l_new_unit;
- 46
l_result.objects(l_source_object.full_name).owner := l_source_object.owner;
- 46
l_result.objects(l_source_object.full_name).name := l_source_object.name;
- 46
l_result.objects(l_source_object.full_name).total_lines := l_source_object.lines_count;
end if;
--map to results
- 46
l_line_no := l_line_calls.first;
- 46
if l_line_no is null then
- 39
l_result.uncovered_lines := l_result.uncovered_lines + l_source_object.lines_count;
- 39
l_result.objects(l_source_object.full_name).uncovered_lines := l_source_object.lines_count;
- 1
else
- 32
loop
- 32
exit when l_line_no is null;
- 25
if l_line_calls(l_line_no).calls > 0 then
--total stats
- 18
l_result.covered_lines := l_result.covered_lines + 1;
- 18
l_result.executions := l_result.executions + l_line_calls(l_line_no).calls;
--object level stats
- 18
l_result.objects(l_source_object.full_name).covered_lines := l_result.objects(l_source_object.full_name).covered_lines + 1;
- 18
l_result.objects(l_source_object.full_name).executions := l_result.objects(l_source_object.full_name).executions + l_line_calls(l_line_no).calls;
- 7
elsif l_line_calls(l_line_no).calls = 0 then
- 7
l_result.uncovered_lines := l_result.uncovered_lines + 1;
- 7
l_result.objects(l_source_object.full_name).uncovered_lines := l_result.objects(l_source_object.full_name).uncovered_lines + 1;
end if;
- 25
l_result.objects(l_source_object.full_name).lines(l_line_no).executions := l_line_calls(l_line_no).calls;
- 25
l_line_no := l_line_calls.next(l_line_no);
end loop;
end if;
end if;
end loop;
- 10
close l_source_objects_crsr;
- 10
return l_result;
end get_coverage_data;
end;
UT3.UT_COVERAGE_REPORTER_BASE
100 % lines covered
16 relevant lines. 16 lines covered and 0 lines missed
type body ut_coverage_reporter_base is
/*
utPLSQL - Version 3
Copyright 2016 - 2019 utPLSQL Project
Licensed under the Apache License, Version 2.0 (the "License"):
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
overriding final member procedure before_calling_run(self in out nocopy ut_coverage_reporter_base, a_run ut_run) as
begin
- 10
(self as ut_output_reporter_base).before_calling_run(a_run);
- 10
ut_coverage.coverage_start(a_coverage_options => a_run.coverage_options);
end;
overriding final member procedure before_calling_before_all(self in out nocopy ut_coverage_reporter_base, a_executable in ut_executable) is
begin
- 1
ut_coverage.coverage_resume();
end;
overriding final member procedure after_calling_before_all (self in out nocopy ut_coverage_reporter_base, a_executable in ut_executable) is
begin
- 1
ut_coverage.coverage_pause();
end;
overriding final member procedure before_calling_before_each(self in out nocopy ut_coverage_reporter_base, a_executable in ut_executable) is
begin
- 3
ut_coverage.coverage_resume();
end;
overriding final member procedure after_calling_before_each (self in out nocopy ut_coverage_reporter_base, a_executable in ut_executable) is
begin
- 3
ut_coverage.coverage_pause();
end;
overriding final member procedure before_calling_before_test(self in out nocopy ut_coverage_reporter_base, a_executable in ut_executable) is
begin
- 1
ut_coverage.coverage_resume();
end;
overriding final member procedure after_calling_before_test (self in out nocopy ut_coverage_reporter_base, a_executable in ut_executable) is
begin
- 1
ut_coverage.coverage_pause();
end;
overriding final member procedure before_calling_test_execute(self in out nocopy ut_coverage_reporter_base, a_executable in ut_executable) is
begin
- 12
ut_coverage.coverage_resume();
end;
overriding final member procedure after_calling_test_execute (self in out nocopy ut_coverage_reporter_base, a_executable in ut_executable) is
begin
- 12
ut_coverage.coverage_pause();
end;
overriding final member procedure before_calling_after_test(self in out nocopy ut_coverage_reporter_base, a_executable in ut_executable) is
begin
- 1
ut_coverage.coverage_resume();
end;
overriding final member procedure after_calling_after_test (self in out nocopy ut_coverage_reporter_base, a_executable in ut_executable) is
begin
- 1
ut_coverage.coverage_pause();
end;
overriding final member procedure before_calling_after_each(self in out nocopy ut_coverage_reporter_base, a_executable in ut_executable) is
begin
- 3
ut_coverage.coverage_resume();
end;
overriding final member procedure after_calling_after_each (self in out nocopy ut_coverage_reporter_base, a_executable in ut_executable) is
begin
- 3
ut_coverage.coverage_pause();
end;
overriding final member procedure before_calling_after_all(self in out nocopy ut_coverage_reporter_base, a_executable in ut_executable) is
begin
- 1
ut_coverage.coverage_resume();
end;
overriding final member procedure after_calling_after_all (self in out nocopy ut_coverage_reporter_base, a_executable in ut_executable) is
begin
- 1
ut_coverage.coverage_pause();
end;
end;
UT3.UT_EVENT_MANAGER
75.68 % lines covered
37 relevant lines. 28 lines covered and 9 lines missed
package body ut_event_manager as
/*
utPLSQL - Version 3
Copyright 2016 - 2019 utPLSQL Project
Licensed under the Apache License, Version 2.0 (the "License"):
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
type t_listeners is table of ut_event_listener;
subtype t_listener_number is binary_integer;
type t_listener_numbers is table of boolean index by t_listener_number;
type t_events_listeners is table of t_listener_numbers index by t_event_name;
type t_event_manager is record (
event_listener_index t_events_listeners,
listeners t_listeners
);
type t_event_managers is table of t_event_manager;
g_event_listeners_index t_events_listeners;
g_listeners t_listeners;
g_suspended_event_managers t_event_managers;
procedure initialize is
begin
- 116
if g_listeners is not null and g_listeners.count > 0 then
if g_suspended_event_managers is null then
g_suspended_event_managers := t_event_managers();
end if;
g_suspended_event_managers.extend;
g_suspended_event_managers(g_suspended_event_managers.count).event_listener_index := g_event_listeners_index;
g_suspended_event_managers(g_suspended_event_managers.count).listeners := g_listeners;
end if;
- 116
g_event_listeners_index.delete;
- 116
g_listeners := t_listeners();
end;
procedure dispose_listeners is
begin
- 116
if g_suspended_event_managers is not null and g_suspended_event_managers.count > 0 then
g_event_listeners_index := g_suspended_event_managers(g_suspended_event_managers.count).event_listener_index;
g_listeners := g_suspended_event_managers(g_suspended_event_managers.count).listeners;
g_suspended_event_managers.trim(1);
else
- 116
g_event_listeners_index.delete;
- 116
g_listeners := t_listeners();
end if;
end;
procedure trigger_event( a_event_name t_event_name, a_event_object ut_event_item := null ) is
procedure trigger_listener_event(
a_listener_numbers t_listener_numbers,
a_event_name t_event_name,
a_event_object ut_event_item
) is
- 2721
l_listener_number t_listener_number := a_listener_numbers.first;
begin
- 7923
while l_listener_number is not null loop
- 5202
g_listeners(l_listener_number).on_event(a_event_name, a_event_object);
- 5202
l_listener_number := a_listener_numbers.next(l_listener_number);
end loop;
end;
begin
- 7619
if a_event_name is not null then
- 7619
if g_event_listeners_index.exists(gc_all) then
- 76
trigger_listener_event( g_event_listeners_index(gc_all), a_event_name, a_event_object );
end if;
- 7619
if g_event_listeners_index.exists(a_event_name) then
- 2645
trigger_listener_event( g_event_listeners_index(a_event_name), a_event_name, a_event_object );
end if;
- 7619
if a_event_name = ut_event_manager.gc_finalize then
- 116
dispose_listeners();
end if;
end if;
end;
procedure add_event( a_event_name t_event_name, a_listener_pos binary_integer ) is
begin
- 4967
g_event_listeners_index(a_event_name)(a_listener_pos) := true;
end;
procedure add_events( a_event_names ut_varchar2_list, a_listener_pos binary_integer ) is
begin
- 5199
for i in 1 .. a_event_names.count loop
- 4967
add_event( a_event_names(i), a_listener_pos );
end loop;
end;
function add_listener( a_listener ut_event_listener ) return t_listener_number is
begin
- 232
if g_listeners is null then
g_listeners := t_listeners();
end if;
- 232
g_listeners.extend;
- 232
g_listeners(g_listeners.last) := a_listener;
- 232
return g_listeners.last;
end;
procedure add_listener( a_listener ut_event_listener ) is
l_event_names ut_varchar2_list;
begin
- 232
if a_listener is not null then
- 232
l_event_names := a_listener.get_supported_events();
- 232
if l_event_names is not empty then
- 232
add_events( l_event_names, add_listener( a_listener ) );
end if;
end if;
end;
end;
UT3.UT_OUTPUT_BUFFER_BASE
100 % lines covered
26 relevant lines. 26 lines covered and 0 lines missed
type body ut_output_buffer_base is
/*
utPLSQL - Version 3
Copyright 2016 - 2019 utPLSQL Project
Licensed under the Apache License, Version 2.0 (the "License"):
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
member procedure init(self in out nocopy ut_output_buffer_base, a_output_id raw := null, a_self_type varchar2 := null) is
pragma autonomous_transaction;
l_exists int;
begin
- 247
cleanup_buffer();
- 247
self.self_type := coalesce(a_self_type,self.self_type);
- 247
self.output_id := coalesce(a_output_id, self.output_id, sys_guid());
- 247
self.start_date := coalesce(self.start_date, sysdate);
- 247
self.last_message_id := 0;
- 247
select count(*) into l_exists from ut_output_buffer_info_tmp where output_id = self.output_id;
- 247
if ( l_exists > 0 ) then
- 119
update ut_output_buffer_info_tmp set start_date = self.start_date where output_id = self.output_id;
else
- 128
insert into ut_output_buffer_info_tmp(output_id, start_date) values (self.output_id, self.start_date);
end if;
- 247
commit;
- 247
self.is_closed := 0;
end;
member function get_lines_cursor(a_initial_timeout natural := null, a_timeout_sec natural := null) return sys_refcursor is
l_lines sys_refcursor;
begin
- 117
open l_lines for
select text, item_type
from table(self.get_lines(a_initial_timeout, a_timeout_sec));
- 117
return l_lines;
end;
member procedure lines_to_dbms_output(self in ut_output_buffer_base, a_initial_timeout natural := null, a_timeout_sec natural := null) is
l_data sys_refcursor;
l_clob clob;
l_item_type varchar2(32767);
l_lines ut_varchar2_list;
begin
- 32
l_data := self.get_lines_cursor(a_initial_timeout, a_timeout_sec);
- 629
loop
- 629
fetch l_data into l_clob, l_item_type;
- 629
exit when l_data%notfound;
- 597
l_lines := ut_utils.clob_to_table(l_clob);
- 1206
for i in 1 .. l_lines.count loop
- 609
dbms_output.put_line(l_lines(i));
end loop;
end loop;
- 32
close l_data;
end;
member procedure cleanup_buffer(self in ut_output_buffer_base, a_retention_time_sec natural := null) is
- 247
gc_buffer_retention_sec constant naturaln := coalesce(a_retention_time_sec, 60 * 60 * 24); -- 24 hours
- 247
l_retention_days number := gc_buffer_retention_sec / (60 * 60 * 24);
- 247
l_max_retention_date date := sysdate - l_retention_days;
pragma autonomous_transaction;
begin
- 247
delete from ut_output_buffer_info_tmp i where i.start_date <= l_max_retention_date;
- 247
commit;
end;
end;
UT3.UT_OUTPUT_CLOB_TABLE_BUFFER
98.21 % lines covered
56 relevant lines. 55 lines covered (including 1 lines partially covered ) and 1 lines missed
type body ut_output_clob_table_buffer is
/*
utPLSQL - Version 3
Copyright 2016 - 2019 utPLSQL Project
Licensed under the Apache License, Version 2.0 (the "License"):
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
constructor function ut_output_clob_table_buffer(self in out nocopy ut_output_clob_table_buffer, a_output_id raw := null) return self as result is
begin
- 5
self.init(a_output_id, $$plsql_unit);
- 5
return;
end;
overriding member procedure close(self in out nocopy ut_output_clob_table_buffer) is
pragma autonomous_transaction;
begin
- 4
self.last_message_id := self.last_message_id + 1;
- 4
insert into ut_output_clob_buffer_tmp(output_id, message_id, is_finished)
values (self.output_id, self.last_message_id, 1);
- 4
commit;
- 4
self.is_closed := 1;
end;
overriding member procedure send_line(self in out nocopy ut_output_clob_table_buffer, a_text varchar2, a_item_type varchar2 := null) is
pragma autonomous_transaction;
begin
- 309
if a_text is not null or a_item_type is not null then
- 309
self.last_message_id := self.last_message_id + 1;
- 309
insert into ut_output_clob_buffer_tmp(output_id, message_id, text, item_type)
values (self.output_id, self.last_message_id, a_text, a_item_type);
end if;
- 309
commit;
end;
overriding member procedure send_lines(self in out nocopy ut_output_clob_table_buffer, a_text_list ut_varchar2_rows, a_item_type varchar2 := null) is
pragma autonomous_transaction;
begin
- 53
insert into ut_output_clob_buffer_tmp(output_id, message_id, text, item_type)
select self.output_id, self.last_message_id + rownum, t.column_value, a_item_type
from table(a_text_list) t
where t.column_value is not null or a_item_type is not null;
- 53
self.last_message_id := self.last_message_id + SQL%rowcount;
- 53
commit;
end;
overriding member procedure send_clob(self in out nocopy ut_output_clob_table_buffer, a_text clob, a_item_type varchar2 := null) is
pragma autonomous_transaction;
begin
- 1/2 31
if a_text is not null and a_text != empty_clob() or a_item_type is not null then
- 31
self.last_message_id := self.last_message_id + 1;
- 31
insert into ut_output_clob_buffer_tmp(output_id, message_id, text, item_type)
values (self.output_id, self.last_message_id, a_text, a_item_type);
end if;
- 31
commit;
end;
overriding member function get_lines(a_initial_timeout natural := null, a_timeout_sec natural := null) return ut_output_data_rows pipelined is
type t_rowid_tab is table of urowid;
l_message_rowids t_rowid_tab;
l_buffer_data ut_output_data_rows;
l_finished_flags ut_integer_list;
- 4
l_already_waited_for number(10,2) := 0;
- 4
l_finished boolean := false;
- 4
lc_init_wait_sec constant naturaln := coalesce(a_initial_timeout, 60 ); -- 1 minute
- 4
lc_max_wait_sec constant naturaln := coalesce(a_timeout_sec, 60 * 60 * 4); -- 4 hours
- 4
l_wait_for integer := lc_init_wait_sec;
- 4
lc_short_sleep_time constant number(1,1) := 0.1; --sleep for 100 ms between checks
- 4
lc_long_sleep_time constant number(1) := 1; --sleep for 1 s when waiting long
- 4
lc_long_wait_time constant number(1) := 1; --waiting more than 1 sec
- 4
l_sleep_time number(2,1) := lc_short_sleep_time;
- 4
lc_bulk_limit constant integer := 5000;
- 4
l_max_message_id integer := lc_bulk_limit;
procedure remove_read_data(a_message_rowids t_rowid_tab) is
pragma autonomous_transaction;
begin
- 3
forall i in 1 .. a_message_rowids.count
- 1
delete from ut_output_clob_buffer_tmp a
where rowid = a_message_rowids(i);
- 3
commit;
end;
procedure remove_buffer_info is
pragma autonomous_transaction;
begin
- 4
delete from ut_output_buffer_info_tmp a
where a.output_id = self.output_id;
- 4
commit;
end;
begin
- 7
while not l_finished loop
- 4
with ordered_buffer as (
select /*+ index(a) */ a.rowid, ut_output_data_row(a.text, a.item_type), is_finished
from ut_output_clob_buffer_tmp a
where a.output_id = self.output_id
and a.message_id <= l_max_message_id
order by a.message_id
)
select b.*
bulk collect into l_message_rowids, l_buffer_data, l_finished_flags
from ordered_buffer b;
--nothing fetched from output, wait and try again
- 4
if l_buffer_data.count = 0 then
$if dbms_db_version.version >= 18 $then
- 1
dbms_session.sleep(l_sleep_time);
$else
dbms_lock.sleep(l_sleep_time);
$end
- 1
l_already_waited_for := l_already_waited_for + l_sleep_time;
- 1
if l_already_waited_for > lc_long_wait_time then
l_sleep_time := lc_long_sleep_time;
end if;
else
--reset wait time
-- we wait lc_max_wait_sec for new message
- 3
l_wait_for := lc_max_wait_sec;
- 3
l_already_waited_for := 0;
- 3
l_sleep_time := lc_short_sleep_time;
- 59
for i in 1 .. l_buffer_data.count loop
- 2540
if l_buffer_data(i).text is not null then
- 2482
pipe row(l_buffer_data(i));
- 58
elsif l_finished_flags(i) = 1 then
- 3
l_finished := true;
- 3
exit;
end if;
end loop;
- 3
remove_read_data(l_message_rowids);
- 3
l_max_message_id := l_max_message_id + lc_bulk_limit;
end if;
- 4
if l_finished or l_already_waited_for >= l_wait_for then
- 4
remove_buffer_info();
- 4
if l_already_waited_for > 0 and l_already_waited_for >= l_wait_for then
- 1
raise_application_error(
ut_utils.gc_out_buffer_timeout,
'Timeout occurred while waiting for output data. Waited for: '||l_already_waited_for||' seconds.'
);
end if;
end if;
end loop;
- 3
return;
end;
end;
UT3.UT_OUTPUT_TABLE_BUFFER
86.21 % lines covered
58 relevant lines. 50 lines covered and 8 lines missed
type body ut_output_table_buffer is
/*
utPLSQL - Version 3
Copyright 2016 - 2019 utPLSQL Project
Licensed under the Apache License, Version 2.0 (the "License"):
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
constructor function ut_output_table_buffer(self in out nocopy ut_output_table_buffer, a_output_id raw := null) return self as result is
begin
- 123
self.init(a_output_id, $$plsql_unit);
- 123
return;
end;
overriding member procedure close(self in out nocopy ut_output_table_buffer) is
pragma autonomous_transaction;
begin
- 117
self.last_message_id := self.last_message_id + 1;
- 117
insert into ut_output_buffer_tmp(output_id, message_id, is_finished)
values (self.output_id, self.last_message_id, 1);
- 117
commit;
- 117
self.is_closed := 1;
end;
overriding member procedure send_line(self in out nocopy ut_output_table_buffer, a_text varchar2, a_item_type varchar2 := null) is
pragma autonomous_transaction;
begin
- 1505
if a_text is not null or a_item_type is not null then
- 1504
if length(a_text) > ut_utils.gc_max_storage_varchar2_len then
self.send_lines(
ut_utils.convert_collection(
ut_utils.clob_to_table(a_text, ut_utils.gc_max_storage_varchar2_len)
),
a_item_type
);
else
- 1504
self.last_message_id := self.last_message_id + 1;
- 1504
insert into ut_output_buffer_tmp(output_id, message_id, text, item_type)
values (self.output_id, self.last_message_id, a_text, a_item_type);
end if;
- 1504
commit;
end if;
end;
overriding member procedure send_lines(self in out nocopy ut_output_table_buffer, a_text_list ut_varchar2_rows, a_item_type varchar2 := null) is
pragma autonomous_transaction;
begin
- 282
insert into ut_output_buffer_tmp(output_id, message_id, text, item_type)
select self.output_id, self.last_message_id + rownum, t.column_value, a_item_type
from table(a_text_list) t
where t.column_value is not null or a_item_type is not null;
- 282
self.last_message_id := self.last_message_id + SQL%rowcount;
- 282
commit;
end;
overriding member procedure send_clob(self in out nocopy ut_output_table_buffer, a_text clob, a_item_type varchar2 := null) is
pragma autonomous_transaction;
begin
if a_text is not null and a_text != empty_clob() or a_item_type is not null then
if length(a_text) > ut_utils.gc_max_storage_varchar2_len then
self.send_lines(
ut_utils.convert_collection(
ut_utils.clob_to_table(a_text, ut_utils.gc_max_storage_varchar2_len)
),
a_item_type
);
else
self.last_message_id := self.last_message_id + 1;
insert into ut_output_buffer_tmp(output_id, message_id, text, item_type)
values (self.output_id, self.last_message_id, a_text, a_item_type);
end if;
commit;
end if;
end;
overriding member function get_lines(a_initial_timeout natural := null, a_timeout_sec natural := null) return ut_output_data_rows pipelined is
l_buffer_data ut_varchar2_rows;
l_item_types ut_varchar2_rows;
l_finished_flags ut_integer_list;
- 116
l_already_waited_for number(10,2) := 0;
- 116
l_finished boolean := false;
- 116
lc_init_wait_sec constant naturaln := coalesce(a_initial_timeout, 60 ); -- 1 minute
- 116
lc_max_wait_sec constant naturaln := coalesce(a_timeout_sec, 60 * 60 * 4); -- 4 hours
- 116
l_wait_for integer := lc_init_wait_sec;
- 116
lc_short_sleep_time constant number(1,1) := 0.1; --sleep for 100 ms between checks
- 116
lc_long_sleep_time constant number(1) := 1; --sleep for 1 s when waiting long
- 116
lc_long_wait_time constant number(1) := 1; --waiting more than 1 sec
- 116
l_sleep_time number(2,1) := lc_short_sleep_time;
- 116
lc_bulk_limit constant integer := 5000;
- 116
l_max_message_id integer := lc_bulk_limit;
procedure get_data_from_buffer(
a_max_message_id integer,
a_buffer_data out nocopy ut_varchar2_rows,
a_item_types out nocopy ut_varchar2_rows,
a_finished_flags out nocopy ut_integer_list
) is
pragma autonomous_transaction;
begin
- 128
delete from (
select *
from ut_output_buffer_tmp o
where o.output_id = self.output_id
and o.message_id <= a_max_message_id
order by o.message_id
) d
returning d.text, d.item_type, d.is_finished
bulk collect into a_buffer_data, a_item_types, a_finished_flags;
- 128
commit;
end;
procedure remove_buffer_info is
pragma autonomous_transaction;
begin
- 116
delete from ut_output_buffer_info_tmp a
where a.output_id = self.output_id;
- 116
commit;
end;
begin
- 242
while not l_finished loop
- 128
get_data_from_buffer( l_max_message_id, l_buffer_data, l_item_types, l_finished_flags);
--nothing fetched from output, wait and try again
- 128
if l_buffer_data.count = 0 then
$if dbms_db_version.version >= 18 $then
- 11
dbms_session.sleep(l_sleep_time);
$else
dbms_lock.sleep(l_sleep_time);
$end
- 11
l_already_waited_for := l_already_waited_for + l_sleep_time;
- 11
if l_already_waited_for > lc_long_wait_time then
l_sleep_time := lc_long_sleep_time;
end if;
else
--reset wait time
-- we wait lc_max_wait_sec for new message
- 117
l_wait_for := lc_max_wait_sec;
- 117
l_already_waited_for := 0;
- 117
l_sleep_time := lc_short_sleep_time;
- 232
for i in 1 .. l_buffer_data.count loop
- 14921
if l_buffer_data(i) is not null then
- 14695
pipe row(ut_output_data_row(l_buffer_data(i),l_item_types(i)));
- 226
elsif l_finished_flags(i) = 1 then
- 114
l_finished := true;
- 114
exit;
end if;
end loop;
- 117
l_max_message_id := l_max_message_id + lc_bulk_limit;
end if;
- 128
if l_finished or l_already_waited_for >= l_wait_for then
- 116
remove_buffer_info();
- 116
if l_already_waited_for > 0 and l_already_waited_for >= l_wait_for then
- 2
raise_application_error(
ut_utils.gc_out_buffer_timeout,
'Timeout occurred while waiting for output data. Waited for: '||l_already_waited_for||' seconds.'
);
end if;
end if;
end loop;
- 114
return;
end;
end;
UT3.UT_SESSION_CONTEXT
85.71 % lines covered
7 relevant lines. 6 lines covered and 1 lines missed
package body ut_session_context as
/*
utPLSQL - Version 3
Copyright 2016 - 2019 utPLSQL Project
Licensed under the Apache License, Version 2.0 (the "License"):
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
$IF $$SELF_TESTING_INSTALL $THEN
gc_context_name constant varchar2(30) := ut_utils.ut_owner()||'_INFO';
$ELSE
- 1
gc_context_name constant varchar2(30) := 'UT3_INFO';
$END
procedure set_context(a_name varchar2, a_value varchar2) is
begin
- 3288
dbms_session.set_context( gc_context_name, a_name, a_value );
end;
procedure clear_context(a_name varchar2) is
begin
- 3284
dbms_session.clear_context( namespace => gc_context_name, attribute => a_name );
end;
procedure clear_all_context is
begin
- 120
dbms_session.clear_all_context( namespace => gc_context_name );
end;
function is_ut_run return boolean is
l_paths varchar2(32767);
begin
- 799
l_paths := sys_context(gc_context_name, 'RUN_PATHS');
- 799
return l_paths is not null;
end;
function get_namespace return varchar2 is
begin
return gc_context_name;
end;
end;
UT3.UT_SESSION_INFO
98.68 % lines covered
76 relevant lines. 75 lines covered and 1 lines missed
type body ut_session_info as
/*
utPLSQL - Version 3
Copyright 2016 - 2019 utPLSQL Project
Licensed under the Apache License, Version 2.0 (the "License"):
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
constructor function ut_session_info(self in out nocopy ut_session_info) return self as result is
begin
- 116
self.self_type := $$plsql_unit;
- 116
dbms_application_info.read_client_info( client_info );
- 116
dbms_application_info.read_module( module, action );
- 116
return;
end;
-- run hooks
member procedure before_calling_run(self in out nocopy ut_session_info, a_run in ut_run) is
begin
- 115
ut_session_context.set_context( 'run_paths', ut_utils.to_string( ut_utils.table_to_clob( a_run.run_paths,',' ), null ) );
- 115
dbms_application_info.set_module( 'utPLSQL', null );
end;
member procedure after_calling_run(self in out nocopy ut_session_info, a_run in ut_run) is
begin
- 115
ut_session_context.clear_context( 'run_paths' );
- 115
dbms_application_info.set_module( module, action );
- 115
dbms_application_info.set_client_info( client_info );
end;
-- suite hooks
member procedure before_calling_suite(self in out nocopy ut_session_info, a_suite in ut_logical_suite) is
begin
- 333
if a_suite is not of (ut_suite_context) then
- 322
ut_session_context.set_context( 'suite_path', a_suite.path );
- 322
ut_session_context.set_context( 'suite_package', a_suite.object_owner||'.'||a_suite.object_name );
- 322
ut_session_context.set_context( 'suite_description', a_suite.description );
- 322
ut_session_context.set_context( 'suite_start_time', ut_utils.to_string(a_suite.start_time) );
- 322
dbms_application_info.set_module( 'utPLSQL', a_suite.object_name );
else
- 11
ut_session_context.set_context( 'context_name', a_suite.name );
- 11
ut_session_context.set_context( 'context_path', a_suite.path);
- 11
ut_session_context.set_context( 'context_description', a_suite.description );
- 11
ut_session_context.set_context( 'context_start_time', ut_utils.to_string(a_suite.start_time) );
end if;
end;
member procedure after_calling_suite(self in out nocopy ut_session_info, a_suite in ut_logical_suite) is
begin
- 333
if a_suite is not of (ut_suite_context) then
- 322
ut_session_context.clear_context( 'suite_package' );
- 322
ut_session_context.clear_context( 'suite_path' );
- 322
ut_session_context.clear_context( 'suite_description' );
- 322
ut_session_context.clear_context( 'suite_start_time' );
else
- 11
ut_session_context.clear_context( 'context_name' );
- 11
ut_session_context.clear_context( 'context_path' );
- 11
ut_session_context.clear_context( 'context_description' );
- 11
ut_session_context.clear_context( 'context_start_time' );
end if;
end;
member procedure before_calling_test(self in out nocopy ut_session_info, a_test in ut_test) is
begin
- 319
ut_session_context.set_context( 'test_name', a_test.object_owner||'.'||a_test.object_name||'.'||a_test.name );
- 319
ut_session_context.set_context( 'test_description', a_test.description );
- 319
ut_session_context.set_context( 'test_start_time', ut_utils.to_string(a_test.start_time) );
end;
member procedure after_calling_test (self in out nocopy ut_session_info, a_test in ut_test) is
begin
- 319
ut_session_context.clear_context( 'test_name' );
- 319
ut_session_context.clear_context( 'test_description' );
- 319
ut_session_context.clear_context( 'test_start_time' );
end;
member procedure before_calling_executable(self in out nocopy ut_session_info, a_executable in ut_executable) is
begin
- 440
ut_session_context.set_context( 'current_executable_type', a_executable.executable_type );
- 440
ut_session_context.set_context(
'current_executable_name',
a_executable.owner_name||'.'||a_executable.object_name||'.'||a_executable.procedure_name
);
- 440
dbms_application_info.set_client_info( a_executable.procedure_name );
end;
member procedure after_calling_executable(self in out nocopy ut_session_info, a_executable in ut_executable) is
begin
- 440
ut_session_context.clear_context( 'current_executable_type' );
- 440
ut_session_context.clear_context( 'current_executable_name' );
- 440
dbms_application_info.set_client_info( null );
end;
member procedure on_finalize(self in out nocopy ut_session_info, a_run in ut_run) is
begin
- 116
dbms_application_info.set_client_info( client_info );
- 116
dbms_application_info.set_module( module, action );
- 117
ut_session_context.clear_all_context();
end;
overriding member function get_supported_events return ut_varchar2_list is
begin
- 116
return ut_varchar2_list(
ut_event_manager.gc_before_run,
ut_event_manager.gc_before_suite,
ut_event_manager.gc_before_test,
ut_event_manager.gc_before_before_all,
ut_event_manager.gc_before_before_each,
ut_event_manager.gc_before_before_test,
ut_event_manager.gc_before_test_execute,
ut_event_manager.gc_before_after_test,
ut_event_manager.gc_before_after_each,
ut_event_manager.gc_before_after_all,
ut_event_manager.gc_after_run,
ut_event_manager.gc_after_suite,
ut_event_manager.gc_after_test,
ut_event_manager.gc_after_before_all,
ut_event_manager.gc_after_before_each,
ut_event_manager.gc_after_before_test,
ut_event_manager.gc_after_test_execute,
ut_event_manager.gc_after_after_test,
ut_event_manager.gc_after_after_each,
ut_event_manager.gc_after_after_all,
ut_event_manager.gc_finalize
);
end;
overriding member procedure on_event( self in out nocopy ut_session_info, a_event_name varchar2, a_event_item ut_event_item) is
begin
- 2530
case
- 2530
when a_event_name in (
ut_event_manager.gc_before_before_all,
- 1
ut_event_manager.gc_before_before_each,
- 1
ut_event_manager.gc_before_before_test,
- 1
ut_event_manager.gc_before_test_execute,
- 1
ut_event_manager.gc_before_after_test,
- 1
ut_event_manager.gc_before_after_each,
- 1
ut_event_manager.gc_before_after_all
)
- 440
then before_calling_executable(treat(a_event_item as ut_executable));
- 2090
when a_event_name in (
ut_event_manager.gc_after_before_all,
- 1
ut_event_manager.gc_after_before_each,
- 1
ut_event_manager.gc_after_before_test,
- 1
ut_event_manager.gc_after_test_execute,
- 1
ut_event_manager.gc_after_after_test,
- 1
ut_event_manager.gc_after_after_each,
- 1
ut_event_manager.gc_after_after_all
)
- 440
then after_calling_executable(treat(a_event_item as ut_executable));
- 1650
when a_event_name = ut_event_manager.gc_before_test
- 319
then self.before_calling_test(treat(a_event_item as ut_test));
- 1331
when a_event_name = ut_event_manager.gc_after_test
- 319
then self.after_calling_test(treat(a_event_item as ut_test));
- 1012
when a_event_name = ut_event_manager.gc_after_suite
- 333
then after_calling_suite(treat(a_event_item as ut_logical_suite));
- 679
when a_event_name = ut_event_manager.gc_before_suite
- 333
then before_calling_suite(treat(a_event_item as ut_logical_suite));
- 346
when a_event_name = ut_event_manager.gc_before_run
- 115
then before_calling_run(treat(a_event_item as ut_run));
- 231
when a_event_name = ut_event_manager.gc_after_run
- 115
then after_calling_run(treat(a_event_item as ut_run));
- 116
when a_event_name = ut_event_manager.gc_finalize
- 116
then on_finalize(treat(a_event_item as ut_run));
else null;
end case;
end;
end;
UT3.UT_CONSOLE_REPORTER_BASE
100 % lines covered
5 relevant lines. 5 lines covered and 0 lines missed
type body ut_console_reporter_base is
/*
utPLSQL - Version 3
Copyright 2016 - 2019 utPLSQL Project
Licensed under the Apache License, Version 2.0 (the "License"):
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
static procedure set_color_enabled(a_flag boolean) is
begin
- 116
ut_ansiconsole_helper.color_enabled(a_flag);
end;
member procedure print_red_text(self in out nocopy ut_console_reporter_base, a_text varchar2) is
begin
- 207
self.print_text(ut_ansiconsole_helper.red(a_text));
end;
member procedure print_green_text(self in out nocopy ut_console_reporter_base, a_text varchar2) is
begin
- 180
self.print_text(ut_ansiconsole_helper.green(a_text));
end;
member procedure print_yellow_text(self in out nocopy ut_console_reporter_base, a_text varchar2) is
begin
- 1
self.print_text(ut_ansiconsole_helper.yellow(a_text));
end;
member procedure print_cyan_text(self in out nocopy ut_console_reporter_base, a_text varchar2) is
begin
- 10
self.print_text(ut_ansiconsole_helper.cyan(a_text));
end;
end;
UT3.UT_EXECUTABLE
92.75 % lines covered
69 relevant lines. 64 lines covered and 5 lines missed
type body ut_executable is
/*
utPLSQL - Version 3
Copyright 2016 - 2019 utPLSQL Project
Licensed under the Apache License, Version 2.0 (the "License"):
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
constructor function ut_executable(
self in out nocopy ut_executable, a_owner varchar2, a_package varchar2,
a_procedure_name varchar2, a_executable_type varchar2
) return self as result is
begin
- 848
self.self_type := $$plsql_unit;
- 848
self.executable_type := a_executable_type;
- 848
self.owner_name := a_owner;
- 848
self.object_name := a_package;
- 848
self.procedure_name := a_procedure_name;
- 848
return;
end;
member function form_name(a_skip_current_user_schema boolean := false) return varchar2 is
- 563
l_owner_name varchar2(250) := owner_name;
begin
- 563
if a_skip_current_user_schema and sys_context('userenv', 'current_schema') = owner_name then
- 379
l_owner_name := null;
end if;
- 563
return ut_metadata.form_name(l_owner_name, object_name, procedure_name);
end;
member procedure do_execute(self in out nocopy ut_executable, a_item in out nocopy ut_suite_item) is
l_completed_without_errors boolean;
begin
- 396
l_completed_without_errors := self.do_execute(a_item);
end do_execute;
- 505
member function do_execute(self in out nocopy ut_executable, a_item in out nocopy ut_suite_item) return boolean is
l_statement varchar2(4000);
l_status number;
l_cursor_number number;
- 505
l_completed_without_errors boolean := true;
- 505
l_failed_with_invalid_pck boolean := true;
l_start_transaction_id varchar2(250);
l_end_transaction_id varchar2(250);
function is_defined return boolean is
- 505
l_result boolean := false;
- 505
l_message_part varchar2(4000) := 'Call params for ' || self.executable_type || ' are not valid: ';
begin
- 505
if self.object_name is null then
- 1
self.error_stack := l_message_part || 'package is not defined';
- 504
elsif self.procedure_name is null then
- 5
self.error_stack := l_message_part || 'procedure is not defined';
else
- 499
l_result := true;
end if;
- 505
return l_result;
end is_defined;
function is_invalid return boolean is
- 12
l_result boolean := true;
- 12
l_message_part varchar2(4000) := 'Call params for ' || self.executable_type || ' are not valid: ';
begin
- 12
if not ut_metadata.package_valid(self.owner_name, self.object_name) then
- 6
self.error_stack := l_message_part || 'package '||upper(self.owner_name||'.'||self.object_name)||' does not exist or is invalid.';
- 6
elsif not ut_metadata.procedure_exists(self.owner_name, self.object_name, self.procedure_name) then
- 6
self.error_stack := l_message_part || 'procedure '||upper(self.owner_name || '.' || self.object_name || '.' ||self.procedure_name)||' does not exist.';
else
l_result := false;
end if;
- 12
return l_result;
end is_invalid;
procedure save_dbms_output is
l_status number;
l_line varchar2(32767);
begin
- 499
dbms_output.get_line(line => l_line, status => l_status);
- 499
if l_status != 1 then
- 326
dbms_lob.createtemporary(self.serveroutput, true, dur => dbms_lob.session);
end if;
- 951
while l_status != 1 loop
- 452
if l_line is not null then
- 451
ut_utils.append_to_clob(self.serveroutput, l_line||chr(10));
end if;
- 452
dbms_output.get_line(line => l_line, status => l_status);
end loop;
end save_dbms_output;
begin
- 505
l_start_transaction_id := dbms_transaction.local_transaction_id(true);
--listener - before call to executable
- 505
ut_event_manager.trigger_event('before_'||self.executable_type, self);
- 505
l_completed_without_errors := is_defined();
- 505
if l_completed_without_errors then
- 499
l_statement :=
'declare' || chr(10) ||
' l_error_stack varchar2(32767);' || chr(10) ||
' l_error_backtrace varchar2(32767);' || chr(10) ||
'begin' || chr(10) ||
' begin' || chr(10) ||
' ' || self.form_name( a_skip_current_user_schema => true ) || ';' || chr(10) ||
' exception' || chr(10) ||
' when others then ' || chr(10) ||
' l_error_stack := dbms_utility.format_error_stack;' || chr(10) ||
' l_error_backtrace := dbms_utility.format_error_backtrace;' || chr(10) ||
' --raise on ORA-04068, ORA-04061: existing state of packages has been discarded to avoid unrecoverable session exception' || chr(10) ||
' end;' || chr(10) ||
' :a_error_stack := l_error_stack;' || chr(10) ||
' :a_error_backtrace := l_error_backtrace;' || chr(10) ||
'end;';
- 499
ut_utils.debug_log('ut_executable.do_execute l_statement: ' || l_statement);
- 499
l_cursor_number := dbms_sql.open_cursor;
/**
* The code will allow to execute once we check if packages are defined
* If it fail with 6550 (usually invalid package) it will check if because of invalid state or missing
* if for any other reason we will propagate it up as we didnt expected.
**/
begin
- 499
dbms_sql.parse(l_cursor_number, statement => l_statement, language_flag => dbms_sql.native);
- 492
dbms_sql.bind_variable(l_cursor_number, 'a_error_stack', to_char(null), 32767);
- 492
dbms_sql.bind_variable(l_cursor_number, 'a_error_backtrace', to_char(null), 32767);
- 492
l_status := dbms_sql.execute(l_cursor_number);
- 487
dbms_sql.variable_value(l_cursor_number, 'a_error_stack', self.error_stack);
- 487
dbms_sql.variable_value(l_cursor_number, 'a_error_backtrace', self.error_backtrace);
- 487
dbms_sql.close_cursor(l_cursor_number);
exception
- 24
when ut_utils.ex_invalid_package then
- 12
l_failed_with_invalid_pck := is_invalid();
- 12
dbms_sql.close_cursor(l_cursor_number);
- 12
if not l_failed_with_invalid_pck then
raise;
end if;
when others then
dbms_sql.close_cursor(l_cursor_number);
raise;
end;
- 499
save_dbms_output;
- 499
l_completed_without_errors := (self.error_stack||self.error_backtrace) is null;
- 499
if self.error_stack like '%ORA-04068%' or self.error_stack like '%ORA-04061%' then
- 2
ut_expectation_processor.set_invalidation_exception();
end if;
end if;
--listener - after call to executable
- 505
ut_event_manager.trigger_event('after_'||self.executable_type, self);
- 505
l_end_transaction_id := dbms_transaction.local_transaction_id();
- 505
if l_start_transaction_id != l_end_transaction_id or l_end_transaction_id is null then
- 3
a_item.add_transaction_invalidator(self.form_name());
end if;
- 505
return l_completed_without_errors;
end do_execute;
member function get_error_stack_trace return varchar2 is
begin
- 589
return rtrim(self.error_stack||self.error_backtrace, chr(10));
end;
end;
UT3.UT_EXECUTABLE_TEST
96.15 % lines covered
26 relevant lines. 25 lines covered and 1 lines missed
type body ut_executable_test as
/*
utPLSQL - Version 3
Copyright 2016 - 2019 utPLSQL Project
Licensed under the Apache License, Version 2.0 (the "License"):
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
constructor function ut_executable_test(
self in out nocopy ut_executable_test, a_owner varchar2, a_package varchar2,
a_procedure_name varchar2, a_executable_type varchar2
) return self as result is
begin
- 2468
self.self_type := $$plsql_unit;
- 2468
self.executable_type := a_executable_type;
- 2468
self.owner_name := a_owner;
- 2468
self.object_name := a_package;
- 2468
self.procedure_name := a_procedure_name;
- 2468
return;
end;
member procedure do_execute(
self in out nocopy ut_executable_test, a_item in out nocopy ut_suite_item,
a_expected_error_codes in ut_integer_list
) is
l_completed_without_errors boolean;
begin
- 337
l_completed_without_errors := self.do_execute(a_item, a_expected_error_codes);
end do_execute;
member function do_execute(
self in out nocopy ut_executable_test, a_item in out nocopy ut_suite_item,
a_expected_error_codes in ut_integer_list
) return boolean is
l_expected_except_message varchar2(4000);
function failed_expec_errnum_message(a_expected_error_codes in ut_integer_list) return varchar is
l_actual_error_no integer;
l_expected_error_codes varchar2(4000);
l_fail_message varchar2(4000);
begin
--Convert the ut_varchar2_list to string to can construct the message
- 16
l_expected_error_codes := ut_utils.table_to_clob(a_expected_error_codes, ', ');
- 16
if self.error_stack is null then
- 1
l_fail_message := 'Expected one of exceptions ('||l_expected_error_codes||') but nothing was raised.';
else
- 15
l_actual_error_no := regexp_substr(self.error_stack, '^[a-zA-Z]{3}(-[0-9]+)', subexpression=>1);
- 15
if not l_actual_error_no member of a_expected_error_codes then
- 2
l_fail_message := 'Actual: '||l_actual_error_no||' was expected to ';
- 2
if cardinality(a_expected_error_codes) > 1 then
l_fail_message := l_fail_message || 'be one of: ('||l_expected_error_codes||')';
else
- 2
l_fail_message := l_fail_message || 'equal: '||l_expected_error_codes;
end if;
- 2
l_fail_message := substr( l_fail_message||chr(10)||self.error_stack||chr(10)||self.error_backtrace, 1, 4000 );
end if;
end if;
- 16
return l_fail_message;
end;
begin
--Create a ut_executable object and call do_execute after that get the data to know the test's execution result
- 337
self.do_execute(a_item);
- 337
if a_expected_error_codes is not null and a_expected_error_codes is not empty then
- 16
l_expected_except_message := failed_expec_errnum_message(a_expected_error_codes);
- 16
if l_expected_except_message is not null then
- 3
ut_expectation_processor.add_expectation_result(
ut_expectation_result(ut_utils.gc_failure, null, l_expected_except_message, false)
);
end if;
- 16
self.error_stack := null;
- 16
self.error_backtrace := null;
end if;
- 337
return (self.error_stack||self.error_backtrace) is null;
end;
end;
UT3.UT_EXPECTATION_RESULT
93.33 % lines covered
15 relevant lines. 14 lines covered and 1 lines missed
type body ut_expectation_result is
/*
utPLSQL - Version 3
Copyright 2016 - 2019 utPLSQL Project
Licensed under the Apache License, Version 2.0 (the "License"):
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
constructor function ut_expectation_result(
self in out nocopy ut_expectation_result, a_status integer,
a_description varchar2, a_message clob, a_include_caller_info boolean := true
) return self as result is
begin
- 799
self.self_type := $$plsql_unit;
- 799
self.status := a_status;
- 799
self.description := a_description;
- 799
self.message := a_message;
- 800
if self.status = ut_utils.gc_failure and a_include_caller_info then
- 427
self.caller_info := ut_expectation_processor.who_called_expectation(dbms_utility.format_call_stack());
end if;
- 799
return;
end;
member function get_result_clob(self in ut_expectation_result) return clob is
l_result clob;
begin
- 33
if self.description is not null then
- 6
ut_utils.append_to_clob(l_result, '"'||self.description||'"');
- 6
if self.message is not null then
- 6
ut_utils.append_to_clob(l_result, chr(10));
end if;
end if;
- 33
ut_utils.append_to_clob(l_result, self.message);
- 33
return l_result;
end;
member function get_result_lines(self in ut_expectation_result) return ut_varchar2_list is
begin
- 33
return ut_utils.clob_to_table(get_result_clob(), 4000 );
end;
member function result return integer is
begin
return self.status;
end;
end;
UT3.UT_FILE_MAPPING
100 % lines covered
2 relevant lines. 2 lines covered and 0 lines missed
type body ut_file_mapping as
/*
utPLSQL - Version 3
Copyright 2016 - 2019 utPLSQL Project
Licensed under the Apache License, Version 2.0 (the "License"):
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
- 48
map member function pk return varchar2 is
begin
- 48
return object_type||' '||object_owner||'.'||object_name;
end;
end;
UT3.UT_LOGICAL_SUITE
100 % lines covered
42 relevant lines. 42 lines covered and 0 lines missed
type body ut_logical_suite as
/*
utPLSQL - Version 3
Copyright 2016 - 2019 utPLSQL Project
Licensed under the Apache License, Version 2.0 (the "License"):
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
overriding member procedure mark_as_skipped(self in out nocopy ut_logical_suite) is
begin
- 2
ut_event_manager.trigger_event(ut_event_manager.gc_before_suite, self);
- 1
self.start_time := current_timestamp;
- 3
for i in 1 .. self.items.count loop
- 2
self.items(i).mark_as_skipped();
end loop;
- 1
self.end_time := self.start_time;
- 1
ut_event_manager.trigger_event(ut_event_manager.gc_after_suite, self);
- 1
self.calc_execution_result();
end;
overriding member procedure set_rollback_type(self in out nocopy ut_logical_suite, a_rollback_type integer, a_force boolean := false) is
begin
- 1419
self.rollback_type := case when a_force then a_rollback_type else coalesce(self.rollback_type, a_rollback_type) end;
- 3289
for i in 1 .. self.items.count loop
- 1870
self.items(i).set_rollback_type(self.rollback_type, a_force);
end loop;
end;
overriding member function do_execute(self in out nocopy ut_logical_suite) return boolean is
l_suite_savepoint varchar2(30);
l_item_savepoint varchar2(30);
l_completed_without_errors boolean;
begin
- 141
ut_utils.debug_log('ut_logical_suite.execute');
- 141
ut_event_manager.trigger_event(ut_event_manager.gc_before_suite, self);
- 141
self.start_time := current_timestamp;
- 285
for i in 1 .. self.items.count loop
-- execute the item (test or suite)
- 144
self.items(i).do_execute();
end loop;
- 141
self.calc_execution_result();
- 141
self.end_time := current_timestamp;
- 141
ut_event_manager.trigger_event(ut_event_manager.gc_after_suite, self);
- 141
return l_completed_without_errors;
end;
overriding member procedure calc_execution_result(self in out nocopy ut_logical_suite) is
l_result integer(1);
begin
- 347
if self.items is not null and self.items.count > 0 then
- 876
for i in 1 .. self.items.count loop
- 531
self.results_count.sum_counter_values( self.items(i).results_count );
end loop;
- 345
l_result := self.results_count.result_status();
else
--if suite is empty then it's successful (no errors)
- 2
l_result := ut_utils.gc_success;
end if;
- 347
self.result := l_result;
end;
overriding member procedure mark_as_errored(self in out nocopy ut_logical_suite, a_error_stack_trace varchar2) is
begin
- 2
ut_utils.debug_log('ut_logical_suite.fail');
- 2
ut_event_manager.trigger_event(ut_event_manager.gc_before_suite, self);
- 2
self.start_time := current_timestamp;
- 4
for i in 1 .. self.items.count loop
-- execute the item (test or suite)
- 2
self.items(i).mark_as_errored(a_error_stack_trace);
end loop;
- 2
self.calc_execution_result();
- 2
self.end_time := self.start_time;
- 2
ut_event_manager.trigger_event(ut_event_manager.gc_after_suite, self);
end;
overriding member function get_error_stack_traces return ut_varchar2_list is
begin
- 1
return ut_varchar2_list();
end;
overriding member function get_serveroutputs return clob is
begin
- 1
return null;
end;
overriding member function get_transaction_invalidators return ut_varchar2_list is
l_result ut_varchar2_list;
l_child_results ut_varchar2_list;
begin
- 3
l_result := self.transaction_invalidators;
- 5
for i in 1 .. self.items.count loop
- 2
l_child_results := self.items(i).get_transaction_invalidators();
- 4
for j in 1 .. l_child_results.count loop
- 2
if l_child_results(j) not member of l_result then
- 4
l_result.extend; l_result(l_result.last) := l_child_results(j);
end if;
end loop;
end loop;
- 3
return l_result;
end;
end;
UT3.UT_OBJECT_NAME
90 % lines covered
10 relevant lines. 9 lines covered and 1 lines missed
type body ut_object_name as
/*
utPLSQL - Version 3
Copyright 2016 - 2019 utPLSQL Project
Licensed under the Apache License, Version 2.0 (the "License"):
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
constructor function ut_object_name(self in out nocopy ut_object_name, owner varchar2, name varchar2) return self as result is
begin
- 2545
self.owner := upper(owner);
- 2545
self.name := upper(name);
- 2545
return;
end;
constructor function ut_object_name(self in out nocopy ut_object_name, a_unit_name varchar2) return self as result is
begin
- 3
if instr(a_unit_name,'.') > 0 then
- 3
self.owner := upper(regexp_substr(a_unit_name,'[^\.]+', 1, 1));
- 3
self.name := upper(regexp_substr(a_unit_name,'[^\.]+', 1, 2));
else
self.name := upper(a_unit_name);
end if;
- 3
return;
end;
- 1
map member function identity return varchar2 is
begin
- 1
return owner||'.'||name;
end;
end;
UT3.UT_OUTPUT_REPORTER_BASE
75 % lines covered
20 relevant lines. 15 lines covered (including 1 lines partially covered ) and 5 lines missed
type body ut_output_reporter_base is
/*
utPLSQL - Version 3
Copyright 2016 - 2019 utPLSQL Project
Licensed under the Apache License, Version 2.0 (the "License"):
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
constructor function ut_output_reporter_base(self in out nocopy ut_output_reporter_base) return self as result is
begin
return;
end;
member procedure init(self in out nocopy ut_output_reporter_base, a_self_type varchar2, a_output_buffer ut_output_buffer_base := null) is
begin
- 117
(self as ut_reporter_base).init(a_self_type);
- 117
self.output_buffer := coalesce(a_output_buffer, ut_output_table_buffer());
- 117
self.set_reporter_id(self.output_buffer.output_id);
end;
overriding member procedure set_reporter_id(self in out nocopy ut_output_reporter_base, a_reporter_id raw) is
begin
- 117
self.id := a_reporter_id;
- 117
self.output_buffer.init(a_reporter_id);
end;
member function set_reporter_id(self in ut_output_reporter_base, a_reporter_id raw) return ut_output_reporter_base is
l_result ut_output_reporter_base := self;
begin
l_result.set_reporter_id(a_reporter_id);
return l_result;
end;
overriding member procedure before_calling_run(self in out nocopy ut_output_reporter_base, a_run in ut_run) is
l_output_table_buffer ut_output_table_buffer;
begin
- 113
(self as ut_reporter_base).before_calling_run(a_run);
- 113
l_output_table_buffer := treat(self.output_buffer as ut_output_table_buffer);
end;
member procedure print_text(self in out nocopy ut_output_reporter_base, a_text varchar2, a_item_type varchar2 := null) is
begin
- 1691
self.output_buffer.send_line(a_text, a_item_type);
end;
member procedure print_text_lines(self in out nocopy ut_output_reporter_base, a_text_lines ut_varchar2_rows, a_item_type varchar2 := null) is
begin
- 333
self.output_buffer.send_lines(a_text_lines, a_item_type);
end;
member procedure print_clob(self in out nocopy ut_output_reporter_base, a_clob clob, a_item_type varchar2 := null) is
begin
- 30
self.output_buffer.send_clob( a_clob, a_item_type );
end;
final member function get_lines(a_initial_timeout natural := null, a_timeout_sec natural) return ut_output_data_rows pipelined is
begin
- 1/2 32
for i in (select value(x) val from table(self.output_buffer.get_lines(a_initial_timeout, a_timeout_sec)) x ) loop
pipe row (i.val);
end loop;
end;
final member function get_lines_cursor(a_initial_timeout natural := null, a_timeout_sec natural) return sys_refcursor is
begin
- 81
return self.output_buffer.get_lines_cursor(a_initial_timeout, a_timeout_sec);
end;
final member procedure lines_to_dbms_output(self in ut_output_reporter_base, a_initial_timeout natural := null, a_timeout_sec natural) is
begin
- 32
self.output_buffer.lines_to_dbms_output(a_initial_timeout, a_timeout_sec);
end;
overriding final member procedure on_finalize(self in out nocopy ut_output_reporter_base, a_run in ut_run) is
begin
- 116
self.output_buffer.close();
end;
overriding member procedure on_initialize(self in out nocopy ut_output_reporter_base, a_run in ut_run) is
begin
- 116
self.output_buffer.send_line(null, 'initialize');
end;
end;
UT3.UT_REPORTER_BASE
94.52 % lines covered
73 relevant lines. 69 lines covered and 4 lines missed
type body ut_reporter_base is
/*
utPLSQL - Version 3
Copyright 2016 - 2019 utPLSQL Project
Licensed under the Apache License, Version 2.0 (the "License"):
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
final member procedure init(self in out nocopy ut_reporter_base, a_self_type varchar2) is
begin
- 117
self.self_type := a_self_type;
- 117
self.id := sys_guid();
- 117
return;
end;
member procedure set_reporter_id(self in out nocopy ut_reporter_base, a_reporter_id raw) is
begin
self.id := a_reporter_id;
end;
member function get_reporter_id return raw is
begin
return self.id;
end;
member function get_description return varchar2 is
begin
return 'No description available';
end;
-- run hooks
member procedure before_calling_run(self in out nocopy ut_reporter_base, a_run in ut_run) is
begin
- 113
null;
end;
-- suite hooks
member procedure before_calling_suite(self in out nocopy ut_reporter_base, a_suite in ut_logical_suite) is
begin
- 107
null;
end;
member procedure before_calling_before_all(self in out nocopy ut_reporter_base, a_executable in ut_executable) is
begin
- 14
null;
end;
member procedure after_calling_before_all (self in out nocopy ut_reporter_base, a_executable in ut_executable) is
begin
- 7
null;
end;
member procedure before_calling_before_each(self in out nocopy ut_reporter_base, a_executable in ut_executable) is
begin
- 24
null;
end;
member procedure after_calling_before_each (self in out nocopy ut_reporter_base, a_executable in ut_executable) is
begin
- 24
null;
end;
-- test hooks
member procedure before_calling_test(self in out nocopy ut_reporter_base, a_test in ut_test) is
begin
- 301
null;
end;
member procedure before_calling_before_test(self in out nocopy ut_reporter_base, a_executable in ut_executable) is
begin
- 23
null;
end;
member procedure after_calling_before_test (self in out nocopy ut_reporter_base, a_executable in ut_executable) is
begin
- 23
null;
end;
member procedure before_calling_test_execute(self in out nocopy ut_reporter_base, a_executable in ut_executable) is
begin
- 291
null;
end;
member procedure after_calling_test_execute (self in out nocopy ut_reporter_base, a_executable in ut_executable) is
begin
- 291
null;
end;
member procedure before_calling_after_test(self in out nocopy ut_reporter_base, a_executable in ut_executable) is
begin
- 10
null;
end;
member procedure after_calling_after_test (self in out nocopy ut_reporter_base, a_executable in ut_executable) is
begin
- 10
null;
end;
member procedure after_calling_test(self in out nocopy ut_reporter_base, a_test in ut_test) is
begin
- 85
null;
end;
--suite hooks continued
member procedure before_calling_after_each(self in out nocopy ut_reporter_base, a_executable in ut_executable) is
begin
- 31
null;
end;
member procedure after_calling_after_each (self in out nocopy ut_reporter_base, a_executable in ut_executable) is
begin
- 31
null;
end;
member procedure before_calling_after_all(self in out nocopy ut_reporter_base, a_executable in ut_executable) is
begin
- 12
null;
end;
member procedure after_calling_after_all (self in out nocopy ut_reporter_base, a_executable in ut_executable) is
begin
- 7
null;
end;
member procedure after_calling_suite(self in out nocopy ut_reporter_base, a_suite in ut_logical_suite) is
begin
- 107
null;
end;
-- run hooks continued
member procedure after_calling_run (self in out nocopy ut_reporter_base, a_run in ut_run) is
begin
- 75
null;
end;
overriding member function get_supported_events return ut_varchar2_list is
begin
- 115
return ut_varchar2_list(
ut_event_manager.gc_initialize,
ut_event_manager.gc_before_run,
ut_event_manager.gc_before_suite,
ut_event_manager.gc_before_test,
ut_event_manager.gc_before_before_all,
ut_event_manager.gc_before_before_each,
ut_event_manager.gc_before_before_test,
ut_event_manager.gc_before_test_execute,
ut_event_manager.gc_before_after_test,
ut_event_manager.gc_before_after_each,
ut_event_manager.gc_before_after_all,
ut_event_manager.gc_after_run,
ut_event_manager.gc_after_suite,
ut_event_manager.gc_after_test,
ut_event_manager.gc_after_before_all,
ut_event_manager.gc_after_before_each,
ut_event_manager.gc_after_before_test,
ut_event_manager.gc_after_test_execute,
ut_event_manager.gc_after_after_test,
ut_event_manager.gc_after_after_each,
ut_event_manager.gc_after_after_all,
ut_event_manager.gc_finalize
);
end;
overriding member procedure on_event( self in out nocopy ut_reporter_base, a_event_name varchar2, a_event_item ut_event_item) is
begin
- 2596
case a_event_name
- 2596
when ut_event_manager.gc_initialize
- 115
then self.on_initialize(treat(a_event_item as ut_run));
- 2481
when ut_event_manager.gc_before_run
- 114
then self.before_calling_run(treat(a_event_item as ut_run));
- 2367
when ut_event_manager.gc_before_suite
- 327
then self.before_calling_suite(treat(a_event_item as ut_logical_suite));
- 2040
when ut_event_manager.gc_before_before_all
- 15
then self.before_calling_before_all(treat(a_event_item as ut_executable));
- 2025
when ut_event_manager.gc_before_before_each
- 27
then self.before_calling_before_each(treat(a_event_item as ut_executable));
- 1998
when ut_event_manager.gc_before_test
- 315
then self.before_calling_test(treat(a_event_item as ut_test));
- 1683
when ut_event_manager.gc_before_before_test
- 24
then self.before_calling_before_test(treat(a_event_item as ut_executable));
- 1659
when ut_event_manager.gc_before_test_execute
- 303
then self.before_calling_test_execute(treat(a_event_item as ut_executable));
- 1356
when ut_event_manager.gc_before_after_test
- 11
then self.before_calling_after_test(treat(a_event_item as ut_executable));
- 1345
when ut_event_manager.gc_before_after_each
- 34
then self.before_calling_after_each(treat(a_event_item as ut_executable));
- 1311
when ut_event_manager.gc_before_after_all
- 13
then self.before_calling_after_all(treat(a_event_item as ut_executable));
- 1298
when ut_event_manager.gc_after_run
- 114
then self.after_calling_run(treat(a_event_item as ut_run));
- 1184
when ut_event_manager.gc_after_suite
- 327
then self.after_calling_suite(treat(a_event_item as ut_logical_suite));
- 857
when ut_event_manager.gc_after_before_all
- 15
then self.after_calling_before_all(treat(a_event_item as ut_executable));
- 842
when ut_event_manager.gc_after_before_each
- 27
then self.after_calling_before_each(treat(a_event_item as ut_executable));
- 815
when ut_event_manager.gc_after_test
- 315
then self.after_calling_test(treat(a_event_item as ut_test));
- 500
when ut_event_manager.gc_after_before_test
- 24
then self.after_calling_before_test(treat(a_event_item as ut_executable));
- 476
when ut_event_manager.gc_after_test_execute
- 303
then self.after_calling_test_execute(treat(a_event_item as ut_executable));
- 173
when ut_event_manager.gc_after_after_test
- 11
then self.after_calling_after_test(treat(a_event_item as ut_executable));
- 162
when ut_event_manager.gc_after_after_each
- 34
then self.after_calling_after_each(treat(a_event_item as ut_executable));
- 128
when ut_event_manager.gc_after_after_all
- 13
then self.after_calling_after_all(treat(a_event_item as ut_executable));
- 115
when ut_event_manager.gc_finalize
- 115
then self.on_finalize(treat(a_event_item as ut_run));
else null;
end case;
end;
end;
UT3.UT_RESULTS_COUNTER
100 % lines covered
27 relevant lines. 27 lines covered and 0 lines missed
type body ut_results_counter as
/*
utPLSQL - Version 3
Copyright 2016 - 2019 utPLSQL Project
Licensed under the Apache License, Version 2.0 (the "License"):
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
constructor function ut_results_counter(self in out nocopy ut_results_counter) return self as result is
begin
- 4201
self.disabled_count := 0;
- 4201
self.success_count := 0;
- 4201
self.failure_count := 0;
- 4201
self.errored_count := 0;
- 4201
self.warnings_count := 0;
- 4201
return;
end;
member procedure set_counter_values(self in out nocopy ut_results_counter, a_status integer) is
begin
- 361
self.disabled_count := case when a_status = ut_utils.gc_disabled then 1 else 0 end;
- 360
self.success_count := case when a_status = ut_utils.gc_success then 1 else 0 end;
- 360
self.failure_count := case when a_status = ut_utils.gc_failure then 1 else 0 end;
- 360
self.errored_count := case when a_status = ut_utils.gc_error then 1 else 0 end;
end;
member procedure sum_counter_values(self in out nocopy ut_results_counter, a_item ut_results_counter) is
begin
- 673
self.disabled_count := self.disabled_count + a_item.disabled_count;
- 673
self.success_count := self.success_count + a_item.success_count;
- 673
self.failure_count := self.failure_count + a_item.failure_count;
- 673
self.errored_count := self.errored_count + a_item.errored_count;
- 673
self.warnings_count := self.warnings_count + a_item.warnings_count;
end;
member procedure increase_warning_count(self in out nocopy ut_results_counter, a_count integer := 1) is
begin
- 409
self.warnings_count := self.warnings_count + nvl(a_count,0);
end;
member function total_count return integer is
begin
--skip warnings here
- 70
return self.disabled_count + self.success_count + self.failure_count + self.errored_count;
end;
member function result_status return integer is
l_result integer;
begin
- 459
if self.errored_count > 0 then
- 208
l_result := ut_utils.gc_error;
- 251
elsif self.failure_count > 0 then
- 46
l_result := ut_utils.gc_failure;
- 205
elsif self.success_count > 0 then
- 200
l_result := ut_utils.gc_success;
- 5
elsif self.disabled_count > 0 then
- 1
l_result := ut_utils.gc_disabled;
else
- 4
l_result := ut_utils.gc_error;
end if;
- 459
return l_result;
end;
end;
UT3.UT_RUN
93.94 % lines covered
33 relevant lines. 31 lines covered (including 1 lines partially covered ) and 2 lines missed
type body ut_run as
/*
utPLSQL - Version 3
Copyright 2016 - 2019 utPLSQL Project
Licensed under the Apache License, Version 2.0 (the "License"):
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
constructor function ut_run(
self in out nocopy ut_run,
a_items ut_suite_items,
a_run_paths ut_varchar2_list := null,
a_schema_names ut_varchar2_rows := null,
a_exclude_objects ut_object_names := null,
a_include_objects ut_object_names := null,
a_project_file_mappings ut_file_mappings := null,
a_test_file_mappings ut_file_mappings := null,
a_client_character_set varchar2 := null,
a_random_test_order_seed positive := null,
a_run_tags ut_varchar2_rows := null
) return self as result is
begin
- 116
self.run_paths := a_run_paths;
- 116
self.run_tags := a_run_tags;
- 116
self.self_type := $$plsql_unit;
- 116
self.items := a_items;
- 116
self.client_character_set := lower(a_client_character_set);
- 116
self.random_test_order_seed := a_random_test_order_seed;
- 116
self.results_count := ut_results_counter();
- 116
self.test_file_mappings := coalesce(a_test_file_mappings, ut_file_mappings());
- 116
self.coverage_options := ut_coverage_options(
a_schema_names,
a_exclude_objects,
a_include_objects,
a_project_file_mappings
);
- 116
return;
end;
overriding member procedure mark_as_skipped(self in out nocopy ut_run) is
begin
null;
end;
overriding member function do_execute(self in out nocopy ut_run) return boolean is
l_completed_without_errors boolean;
begin
- 115
ut_utils.debug_log('ut_run.execute');
- 116
ut_event_manager.trigger_event(ut_event_manager.gc_before_run, self);
- 115
self.start_time := current_timestamp;
-- clear anything that might stay in the session's cache
- 116
ut_expectation_processor.clear_expectations;
- 257
for i in 1 .. self.items.count loop
- 142
l_completed_without_errors := self.items(i).do_execute();
end loop;
- 115
self.calc_execution_result();
- 115
self.end_time := current_timestamp;
- 115
ut_event_manager.trigger_event(ut_event_manager.gc_after_run, self);
- 115
return l_completed_without_errors;
end;
overriding member procedure set_rollback_type(self in out nocopy ut_run, a_rollback_type integer, a_force boolean := false) is
begin
- 2/4 2
self.rollback_type := case when a_force then a_rollback_type else coalesce(self.rollback_type, a_rollback_type) end;
- 4
for i in 1 .. self.items.count loop
- 2
self.items(i).set_rollback_type(self.rollback_type, a_force);
end loop;
end;
overriding member procedure calc_execution_result(self in out nocopy ut_run) is
l_result integer(1);
begin
- 115
if self.items is not null and self.items.count > 0 then
- 256
for i in 1 .. self.items.count loop
- 142
self.results_count.sum_counter_values( self.items(i).results_count );
end loop;
- 114
l_result := self.results_count.result_status();
else
--if suite is empty then it's successful (no errors)
- 1
l_result := ut_utils.gc_success;
end if;
- 115
self.result := l_result;
end;
overriding member procedure mark_as_errored(self in out nocopy ut_run, a_error_stack_trace varchar2) is
begin
null;
end;
overriding member function get_error_stack_traces return ut_varchar2_list is
begin
- 1
return ut_varchar2_list();
end;
overriding member function get_serveroutputs return clob is
begin
- 1
return null;
end;
end;
UT3.UT_RUN_INFO
100 % lines covered
10 relevant lines. 10 lines covered and 0 lines missed
type body ut_run_info as
/*
utPLSQL - Version 3
Copyright 2016 - 2019 utPLSQL Project
Licensed under the Apache License, Version 2.0 (the "License"):
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions andTEST_GET_REPORTERS_LIST
limitations under the License.
*/
constructor function ut_run_info(self in out nocopy ut_run_info) return self as result is
- 116
l_ut_owner varchar2(250) := ut_utils.ut_owner;
begin
- 116
self.self_type := $$plsql_unit;
- 116
execute immediate
'select '||l_ut_owner||'.ut.version() from dual'
into self.ut_version;
- 116
dbms_utility.db_version( self.db_version, self.db_compatibility );
- 116
db_os_type := dbms_utility.port_string();
- 116
execute immediate
'select '||l_ut_owner||'.ut_key_value_pair(x.product, x.version) from product_component_version x'
bulk collect into self.db_component_version;
- 116
execute immediate
'select '||l_ut_owner||'.ut_key_value_pair(x.parameter, x.value)
from nls_session_parameters x'
bulk collect into self.nls_session_params;
- 116
execute immediate
'select '||l_ut_owner||'.ut_key_value_pair(x.parameter, x.value) from nls_instance_parameters x'
bulk collect into self.nls_instance_params;
- 116
execute immediate
'select '||l_ut_owner||'.ut_key_value_pair(x.parameter, x.value) from nls_database_parameters x'
bulk collect into self.nls_db_params;
- 116
return;
end;
end;
UT3.UT_SUITE
100 % lines covered
44 relevant lines. 44 lines covered and 0 lines missed
type body ut_suite as
/*
utPLSQL - Version 3
Copyright 2016 - 2019 utPLSQL Project
Licensed under the Apache License, Version 2.0 (the "License"):
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
constructor function ut_suite (
self in out nocopy ut_suite, a_object_owner varchar2, a_object_name varchar2, a_line_no integer,
a_tags ut_varchar2_rows := null
) return self as result is
begin
- 284
self.self_type := $$plsql_unit;
- 284
self.init(a_object_owner, a_object_name, a_object_name, a_line_no);
- 284
self.items := ut_suite_items();
- 284
before_all_list := ut_executables();
- 284
after_all_list := ut_executables();
- 284
self.tags := coalesce(a_tags,ut_varchar2_rows());
- 284
return;
end;
overriding member function do_execute(self in out nocopy ut_suite) return boolean is
l_suite_savepoint varchar2(30);
l_no_errors boolean;
procedure propagate_error(a_error_stack_trace varchar2) is
begin
- 4
for i in 1..self.items.count loop
- 2
self.items(i).mark_as_errored(a_error_stack_trace);
end loop;
end;
begin
- 204
ut_utils.debug_log('ut_suite.execute');
- 204
if self.get_disabled_flag() then
- 1
self.mark_as_skipped();
else
- 203
self.start_time := current_timestamp;
- 204
ut_event_manager.trigger_event(ut_event_manager.gc_before_suite, self);
- 203
l_suite_savepoint := self.create_savepoint_if_needed();
--includes listener calls for before and after actions
- 203
l_no_errors := true;
- 227
for i in 1 .. self.before_all_list.count loop
- 26
l_no_errors := self.before_all_list(i).do_execute(self);
- 26
if not l_no_errors then
- 2
propagate_error(self.before_all_list(i).get_error_stack_trace());
- 2
exit;
end if;
end loop;
- 203
if l_no_errors then
- 582
for i in 1 .. self.items.count loop
- 381
self.items(i).do_execute();
end loop;
end if;
- 218
for i in 1 .. after_all_list.count loop
- 15
l_no_errors := self.after_all_list(i).do_execute(self);
- 15
if not l_no_errors then
- 2
self.put_warning(self.after_all_list(i).get_error_stack_trace());
end if;
end loop;
- 203
self.rollback_to_savepoint(l_suite_savepoint);
- 203
self.calc_execution_result();
- 203
self.end_time := current_timestamp;
- 203
ut_event_manager.trigger_event(ut_event_manager.gc_after_suite, self);
end if;
- 204
return l_no_errors;
end;
overriding member function get_error_stack_traces(self ut_suite) return ut_varchar2_list is
- 29
l_stack_traces ut_varchar2_list := ut_varchar2_list();
begin
- 33
for i in 1 .. before_all_list.count loop
- 4
ut_utils.append_to_list(l_stack_traces, self.before_all_list(i).get_error_stack_trace());
end loop;
- 33
for i in 1 .. after_all_list.count loop
- 4
ut_utils.append_to_list(l_stack_traces, self.after_all_list(i).get_error_stack_trace());
end loop;
- 29
return l_stack_traces;
end;
overriding member function get_serveroutputs return clob is
l_outputs clob;
begin
- 35
for i in 1 .. before_all_list.count loop
- 5
ut_utils.append_to_clob(l_outputs, self.before_all_list(i).serveroutput);
end loop;
- 35
for i in 1 .. after_all_list.count loop
- 5
ut_utils.append_to_clob(l_outputs, self.after_all_list(i).serveroutput);
end loop;
- 30
return l_outputs;
end;
end;
UT3.UT_SUITE_CONTEXT
100 % lines covered
6 relevant lines. 6 lines covered and 0 lines missed
type body ut_suite_context as
/*
utPLSQL - Version 3
Copyright 2016 - 2019 utPLSQL Project
Licensed under the Apache License, Version 2.0 (the "License"):
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
constructor function ut_suite_context (
self in out nocopy ut_suite_context, a_object_owner varchar2, a_object_name varchar2, a_context_name varchar2 := null, a_line_no integer
) return self as result is
begin
- 176
self.self_type := $$plsql_unit;
- 176
self.init(a_object_owner, a_object_name, a_context_name, a_line_no);
- 176
self.items := ut_suite_items();
- 176
before_all_list := ut_executables();
- 176
after_all_list := ut_executables();
- 176
return;
end;
end;
UT3.UT_SUITE_ITEM
100 % lines covered
33 relevant lines. 33 lines covered and 0 lines missed
type body ut_suite_item as
/*
utPLSQL - Version 3
Copyright 2016 - 2019 utPLSQL Project
Licensed under the Apache License, Version 2.0 (the "License"):
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
member procedure init(self in out nocopy ut_suite_item, a_object_owner varchar2, a_object_name varchar2, a_name varchar2, a_line_no integer) is
begin
- 2921
self.object_owner := a_object_owner;
- 2921
self.object_name := lower(trim(a_object_name));
- 2921
self.name := lower(trim(a_name));
- 2921
self.results_count := ut_results_counter();
- 2921
self.warnings := ut_varchar2_rows();
- 2921
self.line_no := a_line_no;
- 2921
self.transaction_invalidators := ut_varchar2_list();
- 2921
self.disabled_flag := ut_utils.boolean_to_int(false);
end;
member function get_disabled_flag return boolean is
begin
- 569
return ut_utils.int_to_boolean(self.disabled_flag);
end;
member procedure set_rollback_type(self in out nocopy ut_suite_item, a_rollback_type integer, a_force boolean := false) is
begin
- 1315
self.rollback_type := case when a_force then a_rollback_type else coalesce(self.rollback_type, a_rollback_type) end;
end;
member function get_rollback_type return integer is
begin
- 1512
return nvl(self.rollback_type, ut_utils.gc_rollback_default);
end;
final member procedure do_execute(self in out nocopy ut_suite_item) is
l_completed_without_errors boolean;
begin
- 674
l_completed_without_errors := self.do_execute();
end;
member function create_savepoint_if_needed return varchar2 is
l_savepoint varchar2(30);
begin
- 548
if get_rollback_type() = ut_utils.gc_rollback_auto then
- 321
l_savepoint := ut_utils.gen_savepoint_name();
- 321
execute immediate 'savepoint ' || l_savepoint;
end if;
- 548
return l_savepoint;
end;
member procedure rollback_to_savepoint(self in out nocopy ut_suite_item, a_savepoint varchar2) is
ex_savepoint_not_exists exception;
l_transaction_invalidators clob;
pragma exception_init(ex_savepoint_not_exists, -1086);
l_savepoint varchar2(250);
begin
- 549
if get_rollback_type() = ut_utils.gc_rollback_auto and a_savepoint is not null then
- 322
l_savepoint := sys.dbms_assert.qualified_sql_name(a_savepoint);
- 322
execute immediate 'rollback to ' || l_savepoint;
end if;
exception
- 12
when ex_savepoint_not_exists then
- 6
l_transaction_invalidators :=
lower( ut_utils.indent_lines( ut_utils.table_to_clob( self.get_transaction_invalidators() ), 2, true ) );
- 6
if length(l_transaction_invalidators) > 3000 then
- 1
l_transaction_invalidators := substr(l_transaction_invalidators,1,3000)||'...';
end if;
- 6
put_warning(
'Unable to perform automatic rollback after test'
- 1
|| case when self_type like '%SUITE' then ' suite' when self_type like '%CONTEXT' then ' context' end || '. '
||'An implicit or explicit commit/rollback occurred in procedures:'||chr(10)
||l_transaction_invalidators||chr(10)
||'Use the "--%rollback(manual)" annotation or remove commit/rollback/ddl statements that are causing the issue.'
);
end;
member function execution_time return number is
begin
- 424
return ut_utils.time_diff(start_time, end_time);
end;
member procedure put_warning(self in out nocopy ut_suite_item, a_message varchar2) is
begin
- 62
self.warnings.extend;
- 62
self.warnings(self.warnings.last) := a_message;
- 62
self.results_count.increase_warning_count;
end;
member function get_transaction_invalidators return ut_varchar2_list is
begin
- 5
return transaction_invalidators;
end;
member procedure add_transaction_invalidator(self in out nocopy ut_suite_item, a_object_name varchar2) is
begin
- 103
if a_object_name not member of transaction_invalidators then
- 103
transaction_invalidators.extend();
- 103
transaction_invalidators(transaction_invalidators.last) := a_object_name;
end if;
end;
end;
UT3.UT_TEST
100 % lines covered
87 relevant lines. 87 lines covered and 0 lines missed
type body ut_test as
/*
utPLSQL - Version 3
Copyright 2016 - 2019 utPLSQL Project
Licensed under the Apache License, Version 2.0 (the "License"):
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
constructor function ut_test(
self in out nocopy ut_test, a_object_owner varchar2 := null, a_object_name varchar2, a_name varchar2,
a_line_no integer, a_expected_error_codes ut_integer_list := null, a_tags ut_varchar2_rows := null
) return self as result is
begin
- 2461
self.self_type := $$plsql_unit;
- 2461
self.init(a_object_owner, a_object_name, a_name, a_line_no);
- 2461
self.item := ut_executable_test(a_object_owner, a_object_name, a_name, ut_utils.gc_test_execute);
- 2461
self.before_each_list := ut_executables();
- 2461
self.before_test_list := ut_executables();
- 2461
self.after_test_list := ut_executables();
- 2461
self.after_each_list := ut_executables();
- 2461
self.all_expectations := ut_expectation_results();
- 2461
self.failed_expectations := ut_expectation_results();
- 2461
self.expected_error_codes := a_expected_error_codes;
- 2461
self.tags := coalesce(a_tags,ut_varchar2_rows());
- 2461
return;
end;
overriding member procedure mark_as_skipped(self in out nocopy ut_test) is
begin
- 13
ut_event_manager.trigger_event(ut_event_manager.gc_before_test, self);
- 13
self.start_time := current_timestamp;
- 13
self.result := ut_utils.gc_disabled;
- 13
ut_utils.debug_log('ut_test.execute - disabled');
- 13
self.results_count.set_counter_values(self.result);
- 13
self.end_time := self.start_time;
- 13
ut_event_manager.trigger_event(ut_event_manager.gc_after_test, self);
end;
overriding member function do_execute(self in out nocopy ut_test) return boolean is
l_no_errors boolean;
l_savepoint varchar2(30);
begin
- 356
ut_utils.debug_log('ut_test.execute');
- 356
if self.get_disabled_flag() then
- 11
mark_as_skipped();
else
- 345
self.start_time := current_timestamp;
- 346
ut_event_manager.trigger_event(ut_event_manager.gc_before_test, self);
- 345
l_savepoint := self.create_savepoint_if_needed();
--includes listener calls for before and after actions
- 345
l_no_errors := true;
- 345
for i in 1 .. self.before_each_list.count loop
- 35
l_no_errors := self.before_each_list(i).do_execute(self);
- 35
exit when not l_no_errors;
end loop;
- 345
if l_no_errors then
- 342
for i in 1 .. self.before_test_list.count loop
- 30
l_no_errors := self.before_test_list(i).do_execute(self);
- 30
exit when not l_no_errors;
end loop;
- 342
if l_no_errors then
-- execute the test
- 337
self.item.do_execute(self, self.expected_error_codes);
end if;
-- perform cleanup regardless of the test or setup failure
- 359
for i in 1 .. self.after_test_list.count loop
- 17
self.after_test_list(i).do_execute(self);
end loop;
end if;
- 387
for i in 1 .. self.after_each_list.count loop
- 42
self.after_each_list(i).do_execute(self);
end loop;
- 345
self.rollback_to_savepoint(l_savepoint);
- 345
self.calc_execution_result();
- 345
self.end_time := current_timestamp;
- 345
ut_event_manager.trigger_event(ut_event_manager.gc_after_test, self);
end if;
- 356
return l_no_errors;
end;
overriding member procedure calc_execution_result(self in out nocopy ut_test) is
l_warnings ut_varchar2_rows;
begin
- 347
if self.get_error_stack_traces().count = 0 then
- 261
self.result := ut_expectation_processor.get_status();
else
- 86
self.result := ut_utils.gc_error;
end if;
--expectation results need to be part of test results
- 347
self.all_expectations := ut_expectation_processor.get_all_expectations();
- 347
self.failed_expectations := ut_expectation_processor.get_failed_expectations();
- 347
l_warnings := coalesce( ut_expectation_processor.get_warnings(), ut_varchar2_rows() );
- 347
self.warnings := self.warnings multiset union all l_warnings;
- 347
self.results_count.increase_warning_count( cardinality(l_warnings) );
- 347
self.results_count.set_counter_values(self.result);
- 347
ut_expectation_processor.clear_expectations();
end;
overriding member procedure mark_as_errored(self in out nocopy ut_test, a_error_stack_trace varchar2) is
begin
- 2
ut_utils.debug_log('ut_test.fail');
- 2
ut_event_manager.trigger_event(ut_event_manager.gc_before_test, self);
- 2
self.start_time := current_timestamp;
- 2
self.parent_error_stack_trace := a_error_stack_trace;
- 2
self.calc_execution_result();
- 2
self.end_time := self.start_time;
- 2
ut_event_manager.trigger_event(ut_event_manager.gc_after_test, self);
end;
overriding member function get_error_stack_traces(self ut_test) return ut_varchar2_list is
- 424
l_stack_traces ut_varchar2_list := ut_varchar2_list();
begin
- 424
ut_utils.append_to_list(l_stack_traces, self.parent_error_stack_trace);
- 466
for i in 1 .. before_each_list.count loop
- 42
ut_utils.append_to_list(l_stack_traces, self.before_each_list(i).get_error_stack_trace());
end loop;
- 464
for i in 1 .. before_test_list.count loop
- 40
ut_utils.append_to_list(l_stack_traces, self.before_test_list(i).get_error_stack_trace());
end loop;
- 424
ut_utils.append_to_list(l_stack_traces, self.item.get_error_stack_trace());
- 441
for i in 1 .. after_test_list.count loop
- 17
ut_utils.append_to_list(l_stack_traces, self.after_test_list(i).get_error_stack_trace());
end loop;
- 475
for i in 1 .. after_each_list.count loop
- 51
ut_utils.append_to_list(l_stack_traces, self.after_each_list(i).get_error_stack_trace());
end loop;
- 424
return l_stack_traces;
end;
overriding member function get_serveroutputs return clob is
l_outputs clob;
begin
- 278
for i in 1 .. before_each_list.count loop
- 24
ut_utils.append_to_clob(l_outputs, self.before_each_list(i).serveroutput);
end loop;
- 278
for i in 1 .. before_test_list.count loop
- 24
ut_utils.append_to_clob(l_outputs, self.before_test_list(i).serveroutput);
end loop;
- 254
ut_utils.append_to_clob(l_outputs, self.item.serveroutput );
- 263
for i in 1 .. after_test_list.count loop
- 9
ut_utils.append_to_clob(l_outputs, self.after_test_list(i).serveroutput);
end loop;
- 285
for i in 1 .. after_each_list.count loop
- 31
ut_utils.append_to_clob(l_outputs, self.after_each_list(i).serveroutput);
end loop;
- 254
return l_outputs;
end;
member function get_failed_expectation_lines return ut_varchar2_rows is
l_results ut_varchar2_rows;
begin
- 34
for i in 1 .. failed_expectations.count loop
- 17
ut_utils.append_to_list( l_results, ut_utils.convert_collection( failed_expectations(i).get_result_lines() ) );
- 17
ut_utils.append_to_list( l_results, failed_expectations(i).caller_info );
end loop;
- 17
return l_results;
end;
end;
UT3.UT_EXPECTATION_PROCESSOR
100 % lines covered
71 relevant lines. 71 lines covered and 0 lines missed
package body ut_expectation_processor as
/*
utPLSQL - Version 3
Copyright 2016 - 2019 utPLSQL Project
Licensed under the Apache License, Version 2.0 (the "License"):
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
type tt_nls_params is table of nls_session_parameters%rowtype;
g_session_params tt_nls_params;
- 1
g_expectations_called ut_expectation_results := ut_expectation_results();
- 1
g_warnings ut_varchar2_rows := ut_varchar2_rows();
- 1
g_nulls_are_equal boolean_not_null := gc_default_nulls_are_equal;
- 1
g_package_invalidated boolean := false;
function nulls_are_equal return boolean is
begin
- 373
return g_nulls_are_equal;
end;
procedure nulls_are_equal(a_setting boolean_not_null) is
begin
- 4
g_nulls_are_equal := a_setting;
end;
function get_status return integer is
- 261
l_result integer := ut_utils.gc_success;
begin
- 261
ut_utils.debug_log('ut_expectation_processor.get_status');
- 261
for i in 1 .. g_expectations_called.count loop
- 82
l_result := greatest(l_result, g_expectations_called(i).status);
- 82
exit when l_result = ut_utils.gc_error;
end loop;
- 261
return l_result;
end get_status;
procedure clear_expectations is
begin
- 1188
ut_utils.debug_log('ut_expectation_processor.clear_expectations');
- 1188
g_expectations_called.delete;
- 1188
g_warnings.delete;
end;
function get_all_expectations return ut_expectation_results is
begin
- 347
ut_utils.debug_log('ut_expectation_processor.get_all_expectations: g_expectations_called.count='||g_expectations_called.count);
- 347
return g_expectations_called;
end get_all_expectations;
function get_failed_expectations return ut_expectation_results is
- 1039
l_expectations_results ut_expectation_results := ut_expectation_results();
begin
- 1039
ut_utils.debug_log('ut_expectation_processor.get_failed_expectations: g_expectations_called.count='||g_expectations_called.count);
- 1813
for i in 1 .. g_expectations_called.count loop
- 774
if g_expectations_called(i).status > ut_utils.gc_success then
- 423
l_expectations_results.extend;
- 423
l_expectations_results(l_expectations_results.last) := g_expectations_called(i);
end if;
end loop;
- 1039
ut_utils.debug_log('ut_expectation_processor.get_failed_expectations: l_expectations_results.count='||l_expectations_results.count);
- 1039
return l_expectations_results;
end get_failed_expectations;
procedure add_expectation_result(a_expectation_result ut_expectation_result) is
l_results ut_varchar2_list;
begin
- 799
if ut_session_context.is_ut_run then
- 794
ut_event_manager.trigger_event(ut_event_manager.gc_debug, a_expectation_result);
- 793
g_expectations_called.extend;
- 793
g_expectations_called(g_expectations_called.last) := a_expectation_result;
else
- 6
l_results := a_expectation_result.get_result_lines();
- 6
dbms_output.put_line( upper( ut_utils.test_result_to_char( a_expectation_result.status ) ) || '');
- 12
for i in 1 .. l_results.count loop
- 6
dbms_output.put_line( ' ' || l_results(i) );
end loop;
- 6
if a_expectation_result.caller_info is not null then
- 2
dbms_output.put_line( ut_utils.indent_lines( a_expectation_result.caller_info, 2, true) );
end if;
end if;
end;
procedure report_failure(a_message in varchar2) is
begin
- 1
add_expectation_result(ut_expectation_result(ut_utils.gc_failure, null, a_message));
end;
function get_session_parameters return tt_nls_params is
l_session_params tt_nls_params;
begin
- 397
select nsp.parameter, nsp.value
bulk collect into l_session_params
from nls_session_parameters nsp
where parameter
in ( 'NLS_DATE_FORMAT', 'NLS_TIMESTAMP_FORMAT', 'NLS_TIMESTAMP_TZ_FORMAT')
order by 1;
- 397
return l_session_params;
end;
procedure set_xml_nls_params is
insuf_privs exception;
pragma exception_init(insuf_privs, -1031);
begin
- 397
g_session_params := get_session_parameters();
begin
- 397
execute immediate q'[alter session set events '19119 trace name context forever, level 0x8']';
exception
- 1191
when insuf_privs then NULL;
end;
- 397
execute immediate 'alter session set nls_timestamp_format = '''||ut_utils.gc_timestamp_format||'''';
- 397
execute immediate 'alter session set nls_timestamp_tz_format = '''||ut_utils.gc_timestamp_tz_format||'''';
end;
procedure reset_nls_params is
insuf_privs exception;
pragma exception_init(insuf_privs, -1031);
begin
begin
- 397
execute immediate q'[alter session set events '19119 trace name context off']';
exception
- 1191
when insuf_privs then NULL;
end;
- 397
if g_session_params is not null then
- 1588
for i in 1 .. g_session_params.count loop
- 1191
execute immediate 'alter session set '||g_session_params(i).parameter||' = '''||g_session_params(i).value||'''';
end loop;
end if;
end;
function who_called_expectation(a_call_stack varchar2) return varchar2 is
l_caller_stack_line varchar2(4000);
l_call_stack varchar2(4000);
l_line_no integer;
l_owner varchar2(1000);
l_object_name varchar2(1000);
l_result varchar2(4000);
-- in 12.2 format_call_stack reportes not only package name, but also the procedure name
-- when 11g and 12c reports only package name
function cut_header_and_expectations( a_stack varchar2 ) return varchar2 is
begin
- 450
return regexp_substr( a_stack, '(.*\.(UT_EXPECTATION[A-Z0-9#_$]*|UT|UTASSERT2?)(\.[A-Z0-9#_$]+)?\s+)+((.|\s)*)', 1, 1, 'm', 4);
end;
function cut_address_columns( a_stack varchar2 ) return varchar2 is
begin
- 450
return regexp_replace( a_stack, '^(0x)?[0-9a-f]+\s+', '', 1, 0, 'm' );
end;
function cut_framework_stack( a_stack varchar2 ) return varchar2 is
begin
- 450
return regexp_replace(
a_stack,
'[0-9]+\s+anonymous\s+block\s+[0-9]+\s+package\s+body\s+sys\.dbms_sql(\.execute)?\s+[0-9]+\s+[0-9_$#a-z ]+\.ut_executable.*',
'',
1, 1, 'mni'
);
end;
function format_stack( a_stack varchar2 ) return varchar2 is
begin
- 450
return regexp_replace(
a_stack,
'([0-9]+)\s+(.* )?((anonymous block)|(([0-9_$#a-z]+\.[0-9_$#a-z]+(\.([0-9_$#a-z])+)?)))',
'at "\3", line \1', 1, 0, 'i'
);
end;
begin
- 450
l_call_stack := cut_header_and_expectations( a_call_stack );
- 450
l_call_stack := cut_address_columns( l_call_stack );
- 450
l_call_stack := cut_framework_stack( l_call_stack );
- 450
l_call_stack := format_stack( l_call_stack );
- 450
l_caller_stack_line := regexp_substr(l_call_stack,'^(.*)');
- 450
if l_caller_stack_line like '%.%' then
- 195
l_line_no := to_number( regexp_substr( l_caller_stack_line, ', line (\d+)', subexpression => 1 ) );
- 195
l_owner := regexp_substr( l_caller_stack_line, 'at "([A-Za-z0-9$#_]+)\.(([A-Za-z0-9$#_]+)(\.([A-Za-z0-9$#_]+))?)", line (\d+)', subexpression => 1 );
- 195
l_object_name := regexp_substr( l_caller_stack_line, 'at "([A-Za-z0-9$#_]+)\.(([A-Za-z0-9$#_]+)(\.([A-Za-z0-9$#_]+))?)", line (\d+)', subexpression => 3 );
- 195
l_result :=
l_caller_stack_line || ' ' || rtrim(ut_metadata.get_source_definition_line(l_owner, l_object_name, l_line_no),chr(10))
|| replace( l_call_stack, l_caller_stack_line );
else
- 255
l_result := l_call_stack;
end if;
- 450
return rtrim(l_result,chr(10));
end;
procedure add_warning(a_messsage varchar2) is
begin
- 23
g_warnings.extend;
- 23
g_warnings(g_warnings.last) := a_messsage;
end;
procedure add_depreciation_warning(a_deprecated_syntax varchar2, a_new_syntax varchar2) is
begin
- 17
add_warning(
ut_utils.build_depreciation_warning( a_deprecated_syntax, a_new_syntax ) || chr(10)
|| ut_expectation_processor.who_called_expectation(dbms_utility.format_call_stack())
);
end;
function get_warnings return ut_varchar2_rows is
begin
- 371
return g_warnings;
end;
function invalidation_exception_found return boolean is
begin
- 113
return g_package_invalidated;
end;
procedure set_invalidation_exception is
begin
- 1
g_package_invalidated := true;
end;
procedure reset_invalidation_exception is
begin
- 117
g_package_invalidated := false;
end;
end;
UT3.UT_FILE_MAPPER
100 % lines covered
27 relevant lines. 27 lines covered and 0 lines missed
package body ut_file_mapper is
/*
utPLSQL - Version 3
Copyright 2016 - 2019 utPLSQL Project
Licensed under the Apache License, Version 2.0 (the "License"):
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
type tt_key_values is table of varchar2(4000) index by varchar2(4000);
/**
* Private functions
*/
function to_hash_table(a_key_value_tab ut_key_value_pairs) return tt_key_values is
l_result tt_key_values;
begin
- 31
if a_key_value_tab is not null then
- 217
for i in 1 .. a_key_value_tab.count loop
- 186
l_result(upper(a_key_value_tab(i).key)) := a_key_value_tab(i).value;
end loop;
end if;
- 31
return l_result;
end;
/**
* Public functions
*/
function default_file_to_obj_type_map return ut_key_value_pairs is
begin
- 31
return ut_key_value_pairs(
ut_key_value_pair('fnc', 'FUNCTION'),
ut_key_value_pair('prc', 'PROCEDURE'),
ut_key_value_pair('tpb', 'TYPE BODY'),
ut_key_value_pair('pkb', 'PACKAGE BODY'),
ut_key_value_pair('bdy', 'PACKAGE BODY'),
ut_key_value_pair('trg', 'TRIGGER')
);
end;
function build_file_mappings(
a_file_paths ut_varchar2_list,
a_file_to_object_type_mapping ut_key_value_pairs := null,
a_regex_pattern varchar2 := null,
a_object_owner_subexpression positive := null,
a_object_name_subexpression positive := null,
a_object_type_subexpression positive := null
) return ut_file_mappings is
begin
- 29
return build_file_mappings(
null, a_file_paths, a_file_to_object_type_mapping, a_regex_pattern,
a_object_owner_subexpression, a_object_name_subexpression, a_object_type_subexpression
);
end;
function build_file_mappings(
a_object_owner varchar2,
a_file_paths ut_varchar2_list,
a_file_to_object_type_mapping ut_key_value_pairs := null,
a_regex_pattern varchar2 := null,
a_object_owner_subexpression positive := null,
a_object_name_subexpression positive := null,
a_object_type_subexpression positive := null
) return ut_file_mappings is
- 31
l_file_to_object_type_mapping ut_key_value_pairs := coalesce(a_file_to_object_type_mapping, default_file_to_obj_type_map());
- 31
l_regex_pattern varchar2(4000) := coalesce(a_regex_pattern, gc_file_mapping_regex);
- 31
l_object_owner_subexpression positive := coalesce(a_object_owner_subexpression, gc_regex_owner_subexpression);
- 31
l_object_name_subexpression positive := coalesce(a_object_name_subexpression, gc_regex_name_subexpression);
- 31
l_object_type_subexpression positive := coalesce(a_object_type_subexpression, gc_regex_type_subexpression);
l_key_values tt_key_values;
l_mappings ut_file_mappings;
l_mapping ut_file_mapping;
l_object_type_key varchar2(4000);
l_object_type varchar2(4000);
l_object_owner varchar2(4000);
l_file_path varchar2(32767);
begin
- 31
if a_file_paths is not null then
- 31
l_key_values := to_hash_table(l_file_to_object_type_mapping);
- 31
l_mappings := ut_file_mappings();
- 67
for i in 1 .. a_file_paths.count loop
- 36
l_file_path := replace(a_file_paths(i),'\','/');
- 36
l_object_type_key := upper(regexp_substr(l_file_path, l_regex_pattern, 1, 1, 'i', l_object_type_subexpression));
- 36
if l_key_values.exists(l_object_type_key) then
- 34
l_object_type := upper(l_key_values(l_object_type_key));
else
- 2
l_object_type := null;
end if;
- 36
l_object_owner := coalesce(
- 1
upper(a_object_owner),
- 1
upper(regexp_substr(l_file_path, l_regex_pattern, 1, 1, 'i', l_object_owner_subexpression)),
sys_context('USERENV', 'CURRENT_SCHEMA'));
- 36
l_mapping := ut_file_mapping(
file_name => a_file_paths(i),
object_owner => l_object_owner,
object_name => upper(regexp_substr(l_file_path, l_regex_pattern, 1, 1, 'i', l_object_name_subexpression)),
object_type => l_object_type
);
- 36
l_mappings.extend();
- 36
l_mappings(l_mappings.last) := l_mapping;
end loop;
end if;
- 31
return l_mappings;
end;
end;
UT3.UT_METADATA
91.76 % lines covered
85 relevant lines. 78 lines covered and 7 lines missed
package body ut_metadata as
/*
utPLSQL - Version 3
Copyright 2016 - 2019 utPLSQL Project
Licensed under the Apache License, Version 2.0 (the "License"):
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
type t_cache is table of all_source.text%type;
g_source_cache t_cache;
g_cached_object varchar2(500);
------------------------------
--public definitions
function form_name(a_owner_name varchar2, a_object varchar2, a_subprogram varchar2 default null) return varchar2 is
l_name varchar2(200);
begin
- 563
l_name := trim(a_object);
- 563
if trim(a_owner_name) is not null then
- 176
l_name := trim(a_owner_name) || '.' || l_name;
end if;
- 563
if trim(a_subprogram) is not null then
- 561
l_name := l_name || '.' || trim(a_subprogram);
end if;
- 563
return l_name;
end form_name;
function package_valid(a_owner_name varchar2, a_package_name in varchar2) return boolean as
l_cnt number;
- 12
l_view_name varchar2(200) := get_objects_view_name;
begin
- 12
execute immediate q'[select count(*)
from ]'||l_view_name||q'[
where owner = :a_owner_name
and object_name = :a_package_name
and object_type = 'PACKAGE'
and status = 'VALID']'
into l_cnt using upper(a_owner_name), upper(a_package_name);
- 12
return l_cnt = 1;
exception
when others then
return false;
end;
function procedure_exists(a_owner_name varchar2, a_package_name in varchar2, a_procedure_name in varchar2)
return boolean as
l_cnt number;
- 6
l_view_name varchar2(200) := get_dba_view('dba_procedures');
begin
- 6
execute immediate
'select count(*) from '||l_view_name
||' where owner = :l_schema and object_name = :l_package_name and procedure_name = :l_procedure_name and rownum = 1'
into l_cnt using a_owner_name, a_package_name, a_procedure_name;
--expect one method only for the package with that name.
- 6
return l_cnt = 1;
exception
when others then
return false;
end;
function get_source_definition_line(a_owner varchar2, a_object_name varchar2, a_line_no integer) return varchar2 is
- 195
l_view_name varchar2(128) := get_source_view_name();
l_line all_source.text%type;
- 195
c_key constant varchar2(500) := a_owner || '.' || a_object_name;
begin
- 195
if not nvl(c_key = g_cached_object, false) then
- 50
g_cached_object := c_key;
- 50
execute immediate
'select trim(text) text
from '||l_view_name||q'[ s
where s.owner = :a_owner
and s.name = :a_object_name
/*skip the declarations, consider only definitions*/
and s.type not in ('PACKAGE', 'TYPE')
order by line]'
bulk collect into g_source_cache
using a_owner, a_object_name;
end if;
- 195
if g_source_cache.exists(a_line_no) then
- 190
l_line := g_source_cache(a_line_no);
end if;
- 195
return l_line;
end;
procedure reset_source_definition_cache is
begin
- 116
g_source_cache := null;
- 116
g_cached_object := null;
end;
function get_dba_view(a_dba_view_name varchar2) return varchar2 is
- 903
l_result varchar2(128) := lower(a_dba_view_name);
begin
- 903
if not is_object_visible(a_dba_view_name) then
- 761
l_result := replace(l_result,'dba_','all_');
end if;
- 903
return l_result;
end;
function get_source_view_name return varchar2 is
begin
- 293
return get_dba_view('dba_source');
end;
function get_objects_view_name return varchar2 is
begin
- 604
return get_dba_view('dba_objects');
end;
function user_has_execute_any_proc return boolean is
- 169
l_ut_owner varchar2(250) := ut_utils.ut_owner;
begin
- 169
return is_object_visible(l_ut_owner||'.ut_utils');
end;
function is_object_visible(a_object_name varchar2) return boolean is
l_invalid_object_name exception;
pragma exception_init(l_invalid_object_name,-44002);
begin
- 1377
return dbms_assert.sql_object_name(a_object_name) is not null;
exception
- 1972
when l_invalid_object_name then
- 986
return false;
end;
function package_exists_in_cur_schema(a_object_name varchar2) return boolean is
l_cnt number;
- 135
c_current_schema constant all_tables.owner%type := sys_context('USERENV','CURRENT_SCHEMA');
begin
- 135
select count(*)
into l_cnt
from all_objects t
where t.object_name = a_object_name
and t.object_type = 'PACKAGE'
and t.owner = c_current_schema;
- 135
return l_cnt > 0;
end;
function is_collection (a_anytype_code in integer) return boolean is
begin
- 1062
return coalesce(a_anytype_code in (dbms_types.typecode_varray,dbms_types.typecode_table,dbms_types.typecode_namedcollection),false);
end;
function is_collection (a_owner varchar2, a_type_name varchar2) return boolean is
begin
- 845
return is_collection(
get_anytype_members_info(
get_user_defined_type(a_owner, a_type_name)
).type_code
);
end;
function get_attr_elem_info( a_anytype anytype, a_pos pls_integer := null )
return t_anytype_elem_info_rec is
l_result t_anytype_elem_info_rec;
begin
- 525
if a_anytype is not null then
- 525
l_result.type_code := a_anytype.getattreleminfo(
pos => a_pos,
prec => l_result.precision,
scale => l_result.scale,
len => l_result.length,
csid => l_result.char_set_id,
csfrm => l_result.char_set_frm,
attr_elt_type => l_result.attr_elt_type,
aname => l_result.attribute_name
);
end if;
- 525
return l_result;
end;
function get_anytype_members_info( a_anytype anytype )
return t_anytype_members_rec is
l_result t_anytype_members_rec;
begin
- 1062
if a_anytype is not null then
- 336
l_result.type_code := a_anytype.getinfo(
prec => l_result.precision,
scale => l_result.scale,
len => l_result.length,
csid => l_result.char_set_id,
csfrm => l_result.char_set_frm,
schema_name => l_result.schema_name,
type_name => l_result.type_name,
version => l_result.version,
numelems => l_result.elements_count
);
end if;
- 1062
return l_result;
end;
function get_user_defined_type(a_owner varchar2, a_type_name varchar2) return anytype is
l_anytype anytype;
not_found exception;
pragma exception_init(not_found,-22303);
begin
- 964
if a_type_name is not null then
begin
- 238
if ut_metadata.is_object_visible('GETANYTYPEFROMPERSISTENT') then
- 238
execute immediate 'begin :l_anytype := getanytypefrompersistent( :a_owner, :a_type_name ); end;'
using out l_anytype, in nvl(a_owner,sys_context('userenv','current_schema')), in a_type_name;
else
execute immediate 'begin :l_anytype := anytype.getpersistent( :a_owner, :a_type_name ); end;'
using out l_anytype, in nvl(a_owner,sys_context('userenv','current_schema')), in a_type_name;
end if;
exception
when not_found then
null;
end;
end if;
- 964
return l_anytype;
end;
function get_collection_element(a_anydata in anydata) return varchar2
is
l_anytype anytype;
l_nested_type t_anytype_members_rec;
l_elements_rec t_anytype_elem_info_rec;
l_type_code integer;
begin
- 72
l_type_code := a_anydata.gettype(l_anytype);
- 72
if is_collection(l_type_code) then
- 72
l_elements_rec := get_attr_elem_info(l_anytype);
- 72
if l_elements_rec.attr_elt_type is null then
- 38
l_nested_type := get_anytype_members_info(l_anytype);
else
- 34
l_nested_type := get_anytype_members_info(l_elements_rec.attr_elt_type);
end if;
end if;
- 72
return l_nested_type.schema_name || '.' ||l_nested_type.type_name;
end;
function has_collection_members (a_anydata in anydata) return boolean is
l_anytype anytype;
l_elements_rec t_anytype_elem_info_rec;
l_type_code integer;
begin
- 72
l_type_code := a_anydata.gettype(l_anytype);
- 72
l_elements_rec := get_attr_elem_info(l_anytype);
- 72
return l_elements_rec.attr_elt_type is not null;
end;
function get_anydata_typename(a_data_value anydata) return varchar2
is
begin
- 335
return case when a_data_value is not null then lower(a_data_value.gettypename()) else 'undefined' end;
end;
function is_anytype_null(a_value in anydata, a_compound_type in varchar2) return number is
- 173
l_result integer := 0;
l_anydata_sql varchar2(4000);
l_compound_type varchar2(250);
begin
- 173
if a_value is not null then
- 162
l_compound_type := sys.dbms_assert.qualified_sql_name(a_compound_type);
- 162
l_anydata_sql := '
declare
l_data '||get_anydata_typename(a_value)||';
l_value anydata := :a_value;
l_status integer;
begin
l_status := l_value.get'||l_compound_type||'(l_data);
:l_data_is_null := case when l_data is null then 1 else 0 end;
end;';
- 162
execute immediate l_anydata_sql using in a_value, out l_result;
else
- 11
l_result := 1;
end if;
- 173
return l_result;
end;
function get_object_name(a_full_object_name in varchar2) return varchar2 is
l_result varchar2(250);
begin
- 127
l_result := regexp_substr(
a_full_object_name,
'^([A-Za-z0-9$#_]+|".*?")\.([A-Za-z0-9$#_]+|".*?")', subexpression => 2
);
- 127
if not l_result like '"%"' then
- 127
l_result := upper(l_result);
end if;
- 127
return ut_utils.qualified_sql_name(l_result);
end;
function get_anydata_compound_type(a_data_value anydata) return varchar2 is
l_result varchar2(30);
l_type anytype;
l_type_code integer;
begin
- 173
if a_data_value is not null then
- 162
l_type_code := a_data_value.gettype(l_type);
- 162
if l_type_code in (dbms_types.typecode_table, dbms_types.typecode_varray, dbms_types.typecode_namedcollection,
- 1
dbms_types.typecode_object) then
- 162
if l_type_code = dbms_types.typecode_object then
- 67
l_result := 'object';
else
- 95
l_result := 'collection';
end if;
end if;
end if;
- 173
return l_result;
end;
end;
UT3.UT_SUITE_BUILDER
98.76 % lines covered
322 relevant lines. 318 lines covered and 4 lines missed
package body ut_suite_builder is
/*
utPLSQL - Version 3
Copyright 2016 - 2019 utPLSQL Project
Licensed under the Apache License, Version 2.0 (the "License"):
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
subtype t_annotation_text is varchar2(4000);
subtype t_annotation_name is varchar2(4000);
subtype t_object_name is varchar2(500);
subtype t_annotation_position is binary_integer;
- 1
gc_suite constant t_annotation_name := 'suite';
- 1
gc_suitepath constant t_annotation_name := 'suitepath';
- 1
gc_tags constant t_annotation_name := 'tags';
- 1
gc_test constant t_annotation_name := ut_utils.gc_test_execute;
- 1
gc_disabled constant t_annotation_name := 'disabled';
- 1
gc_displayname constant t_annotation_name := 'displayname';
- 1
gc_beforeall constant t_annotation_name := ut_utils.gc_before_all;
- 1
gc_beforeeach constant t_annotation_name := ut_utils.gc_before_each;
- 1
gc_beforetest constant t_annotation_name := ut_utils.gc_before_test;
- 1
gc_afterall constant t_annotation_name := ut_utils.gc_after_all;
- 1
gc_aftereach constant t_annotation_name := ut_utils.gc_after_each;
- 1
gc_aftertest constant t_annotation_name := ut_utils.gc_after_test;
- 1
gc_throws constant t_annotation_name := 'throws';
- 1
gc_rollback constant t_annotation_name := 'rollback';
- 1
gc_context constant t_annotation_name := 'context';
- 1
gc_endcontext constant t_annotation_name := 'endcontext';
type tt_annotations is table of t_annotation_name;
- 1
gc_supported_annotations constant tt_annotations
:= tt_annotations(
gc_suite,
gc_suitepath,
gc_tags,
gc_test,
gc_disabled,
gc_displayname,
gc_beforeall,
gc_beforeeach,
gc_beforetest,
gc_afterall,
gc_aftereach,
gc_aftertest,
gc_throws,
gc_rollback,
gc_context,
gc_endcontext
);
- 1
gc_integer_exception constant varchar2(1) := 'I';
- 1
gc_named_exception constant varchar2(1) := 'N';
type tt_executables is table of ut_executables index by t_annotation_position;
type t_annotation is record(
name t_annotation_name,
text t_annotation_text,
procedure_name t_object_name
);
type tt_annotations_by_line is table of t_annotation index by t_annotation_position;
--list of annotation texts for a given annotation indexed by annotation position:
--This would hold: ('some', 'other') for a single annotation name recurring in a single procedure example
-- --%beforetest(some)
-- --%beforetest(other)
-- --%test(some test with two before test procedures)
-- procedure some_test ...
-- when you'd like to have two beforetest procedures executed in a single test
type tt_annotation_texts is table of t_annotation_text index by t_annotation_position;
type tt_annotations_by_name is table of tt_annotation_texts index by t_annotation_name;
type tt_annotations_by_proc is table of tt_annotations_by_name index by t_object_name;
type t_annotations_info is record (
owner t_object_name,
name t_object_name,
parse_time timestamp,
by_line tt_annotations_by_line,
by_proc tt_annotations_by_proc,
by_name tt_annotations_by_name
);
function get_qualified_object_name(
a_suite ut_suite_item, a_procedure_name t_object_name
) return varchar2 is
l_result varchar2(1000);
begin
- 54
if a_suite is not null then
- 54
l_result := upper( a_suite.object_owner || '.' || a_suite.object_name );
- 54
if a_procedure_name is not null then
- 32
l_result := l_result || upper( '.' || a_procedure_name );
end if;
end if;
- 54
return l_result;
end;
function get_object_reference(
a_suite ut_suite_item, a_procedure_name t_object_name, a_line_no binary_integer
) return varchar2 is
begin
- 54
return chr( 10 ) || 'at package "' || get_qualified_object_name(a_suite, a_procedure_name) || '", line ' || a_line_no;
end;
procedure delete_annotations_range(
a_annotations in out nocopy t_annotations_info,
a_start_pos t_annotation_position,
a_end_pos t_annotation_position
) is
- 177
l_pos t_annotation_position := a_start_pos;
l_annotation t_annotation;
begin
- 2037
while l_pos is not null and l_pos <= a_end_pos loop
- 1860
l_annotation := a_annotations.by_line(l_pos);
- 1860
if l_annotation.procedure_name is not null and a_annotations.by_proc.exists(l_annotation.procedure_name) then
- 1163
a_annotations.by_proc.delete(l_annotation.procedure_name);
- 697
elsif a_annotations.by_name.exists(l_annotation.name) then
- 530
a_annotations.by_name(l_annotation.name).delete(l_pos);
- 530
if a_annotations.by_name(l_annotation.name).count = 0 then
- 169
a_annotations.by_name.delete(l_annotation.name);
end if;
end if;
- 1860
l_pos := a_annotations.by_line.next( l_pos );
end loop;
- 177
a_annotations.by_line.delete(a_start_pos, a_end_pos);
end;
procedure add_items_to_list(a_list in out nocopy ut_suite_items, a_items ut_suite_items) is
begin
- 1286
for i in 1 .. a_items.count loop
- 1110
a_list.extend();
- 1110
a_list(a_list.last) := a_items(i);
end loop;
end;
-----------------------------------------------
-- Processing annotations
-----------------------------------------------
procedure add_annotation_ignored_warning(
a_suite in out nocopy ut_suite_item,
a_annotation t_annotation_name,
a_message varchar2,
a_line_no binary_integer,
a_procedure_name t_object_name := null
) is
begin
- 30
a_suite.put_warning(
replace(a_message,'%%%','"--%'||a_annotation||'"')
|| ' Annotation ignored.' || get_object_reference( a_suite, a_procedure_name, a_line_no )
);
end;
function get_rollback_type(a_rollback_type_name varchar2) return ut_utils.t_rollback_type is
l_rollback_type ut_utils.t_rollback_type;
begin
- 22
l_rollback_type :=
- 1
case lower(a_rollback_type_name)
- 1
when 'manual' then ut_utils.gc_rollback_manual
- 1
when 'auto' then ut_utils.gc_rollback_auto
end;
- 22
return l_rollback_type;
end;
procedure add_to_throws_numbers_list(
a_suite in out nocopy ut_suite,
a_list in out nocopy ut_integer_list,
a_procedure_name t_object_name,
a_throws_ann_text tt_annotation_texts
) is
l_annotation_pos binary_integer;
function is_valid_qualified_name (a_name varchar2) return boolean is
l_name varchar2(500);
begin
- 51
l_name := dbms_assert.qualified_sql_name(a_name);
- 19
return true;
- 64
exception when others then
- 32
return false;
end;
function check_exception_type(a_exception_name in varchar2) return varchar2 is
l_exception_type varchar2(50);
begin
--check if it is a predefined exception
begin
- 19
execute immediate 'begin null; exception when '||a_exception_name||' then null; end;';
- 3
l_exception_type := gc_named_exception;
exception
- 32
when others then
- 16
if dbms_utility.format_error_stack() like '%PLS-00485%' then
begin
- 7
execute immediate 'declare x positiven := -('||a_exception_name||'); begin null; end;';
- 7
l_exception_type := gc_integer_exception;
exception
when others then
--invalid exception number (positive)
--TODO add warning for this value
null;
end;
end if;
end;
- 19
return l_exception_type;
end;
function get_exception_number (a_exception_var in varchar2) return integer is
l_exc_no integer;
l_exc_type varchar2(50);
function remap_no_data_found (a_number integer) return integer is
begin
- 19
return case a_number when 100 then -1403 else a_number end;
end;
begin
- 19
l_exc_type := check_exception_type(a_exception_var);
- 19
if l_exc_type is not null then
- 10
execute immediate
- 1
case l_exc_type
- 1
when gc_integer_exception then
'declare
l_exception number;
begin
:l_exception := '||a_exception_var||'; '
- 1
when gc_named_exception then
'begin
raise '||a_exception_var||';
exception
when others then
:l_exception := sqlcode; '
end ||
'end;'
using out l_exc_no;
end if;
- 19
return remap_no_data_found(l_exc_no);
end;
function build_exception_numbers_list(
a_suite in out nocopy ut_suite,
a_procedure_name t_object_name,
a_line_no integer,
a_annotation_text in varchar2
) return ut_integer_list is
l_throws_list ut_varchar2_list;
l_exception_number integer;
- 29
l_exception_number_list ut_integer_list := ut_integer_list();
- 29
c_regexp_for_exception_no constant varchar2(30) := '^-?[[:digit:]]{1,5}$';
begin
--the a_expected_error_codes is converted to a ut_varchar2_list after that is trimmed and filtered to left only valid exception numbers
- 29
l_throws_list := ut_utils.trim_list_elements(ut_utils.string_to_table(a_annotation_text, ',', 'Y'));
- 80
for i in 1 .. l_throws_list.count
loop
/**
* Check if its a valid qualified name and if so try to resolve name to an exception number
*/
- 51
if is_valid_qualified_name(l_throws_list(i)) then
- 19
l_exception_number := get_exception_number(l_throws_list(i));
- 32
elsif regexp_like(l_throws_list(i), c_regexp_for_exception_no) then
- 24
l_exception_number := l_throws_list(i);
end if;
- 51
if l_exception_number is null then
- 17
a_suite.put_warning(
'Invalid parameter value "'||l_throws_list(i)
||'" for "--%throws" annotation. Parameter ignored.'||get_object_reference( a_suite, a_procedure_name, a_line_no )
);
else
- 34
l_exception_number_list.extend;
- 34
l_exception_number_list(l_exception_number_list.last) := l_exception_number;
end if;
- 51
l_exception_number := null;
end loop;
- 29
return l_exception_number_list;
end;
begin
- 33
a_list := ut_integer_list();
- 33
l_annotation_pos := a_throws_ann_text.first;
- 66
while l_annotation_pos is not null loop
- 33
if a_throws_ann_text(l_annotation_pos) is null then
- 4
a_suite.put_warning(
'"--%throws" annotation requires a parameter. Annotation ignored.'
|| get_object_reference( a_suite, a_procedure_name, l_annotation_pos )
);
else
- 29
a_list :=
a_list multiset union
build_exception_numbers_list(
a_suite,
a_procedure_name,
l_annotation_pos,
a_throws_ann_text(l_annotation_pos)
);
end if;
- 33
l_annotation_pos := a_throws_ann_text.next(l_annotation_pos);
end loop;
end;
procedure add_tags_to_suite_item(
a_suite in out nocopy ut_suite,
a_tags_ann_text tt_annotation_texts,
a_list in out nocopy ut_varchar2_rows,
a_procedure_name t_object_name := null
) is
l_annotation_pos binary_integer;
- 55
l_tag_list ut_varchar2_list := ut_varchar2_list();
begin
- 55
l_annotation_pos := a_tags_ann_text.first;
- 114
while l_annotation_pos is not null loop
- 59
if a_tags_ann_text(l_annotation_pos) is null then
- 3
a_suite.put_warning(
'"--%tags" annotation requires a tag value populated. Annotation ignored.'
|| get_object_reference( a_suite, a_procedure_name, l_annotation_pos )
);
else
- 56
l_tag_list := l_tag_list multiset union distinct ut_utils.trim_list_elements(
ut_utils.string_to_table(a_tags_ann_text(l_annotation_pos),',')
);
end if;
- 59
l_annotation_pos := a_tags_ann_text.next(l_annotation_pos);
end loop;
--remove empty strings from table list e.g. tag1,,tag2 and conver to rows
- 55
a_list := ut_utils.convert_collection( ut_utils.filter_list(l_tag_list,ut_utils.gc_word_no_space) );
end;
procedure set_seq_no(
a_list in out nocopy ut_executables
) is
begin
- 8368
if a_list is not null then
- 10116
for i in 1 .. a_list.count loop
- 1748
a_list(i).seq_no := i;
end loop;
end if;
end;
function convert_list(
a_list tt_executables
) return ut_executables is
- 8368
l_result ut_executables := ut_executables();
- 8368
l_pos t_annotation_position := a_list.first;
begin
- 10004
while l_pos is not null loop
- 3308
for i in 1 .. a_list(l_pos).count loop
- 1672
l_result.extend;
- 1672
l_result(l_result.last) := a_list(l_pos)(i);
end loop;
- 1636
l_pos := a_list.next(l_pos);
end loop;
- 8368
return l_result;
end;
function add_executables(
a_owner t_object_name,
a_package_name t_object_name,
a_annotation_texts tt_annotation_texts,
a_event_name ut_event_manager.t_event_name
) return tt_executables is
l_executables ut_executables;
l_result tt_executables;
l_annotation_pos binary_integer;
l_procedures_list ut_varchar2_list;
l_procedures_pos binary_integer;
l_components_list ut_varchar2_list;
begin
- 543
l_annotation_pos := a_annotation_texts.first;
- 1103
while l_annotation_pos is not null loop
- 560
l_procedures_list :=
ut_utils.filter_list(
ut_utils.trim_list_elements(
ut_utils.string_to_table(a_annotation_texts(l_annotation_pos), ',')
)
, '[[:alpha:]]+'
);
- 560
l_procedures_pos := l_procedures_list.first;
- 560
l_executables := ut_executables();
- 1144
while l_procedures_pos is not null loop
- 584
l_components_list := ut_utils.string_to_table(l_procedures_list(l_procedures_pos), '.');
- 584
l_executables.extend;
- 584
l_executables(l_executables.last) :=
- 1
case(l_components_list.count())
- 1
when 1 then
ut_executable(a_owner, a_package_name, l_components_list(1), a_event_name)
- 1
when 2 then
ut_executable(a_owner,l_components_list(1), l_components_list(2), a_event_name)
- 1
when 3 then
ut_executable(l_components_list(1), l_components_list(2), l_components_list(3), a_event_name)
else
null
end;
- 584
l_procedures_pos := l_procedures_list.next(l_procedures_pos);
end loop;
- 560
l_result(l_annotation_pos) := l_executables;
- 560
l_annotation_pos := a_annotation_texts.next(l_annotation_pos);
end loop;
- 543
return l_result;
end;
procedure warning_on_duplicate_annot(
a_suite in out nocopy ut_suite_item,
a_annotations tt_annotations_by_name,
a_for_annotation varchar2,
a_procedure_name t_object_name := null
) is
l_line_no binary_integer;
begin
- 8204
if a_annotations.exists(a_for_annotation) and a_annotations(a_for_annotation).count > 1 then
--start from second occurrence of annotation
- 14
l_line_no := a_annotations(a_for_annotation).next( a_annotations(a_for_annotation).first );
- 28
while l_line_no is not null loop
- 14
add_annotation_ignored_warning( a_suite, a_for_annotation, 'Duplicate annotation %%%.', l_line_no, a_procedure_name );
- 14
l_line_no := a_annotations(a_for_annotation).next( l_line_no );
end loop;
end if;
end;
procedure warning_bad_annot_combination(
a_suite in out nocopy ut_suite_item,
a_procedure_name t_object_name,
a_proc_annotations tt_annotations_by_name,
a_for_annotation varchar2,
a_invalid_annotations ut_varchar2_list
) is
l_annotation_name t_annotation_name;
l_line_no binary_integer;
begin
- 2417
if a_proc_annotations.exists(a_for_annotation) then
- 2417
l_annotation_name := a_proc_annotations.first;
- 5359
while l_annotation_name is not null loop
- 2942
if l_annotation_name member of a_invalid_annotations then
- 4
l_line_no := a_proc_annotations(l_annotation_name).first;
- 8
while l_line_no is not null loop
- 4
add_annotation_ignored_warning(
a_suite, l_annotation_name, 'Annotation %%% cannot be used with "--%'|| a_for_annotation || '".',
l_line_no, a_procedure_name
);
- 4
l_line_no := a_proc_annotations(l_annotation_name).next(l_line_no);
end loop;
end if;
- 2942
l_annotation_name := a_proc_annotations.next(l_annotation_name);
end loop;
end if;
end;
procedure add_test(
a_suite in out nocopy ut_suite,
a_suite_items in out nocopy ut_suite_items,
a_procedure_name t_object_name,
a_annotations t_annotations_info
) is
l_test ut_test;
l_annotation_texts tt_annotation_texts;
- 2646
l_proc_annotations tt_annotations_by_name := a_annotations.by_proc(a_procedure_name);
begin
- 2646
if not l_proc_annotations.exists(gc_test) then
- 229
return;
end if;
- 2417
warning_on_duplicate_annot( a_suite, l_proc_annotations, gc_test, a_procedure_name);
- 2417
warning_on_duplicate_annot( a_suite, l_proc_annotations, gc_displayname, a_procedure_name);
- 2417
warning_on_duplicate_annot( a_suite, l_proc_annotations, gc_rollback, a_procedure_name);
- 2417
warning_bad_annot_combination(
a_suite, a_procedure_name, l_proc_annotations, gc_test,
ut_varchar2_list(gc_beforeeach, gc_aftereach, gc_beforeall, gc_afterall)
);
- 2417
l_test := ut_test(a_suite.object_owner, a_suite.object_name, a_procedure_name, l_proc_annotations( gc_test).first);
- 2417
l_test.parse_time := a_annotations.parse_time;
- 2417
if l_proc_annotations.exists( gc_displayname) then
- 5
l_annotation_texts := l_proc_annotations( gc_displayname);
--take the last definition if more than one was provided
- 5
l_test.description := l_annotation_texts(l_annotation_texts.first);
--TODO if more than one - warning
else
- 2412
l_test.description := l_proc_annotations(gc_test)(l_proc_annotations(gc_test).first);
end if;
- 2417
l_test.path := a_suite.path ||'.'||a_procedure_name;
- 2417
if l_proc_annotations.exists(gc_rollback) then
- 1
l_annotation_texts := l_proc_annotations(gc_rollback);
- 1
l_test.rollback_type := get_rollback_type(l_annotation_texts(l_annotation_texts.first));
- 1
if l_test.rollback_type is null then
add_annotation_ignored_warning(
a_suite, gc_rollback, 'Annotation %%% must be provided with one of values: "auto" or "manual".',
l_annotation_texts.first, a_procedure_name
);
end if;
end if;
- 2417
if l_proc_annotations.exists( gc_beforetest) then
- 215
l_test.before_test_list := convert_list(