Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
0daab33
Checkpoint
lwasylow Mar 28, 2023
adbc76e
Address too long identified in 11g.
lwasylow Mar 28, 2023
1478b0d
Adding validation for tag expression
lwasylow Mar 29, 2023
b5ad747
Comment out to see why its failing.
lwasylow Mar 29, 2023
06cb054
Revert "Comment out to see why its failing."
lwasylow Mar 29, 2023
e87d39f
Adding validate function, with no calls
lwasylow Mar 29, 2023
97537de
Remove a & from text
lwasylow Mar 29, 2023
2a0f99a
Extra changes and added tests
lwasylow Mar 31, 2023
5b46140
Merge branch 'develop' of https://github.com/utPLSQL/utPLSQL into fea…
lwasylow Mar 31, 2023
b30688c
Address sonar coverage issues.
lwasylow Apr 1, 2023
0c41a0f
Adding tests covering exception of invalid tags
lwasylow Apr 1, 2023
543685d
Removing that , we will not implement that, there is no benefit at th…
lwasylow Apr 1, 2023
0d3cfa1
Removing force
lwasylow Apr 1, 2023
20e3177
Changing to use Dijkstra algorithm to parse infix notation into postf…
lwasylow Apr 10, 2023
f51cc99
Missing slash at end of type
lwasylow Apr 10, 2023
4b8e2ab
Cleanup.
lwasylow Apr 10, 2023
84e8684
Update tests after removed function
lwasylow Apr 10, 2023
2e7a766
Tidy up tests
lwasylow Apr 10, 2023
cbdf83a
Added ut_stack to uninstall
lwasylow Apr 10, 2023
436eb5b
Addressing test failures and sonar smells
lwasylow Apr 11, 2023
3d77514
Update name
lwasylow Apr 11, 2023
bf6959f
Update tests and code
lwasylow Apr 11, 2023
d8233ff
fixing typo in docs
lwasylow Apr 12, 2023
bd860f6
Removed unused variable
lwasylow Apr 12, 2023
313d5e9
Stage 1 Resolving PR comments
lwasylow Apr 13, 2023
02a071c
Separate tag logic.
lwasylow Apr 13, 2023
b8b66ee
Fix uninstall
lwasylow Apr 14, 2023
077fdb1
Various PR fixe
lwasylow Apr 14, 2023
01e5364
Update tests and code
lwasylow Apr 15, 2023
dc0b4a6
Addressing changes via PR review.
lwasylow Apr 18, 2023
ef1c02b
Update docs
lwasylow Apr 18, 2023
1551ea5
Adding any and none
lwasylow Apr 25, 2023
9dee7e0
Update docs
lwasylow Apr 26, 2023
beb9a3a
Resolving PR
lwasylow Apr 27, 2023
46ffe73
Update note
lwasylow Apr 27, 2023
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
Separate tag logic.
  • Loading branch information
lwasylow committed Apr 13, 2023
commit 02a071cb43799b8b68aa12cddb8cba757e6654a2
143 changes: 14 additions & 129 deletions source/core/ut_suite_cache_manager.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -220,121 +220,7 @@ create or replace package body ut_suite_cache_manager is
and c.name = nvl(upper(sp.procedure_name),c.name)))) where r_num =1;
return l_suite_items;
end;

Comment thread
lwasylow marked this conversation as resolved.
/*
To support a legact tag notation
, = OR
- = NOT
we will perform a replace of that characters into
new notation.
| = OR
& = AND
! = NOT
*/
function replace_legacy_tag_notation(a_tags varchar2
) return varchar2 is
l_tags ut_varchar2_list := ut_utils.string_to_table(a_tags,',');
l_tags_include varchar2(4000);
l_tags_exclude varchar2(4000);
l_return_tag varchar2(4000);
begin
if instr(a_tags,',') > 0 or instr(a_tags,'-') > 0 then

select '('||listagg( t.column_value,'|')
within group( order by column_value)||')'
into l_tags_include
from table(l_tags) t
where t.column_value not like '-%';

select '('||listagg( replace(t.column_value,'-','!'),' & ')
within group( order by column_value)||')'
into l_tags_exclude
from table(l_tags) t
where t.column_value like '-%';


l_return_tag:=
case
when l_tags_include <> '()' and l_tags_exclude <> '()'
then l_tags_include || ' & ' || l_tags_exclude
when l_tags_include <> '()'
then l_tags_include
when l_tags_exclude <> '()'
then l_tags_exclude
end;
else
l_return_tag := a_tags;
end if;
return l_return_tag;
end;

function create_where_filter(a_tags varchar2
) return varchar2 is
l_tags varchar2(4000);
begin
l_tags := replace(replace_legacy_tag_notation(a_tags),' ');
l_tags := ut_utils.conv_postfix_to_infix_sql(ut_utils.shunt_logical_expression(l_tags));
l_tags := replace(l_tags, '|',' or ');
l_tags := replace(l_tags ,'&',' and ');
l_tags := replace(l_tags ,'!','not');
return l_tags;
end;

