Skip to content

12.2 Oracle Native Block Coverage#604

Merged
lwasylow merged 54 commits intodevelopfrom
feature/12cblockcoverage
Apr 16, 2018
Merged

12.2 Oracle Native Block Coverage#604
lwasylow merged 54 commits intodevelopfrom
feature/12cblockcoverage

Conversation

@lwasylow
Copy link
Copy Markdown
Member

@lwasylow lwasylow commented Mar 15, 2018

Added a support for running cover coverage from Oracle Block Coverage.
Changes includes,update to html reporter for presentation of data,update to core types to support new coverage type option as well as few minor changes.
Default option remains profiler. The queries are in sys refcursors to avoid a compilation issues on older version of databases.
Fixes #476

lwasylow and others added 21 commits March 11, 2018 17:59
Adding a types required to support block coverage
Updated html reporter
Changed name of get raw data coverage for profiler to allow execution of block one.
Get coverage data have now logical block to allow run type of proftab or block coverage (block will be added in next iteration).

Signed-off-by: lwasylow <lwasylow@gmail.com>
Add block coverage
Moved get raw coverage into dynamic cursors to minimize impact on compilation
Added Some more tests for test block coverage.
Fixes to cycle dependancies
Added test to cover for block coverage in regression
Update block to be called from dynamic sql to avoid a compilation issues.
Updated documentation
Amended install script to not fail when block coverage not present
split block and proftab for better visibility.
Moved HTML reporters stable version
Introduced constant for easier maintain.

Signed-off-by: lwasylow <lwasylow@gmail.com>
Split block and profiler
Added conditional blocks for version less than 12.2
Split html reporter
Split block and profiler
Added conditional blocks for version less than 12.2
Split html reporter
Comment thread source/core/coverage/ut_coverage.pkb Outdated
$if dbms_db_version.version = 12 and dbms_db_version.release >= 2 or dbms_db_version.version > 12 $then
return ut_coverage_block.get_coverage_data_block(a_coverage_options => a_coverage_options);
$else
return null;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we create warning here?

Copy link
Copy Markdown
Member Author

@lwasylow lwasylow Mar 29, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its something we could consider. However if we want to warn then probably at the coverage_start function.
I could create a new type of error and raise an error at the start of the coverage something like:
Requested reporter is not available, please check you install and documentation.

that would stop running rest of test which is probably valid as when you request coverage you don't want to continue without it.

Another option would be to force user to switch to profiler instead however some information would have to be displayed not a really big fan of forcing solutions.

Comment thread source/api/ut.pkb Outdated
procedure run_autonomous(
a_paths ut_varchar2_list, a_reporter ut_reporter_base, a_color_console integer,
a_coverage_schemes ut_varchar2_list := null, a_source_file_mappings ut_file_mappings, a_test_file_mappings ut_file_mappings,
a_coverage_schemes ut_varchar2_list := null,a_coverage_type varchar2:=null, a_source_file_mappings ut_file_mappings, a_test_file_mappings ut_file_mappings,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new parameter should be added as last to avoid breaking changes to API.

Comment thread source/api/ut.pkb Outdated
procedure run_autonomous(
a_paths ut_varchar2_list, a_reporter ut_reporter_base, a_color_console integer,
a_coverage_schemes ut_varchar2_list := null, a_source_files ut_varchar2_list, a_test_files ut_varchar2_list,
a_coverage_schemes ut_varchar2_list := null,a_coverage_type varchar2:=null, a_source_files ut_varchar2_list, a_test_files ut_varchar2_list,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as above

@@ -0,0 +1,89 @@
create or replace package body ut_block_helper is
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe name it ut_block_coverage_helper - easier to understand


type t_proftab_rows is table of t_proftab_row;

type t_block_row is record(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would transform the not-so-good Oracle results into:

  • start_line binary_integer
  • end_line binary_integer - (lead(line,1) over(order by line) from coverage data - null if no next line)
  • blocks binary_integer
  • covered_blocks binary_integer

I assume that there is no situation where we have more than 1 block spanning across more than one line.
That is:
only when start_line = end_line we can get blocks>1

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m afraid it might be possible for complex multi line if Statement

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even when simple if and bad beutifier we would have one block in single line.

Copy link
Copy Markdown
Member Author

@lwasylow lwasylow Apr 7, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That will skew the results. Block is not necessary span across mutliple lines, using start and end line will result in showing execution on multiple lines that are not part of block.
Unfortunately block coverage is not including things like LOOP etc. That will give a wrong impression of loop not being executed etc.

-- The subquery is optimized by:
-- - COALESCE function -> it will execute only for TRIGGERS
-- - scalar subquery cache -> it will only execute once for one trigger source code.
function get_cov_sources_sql(a_coverage_options ut_coverage_options) return varchar2 is
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't that function duplicated in two packages now?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not exactly, I block coverage we do not skip any lines. I tried to keep to minimum number of places where there is a If decision. What I might do is to move it to generic helper and in profiler coverage package put some code to apply case statement for skipping lines before execution. So that main query will be maintained in one place.

lwasylow added 7 commits April 3, 2018 23:23
Fixes to order of new attribute.
Rename package to more meaningful name
Introduce an raise an error for non existing coverage type
Update tests
Fixes to order of new attribute.
Rename package to more meaningful name
Introduce an raise an error for non existing coverage type
Update tests
@lwasylow
Copy link
Copy Markdown
Member Author

Changes has been added for extended coverage and fixes implemented as per recommendation when required.

Copy link
Copy Markdown
Member

@jgebal jgebal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once conflicts are resolved, we're good to merge the changes.

@jgebal jgebal added this to the v3.1.0 milestone Apr 16, 2018
@lwasylow lwasylow merged commit 0d69d63 into develop Apr 16, 2018
@rlove rlove removed the in progress label Apr 16, 2018
@lwasylow lwasylow deleted the feature/12cblockcoverage branch April 16, 2018 11:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants