Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added support for a_client_character_set
  • Loading branch information
jgebal committed Jun 10, 2018
commit fe90466ea6cc4dba9fa7fe225105b01cdd35c351
328 changes: 254 additions & 74 deletions source/api/ut.pkb

Large diffs are not rendered by default.

140 changes: 104 additions & 36 deletions source/api/ut.pks
Original file line number Diff line number Diff line change
Expand Up @@ -48,75 +48,143 @@ create or replace package ut authid current_user as
procedure fail(a_message in varchar2);

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_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
) return ut_varchar2_rows pipelined;

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_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
) return ut_varchar2_rows pipelined;

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_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
) return ut_varchar2_rows pipelined;

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_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
) return ut_varchar2_rows pipelined;

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_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
) return ut_varchar2_rows pipelined;

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_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
) return ut_varchar2_rows pipelined;

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_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
);

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_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
);

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_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
);

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_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
);

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_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
);

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_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
);

/**
Expand Down
16 changes: 12 additions & 4 deletions source/api/ut_runner.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,16 @@ create or replace package body ut_runner is
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 default false
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
) is
l_run ut_run;
l_coverage_schema_names ut_varchar2_rows;
Expand Down Expand Up @@ -118,7 +125,8 @@ create or replace package body ut_runner is
l_exclude_object_names,
l_include_object_names,
set(a_source_file_mappings),
set(a_test_file_mappings)
set(a_test_file_mappings),
a_client_character_set
);
l_run.do_execute();

Expand Down
14 changes: 10 additions & 4 deletions source/api/ut_runner.pks
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,16 @@ create or replace package ut_runner authid current_user is
* schema.suite1.test2 - executes test2 procedure of suite1 suite with execution of all parent setup/teardown procedures
*/
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 default false
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
);

/**
Expand Down
4 changes: 3 additions & 1 deletion source/core/types/ut_run.tpb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ create or replace type body ut_run as
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_test_file_mappings ut_file_mappings := null,
a_client_character_set varchar2 := null
) return self as result is
l_coverage_schema_names ut_varchar2_rows;
l_coverage_options ut_coverage_options;
Expand All @@ -33,6 +34,7 @@ create or replace type body ut_run as
self.run_paths := a_run_paths;
self.self_type := $$plsql_unit;
self.items := a_items;
self.client_character_set := lower(a_client_character_set);
self.results_count := ut_results_counter();
self.test_file_mappings := coalesce(a_test_file_mappings, ut_file_mappings());
self.coverage_options := ut_coverage_options(
Expand Down
4 changes: 3 additions & 1 deletion source/core/types/ut_run.tps
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ create or replace type ut_run under ut_suite_item (
run_paths ut_varchar2_list,
coverage_options ut_coverage_options,
test_file_mappings ut_file_mappings,
client_character_set varchar2(100),
constructor function ut_run(
self in out nocopy ut_run,
a_items ut_suite_items,
Expand All @@ -31,7 +32,8 @@ create or replace type ut_run under ut_suite_item (
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_test_file_mappings ut_file_mappings := null,
a_client_character_set varchar2 := null
) return self as result,
overriding member procedure mark_as_skipped(self in out nocopy ut_run),
overriding member function do_execute(self in out nocopy ut_run) return boolean,
Expand Down
11 changes: 11 additions & 0 deletions source/core/ut_utils.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,17 @@ procedure append_to_clob(a_src_clob in out nocopy clob, a_clob_table t_clob_tab,
return to_char(a_value, gc_number_format, 'NLS_NUMERIC_CHARACTERS=''. ''');
end;

function get_xml_header(a_encoding varchar2) return varchar2 is
begin
return
'<?xml version="1.0"'
||case
when a_encoding is not null
then ' encoding="'||lower(a_encoding)||'"'
end
||'?>';
end;

function trim_list_elements(a_list IN ut_varchar2_list, a_regexp_to_trim in varchar2 default '[:space:]') return ut_varchar2_list is
l_trimmed_list ut_varchar2_list;
l_index integer;
Expand Down
7 changes: 7 additions & 0 deletions source/core/ut_utils.pks
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,13 @@ create or replace package ut_utils authid definer is
*/
function to_xml_number_format(a_value number) return varchar2;


/**
* Returns xml header. If a_encoding is not null, header will include encoding attribute with provided value
*/
function get_xml_header(a_encoding varchar2) return varchar2;


/*It takes a collection of type ut_varchar2_list and it trims the characters passed as arguments for every element*/
function trim_list_elements(a_list IN ut_varchar2_list, a_regexp_to_trim in varchar2 default '[:space:]') return ut_varchar2_list;

Expand Down
24 changes: 13 additions & 11 deletions source/reporters/ut_coverage_cobertura_reporter.tpb
Original file line number Diff line number Diff line change
Expand Up @@ -66,25 +66,27 @@ create or replace type body ut_coverage_cobertura_reporter is
end;

