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

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
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
Added ability to publish coverage generated by test jobs running utPL…
…SQL with coverage into main testing session coverage.
  • Loading branch information
jgebal committed Feb 26, 2022
commit 4ab0f5875d3da51a8fdf17964f9018b71d04845b
2 changes: 1 addition & 1 deletion source/api/ut_runner.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ create or replace package body ut_runner is
l_run := ut_run(
a_run_paths => l_paths,
a_coverage_options => ut_coverage_options(
coverage_run_id => sys_guid(),
coverage_run_id => ut_coverage.get_coverage_run_id(),
schema_names => l_coverage_schema_names,
exclude_objects => ut_utils.convert_collection(a_exclude_objects),
include_objects => ut_utils.convert_collection(a_include_objects),
Expand Down
13 changes: 11 additions & 2 deletions source/core/coverage/ut_coverage.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ create or replace package body ut_coverage is

g_develop_mode boolean not null := false;
g_is_started boolean not null := false;
g_coverage_run_id raw(32);

procedure set_develop_mode(a_develop_mode in boolean) is
begin
Expand Down Expand Up @@ -231,6 +232,7 @@ create or replace package body ut_coverage is
l_block_coverage_id integer;
begin
if not is_develop_mode() and not g_is_started then
g_coverage_run_id := a_coverage_run_id;
l_line_coverage_id := ut_coverage_helper_profiler.coverage_start( l_run_comment );
l_block_coverage_id := ut_coverage_helper_block.coverage_start( l_run_comment );
g_is_started := true;
Expand All @@ -256,7 +258,6 @@ create or replace package body ut_coverage is
g_is_started := false;
ut_coverage_helper_block.coverage_stop();
ut_coverage_helper_profiler.coverage_stop();
g_is_started := false;
end if;
end;

Expand Down Expand Up @@ -314,7 +315,15 @@ create or replace package body ut_coverage is
$end

return l_result_profiler_enrich;
end get_coverage_data;
end get_coverage_data;

function get_coverage_run_id return raw is
begin
if g_coverage_run_id is null then
g_coverage_run_id := sys_guid();
end if;
return g_coverage_run_id;
end;

end;
/
2 changes: 2 additions & 0 deletions source/core/coverage/ut_coverage.pks
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,7 @@ create or replace package ut_coverage authid current_user is

function get_coverage_data(a_coverage_options ut_coverage_options) return t_coverage;

function get_coverage_run_id return raw;

end;
/
67 changes: 64 additions & 3 deletions test/ut3_tester_helper/coverage_helper.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -381,14 +381,75 @@ create or replace package body coverage_helper is
return l_result_clob;
end;

procedure copy_coverage_data_to_ut3(a_coverage_run_id raw) is
pragma autonomous_transaction;
l_current_coverage_run_id raw(32) := hextoraw(sys_context('UT3_INFO','COVERAGE_RUN_ID'));
begin
insert into ut3.ut_coverage_runs(coverage_run_id, line_coverage_id, block_coverage_id)
select l_current_coverage_run_id, -line_coverage_id, -block_coverage_id
from ut3_develop.ut_coverage_runs
where coverage_run_id = a_coverage_run_id;

insert into ut3.plsql_profiler_runs(runid, related_run, run_owner, run_date, run_comment, run_total_time, run_system_info, run_comment1, spare1)
select -runid, related_run, run_owner, run_date, run_comment, run_total_time, run_system_info, run_comment1, spare1
from ut3_develop.plsql_profiler_runs c
join ut3_develop.ut_coverage_runs r
on r.line_coverage_id = c.runid
where r.coverage_run_id = a_coverage_run_id;

insert into ut3.plsql_profiler_units(runid, unit_number, unit_type, unit_owner, unit_name, unit_timestamp, total_time, spare1, spare2)
select -runid, unit_number, unit_type, unit_owner, unit_name, unit_timestamp, total_time, spare1, spare2
from ut3_develop.plsql_profiler_units c
join ut3_develop.ut_coverage_runs r
on r.line_coverage_id = c.runid
where r.coverage_run_id = a_coverage_run_id;

insert into ut3.plsql_profiler_data(runid, unit_number, line#, total_occur, total_time, min_time, max_time, spare1, spare2, spare3, spare4)
select -runid, unit_number, line#, total_occur, total_time, min_time, max_time, spare1, spare2, spare3, spare4
from ut3_develop.plsql_profiler_data c
join ut3_develop.ut_coverage_runs r
on r.line_coverage_id = c.runid
where r.coverage_run_id = a_coverage_run_id;

insert into ut3.dbmspcc_runs(run_id, run_comment, run_owner, run_timestamp)
select -run_id, run_comment, run_owner, run_timestamp
from ut3_develop.dbmspcc_runs c
join ut3_develop.ut_coverage_runs r
on r.block_coverage_id = c.run_id
where r.coverage_run_id = a_coverage_run_id;

insert into ut3.dbmspcc_units(run_id, object_id, owner, name, type, last_ddl_time)
select -run_id, object_id, owner, name, type, last_ddl_time
from ut3_develop.dbmspcc_units c
join ut3_develop.ut_coverage_runs r
on r.block_coverage_id = c.run_id
where r.coverage_run_id = a_coverage_run_id;

insert into ut3.dbmspcc_blocks(run_id, object_id, block, line, col, covered, not_feasible)
select -run_id, object_id, block, line, col, covered, not_feasible
from ut3_develop.dbmspcc_blocks c
join ut3_develop.ut_coverage_runs r
on r.block_coverage_id = c.run_id
where r.coverage_run_id = a_coverage_run_id;

commit;
end;

function run_tests_as_job( a_run_command varchar2 ) return clob is
l_plsql_block varchar2(32767);
l_result_clob clob;
pragma autonomous_transaction;
l_coverage_id raw(32) := sys_guid();
begin
l_plsql_block := 'begin insert into test_results select * from table( {a_run_command} ); commit; end;';
l_plsql_block := q'[
begin
ut3_develop.ut_runner.coverage_start(']'||rawtohex(l_coverage_id)||q'[');
insert into test_results select * from table( {a_run_command} );
commit;
end;]';
l_plsql_block := replace(l_plsql_block,'{a_run_command}',a_run_command);
return run_code_as_job( l_plsql_block );
l_result_clob := run_code_as_job( l_plsql_block );
copy_coverage_data_to_ut3(l_coverage_id);
return l_result_clob;
end;

procedure create_dup_object_name is
Expand Down