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
Next Next commit
Interim commit with lots of dirty code - got to a place where I get t…
…he infamous ORA-00600

`ORA-00600: internal error code, arguments: [pfrobj.c: invalid RTTI for Object], [], [], [], [], [], [], [], [], [], [], []``
  • Loading branch information
jgebal committed Nov 4, 2018
commit e41d6f9471ffa99e609e7c4f05a1e163e4948cfe
1 change: 1 addition & 0 deletions source/core/annotations/ut_annotated_object.tps
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ create type ut_annotated_object as object(
object_owner varchar2(250),
object_name varchar2(250),
object_type varchar2(50),
parse_time date,
annotations ut_annotations
)
/
Expand Down
19 changes: 7 additions & 12 deletions source/core/annotations/ut_annotation_cache_manager.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,10 @@ create or replace package body ut_annotation_cache_manager as
where cache_id = l_cache_id;

if a_object.annotations is not null and a_object.annotations.count > 0 then
-- begin
insert into ut_annotation_cache
(cache_id, annotation_position, annotation_name, annotation_text, subobject_name)
select l_cache_id, a.position, a.name, a.text, a.subobject_name
from table(a_object.annotations) a;
--TODO - duplicate annotations found?? - should not happen, getting standalone annotations need to happen after procedure annotations were parsed
-- exception
-- when others then
-- dbms_output.put_line(xmltype(anydata.convertCollection(a_object.annotations)).getclobval);
-- raise;
-- end;
end if;
commit;
end;
Expand Down Expand Up @@ -81,12 +74,12 @@ create or replace package body ut_annotation_cache_manager as
commit;
end;

function get_annotations_for_objects(a_cached_objects ut_annotation_objs_cache_info) return sys_refcursor is
function get_annotations_for_objects(a_cached_objects ut_annotation_objs_cache_info, a_parse_date date) return sys_refcursor is
l_results sys_refcursor;
begin
open l_results for
open l_results for q'[
select ut_annotated_object(
o.object_owner, o.object_name, o.object_type,
i.object_owner, i.object_name, i.object_type, i.parse_time,
cast(
collect(
ut_annotation(
Expand All @@ -95,11 +88,13 @@ create or replace package body ut_annotation_cache_manager as
) as ut_annotations
)
)
from table(a_cached_objects) o
from table(:a_cached_objects) o
join ut_annotation_cache_info i
on o.object_owner = i.object_owner and o.object_name = i.object_name and o.object_type = i.object_type
join ut_annotation_cache c on i.cache_id = c.cache_id
group by o.object_owner, o.object_name, o.object_type;
where ]'|| case when a_parse_date is null then ':a_parse_date is null' else 'i.parse_time > :a_parse_date' end ||q'[
group by i.object_owner, i.object_name, i.object_type, i.parse_time]'
using a_cached_objects, a_parse_date;
return l_results;
end;

Expand Down
2 changes: 1 addition & 1 deletion source/core/annotations/ut_annotation_cache_manager.pks
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ create or replace package ut_annotation_cache_manager authid definer as
*
* @param a_cached_objects a `ut_annotation_objs_cache_info` list with information about objects to get from cache
*/
function get_annotations_for_objects(a_cached_objects ut_annotation_objs_cache_info) return sys_refcursor;
function get_annotations_for_objects(a_cached_objects ut_annotation_objs_cache_info, a_parse_date date) return sys_refcursor;

/**
* Removes cached information about annotations for objects on the list and updates parse_time in cache info table.
Expand Down
54 changes: 31 additions & 23 deletions source/core/annotations/ut_annotation_manager.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ create or replace package body ut_annotation_manager as
------------------------------
--private definitions

function get_annotation_objs_info_cur(a_object_owner varchar2, a_object_type varchar2) return sys_refcursor is
l_result sys_refcursor;
function get_annotation_objs_info(a_object_owner varchar2, a_object_type varchar2, a_parse_date date := null) return ut_annotation_objs_cache_info is
l_rows sys_refcursor;
l_ut_owner varchar2(250) := ut_utils.ut_owner;
l_objects_view varchar2(200) := ut_metadata.get_dba_view('dba_objects');
l_cursor_text long;
l_cursor_text varchar2(32767);
l_result ut_annotation_objs_cache_info;
begin
l_cursor_text :=
q'[select ]'||l_ut_owner||q'[.ut_annotation_obj_cache_info(
Expand All @@ -34,10 +35,20 @@ create or replace package body ut_annotation_manager as
)
from ]'||l_objects_view||q'[ o
left join ]'||l_ut_owner||q'[.ut_annotation_cache_info i
on o.owner = i.object_owner and o.object_name = i.object_name and o.object_type = i.object_type
on o.owner = i.object_owner
and o.object_name = i.object_name
and o.object_type = i.object_type
where o.owner = :a_object_owner
and o.object_type = :a_object_type]';
open l_result for l_cursor_text using a_object_owner, a_object_type;
and o.object_type = :a_object_type
and ]'
|| case
when a_parse_date is null
then ':a_parse_date is null'
else 'o.last_ddl_time > :a_parse_date'
end;
open l_rows for l_cursor_text using a_object_owner, a_object_type, a_parse_date;
fetch l_rows bulk collect into l_result limit 1000000;
close l_rows;
return l_result;
end;

Expand Down Expand Up @@ -103,6 +114,7 @@ create or replace package body ut_annotation_manager as
l_names dbms_preprocessor.source_lines_t;
l_name varchar2(250);
l_object_lines dbms_preprocessor.source_lines_t;
l_parse_time date := sysdate;
pragma autonomous_transaction;
begin
ut_annotation_cache_manager.cleanup_cache(a_schema_objects);
Expand All @@ -112,7 +124,7 @@ create or replace package body ut_annotation_manager as
if l_names(i) != l_name then
l_annotations := ut_annotation_parser.parse_object_annotations(l_object_lines);
ut_annotation_cache_manager.update_cache(
ut_annotated_object(a_object_owner, l_name, a_object_type, l_annotations)
ut_annotated_object(a_object_owner, l_name, a_object_type, l_parse_time, l_annotations)
);
l_object_lines.delete;
end if;
Expand All @@ -126,7 +138,7 @@ create or replace package body ut_annotation_manager as
if a_sources_cursor%rowcount > 0 then
l_annotations := ut_annotation_parser.parse_object_annotations(l_object_lines);
ut_annotation_cache_manager.update_cache(
ut_annotated_object(a_object_owner, l_name, a_object_type, l_annotations)
ut_annotated_object(a_object_owner, l_name, a_object_type, l_parse_time, l_annotations)
);
l_object_lines.delete;
end if;
Expand All @@ -140,7 +152,8 @@ create or replace package body ut_annotation_manager as
l_objects_to_parse ut_annotation_objs_cache_info := ut_annotation_objs_cache_info();
begin
--get list of objects in cache
select count( 1)into l_objects_in_cache_count from table(a_info_rows) x where x.needs_refresh = 'N';
select count(1) into l_objects_in_cache_count
from table(a_info_rows) x where x.needs_refresh = 'N';

--if cache is empty and there are objects to parse
if l_objects_in_cache_count = 0 and a_info_rows.count > 0 then
Expand Down Expand Up @@ -173,30 +186,26 @@ create or replace package body ut_annotation_manager as
--public definitions
------------------------------------------------------------
procedure rebuild_annotation_cache(a_object_owner varchar2, a_object_type varchar2) is
l_info_cursor sys_refcursor;
l_info_rows ut_annotation_objs_cache_info;
begin
l_info_cursor := get_annotation_objs_info_cur(a_object_owner, a_object_type);
fetch l_info_cursor bulk collect into l_info_rows;
close l_info_cursor;
rebuild_annotation_cache(a_object_owner, a_object_type, l_info_rows);
rebuild_annotation_cache(
a_object_owner,
a_object_type,
get_annotation_objs_info(a_object_owner, a_object_type, null)
);
end;

function get_annotated_objects(a_object_owner varchar2, a_object_type varchar2) return ut_annotated_objects pipelined is
l_info_cursor sys_refcursor;
function get_annotated_objects(a_object_owner varchar2, a_object_type varchar2, a_parse_date date := null) return ut_annotated_objects pipelined is
l_info_rows ut_annotation_objs_cache_info;
l_cursor sys_refcursor;
l_results ut_annotated_objects;
c_object_fetch_limit constant integer := 10;
begin

l_info_cursor := get_annotation_objs_info_cur(a_object_owner, a_object_type);
fetch l_info_cursor bulk collect into l_info_rows;
close l_info_cursor;

l_info_rows := get_annotation_objs_info(a_object_owner, a_object_type, a_parse_date);
rebuild_annotation_cache(a_object_owner, a_object_type, l_info_rows);

--pipe annotations from cache
l_cursor := ut_annotation_cache_manager.get_annotations_for_objects(l_info_rows);
l_cursor := ut_annotation_cache_manager.get_annotations_for_objects(l_info_rows, a_parse_date);
loop
fetch l_cursor bulk collect into l_results limit c_object_fetch_limit;
for i in 1 .. l_results.count loop
Expand All @@ -205,7 +214,6 @@ create or replace package body ut_annotation_manager as
exit when l_cursor%notfound;
end loop;
close l_cursor;

end;

procedure purge_cache(a_object_owner varchar2, a_object_type varchar2) is
Expand Down
3 changes: 2 additions & 1 deletion source/core/annotations/ut_annotation_manager.pks
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ create or replace package ut_annotation_manager authid current_user as
*
* @param a_object_owner owner of objects to get annotations for
* @param a_object_type type of objects to get annotations for
* @param a_parse_date date when object was last parsed
* @return array containing annotated objects along with annotations for each object (nested)
*/
function get_annotated_objects(a_object_owner varchar2, a_object_type varchar2) return ut_annotated_objects pipelined;
function get_annotated_objects(a_object_owner varchar2, a_object_type varchar2, a_parse_date date := null) return ut_annotated_objects pipelined;

/**
* Rebuilds annotation cache for a specified schema and object type.
Expand Down
2 changes: 1 addition & 1 deletion source/core/types/ut_logical_suite.tpb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ create or replace type body ut_logical_suite as
) return self as result is
begin
self.self_type := $$plsql_unit;
self.init(a_object_owner, a_object_name, a_name);
self.init(a_object_owner, a_object_name, a_name, 0);
self.path := a_path;
self.disabled_flag := ut_utils.boolean_to_int(false);
self.items := ut_suite_items();
Expand Down
19 changes: 19 additions & 0 deletions source/core/types/ut_logical_suites.tps
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
create or replace type ut_logical_suites as
/*
utPLSQL - Version 3
Copyright 2016 - 2018 utPLSQL Project

Licensed under the Apache License, Version 2.0 (the "License"):
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
table of ut_logical_suite
/
4 changes: 2 additions & 2 deletions source/core/types/ut_suite.tpb
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ create or replace type body ut_suite as
*/

constructor function ut_suite (
self in out nocopy ut_suite, a_object_owner varchar2, a_object_name varchar2
self in out nocopy ut_suite, a_object_owner varchar2, a_object_name varchar2, a_line_no integer
) return self as result is
begin
self.self_type := $$plsql_unit;
self.init(a_object_owner, a_object_name, a_object_name);
self.init(a_object_owner, a_object_name, a_object_name, a_line_no);
self.items := ut_suite_items();
before_all_list := ut_executables();
after_all_list := ut_executables();
Expand Down
2 changes: 1 addition & 1 deletion source/core/types/ut_suite.tps
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ create or replace type ut_suite under ut_logical_suite (
*/
after_all_list ut_executables,
constructor function ut_suite (
self in out nocopy ut_suite, a_object_owner varchar2, a_object_name varchar2
self in out nocopy ut_suite, a_object_owner varchar2, a_object_name varchar2, a_line_no integer
) return self as result,
overriding member function do_execute(self in out nocopy ut_suite) return boolean,
overriding member function get_error_stack_traces(self ut_suite) return ut_varchar2_list,
Expand Down
4 changes: 2 additions & 2 deletions source/core/types/ut_suite_context.tpb
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ create or replace type body ut_suite_context as
*/

constructor function ut_suite_context (
self in out nocopy ut_suite_context, a_object_owner varchar2, a_object_name varchar2, a_context_name varchar2 := null
self in out nocopy ut_suite_context, a_object_owner varchar2, a_object_name varchar2, a_context_name varchar2 := null, a_line_no integer
) return self as result is
begin
self.self_type := $$plsql_unit;
self.init(a_object_owner, a_object_name, a_context_name);
self.init(a_object_owner, a_object_name, a_context_name, a_line_no);
self.items := ut_suite_items();
before_all_list := ut_executables();
after_all_list := ut_executables();
Expand Down
2 changes: 1 addition & 1 deletion source/core/types/ut_suite_context.tps
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ create or replace type ut_suite_context under ut_suite (
limitations under the License.
*/
constructor function ut_suite_context (
self in out nocopy ut_suite_context, a_object_owner varchar2, a_object_name varchar2, a_context_name varchar2 := null
self in out nocopy ut_suite_context, a_object_owner varchar2, a_object_name varchar2, a_context_name varchar2 := null, a_line_no integer
) return self as result
)
/
12 changes: 4 additions & 8 deletions source/core/types/ut_suite_item.tpb
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,18 @@ create or replace type body ut_suite_item as
limitations under the License.
*/

member procedure init(self in out nocopy ut_suite_item, a_object_owner varchar2, a_object_name varchar2, a_name varchar2) is
member procedure init(self in out nocopy ut_suite_item, a_object_owner varchar2, a_object_name varchar2, a_name varchar2, a_line_no integer) is
begin
self.object_owner := a_object_owner;
self.object_name := lower(trim(a_object_name));
self.name := lower(trim(a_name));
self.results_count := ut_results_counter();
self.warnings := ut_varchar2_list();
self.warnings := ut_varchar2_rows();
self.line_no := a_line_no;
self.transaction_invalidators := ut_varchar2_list();
self.disabled_flag := ut_utils.boolean_to_int(false);
end;

member procedure set_disabled_flag(self in out nocopy ut_suite_item, a_disabled_flag boolean) is
begin
self.disabled_flag := ut_utils.boolean_to_int(a_disabled_flag);
end;

member function get_disabled_flag return boolean is
begin
return ut_utils.int_to_boolean(self.disabled_flag);
Expand All @@ -47,7 +43,7 @@ create or replace type body ut_suite_item as
return nvl(self.rollback_type, ut_utils.gc_rollback_default);
end;

final member procedure do_execute(self in out nocopy ut_suite_item) is
final member procedure do_execute(self in out nocopy ut_suite_item) is
l_completed_without_errors boolean;
begin
l_completed_without_errors := self.do_execute();
Expand Down
19 changes: 13 additions & 6 deletions source/core/types/ut_suite_item.tps
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ create or replace type ut_suite_item force under ut_event_item (
/**
* owner of the database object (package)
*/
object_owner varchar2(4000 byte),
object_owner varchar2(250 byte),
/**
* name of the database object (package)
*/
object_name varchar2(4000 byte),
object_name varchar2(250 byte),
/**
* Name of the object (suite, sub-suite, test)
*/
name varchar2(4000 byte),
name varchar2(250 byte),
/**
* Description fo the suite item (as given by the annotation)
*/
Expand All @@ -45,15 +45,22 @@ create or replace type ut_suite_item force under ut_event_item (
* Indicates if the test is to be disabled by execution
*/
disabled_flag integer(1),
/**
* Line no where annotation identifying this item is placed in package
*/
line_no integer,
/**
* Time when the suite item was last parsed from package source
*/
parse_time date,
--execution result fields
start_time timestamp with time zone,
end_time timestamp with time zone,
result integer(1),
warnings ut_varchar2_list,
warnings ut_varchar2_rows,
results_count ut_results_counter,
transaction_invalidators ut_varchar2_list,
member procedure init(self in out nocopy ut_suite_item, a_object_owner varchar2, a_object_name varchar2, a_name varchar2),
member procedure set_disabled_flag(self in out nocopy ut_suite_item, a_disabled_flag boolean),
member procedure init(self in out nocopy ut_suite_item, a_object_owner varchar2, a_object_name varchar2, a_name varchar2, a_line_no integer),
member function get_disabled_flag return boolean,
not instantiable member procedure mark_as_skipped(self in out nocopy ut_suite_item),
member procedure set_rollback_type(self in out nocopy ut_suite_item, a_rollback_type integer),
Expand Down
8 changes: 4 additions & 4 deletions source/core/types/ut_test.tpb
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ create or replace type body ut_test as

constructor function ut_test(
self in out nocopy ut_test, a_object_owner varchar2 := null, a_object_name varchar2, a_name varchar2,
a_expected_error_codes ut_integer_list := null
a_line_no integer, a_expected_error_codes ut_integer_list := null
) return self as result is
begin
self.self_type := $$plsql_unit;
self.init(a_object_owner, a_object_name, a_name);
self.init(a_object_owner, a_object_name, a_name, a_line_no);
self.item := ut_executable_test(a_object_owner, a_object_name, a_name, ut_utils.gc_test_execute);
self.before_each_list := ut_executables();
self.before_test_list := ut_executables();
Expand Down Expand Up @@ -97,7 +97,7 @@ create or replace type body ut_test as
end;

overriding member procedure calc_execution_result(self in out nocopy ut_test) is
l_warnings ut_varchar2_list;
l_warnings ut_varchar2_rows;
begin
if self.get_error_stack_traces().count = 0 then
self.result := ut_expectation_processor.get_status();
Expand All @@ -107,7 +107,7 @@ create or replace type body ut_test as
--expectation results need to be part of test results
self.all_expectations := ut_expectation_processor.get_all_expectations();
self.failed_expectations := ut_expectation_processor.get_failed_expectations();
l_warnings := coalesce( ut_expectation_processor.get_warnings(), ut_varchar2_list() );
l_warnings := coalesce( ut_expectation_processor.get_warnings(), ut_varchar2_rows() );
self.warnings := self.warnings multiset union all l_warnings;
self.results_count.increase_warning_count( cardinality(l_warnings) );
self.results_count.set_counter_values(self.result);
Expand Down
2 changes: 1 addition & 1 deletion source/core/types/ut_test.tps
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ create or replace type ut_test under ut_suite_item (
expected_error_codes ut_integer_list,
constructor function ut_test(
self in out nocopy ut_test, a_object_owner varchar2 := null, a_object_name varchar2, a_name varchar2,
a_expected_error_codes ut_integer_list := null
a_line_no integer, a_expected_error_codes ut_integer_list := null
) return self as result,
overriding member procedure mark_as_skipped(self in out nocopy ut_test),
overriding member function do_execute(self in out nocopy ut_test) return boolean,
Expand Down
Loading