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
Resolved issue with sorting of nested-tables.
Added `seq_no`, numbering before storage and sorting after retrieval.
  • Loading branch information
jgebal committed Nov 4, 2018
commit 15163a82f610bd5198ec0541105818501e82c44d
4 changes: 4 additions & 0 deletions source/core/types/ut_executable.tps
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ create or replace type ut_executable under ut_event_item(
error_backtrace varchar2(4000),
error_stack varchar2(4000),
serveroutput clob,
/**
* Used for ordering of executables, as Oracle doesn not guarantee ordering of items in a nested table.
*/
seq_no integer,
constructor function ut_executable( self in out nocopy ut_executable, a_owner varchar2, a_package varchar2, a_procedure_name varchar2, a_executable_type varchar2) return self as result,
member function form_name return varchar2,
member procedure do_execute(self in out nocopy ut_executable, a_item in out nocopy ut_suite_item),
Expand Down
96 changes: 55 additions & 41 deletions source/core/ut_suite_builder.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,6 @@ create or replace package body ut_suite_builder is

type tt_executables is table of ut_executables index by t_annotation_position;

type tt_tests is table of ut_test index by t_annotation_position;


type t_annotation is record(
name t_annotation_name,
text t_annotation_text,
Expand Down Expand Up @@ -315,35 +312,46 @@ create or replace package body ut_suite_builder is
end loop;
end;

function convert_list(
a_list tt_executables
procedure set_seq_no(
a_list in out nocopy ut_executables
) is
begin
if a_list is not null then
for i in 1 .. a_list.count loop
a_list(i).seq_no := i;
end loop;
end if;
end;

function sort_by_seq_no(
a_list ut_executables
) return ut_executables is
l_result ut_executables := ut_executables();
l_pos t_annotation_position := a_list.first;
begin
while l_pos is not null loop
for i in 1 .. a_list(l_pos).count loop
l_result.extend;
l_result(l_result.last) := a_list(l_pos)(i);
end loop;
l_pos := a_list.next(l_pos);
l_results ut_executables := ut_executables();
begin
if a_list is not null then
l_results.extend(a_list.count);
for i in 1 .. a_list.count loop
l_results(a_list(i).seq_no) := a_list(i);
end loop;
return l_result;
end;
end if;
return l_results;
end;

function convert_list(
a_list tt_tests
) return ut_suite_items is
l_result ut_suite_items := ut_suite_items();
a_list tt_executables
) return ut_executables is
l_result ut_executables := ut_executables();
l_pos t_annotation_position := a_list.first;
begin
while l_pos is not null loop
begin
while l_pos is not null loop
for i in 1 .. a_list(l_pos).count loop
l_result.extend;
l_result(l_result.last) := a_list(l_pos);
l_pos := a_list.next(l_pos);
l_result(l_result.last) := a_list(l_pos)(i);
end loop;
return l_result;
end;
l_pos := a_list.next(l_pos);
end loop;
return l_result;
end;

function add_executables(
a_owner t_object_name,
Expand Down Expand Up @@ -492,11 +500,13 @@ create or replace package body ut_suite_builder is
l_test.before_test_list := convert_list(
add_executables( l_test.object_owner, l_test.object_name, l_proc_annotations( gc_beforetest ), gc_beforetest )
);
set_seq_no(l_test.before_test_list);
end if;
if l_proc_annotations.exists( gc_aftertest) then
l_test.after_test_list := convert_list(
add_executables( l_test.object_owner, l_test.object_name, l_proc_annotations( gc_aftertest ), gc_aftertest )
);
set_seq_no(l_test.after_test_list);
end if;
if l_proc_annotations.exists( gc_throws) then
add_to_throws_numbers_list(a_suite, l_test.expected_error_codes, a_procedure_name, l_proc_annotations( gc_throws));
Expand All @@ -519,8 +529,10 @@ create or replace package body ut_suite_builder is
for i in 1 .. a_suite.items.count loop
if a_suite.items(i) is of (ut_test) then
l_test := treat( a_suite.items(i) as ut_test);
l_test.before_each_list := coalesce(convert_list(a_before_each_list),ut_executables()) multiset union all l_test.before_each_list;
l_test.after_each_list := l_test.after_each_list multiset union all coalesce(convert_list(a_after_each_list),ut_executables());
l_test.before_each_list := convert_list(a_before_each_list) multiset union all l_test.before_each_list;
set_seq_no(l_test.before_each_list);
l_test.after_each_list := l_test.after_each_list multiset union all convert_list(a_after_each_list);
set_seq_no(l_test.after_each_list);
a_suite.items(i) := l_test;
elsif a_suite.items(i) is of (ut_logical_suite) then
l_context := treat(a_suite.items(i) as ut_logical_suite);
Expand All @@ -543,8 +555,10 @@ create or replace package body ut_suite_builder is
for i in 1 .. a_suite_items.count loop
if a_suite_items(i) is of (ut_test) then
l_test := treat( a_suite_items(i) as ut_test);
l_test.before_each_list := coalesce(convert_list(a_before_each_list),ut_executables()) multiset union all l_test.before_each_list;
l_test.after_each_list := l_test.after_each_list multiset union all coalesce(convert_list(a_after_each_list),ut_executables());
l_test.before_each_list := convert_list(a_before_each_list) multiset union all l_test.before_each_list;
set_seq_no(l_test.before_each_list);
l_test.after_each_list := l_test.after_each_list multiset union all convert_list(a_after_each_list);
set_seq_no(l_test.after_each_list);
a_suite_items(i) := l_test;
elsif a_suite_items(i) is of (ut_logical_suite) then
l_context := treat(a_suite_items(i) as ut_logical_suite);
Expand Down Expand Up @@ -580,8 +594,6 @@ create or replace package body ut_suite_builder is
a_after_all_list in out nocopy tt_executables
) is
l_procedure_name t_object_name;
l_tests tt_tests;

begin
l_procedure_name := a_proc_annotations.by_proc.first;
while l_procedure_name is not null loop
Expand Down Expand Up @@ -679,7 +691,9 @@ create or replace package body ut_suite_builder is
a_suite.set_rollback_type(l_rollback_type);
propagate_before_after_each( a_suite_items, l_before_each_list, l_after_each_list);
a_suite.before_all_list := convert_list(l_before_all_list);
set_seq_no(a_suite.before_all_list);
a_suite.after_all_list := convert_list(l_after_all_list);
set_seq_no(a_suite.after_all_list);
end;

function get_endcontext_position(
Expand Down Expand Up @@ -943,9 +957,9 @@ create or replace package body ut_suite_builder is
line_no => l_rows(i).line_no, parse_time => l_rows(i).parse_time,
start_time => null, end_time => null, result => null, warnings => l_rows(i).warnings,
results_count => ut_results_counter(), transaction_invalidators => ut_varchar2_list(),
before_each_list => l_rows(i).before_each_list, before_test_list => l_rows(i).before_test_list,
before_each_list => sort_by_seq_no(l_rows(i).before_each_list), before_test_list => sort_by_seq_no(l_rows(i).before_test_list),
item => l_rows(i).item,
after_test_list => l_rows(i).after_test_list, after_each_list => l_rows(i).after_each_list,
after_test_list => sort_by_seq_no(l_rows(i).after_test_list), after_each_list => sort_by_seq_no(l_rows(i).after_each_list),
all_expectations => ut_expectation_results(), failed_expectations => ut_expectation_results(),
parent_error_stack_trace => null, expected_error_codes => l_rows(i).expected_error_codes
);
Expand All @@ -960,7 +974,7 @@ create or replace package body ut_suite_builder is
start_time => null, end_time => null, result => null, warnings => l_rows(i).warnings,
results_count => ut_results_counter(), transaction_invalidators => ut_varchar2_list(),
items => ut_suite_items(),
before_all_list => l_rows(i).before_all_list, after_all_list => l_rows(i).after_all_list
before_all_list => sort_by_seq_no(l_rows(i).before_all_list), after_all_list => sort_by_seq_no(l_rows(i).after_all_list)
);
when 'UT_SUITE_CONTEXT' then
l_logical_suites(i) :=
Expand All @@ -973,7 +987,7 @@ create or replace package body ut_suite_builder is
start_time => null, end_time => null, result => null, warnings => l_rows(i).warnings,
results_count => ut_results_counter(), transaction_invalidators => ut_varchar2_list(),
items => ut_suite_items(),
before_all_list => l_rows(i).before_all_list, after_all_list => l_rows(i).after_all_list
before_all_list => sort_by_seq_no(l_rows(i).before_all_list), after_all_list => sort_by_seq_no(l_rows(i).after_all_list)
);
when 'UT_LOGICAL_SUITE' then
l_logical_suites(i) :=
Expand Down Expand Up @@ -1054,7 +1068,7 @@ create or replace package body ut_suite_builder is
suite_items as (
select c.*
from ]'||l_ut_owner||q'[.ut_suite_cache c
where 1 = 1 ]'||case when not a_skip_all_objects /*1 = 0*/ then q'[
where 1 = 1 ]'||case when not a_skip_all_objects then q'[
and exists
( select 1
from all_objects a
Expand Down Expand Up @@ -1226,11 +1240,11 @@ create or replace package body ut_suite_builder is
from '||l_ut_owner||q'[.ut_suite_cache_package c
join table ( :a_schema_names ) s
on c.object_owner = upper(s.column_value)
-- where exists
-- (select 1 from all_objects a
-- where a.owner = c.object_owner
-- and a.object_name = c.object_name
-- and a.object_type = 'PACKAGE')
where exists
(select 1 from all_objects a
where a.owner = c.object_owner
and a.object_name = c.object_name
and a.object_type = 'PACKAGE')
]'
bulk collect into l_schema_names, l_object_names using a_schema_names;
l_results.extend( l_schema_names.count );
Expand Down
2 changes: 0 additions & 2 deletions test/api/test_ut_run.pks
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ create or replace package test_ut_run is
--%test(Runs all tests in current schema with coverage file list)
procedure run_proc_cov_file_list;

--%disabled(TODO - currently it executes the package and all child packages)
--%test(Runs given package only with package name given as path)
procedure run_proc_pkg_name;
--%test(Runs all from given package with package name given as path and coverage file list)
Expand Down Expand Up @@ -57,7 +56,6 @@ create or replace package test_ut_run is
--%test(Runs all tests in current schema with coverage file list)
procedure run_func_cov_file_list;

--%disabled(TODO - currently it executes the package and all child packages)
--%test(Runs given package only with package name given as path)
procedure run_func_pkg_name;
--%test(Runs all from given package with package name given as path and coverage file list)
Expand Down