function get_coverage_xml(
a_coverage_data ut_coverage.t_coverage
a_coverage_data ut_coverage.t_coverage,
a_run ut_run
) return clob is
l_file_part varchar2(32767);
l_result clob;
l_unit ut_coverage.t_full_name;
l_obj_name ut_coverage.t_object_name;
c_coverage_def constant varchar2(200) := '<?xml version="1.0"?>'||CHR(10)||'<!DOCTYPE coverage SYSTEM "http://cobertura.sourceforge.net/xml/coverage-04.dtd">'||chr(10);
l_file_part varchar2(32767);
l_result clob;
l_unit ut_coverage.t_full_name;
l_obj_name ut_coverage.t_object_name;
c_coverage_def constant varchar2(200) := '<!DOCTYPE coverage SYSTEM "http://cobertura.sourceforge.net/xml/coverage-04.dtd">'||chr(10);
c_file_footer constant varchar2(30) := '</file>'||chr(10);
c_coverage_footer constant varchar2(30) := '</coverage>';
c_sources_footer constant varchar2(30) := '</sources>'||chr(10);
c_packages_footer constant varchar2(30) := '</packages>'||chr(10);
c_packages_footer constant varchar2(30) := '</packages>'||chr(10);
c_package_footer constant varchar2(30) := '</package>'||chr(10);
c_class_footer constant varchar2(30) := '</class>'||chr(10);
c_lines_footer constant varchar2(30) := '</lines>'||chr(10);
l_epoch varchar2(50) := (sysdate - to_date('01-01-1970 00:00:00', 'dd-mm-yyyy hh24:mi:ss')) * 24 * 60 * 60;
c_class_footer constant varchar2(30) := '</class>'||chr(10);
c_lines_footer constant varchar2(30) := '</lines>'||chr(10);
l_epoch varchar2(50) := (sysdate - to_date('01-01-1970 00:00:00', 'dd-mm-yyyy hh24:mi:ss')) * 24 * 60 * 60;
begin

dbms_lob.createtemporary(l_result,true);

ut_utils.append_to_clob(l_result, ut_utils.get_xml_header(a_run.client_character_set)||chr(10));
ut_utils.append_to_clob(l_result, c_coverage_def);

--write header
Expand Down Expand Up @@ -138,7 +140,7 @@ create or replace type body ut_coverage_cobertura_reporter is

l_coverage_data := ut_coverage.get_coverage_data(a_run.coverage_options);

self.print_clob( get_coverage_xml( l_coverage_data ) );
self.print_clob( get_coverage_xml( l_coverage_data, a_run ) );

(self as ut_reporter_base).after_calling_run(a_run);
end;
Expand Down
6 changes: 4 additions & 2 deletions source/reporters/ut_coverage_sonar_reporter.tpb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ create or replace type body ut_coverage_sonar_reporter is
return l_result;
end;
function get_coverage_xml(
a_coverage_data ut_coverage.t_coverage
a_coverage_data ut_coverage.t_coverage,
a_run ut_run
) return clob is
l_file_part varchar2(32767);
l_result clob;
Expand All @@ -70,6 +71,7 @@ create or replace type body ut_coverage_sonar_reporter is
begin
dbms_lob.createtemporary(l_result,true);

ut_utils.append_to_clob(l_result, ut_utils.get_xml_header(a_run.client_character_set)||chr(10));
ut_utils.append_to_clob(l_result, c_coverage_header);
l_unit := a_coverage_data.objects.first;
while l_unit is not null loop
Expand All @@ -90,7 +92,7 @@ create or replace type body ut_coverage_sonar_reporter is

l_coverage_data := ut_coverage.get_coverage_data(a_run.coverage_options);

self.print_clob( get_coverage_xml( l_coverage_data ) );
self.print_clob( get_coverage_xml( l_coverage_data, a_run ) );
end;

overriding member function get_description return varchar2 as
Expand Down
1 change: 1 addition & 0 deletions source/reporters/ut_junit_reporter.tpb
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ create or replace type body ut_junit_reporter is
end;
begin
l_suite_id := 0;
self.print_text(ut_utils.get_xml_header(a_run.client_character_set));
self.print_text('<testsuites tests="' || l_tests_count || '"' || self.get_common_suite_attributes(a_run) || '>');
for i in 1 .. a_run.items.count loop
print_suite_elements(treat(a_run.items(i) as ut_logical_suite), l_suite_id);
Expand Down
1 change: 1 addition & 0 deletions source/reporters/ut_sonar_test_reporter.tpb
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ create or replace type body ut_sonar_test_reporter is
end;

begin
self.print_text(ut_utils.get_xml_header(a_run.client_character_set));
self.print_text('<testExecutions version="1">');
for i in 1 .. a_run.items.count loop
print_suite_results(treat(a_run.items(i) as ut_logical_suite), a_run.test_file_mappings);
Expand Down
1 change: 1 addition & 0 deletions source/reporters/ut_tfs_junit_reporter.tpb
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ create or replace type body ut_tfs_junit_reporter is

begin
l_suite_id := 0;
self.print_text(ut_utils.get_xml_header(a_run.client_character_set));
self.print_text('<testsuites>');
for i in 1 .. a_run.items.count loop
print_suite_results(treat(a_run.items(i) as ut_logical_suite), l_suite_id);
Expand Down
Loading