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

Skip to content

Commit 6ff7f38

Browse files
committed
Peer review changes
1 parent 9296f38 commit 6ff7f38

5 files changed

Lines changed: 42 additions & 36 deletions

File tree

source/core/ut_suite_cache_manager.pkb

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,11 @@ create or replace package body ut_suite_cache_manager is
1919
/*
2020
* Private code
2121
*/
22-
23-
gc_get_bulk_cache_suite_sql constant varchar2(32767) :=
24-
q'[with
22+
cursor c_get_bulk_cache_suite(cp_suite_items in ut_suite_cache_rows) is
23+
with
2524
suite_items as (
2625
select /*+ cardinality(c 500) */ value(c) as obj
27-
from table(:suite_items) c),
26+
from table(cp_suite_items) c),
2827
suitepaths as (
2928
select distinct substr(c.obj.path,1,instr(c.obj.path,'.',-1)-1) as suitepath,
3029
c.obj.path as path,
@@ -65,9 +64,9 @@ create or replace package body ut_suite_cache_manager is
6564
) as obj
6665
from logical_suite_data s
6766
)
68-
select /*+ no_parallel */obj from suite_items
67+
select /*+ no_parallel */ obj from suite_items
6968
union all
70-
select /*+ no_parallel */ obj from logical_suites]';
69+
select /*+ no_parallel */ obj from logical_suites;
7170

7271
function get_missing_cache_objects(a_object_owner varchar2) return ut_varchar2_rows is
7372
l_result ut_varchar2_rows;
@@ -126,6 +125,9 @@ create or replace package body ut_suite_cache_manager is
126125

127126
Fourth SQL cover scenario where suitepath is populated with no filters
128127
*/
128+
129+
--TODO: Przenies w osobny with clause z nazwami jako opis.
130+
-- i with clause na tablice.
129131
function expand_paths(a_schema_paths ut_path_items) return ut_path_items is
130132
l_schema_paths ut_path_items:= ut_path_items();
131133
begin
@@ -310,26 +312,21 @@ create or replace package body ut_suite_cache_manager is
310312
a_tags ut_varchar2_rows := null
311313
) return ut_suite_cache_rows is
312314
l_results ut_suite_cache_rows := ut_suite_cache_rows();
313-
l_results2 ut_suite_cache_rows := ut_suite_cache_rows();
314315
l_suite_items ut_suite_cache_rows := ut_suite_cache_rows();
315316
l_schema_paths ut_path_items;
316317
l_tags ut_varchar2_rows := coalesce(a_tags,ut_varchar2_rows());
317-
l_sql varchar2(32767);
318318
begin
319319

320320
l_schema_paths := a_schema_paths;
321-
l_sql := gc_get_bulk_cache_suite_sql;
322321
l_suite_items := get_suite_items(a_schema_paths);
323322
if l_tags.count > 0 then
324323
l_suite_items := get_tags_suites(l_suite_items,l_tags);
325324
end if;
326-
ut_event_manager.trigger_event(ut_event_manager.gc_debug, ut_key_anyvalues().put('l_sql',l_sql) );
327-
328-
execute immediate l_sql
329-
bulk collect into l_results
330-
using l_suite_items;
325+
326+
open c_get_bulk_cache_suite(l_suite_items);
327+
fetch c_get_bulk_cache_suite bulk collect into l_results;
328+
close c_get_bulk_cache_suite;
331329

332-
sort_and_randomize_tests(l_results,a_random_seed);
333330
return l_results;
334331
end;
335332

source/core/ut_suite_cache_manager.pks

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,15 @@ create or replace package ut_suite_cache_manager authid definer is
4040
*/
4141
procedure remove_missing_objs_from_cache(a_schema_name varchar2);
4242

