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
34 commits
Select commit Hold shift + click to select a range
e41d6f9
Interim commit with lots of dirty code - got to a place where I get t…
jgebal Oct 30, 2018
f475b7c
Added `suite_cache`.
jgebal Nov 2, 2018
4dc48e6
Interim commit - performance check on Travis.
jgebal Nov 4, 2018
1611e09
Interim commit some fixes to old tests, examples and code itself.
jgebal Nov 4, 2018
15163a8
Resolved issue with sorting of nested-tables.
jgebal Nov 4, 2018
1b14bb5
Fixing re-enabled test.
jgebal Nov 4, 2018
3bc8da5
Adding missing items to uninstall.
jgebal Nov 4, 2018
8911f97
Small improvements and cleanup.
jgebal Nov 5, 2018
a1f6b34
Removing duplicate with block.
jgebal Nov 6, 2018
59f7738
Adding cache cleanup and "intelligent" join to all_source, only when …
jgebal Nov 11, 2018
cb9cf97
Resolving some sonar violations.
jgebal Nov 11, 2018
8779025
Moving away from full outer join.
jgebal Nov 11, 2018
b3e98be
Reorganizing code a bit.
jgebal Nov 11, 2018
64dfb41
Output buffer&reporters performance improvements
jgebal Nov 12, 2018
9ea805b
Increased fetch size for coverage sources tmp seeding.
jgebal Nov 12, 2018
248bf8c
Small refactoring.
jgebal Nov 13, 2018
8fc2ea6
Further optimizations to suite parsing.
jgebal Nov 15, 2018
3543e3d
Disabled `PLSQL_OPTIMIZE_LEVEL=0` for testing
jgebal Nov 15, 2018
23c0557
Fixed formal parameter names
jgebal Nov 15, 2018
f7f6811
Revert "Disabled `PLSQL_OPTIMIZE_LEVEL=0` for testing"
jgebal Nov 15, 2018
d002d18
Refactored procedure `get_unit_test_info` to return more relevant inf…
jgebal Nov 16, 2018
e1f1eec
Renamed `get_unit_test_info` to `get_suites_info` - the latter one wa…
jgebal Nov 16, 2018
d8d251f
Improved automation of `refresh_sources.sh`
jgebal Nov 16, 2018
eb3df21
Fixing failing test.
jgebal Nov 16, 2018
d211348
Added control over rollback behavior in `ut_runner.run`
jgebal Nov 17, 2018
f342195
Reverting rollback changes - they should go as a separate PR.
jgebal Nov 17, 2018
eeae79b
Added documentation for new functionality.
jgebal Nov 17, 2018
74ec9a1
Removed unused code.
jgebal Nov 18, 2018
44d61d9
Recovering exception handlers as they are needed for handling invalid…
jgebal Nov 18, 2018
360a889
Moved some of old tests into new tests.
jgebal Nov 18, 2018
0ee3ce2
Added missing endcontext in `test_ut_test`
jgebal Nov 18, 2018
48aa338
Removed unused constants.
jgebal Nov 18, 2018
b33aaae
Added additional test for display of parser warnings.
jgebal Nov 18, 2018
e8ea644
Merge branch 'develop' into feature/suite_query_api
jgebal Nov 18, 2018
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
Small refactoring.
Adding new function to return list of suites and tests.
  • Loading branch information
jgebal committed Nov 13, 2018
commit 248bf8c7c4f50195ef33865a657e7bf3904fa596
215 changes: 162 additions & 53 deletions source/core/ut_suite_manager.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ create or replace package body ut_suite_manager is
return l_results;
end;