/*
Having a base set of suites we will do a further filter down if there are
any tags defined.
*/
function get_tags_suites (
a_suite_items ut_suite_cache_rows,
a_tags varchar2
) return ut_suite_cache_rows is
l_suite_tags ut_suite_cache_rows := ut_suite_cache_rows();
l_sql varchar2(32000);
l_tags varchar2(4000):= create_where_filter(a_tags);
begin
l_sql :=
q'[
with
suites_mv as (
select c.id,value(c) as obj,c.path as path,c.self_type,c.object_owner,c.tags
from table(:suite_items) c
),
suites_matching_expr as (
select c.id,c.path as path,c.self_type,c.object_owner,c.tags
from suites_mv c
where c.self_type in ('UT_SUITE','UT_CONTEXT')
and ]'||l_tags||q'[
),
tests_matching_expr as (
select c.id,c.path as path,c.self_type,c.object_owner,c.tags
from suites_mv c where c.self_type in ('UT_TEST')
and ]'||l_tags||q'[
),
tests_with_tags_inh_from_suite as (
select c.id,c.self_type,c.path,c.tags multiset union distinct t.tags tags,c.object_owner
from suites_mv c join suites_matching_expr t
on (c.path||'.' like t.path || '.%' /*all descendants and self*/ and c.object_owner = t.object_owner)
),
tests_with_tags_prom_to_suite as (
select c.id,c.self_type,c.path,c.tags multiset union distinct t.tags tags,c.object_owner
from suites_mv c join tests_matching_expr t
on (t.path||'.' like c.path || '.%' /*all ancestors and self*/ and c.object_owner = t.object_owner)
)
select obj from suites_mv c,
(select id,row_number() over (partition by id order by id) r_num from
(select id
from tests_with_tags_prom_to_suite tst
where ]'||l_tags||q'[
union all
select id from tests_with_tags_inh_from_suite tst
where ]'||l_tags||q'[
)
) t where c.id = t.id and r_num = 1 ]';

execute immediate l_sql bulk collect into l_suite_tags using a_suite_items;
return l_suite_tags;
end;

/*
We will sort a suites in hierarchical structure.
Sorting from bottom to top so when we consolidate
Expand Down Expand Up @@ -387,30 +273,29 @@ with
end;

function get_cached_suite_rows(
a_schema_paths ut_path_items,
a_random_seed positive := null,
a_tags varchar2 := null
a_suites_filtered ut_suite_cache_rows
) return ut_suite_cache_rows is
l_results ut_suite_cache_rows := ut_suite_cache_rows();
l_suite_items ut_suite_cache_rows := ut_suite_cache_rows();
l_schema_paths ut_path_items;
l_tags varchar2(4000) := a_tags;
begin

l_schema_paths := a_schema_paths;
l_suite_items := get_suite_items(a_schema_paths);
if length(l_tags) > 0 then
l_suite_items := get_tags_suites(l_suite_items,l_tags);
end if;

open c_get_bulk_cache_suite(l_suite_items);
open c_get_bulk_cache_suite(a_suites_filtered);
fetch c_get_bulk_cache_suite bulk collect into l_results;
close c_get_bulk_cache_suite;

return l_results;
end;


function get_cached_suites(
Comment thread
lwasylow marked this conversation as resolved.
Outdated
a_schema_paths ut_path_items,
a_random_seed positive := null
) return ut_suite_cache_rows is
l_suite_items ut_suite_cache_rows := ut_suite_cache_rows();
l_schema_paths ut_path_items;
begin
l_schema_paths := a_schema_paths;
l_suite_items := get_suite_items(a_schema_paths);
return l_suite_items;
end;

function get_schema_parse_time(a_schema_name varchar2) return timestamp result_cache is
l_cache_parse_time timestamp;
Expand Down Expand Up @@ -558,7 +443,7 @@ with
a_schema_paths ut_path_items
) return ut_suite_cache_rows is
begin
return get_cached_suite_rows( a_schema_paths );
return get_cached_suite_rows(get_cached_suites( a_schema_paths ));
Comment thread
lwasylow marked this conversation as resolved.
Outdated
end;

function get_suite_items_info(
Expand Down
9 changes: 6 additions & 3 deletions source/core/ut_suite_cache_manager.pks
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,14 @@ create or replace package ut_suite_cache_manager authid definer is
* Not to be used publicly. Used internally for building suites at runtime.
*/
function get_cached_suite_rows(
a_suites_filtered ut_suite_cache_rows
) return ut_suite_cache_rows;

function get_cached_suites(
Comment thread
lwasylow marked this conversation as resolved.
Outdated
a_schema_paths ut_path_items,
a_random_seed positive := null,
a_tags varchar2 := null
a_random_seed positive := null
Comment thread
lwasylow marked this conversation as resolved.
Outdated
) return ut_suite_cache_rows;

function get_schema_paths(a_paths in ut_varchar2_list) return ut_path_items;

/*
Expand Down
15 changes: 8 additions & 7 deletions source/core/ut_suite_manager.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -355,17 +355,18 @@ create or replace package body ut_suite_manager is
a_tags varchar2 := null,
a_skip_all_objects boolean := false
) return t_cached_suites_cursor is
l_unfiltered_rows ut_suite_cache_rows;
l_filtered_rows ut_suite_cache_rows;
l_result t_cached_suites_cursor;
l_unfiltered_rows ut_suite_cache_rows;
l_tag_filter_applied ut_suite_cache_rows;
l_filtered_rows ut_suite_cache_rows;
l_result t_cached_suites_cursor;
begin
l_unfiltered_rows := ut_suite_cache_manager.get_cached_suite_rows(
l_unfiltered_rows := ut_suite_cache_manager.get_cached_suites(
a_schema_paths,
a_random_seed,
a_tags
a_random_seed
);

l_filtered_rows := get_filtered_cursor(l_unfiltered_rows,a_skip_all_objects);
l_tag_filter_applied := ut_suite_tag_filter.apply(l_unfiltered_rows,a_tags);
l_filtered_rows := get_filtered_cursor(ut_suite_cache_manager.get_cached_suite_rows(l_tag_filter_applied),a_skip_all_objects);
reconcile_paths_and_suites(a_schema_paths,l_filtered_rows);

ut_suite_cache_manager.sort_and_randomize_tests(l_filtered_rows,a_random_seed);
Expand Down
Loading