43+
/*
44+
* We will sort a suites in hierarchical structure.
45+
* Sorting from bottom to top so when we consolidate
46+
* we will go in proper order.
47+
*/
48+
procedure sort_and_randomize_tests(
49+
a_suite_rows in out ut_suite_cache_rows,
50+
a_random_seed positive := null);
51+
4352
/*
4453
* Retrieves suite items data from cache.
4554
* Returned data is not filtered by user access rights.

source/core/ut_suite_manager.pkb

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,8 @@ create or replace package body ut_suite_manager is
295295
end loop;
296296
close a_suite_data_cursor;
297297
end reconstruct_from_cache;
298-
298+
299+
--TODO: daj do public ut_suite_cache_rows i zmienic na SQL
299300
function get_filtered_cursor(
300301
a_unfiltered_rows in ut_suite_cache_rows,
301302
a_skip_all_objects boolean := false
@@ -306,26 +307,21 @@ create or replace package body ut_suite_manager is
306307
if ut_metadata.user_has_execute_any_proc() or a_skip_all_objects then
307308
l_result := a_unfiltered_rows;
308309
else
309-
for i in (
310-
select /*+ no_parallel */ c.* from table(a_unfiltered_rows) c
311-
where sys_context( 'userenv', 'current_user' ) = upper(c.object_owner)
312-
union all
313-
select /*+ no_parallel */ c.* from table(a_unfiltered_rows) c
314-
where sys_context( 'userenv', 'current_user' ) != upper(c.object_owner)
315-
and ( exists
316-
( select 1
317-
from all_objects a
318-
where a.object_name = c.object_name
319-
and a.owner = c.object_owner
320-
and a.object_type = 'PACKAGE'
321-
)
322-
or c.self_type = 'UT_LOGICAL_SUITE'))
323-
loop
324-
l_result.extend;
325-
l_result(l_result.last) := ut_suite_cache_row(i.id,i.self_type,i.path,i.object_owner,i.object_name,i.name,i.line_no,i.parse_time,
326-
i.description,i.rollback_type,i.disabled_flag,i.disabled_reason,i.warnings,i.before_all_list,i.after_all_list,i.before_each_list,
327-
i.before_test_list,i.after_each_list,i.after_test_list,i.expected_error_codes,i.tags,i.item);
328-
end loop;
310+
select obj bulk collect into l_result
311+
from (
312+
select /*+ no_parallel */ value(c) as obj from table(a_unfiltered_rows) c
313+
where sys_context( 'userenv', 'current_user' ) = upper(c.object_owner)
314+
union all
315+
select /*+ no_parallel */ value(c) as obj from table(a_unfiltered_rows) c
316+
where sys_context( 'userenv', 'current_user' ) != upper(c.object_owner)
317+
and ( exists
318+
( select 1
319+
from all_objects a
320+
where a.object_name = c.object_name
321+
and a.owner = c.object_owner
322+
and a.object_type = 'PACKAGE'
323+
)
324+
or c.self_type = 'UT_LOGICAL_SUITE'));
329325
end if;
330326
return l_result;
331327
end;
@@ -373,6 +369,8 @@ create or replace package body ut_suite_manager is
373369
l_filtered_rows := get_filtered_cursor(l_unfiltered_rows,a_skip_all_objects);
374370
reconcile_paths_and_suites(a_schema_paths,l_filtered_rows);
375371

372+
ut_suite_cache_manager.sort_and_randomize_tests(l_filtered_rows,a_random_seed);
373+
376374
open l_result for
377375
select * from table(l_filtered_rows);
378376
return l_result;

source/core/ut_suite_manager.pks

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ create or replace package ut_suite_manager authid current_user is
3939
* @return array containing root suites-ready to be executed
4040
*
4141
*/
42+
--TODO:Zerknij czy mozna wywalic
4243
function configure_execution_by_path(a_paths ut_varchar2_list, a_random_seed positive := null) return ut_suite_items;
4344

4445
/**

source/create_grants.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ grant execute on &&ut3_owner..ut_file_mapping to &ut3_user;
6060
grant execute on &&ut3_owner..ut_file_mapper to &ut3_user;
6161
grant execute on &&ut3_owner..ut_suite_items_info to &ut3_user;
6262
grant execute on &&ut3_owner..ut_suite_item_info to &ut3_user;
63+
grant execute on &&ut3_owner..ut_suite_cache_rows to &ut3_user;
6364
grant execute on &&ut3_owner..ut_run_info to &ut3_user;
6465
grant execute on &&ut3_owner..ut_coverage_options to &ut3_user;
6566

0 commit comments

Comments
 (0)