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

Skip to content

Commit e7d59b4

Browse files
committed
Splitting skipped framework objects and excluded objects into separate table types.
Update docs.
1 parent 4eec03e commit e7d59b4

2 files changed

Lines changed: 55 additions & 17 deletions

File tree

docs/userguide/coverage.md

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,34 @@ exec ut.run('unit_test_schema', ut_coverage_html_reporter(), a_coverage_schemes
131131
There are six options that can be used to narrow down the scope of coverage report:
132132
- `a_include_objects` - list of `[object_owner.].object_name` to be included in the coverage report.
133133
- `a_exclude_objects` - list of `[object_owner.].object_name` to be excluded from the coverage report
134-
- `a_include_schema_expr` - string of regex expression of schemas to be included in the coverage report. It will override `a_include_objects`
135-
- `a_include_object_expr` - string of regex expression of objects ( no schema names included ) to be included in the coverage report. It will override `a_include_objects`
136-
- `a_exclude_schema_expr` - string of regex expression of schemas to be excluded from the coverage report. It will override `a_exclude_objects`
137-
- `a_exclude_object_expr` - string of regex expression of objects to be excluded from the coverage report. It will override `a_exclude_objects`
134+
- `a_include_schema_expr` - string of regex expression of schemas to be included in the coverage report. It will override `a_include_objects` for example :
135+
```sql
136+
a_include_schema_expr => '^ut3_develop',
137+
a_include_objects => ut3_develop.ut_varchar2_list( 'ut3_tester_helper.regex_dummy_cov' )
138+
```
139+
Will result in showing coverage for all schemas that match regular expression `^ut3_develop` and ignore objectes defined by parameter `a_include_objects`
140+
141+
- `a_include_object_expr` - string of regex expression of objects ( no schema names included ) to be included in the coverage report. It will override `a_include_objects` for example:
142+
```sql
143+
a_include_object_expr => 'regex123',
144+
a_include_objects => ut3_develop.ut_varchar2_list( 'ut3_tester_helper.regex_dummy_cov' )
145+
```
146+
Will result in showing coverage for all objects that name match regular expression `regex123` and ignore objectes defined by parameter `a_include_objects`
147+
148+
- `a_exclude_schema_expr` - string of regex expression of schemas to be excluded from the coverage report. It will override `a_exclude_objects` for example:
149+
```sql
150+
a_exclude_schema_expr => '^ut3_tester',
151+
a_exclude_objects => ut3_develop.ut_varchar2_list( 'ut3_develop.regex_dummy_cov' )
152+
```
153+
Will result in showing coverage for all objects that schema is not matching regular expression `^ut3_tester` and ignore exclusion defined by parameter `a_exclude_objects`
154+
155+
- `a_exclude_object_expr` - string of regex expression of objects to be excluded from the coverage report. It will override `a_exclude_objects` for example
156+
```sql
157+
a_exclude_object_expr => 'regex123',
158+
a_exclude_objects => ut3_develop.ut_varchar2_list( 'ut3_develop.regex_dummy_cov' )
159+
```
160+
Will result in showing coverage for all objects that name is not matching regular expression `regex123` and ignore exclusion defined by parameter `a_exclude_objects`
161+
138162

139163
You may specify both _include_ and _exclude_ options to gain more control over what needs to be included / excluded from the coverage report.
140164

source/core/coverage/ut_coverage.pkb

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ create or replace package body ut_coverage is
3030
end;
3131

3232
function get_cov_sources_sql(a_coverage_options ut_coverage_options, a_skip_objects ut_object_names) return varchar2 is
33-
l_result varchar2(32767); --QUESTION: Given fact that we can pass large regex filters same as objects filter should we consider a clob ?
33+
l_result varchar2(32767);
3434
l_full_name varchar2(32767);
3535
l_join_mappings varchar2(32767);
3636
l_filters varchar2(32767);
@@ -55,7 +55,12 @@ create or replace package body ut_coverage is
5555
from {sources_view} s {join_file_mappings}
5656
where s.type in ('PACKAGE BODY', 'TYPE BODY', 'PROCEDURE', 'FUNCTION', 'TRIGGER')
5757
{filters}
58-
{regex_exc_filters}
58+
{regex_exc_filters}
59+
and not exists (
60+
select /*+ cardinality(el {excuded_objects_cardinality})*/ 1
61+
from table(:l_excluded_objects) el
62+
where s.owner = el.owner and s.name = el.name
63+
)
5964
),
6065
coverage_sources as (
6166
select full_name, owner, name, type, line, text,
@@ -146,40 +151,49 @@ create or replace package body ut_coverage is
146151
l_result := replace(l_result, '{filters}', l_filters);
147152
l_result := replace(l_result, '{mappings_cardinality}', l_mappings_cardinality);
148153
l_result := replace(l_result, '{skipped_objects_cardinality}', ut_utils.scale_cardinality(cardinality(a_skip_objects)));
154+
l_result := replace(l_result, '{excuded_objects_cardinality}', ut_utils.scale_cardinality(cardinality(coalesce(a_coverage_options.exclude_objects, ut_object_names()))));
149155
l_result := replace(l_result, '{regex_exc_filters}', l_regex_exc_filters);
150156

151157
return l_result;
152158

153159
end;
154160

155161
function get_cov_sources_cursor(a_coverage_options in ut_coverage_options) return sys_refcursor is
156-
l_cursor sys_refcursor;
157-
l_skip_objects ut_object_names;
158-
l_sql varchar2(32767);
162+
l_cursor sys_refcursor;
163+
l_skip_objects ut_object_names;
164+
l_excluded_objects ut_object_names;
165+
l_sql varchar2(32767);
159166
begin
160167
if not is_develop_mode() then
161168
--skip all the utplsql framework objects and all the unit test packages that could potentially be reported by coverage.
162169
l_skip_objects := coalesce(ut_utils.get_utplsql_objects_list(),ut_object_names());
163-
--Regex exclusion override the standard exclusion objects.
164-
if a_coverage_options.exclude_schema_expr is null and a_coverage_options.exclude_object_expr is null then
165-
l_skip_objects := l_skip_objects multiset union all coalesce(a_coverage_options.exclude_objects, ut_object_names());
166-
end if;
167170
end if;
168171

172+
--Regex exclusion override the standard exclusion objects.
173+
if a_coverage_options.exclude_schema_expr is null and a_coverage_options.exclude_object_expr is null then
174+
l_excluded_objects := coalesce(a_coverage_options.exclude_objects, ut_object_names());
175+
end if;
176+
169177
l_sql := get_cov_sources_sql(a_coverage_options, l_skip_objects);
170178

171179
ut_event_manager.trigger_event(ut_event_manager.gc_debug, ut_key_anyvalues().put('l_sql',l_sql) );
172180

173181
if a_coverage_options.file_mappings is not empty then
174-
open l_cursor for l_sql using a_coverage_options.file_mappings,a_coverage_options.exclude_schema_expr,a_coverage_options.exclude_object_expr,l_skip_objects;
182+
open l_cursor for l_sql using a_coverage_options.file_mappings,a_coverage_options.exclude_schema_expr,
183+
a_coverage_options.exclude_object_expr,l_excluded_objects,
184+
l_skip_objects;
175185
elsif a_coverage_options.include_schema_expr is not null or a_coverage_options.include_object_expr is not null then
176186
open l_cursor for l_sql using a_coverage_options.include_schema_expr,a_coverage_options.include_object_expr,
177187
a_coverage_options.exclude_schema_expr,a_coverage_options.exclude_object_expr,
178-
l_skip_objects;
188+
l_excluded_objects,l_skip_objects;
179189
elsif a_coverage_options.include_objects is not empty then
180-
open l_cursor for l_sql using a_coverage_options.include_objects,a_coverage_options.exclude_schema_expr,a_coverage_options.exclude_object_expr,l_skip_objects;
190+
open l_cursor for l_sql using a_coverage_options.include_objects,a_coverage_options.exclude_schema_expr,
191+
a_coverage_options.exclude_object_expr,l_excluded_objects,
192+
l_skip_objects;
181193
else
182-
open l_cursor for l_sql using a_coverage_options.schema_names,a_coverage_options.exclude_schema_expr,a_coverage_options.exclude_object_expr,l_skip_objects;
194+
open l_cursor for l_sql using a_coverage_options.schema_names,a_coverage_options.exclude_schema_expr,
195+
a_coverage_options.exclude_object_expr,l_excluded_objects,
196+
l_skip_objects;
183197
end if;
184198
return l_cursor;
185199
end;

0 commit comments

Comments
 (0)