Skip to content
Merged
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
Trying different approach to coverage gathering.
  • Loading branch information
jgebal committed Jul 16, 2019
commit a8c0c82d8454cda6fa3bcf08b8aebb02040104b0
71 changes: 5 additions & 66 deletions source/core/coverage/ut_coverage.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ create or replace package body ut_coverage is
function get_cov_sources_sql(a_coverage_options ut_coverage_options) return varchar2 is
l_result varchar2(32767);
l_full_name varchar2(32767);
l_mappings varchar2(32767);
l_join_mappings varchar2(32767);
l_filters varchar2(32767);
l_mappings_cardinality integer := 0;
begin
l_result := q'[
with sources as (
select /*+ cardinality(f {mappings_cardinality}) */
{l_full_name} as full_name, s.owner, s.name, s.line, s.text
from {sources_view} s {file_mappings}
from {sources_view} s {join_file_mappings}
where s.type in ('PACKAGE BODY', 'TYPE BODY', 'PROCEDURE', 'FUNCTION')
{filters}
),
Expand All @@ -62,7 +62,7 @@ create or replace package body ut_coverage is
and regexp_like( t.text, '[A-Za-z0-9$#_]*(begin|declare|compound).*', 'i' )
) as line,
s.text
from {sources_view} s {file_mappings}
from {sources_view} s {join_file_mappings}
where s.type = 'TRIGGER'
{filters}
),
Expand Down Expand Up @@ -100,7 +100,7 @@ create or replace package body ut_coverage is
if a_coverage_options.file_mappings is not empty then
l_mappings_cardinality := ut_utils.scale_cardinality(cardinality(a_coverage_options.file_mappings));
l_full_name := 'f.file_name';
l_mappings := '
l_join_mappings := '
join table(:file_mappings) f
on s.name = f.object_name
and s.type = f.object_type
Expand All @@ -117,73 +117,12 @@ create or replace package body ut_coverage is

l_result := replace(l_result, '{sources_view}', ut_metadata.get_source_view_name());
l_result := replace(l_result, '{l_full_name}', l_full_name);
l_result := replace(l_result, '{file_mappings}', l_mappings);
l_result := replace(l_result, '{join_file_mappings}', l_join_mappings);
l_result := replace(l_result, '{filters}', l_filters);
l_result := replace(l_result, '{mappings_cardinality}', l_mappings_cardinality);

return l_result;

-- if a_coverage_options.file_mappings is not null and a_coverage_options.file_mappings.count > 0 then
-- l_full_name := 'f.file_name';
-- else
-- l_full_name := 'lower(s.owner||''.''||s.name)';
-- end if;
-- l_result := '
-- select full_name, owner, name, line, to_be_skipped, text
-- from (
-- select '||l_full_name||q'[ as full_name,
-- s.owner,
-- s.name,
-- s.line -
-- coalesce(
-- case when type!='TRIGGER' then 0 end,
-- (select min(t.line) - 1
-- from ]'||ut_metadata.get_source_view_name()||q'[ t
-- where t.owner = s.owner and t.type = s.type and t.name = s.name
-- and regexp_like( t.text, '[A-Za-z0-9$#_]*(begin|declare|compound).*','i'))
-- ) as line,
-- s.text, ]';
-- l_result := l_result ||
-- q'[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 ]';
--
-- l_result := l_result ||' from '||ut_metadata.get_source_view_name()||q'[ s]';
--
-- if a_coverage_options.file_mappings is not empty then
-- l_result := l_result || '
-- join table(:file_mappings) f
-- on s.name = f.object_name
-- and s.type = f.object_type
-- and s.owner = f.object_owner
-- where 1 = 1';
-- elsif a_coverage_options.include_objects is not empty then
-- l_result := l_result || '
-- where (s.owner, s.name) in (select il.owner, il.name from table(:include_objects) il)';
-- else
-- l_result := l_result || '
-- where s.owner in (select upper(t.column_value) from table(:l_schema_names) t)';
-- end if;
-- l_result := l_result || q'[
-- and s.type not in ('PACKAGE', 'TYPE', 'JAVA SOURCE')
-- --Exclude calls to utPLSQL framework, Unit Test packages and objects from a_exclude_list parameter of coverage reporter
-- and (s.owner, s.name) not in (select el.owner, el.name from table(:l_skipped_objects) el)
-- )
-- where line > 0]';
-- return l_result;
end;

function get_cov_sources_cursor(a_coverage_options in ut_coverage_options,a_sql in varchar2) return sys_refcursor is
Expand Down