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

Skip to content

Commit 49b5fba

Browse files
committed
Added support for charset in HTML reports.
1 parent 7943b57 commit 49b5fba

7 files changed

Lines changed: 36 additions & 14 deletions

File tree

source/core/ut_utils.pkb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ procedure append_to_clob(a_src_clob in out nocopy clob, a_clob_table t_clob_tab,
513513
'<?xml version="1.0"'
514514
||case
515515
when a_encoding is not null
516-
then ' encoding="'||lower(a_encoding)||'"'
516+
then ' encoding="'||upper(a_encoding)||'"'
517517
end
518518
||'?>';
519519
end;

source/reporters/ut_coverage_html_reporter.tpb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,14 @@ create or replace type body ut_coverage_html_reporter is
3535
ut_coverage.coverage_stop();
3636
l_coverage_data := ut_coverage.get_coverage_data(a_run.coverage_options);
3737

38-
self.print_clob( ut_coverage_report_html_helper.get_index( a_coverage_data => l_coverage_data,a_assets_path => self.assets_path, a_project_name=> self.project_name ));
38+
self.print_clob(
39+
ut_coverage_report_html_helper.get_index(
40+
a_coverage_data => l_coverage_data,
41+
a_assets_path => self.assets_path,
42+
a_project_name => self.project_name,
43+
a_charset => a_run.client_character_set
44+
)
45+
);
3946
end;
4047

4148

source/reporters/ut_coverage_report_html_helper.pkb

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -277,8 +277,13 @@ function get_details_file_content(a_object_id varchar2, a_unit ut_object_name, a
277277
/*
278278
* public definitions
279279
*/
280-
function get_index(a_coverage_data ut_coverage.t_coverage, a_assets_path varchar2, a_project_name varchar2 := null, a_command_line varchar2 := null)
281-
return clob is
280+
function get_index(
281+
a_coverage_data ut_coverage.t_coverage,
282+
a_assets_path varchar2,
283+
a_project_name varchar2 := null,
284+
a_command_line varchar2 := null,
285+
a_charset varchar2 := null
286+
) return clob is
282287

283288
l_file_part varchar2(32767);
284289
l_result clob;
@@ -287,8 +292,10 @@ function get_details_file_content(a_object_id varchar2, a_unit ut_object_name, a
287292
l_time_str varchar2(50);
288293
l_using varchar2(1000);
289294
l_unit ut_coverage.t_full_name;
295+
l_charset varchar2(1000);
290296
begin
291-
l_coverage_pct := coverage_pct(a_coverage_data.covered_lines, a_coverage_data.uncovered_lines);
297+
l_charset := coalesce(upper(a_charset),'UTF-8');
298+
l_coverage_pct := coverage_pct(a_coverage_data.covered_lines, a_coverage_data.uncovered_lines);
292299

293300
l_time_str := ut_utils.to_string(sysdate);
294301
l_using := case
@@ -305,7 +312,7 @@ function get_details_file_content(a_object_id varchar2, a_unit ut_object_name, a
305312
end;
306313
--TODO - build main file containing total run data and per schema data
307314
l_file_part := '<!DOCTYPE html><html xmlns=''http://www.w3.org/1999/xhtml''><head>' || '<title>' || l_title ||
308-
'</title>' || '<meta http-equiv="content-type" content="text/html; charset=utf-8" />' ||
315+
'</title>' || '<meta http-equiv="content-type" content="text/html; charset='||l_charset||'" />' ||
309316
'<script src=''' || a_assets_path || 'application.js''></script>' ||
310317
'<link href=''' || a_assets_path ||
311318
'application.css'' media=''screen, print'' rel=''stylesheet'' type=''text/css''/>' ||

source/reporters/ut_coverage_report_html_helper.pks

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,13 @@ create or replace package ut_coverage_report_html_helper authid current_user is
3131

3232
function line_hits_css_class(a_line_hist number) return varchar2;
3333

34-
function get_index(a_coverage_data ut_coverage.t_coverage, a_assets_path varchar2, a_project_name varchar2 := null, a_command_line varchar2 := null) return clob;
34+
function get_index(
35+
a_coverage_data ut_coverage.t_coverage,
36+
a_assets_path varchar2,
37+
a_project_name varchar2 := null,
38+
a_command_line varchar2 := null,
39+
a_charset varchar2 := null
40+
) return clob;
3541

3642
end;
3743
/

test/core/reporters.pkb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ end;]';
138138
from table(ut3.ut.run('test_reporters', a_reporter, a_client_character_set => a_client_character_set));
139139
l_actual := ut3.ut_utils.table_to_clob(l_results);
140140
--Assert
141-
ut.expect(l_actual).to_be_like('<?xml version="1.0" encoding="'||lower(a_client_character_set)||'"?>%');
141+
ut.expect(l_actual).to_be_like('<?xml version="1.0" encoding="'||upper(a_client_character_set)||'"?>%');
142142
end;
143143

144144
end reporters;

test/core/reporters/test_coverage/test_html_extended_reporter.pkb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ create or replace package body test_html_extended_reporter is
44
l_results ut3.ut_varchar2_list;
55
l_expected varchar2(32767);
66
l_actual clob;
7+
l_charset varchar2(100) := 'ISO-8859-1';
78
begin
89
--Arrange
9-
l_expected := '%<h3>UT3.DUMMY_COVERAGE</h3>%<b>4</b> relevant lines. <span class="green"><b>3</b> lines covered</span> (including <span class="yellow"><b>1</b> lines partially covered</span> ) and <span class="red"><b>1</b> lines missed%';
10+
l_expected := '%<meta %charset='||l_charset||'" />%<h3>UT3.DUMMY_COVERAGE</h3>%<b>4</b> relevant lines. <span class="green"><b>3</b> lines covered</span> (including <span class="yellow"><b>1</b> lines partially covered</span> ) and <span class="red"><b>1</b> lines missed%';
1011

1112
select *
1213
bulk collect into l_results
@@ -15,7 +16,8 @@ create or replace package body test_html_extended_reporter is
1516
a_path => 'ut3.test_dummy_coverage',
1617
a_reporter=> ut3.ut_coverage_html_reporter(),
1718
a_source_files => ut3.ut_varchar2_list( 'test/ut3.dummy_coverage.pkb' ),
18-
a_test_files => ut3.ut_varchar2_list( )
19+
a_test_files => ut3.ut_varchar2_list( ),
20+
a_client_character_set => l_charset
1921
)
2022
);
2123
l_actual := ut3.ut_utils.table_to_clob(l_results);

test/core/reporters/test_coverage/test_html_proftab_reporter.pkb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@ create or replace package body test_html_proftab_reporter is
44
l_results ut3.ut_varchar2_list;
55
l_expected varchar2(32767);
66
l_actual clob;
7+
l_charset varchar2(100) := 'ISO-8859-1';
78
begin
89
--Arrange
9-
l_expected := '%<h3>UT3.DUMMY_COVERAGE</h3>%<b>3</b> relevant lines. <span class="green"><b>2</b> lines covered</span> and <span class="red"><b>1</b> lines missed%';
10-
11-
--l_expected := '%<div class="header"> <h3>UT3.DUMMY_COVERAGE</h3><h4><span class="green">66%</span> lines covered</h4><div> <b>3</b> relevant lines. <span class="green"><b>2</b> lines covered</span> ) and <span class="red"><b>1</b> lines missed</span></div></div>%';
10+
l_expected := '%<meta %charset='||l_charset||'" />%<h3>UT3.DUMMY_COVERAGE</h3>%<b>3</b> relevant lines. <span class="green"><b>2</b> lines covered</span> and <span class="red"><b>1</b> lines missed%';
1211
--Act
1312
select *
1413
bulk collect into l_results
@@ -17,7 +16,8 @@ create or replace package body test_html_proftab_reporter is
1716
a_path => 'ut3.test_dummy_coverage',
1817
a_reporter=> ut3.ut_coverage_html_reporter(),
1918
a_source_files => ut3.ut_varchar2_list( 'test/ut3.dummy_coverage.pkb' ),
20-
a_test_files => ut3.ut_varchar2_list( )
19+
a_test_files => ut3.ut_varchar2_list( ),
20+
a_client_character_set => l_charset
2121
)
2222
);
2323
l_actual := ut3.ut_utils.table_to_clob(l_results);

0 commit comments

Comments
 (0)