procedure copy_list_reverse_order(
procedure reverse_list_order(
a_list in out nocopy ut_suite_items
) is
l_start_idx pls_integer;
Expand Down Expand Up @@ -277,9 +277,14 @@ create or replace package body ut_suite_manager is
end loop;
exit when l_rows.count < c_bulk_limit;
end loop;
copy_list_reverse_order( a_suites );

reverse_list_order( a_suites );

for i in 1 .. a_suites.count loop
a_suites( i ).set_rollback_type( a_suites( i ).get_rollback_type );
end loop;
close a_suite_data_cursor;
end;
end reconstruct_from_cache;

function get_missing_objects(a_object_owner varchar2) return ut_varchar2_rows is
l_rows sys_refcursor;
Expand Down Expand Up @@ -338,7 +343,7 @@ create or replace package body ut_suite_manager is
( select 1
from all_objects a
where a.object_name = c.object_name
and a.object_owner = ']'||upper(a_object_owner)||q'['
and a.owner = ']'||upper(a_object_owner)||q'['
and a.owner = c.object_owner
and a.object_type = 'PACKAGE'
)]' end ||q'[
Expand Down Expand Up @@ -417,44 +422,91 @@ create or replace package body ut_suite_manager is
return l_result;
end;

function build_schema_suites(
a_owner_name varchar2,
a_path varchar2 := null,
a_object_name varchar2 := null,
a_procedure_name varchar2 := null
) return ut_suite_items is
function can_skip_all_objects_scan(
a_owner_name varchar2
) return boolean is
begin
return sys_context( 'userenv', 'current_schema' ) = a_owner_name or ut_metadata.is_object_visible( ut_utils.ut_owner ||'.ut_utils' );
end;

procedure build_and_cache_suites(
a_owner_name varchar2,
a_annotated_objects sys_refcursor
) is
l_annotated_objects ut_annotated_objects;
l_suite_items ut_suite_items;
begin
loop
fetch a_annotated_objects bulk collect into l_annotated_objects limit 10;

for i in 1 .. l_annotated_objects.count loop
ut_suite_builder.create_suite_item_list( l_annotated_objects( i ), l_suite_items );
ut_suite_cache_manager.save_object_cache(
a_owner_name,
l_annotated_objects( i ).object_name,
l_annotated_objects( i ).parse_time,
l_suite_items
);
end loop;
exit when a_annotated_objects%notfound;
end loop;
close a_annotated_objects;

end;

procedure refresh_cache(
a_owner_name varchar2,
a_annotations_cursor sys_refcursor := null
) is
l_annotations_cursor sys_refcursor;
l_suite_cache_time timestamp;
l_skip_all_objects_scan boolean := false;
begin
l_suite_cache_time := ut_suite_cache_manager.get_schema_parse_time(a_owner_name);
open l_annotations_cursor for
q'[select value(x)
from table(
]' || ut_utils.ut_owner || q'[.ut_annotation_manager.get_annotated_objects(:a_owner_name, 'PACKAGE', :a_suite_cache_parse_time)
)x ]'
using a_owner_name, l_suite_cache_time;

-- if current user is the onwer or current user has execute any procedure privilege
if sys_context('userenv','current_schema') = a_owner_name
or ut_metadata.is_object_visible('ut3.ut_utils')
then
l_skip_all_objects_scan := true;
if a_annotations_cursor is not null then
l_annotations_cursor := a_annotations_cursor;
else
open l_annotations_cursor for
q'[select value(x)
from table(
]' || ut_utils.ut_owner || q'[.ut_annotation_manager.get_annotated_objects(
:a_owner_name, 'PACKAGE', :a_suite_cache_parse_time
)
)x ]'
using a_owner_name, l_suite_cache_time;
end if;
if l_skip_all_objects_scan or ut_metadata.is_object_visible('dba_objects') then

build_and_cache_suites(a_owner_name, l_annotations_cursor);

if can_skip_all_objects_scan(a_owner_name) or ut_metadata.is_object_visible( 'dba_objects') then
ut_suite_cache_manager.remove_from_cache( a_owner_name, get_missing_objects(a_owner_name) );
end if;

return build_suites_from_annotations(
a_owner_name,
l_annotations_cursor,
a_path,
a_object_name,
a_procedure_name,
l_skip_all_objects_scan
);
end;

function get_suites_for_path(
a_owner_name varchar2,
a_path varchar2 := null,
a_object_name varchar2 := null,
a_procedure_name varchar2 := null
) return ut_suite_items is
l_suites ut_suite_items;
begin
refresh_cache(a_owner_name);

reconstruct_from_cache(
l_suites,
get_cached_suite_data(
a_owner_name,
a_path,
a_object_name,
a_procedure_name,
can_skip_all_objects_scan(a_owner_name)
)
);
return l_suites;

end get_suites_for_path;

-----------------------------------------------
-----------------------------------------------
------------- Public definitions -------------
Expand All @@ -468,24 +520,8 @@ create or replace package body ut_suite_manager is
a_skip_all_objects boolean := false
) return ut_suite_items is
l_suites ut_suite_items;
l_annotated_objects ut_annotated_objects;
l_suite_items ut_suite_items;
begin
loop
fetch a_annotated_objects bulk collect into l_annotated_objects limit 10;

