10000 Ability to report coverage on long lines. by jgebal · Pull Request #1240 · utPLSQL/utPLSQL · GitHub
[go: up one dir, main page]

Skip to content

Ability to report coverage on long lines. #1240

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
15 changes: 11 additions & 4 deletions source/reporters/ut_coverage_report_html_helper.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,11 @@ create or replace package body ut_coverage_report_html_helper is
l_file_part varchar2(32767);
l_result ut_varchar2_rows := ut_varchar2_rows();
l_coverage_pct number(5, 2);
l_coverage_block_pct number(5, 2);
l_hits varchar2(30);
l_blocks varchar2(30);
l_line_text varchar2(32767);
e_buffer_too_small exception;
pragma exception_init ( e_buffer_too_small, -19011 );
begin

l_coverage_pct := coverage_pct(a_coverage_unit.covered_lines, a_coverage_unit.uncovered_lines);
Expand All @@ -148,10 +150,16 @@ create or replace package body ut_coverage_report_html_helper is
ut_utils.append_to_list(l_result, l_file_part);

for line_no in 1 .. a_source_code.count loop
begin
l_line_text := dbms_xmlgen.convert(a_source_code(line_no));
exception
when e_buffer_too_small then
l_line_text := dbms_xmlgen.convert(to_clob(a_source_code(line_no)));
end;
if not a_coverage_unit.lines.exists(line_no) then
l_file_part := '
<li class="' || line_status(null) || '" data-hits="" data-linenumber="' || line_no || '">
<code class="sql">' || (dbms_xmlgen.convert(a_source_code(line_no))) ||
<code class="sql">' || l_line_text ||
8000 '</code></li>';
else
l_hits := to_char(a_coverage_unit.lines(line_no).executions);
Expand Down Expand Up @@ -188,7 +196,7 @@ create or replace package body ut_coverage_report_html_helper is
'</span>';
end if;
l_file_part := l_file_part || '
<code class="sql">' || (dbms_xmlgen.convert(a_source_code(line_no))) ||
<code class="sql">' || l_line_text ||
'</code></li>';
end if;
ut_utils.append_to_list(l_result, l_file_part);
Expand Down Expand Up @@ -222,7 +230,6 @@ create or replace package body ut_coverage_report_html_helper is
l_file_part varchar2(32767);
l_title varchar2(100) := 'All files';
l_coverage_pct number(5, 2);
l_coverage_block_pct number(5, 2);
l_result ut_varchar2_rows;
l_id varchar2(50) := object_id(a_title);
l_unit_coverage ut_coverage.t_unit_coverage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,70 @@ create or replace package body test_html_coverage_reporter is
ut.expect(l_actual).to_be_like(l_expected);
end;

procedure setup_long_lines is
pragma autonomous_transaction;
begin

execute immediate q'[create or replace type string_array is table of varchar2(5 char);]';
execute immediate q'[
create or replace function f return integer is
l_string_array string_array;
l_count integer;
begin
-- line is 1912 chars long, 1911 characters seem to be the max. line length that works (@formatter:off)
l_string_array := string_array('aahed', 'aalii', 'aargh', 'aarti', 'abaca', 'abaci', 'abacs', 'abaft', 'abaka', 'abamp', 'aband', 'abash', 'abask', 'abaya', 'abbas', 'abbed', 'abbes', 'abcee', 'abeam', 'abear', 'abele', 'abers', 'abets', 'abies', 'abler', 'ables', 'ablet', 'ablow', 'abmho', 'abohm', 'aboil', 'aboma', 'aboon', 'abord', 'abore', 'abram', 'abray', 'abrim', 'abrin', 'abris', 'absey', 'absit', 'abuna', 'abune', 'abuts', 'abuzz', 'abyes', 'abysm', 'acais', 'acari', 'accas', 'accoy', 'acerb', 'acers', 'aceta', 'achar', 'ached', 'aches', 'achoo', 'acids', 'acidy', 'acing', 'acini', 'ackee', 'acker', 'acmes', 'acmic', 'acned', 'acnes', 'acock', 'acold', 'acred', 'acres', 'acros', 'acted', 'actin', 'acton', 'acyls', 'adaws', 'adays', 'adbot', 'addax', 'added', 'adder', 'addio', 'addle', 'adeem', 'adhan', 'adieu', 'adios', 'adits', 'adman', 'admen', 'admix', 'adobo', 'adown', 'adoze', 'adrad', 'adred', 'adsum', 'aduki', 'adunc', 'adust', 'advew', 'adyta', 'adzed', 'adzes', 'aecia', 'aedes', 'aegis', 'aeons', 'aerie', 'aeros', 'aesir', 'afald', 'afara', 'afars', 'afear', 'aflaj', 'afore', 'afrit', 'afros', 'agama', 'agami', 'agars', 'agast', 'agave', 'agaze', 'agene', 'agers', 'agger', 'aggie', 'aggri', 'aggro', 'aggry', 'aghas', 'agila', 'agios', 'agism', 'agist', 'agita', 'aglee', 'aglet', 'agley', 'agloo', 'aglus', 'agmas', 'agoge', 'agone', 'agons', 'agood', 'agora', 'agria', 'agrin', 'agros', 'agued', 'agues', 'aguna', 'aguti', 'aheap', 'ahent', 'ahigh', 'ahind', 'ahing', 'ahint', 'ahold', 'ahull', 'ahuru', 'aidas', 'aided', 'aides', 'aidoi', 'aidos', 'aiery', 'aigas', 'aight', 'ailed', 'aimed', 'aimer', 'ainee', 'ainga', 'aioli', 'aired', 'airer', 'airns', 'airth', 'airts', 'aitch', 'aitus', 'aiver', 'aiyee', 'aizle', 'ajies', 'ajiva', 'ajuga', 'ajwan', 'akees', 'akela', 'akene', 'aking', 'akita', 'akkas', 'alaap', 'alack', 'alamo', 'aland', 'alane', 'alang', 'a');
select count(*) into l_count from table(l_string_array);
return l_count;
end;]';

execute immediate q'[
create or replace package test_f is
--%suite

--%test
procedure fail_ut_coverage_html_reporter;
end;]';

execute immediate q'[
create or replace package body test_f is
procedure fail_ut_coverage_html_reporter is
begin
ut3_develop.ut.expect(f()).to_be_greater_or_equal(1);
end;
end;
]';
end;

procedure cleanup_long_lines is
pragma autonomous_transaction;
begin
execute immediate 'drop package test_f';
execute immediate 'drop function f';
execute immediate 'drop type string_array force';
end;

procedure report_long_lines is
l_expected varchar2(32767);
l_actual clob;
l_name varchar2(250);
begin
--Arrange
l_expected := '%l_string_array := string_array%';

l_actual :=
ut3_tester_helper.coverage_helper.run_tests_as_job(
q'[
ut3_develop.ut.run(
a_path => 'ut3_user.test_f',
a_reporter=> ut3_develop.ut_coverage_html_reporter(),
a_include_objects => ut3_develop.ut_varchar2_list( 'UT3_USER.F' )
)
]'
);
--Assert
ut.expect(l_actual).to_be_like(l_expected);
end;


end test_html_coverage_reporter;
/
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,13 @@ create or replace package test_html_coverage_reporter is
--%test(reports on a project file mapped to database object in extended profiler coverage)
procedure report_on_file;

procedure setup_long_lines;
procedure cleanup_long_lines;

--%test(reports on lines exceeding 4000 chars after conversion to XML)
--%beforetest(setup_long_lines)
--%aftertest(cleanup_long_lines)
procedure report_long_lines;

end test_html_coverage_reporter;
/
0