for i in 1 .. l_annotated_objects.count loop
ut_suite_builder.create_suite_item_list( l_annotated_objects( i ), l_suite_items );
ut_suite_cache_manager.save_object_cache(
a_owner_name,
l_annotated_objects( i ).object_name,
l_annotated_objects( i ).parse_time,
l_suite_items
);
end loop;
exit when a_annotated_objects%notfound;
end loop;
close a_annotated_objects;
build_and_cache_suites(a_owner_name, a_annotated_objects);

reconstruct_from_cache(
l_suites,
Expand All @@ -497,9 +533,6 @@ create or replace package body ut_suite_manager is
a_skip_all_objects
)
);
for i in 1 .. l_suites.count loop
l_suites( i ).set_rollback_type( l_suites( i ).get_rollback_type );
end loop;
return l_suites;
end;

Expand Down Expand Up @@ -566,7 +599,7 @@ create or replace package body ut_suite_manager is
l_path_items := l_schema_paths(l_schema);
for i in 1 .. l_path_items.count loop
l_path_item := l_path_items(i);
l_suites := build_schema_suites(
l_suites := get_suites_for_path(
upper(l_schema),
l_path_item.suite_path,
l_path_item.object_name,
Expand Down Expand Up @@ -599,5 +632,81 @@ create or replace package body ut_suite_manager is
return l_objects_to_run;
end configure_execution_by_path;

function get_suites_info(a_owner_name varchar2) return tt_suite_items pipelined is
l_cursor sys_refcursor;
l_ut_owner varchar2(250) := ut_utils.ut_owner;
c_bulk_limit constant integer := 100;
l_results tt_suite_items;
begin
refresh_cache(a_owner_name);

open l_cursor for
q'[with
suite_items as (
select /*+ cardinality(c 100) */ c.*
from ]'||l_ut_owner||q'[.ut_suite_cache c
where 1 = 1 ]'||case when can_skip_all_objects_scan(a_owner_name) then q'[
and exists
( select 1
from all_objects a
where a.object_name = c.object_name
and a.owner = ']'||upper(a_owner_name)||q'['
and a.owner = c.object_owner
and a.object_type = 'PACKAGE'
)]' end ||q'[
and c.object_owner = ']'||upper(a_owner_name)||q'['
),
suitepaths as (
select distinct
substr(path,1,instr(path,'.',-1)-1) as suitepath,
path,
object_owner
from suite_items
where self_type = 'UT_SUITE'
),
gen as (
select rownum as pos
from xmltable('1 to 20')
),
suitepath_part AS (
select distinct
substr(b.suitepath, 1, instr(b.suitepath || '.', '.', 1, g.pos) -1) as path,
object_owner
from suitepaths b
join gen g
on g.pos <= regexp_count(b.suitepath, '\w+')
),
logical_suites as (
select 'UT_LOGICAL_SUITE' as item_type,
p.path, p.object_owner,
upper( substr(p.path, instr( p.path, '.', -1 ) + 1 ) ) as object_name
from suitepath_part p
where p.path
not in (select s.path from suitepaths s)
),
items as (
select object_owner, object_name, name as item_name,
description as item_description, self_type as item_type, line_no as item_line_no,
path, disabled_flag
from suite_items
union all
select object_owner, object_name, object_name as item_name,
null as item_description, item_type, null as item_line_no,
s.path, 0 as disabled_flag
from logical_suites s
)
select c.*
from items c]';
loop
fetch l_cursor bulk collect into l_results limit c_bulk_limit;
for i in 1 .. l_results.count loop
pipe row (l_results(i));
end loop;
exit when l_cursor%notfound;
end loop;
close l_cursor;

end;

end ut_suite_manager;
/
15 changes: 15 additions & 0 deletions source/core/ut_suite_manager.pks
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,21 @@ create or replace package ut_suite_manager authid current_user is
a_skip_all_objects boolean := false
) return ut_suite_items;

type t_suite_item_rec is record (
object_owner varchar2(250),
object_name varchar2(250),
item_name varchar2(250),
item_description varchar2(250),
item_type varchar2(250),
item_line_no varchar2(250),
path varchar2(4000),
disabled_flag integer
);

type tt_suite_items is table of t_suite_item_rec;

function get_suites_info(a_owner_name varchar2) return tt_suite_items pipelined;


end ut_suite_manager;
/