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
Added control over rollback behavior in ut_runner.run
Fixed failing test.
  • Loading branch information
jgebal committed Nov 17, 2018
commit d21134858d2ec73a955070fb2048e408c9a7e7ae
11 changes: 8 additions & 3 deletions source/api/ut_runner.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ create or replace package body ut_runner is
a_include_objects ut_varchar2_list := null,
a_exclude_objects ut_varchar2_list := null,
a_fail_on_errors boolean := false,
a_client_character_set varchar2 := null
a_client_character_set varchar2 := null,
a_perform_rollback boolean := true
) is
l_run ut_run;
l_coverage_schema_names ut_varchar2_rows;
Expand Down Expand Up @@ -141,13 +142,17 @@ create or replace package body ut_runner is
l_run.do_execute();

finish_run(l_run);
rollback;
if a_perform_rollback then
rollback;
end if;
exception
when others then
finish_run(l_run);
dbms_output.put_line(dbms_utility.format_error_backtrace);
dbms_output.put_line(dbms_utility.format_error_stack);
rollback;
if a_perform_rollback then
rollback;
end if;
raise;
end;
if a_fail_on_errors and l_run.result in (ut_utils.gc_failure, ut_utils.gc_error) then
Expand Down
6 changes: 5 additions & 1 deletion source/api/ut_runner.pks
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ create or replace package ut_runner authid current_user is
* @param a_include_objects list of database objects (in format 'owner.name') that coverage should be reported on
* @param a_exclude_objects list of database objects (in format 'owner.name') that coverage should be skipped for
* @param a_fail_on_errors true/false - should an exception be thrown when tests are completed with failures/errors
* @param a_client_character_set if provided, affects some of reporters by setting specific character set for XML/HTML reports
* @param a_perform_rollback true/false - should rollback be performed as part of test execution (default true)

*
* @example
* Parameter `a_paths` accepts values of the following formats:
Expand All @@ -65,7 +68,8 @@ create or replace package ut_runner authid current_user is
a_include_objects ut_varchar2_list := null,
a_exclude_objects ut_varchar2_list := null,
a_fail_on_errors boolean := false,
a_client_character_set varchar2 := null
a_client_character_set varchar2 := null,
a_perform_rollback boolean := true
);

/**
Expand Down
8 changes: 4 additions & 4 deletions source/core/annotations/ut_annotation_manager.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ create or replace package body ut_annotation_manager as
function get_missing_objects(a_object_owner varchar2, a_object_type varchar2) 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_objects_view varchar2(200) := ut_metadata.get_objects_view_name();
l_cursor_text varchar2(32767);
l_result ut_annotation_objs_cache_info;
begin
Expand Down Expand Up @@ -54,7 +54,7 @@ create or replace package body ut_annotation_manager as
function get_annotation_objs_info(a_object_owner varchar2, a_object_type varchar2, a_parse_date timestamp := 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_objects_view varchar2(200) := ut_metadata.get_objects_view_name();
l_cursor_text varchar2(32767);
l_result ut_annotation_objs_cache_info;
begin
Expand Down Expand Up @@ -86,7 +86,7 @@ create or replace package body ut_annotation_manager as

function get_sources_to_annotate(a_object_owner varchar2, a_object_type varchar2) return sys_refcursor is
l_result sys_refcursor;
l_sources_view varchar2(200) := ut_metadata.get_dba_view('dba_source');
l_sources_view varchar2(200) := ut_metadata.get_source_view_name();
begin
open l_result for
q'[select s.name, s.text
Expand All @@ -109,7 +109,7 @@ create or replace package body ut_annotation_manager as

function get_sources_to_annotate(a_object_owner varchar2, a_object_type varchar2, a_objects_to_refresh ut_annotation_objs_cache_info) return sys_refcursor is
l_result sys_refcursor;
l_sources_view varchar2(200) := ut_metadata.get_dba_view('dba_source');
l_sources_view varchar2(200) := ut_metadata.get_source_view_name();
l_card natural;
begin
l_card := ut_utils.scale_cardinality(cardinality(a_objects_to_refresh));
Expand Down
2 changes: 1 addition & 1 deletion source/core/coverage/ut_coverage.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ create or replace package body ut_coverage is
function get_cov_sources_sql(a_coverage_options ut_coverage_options) return varchar2 is
l_result varchar2(32767);
l_full_name varchar2(100);
l_view_name varchar2(200) := ut_metadata.get_dba_view('dba_source');
l_view_name varchar2(200) := ut_metadata.get_source_view_name();
begin
if a_coverage_options.file_mappings is not null and a_coverage_options.file_mappings.count > 0 then
l_full_name := 'f.file_name';
Expand Down
15 changes: 13 additions & 2 deletions source/core/ut_metadata.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ create or replace package body ut_metadata as
l_schema varchar2(200);
l_package_name varchar2(200);
l_procedure_name varchar2(200);
l_view_name varchar2(200) := get_dba_view('dba_objects');
l_view_name varchar2(200) := get_objects_view_name;
begin

l_schema := a_owner_name;
Expand Down Expand Up @@ -116,7 +116,7 @@ create or replace package body ut_metadata as
end;

function get_source_definition_line(a_owner varchar2, a_object_name varchar2, a_line_no integer) return varchar2 is
l_view_name varchar2(128) := get_dba_view('dba_source');
l_view_name varchar2(128) := get_source_view_name();
l_line all_source.text%type;
c_key constant varchar2(500) := a_owner || '.' || a_object_name;
begin
Expand Down Expand Up @@ -155,6 +155,17 @@ create or replace package body ut_metadata as
return l_result;
end;

function get_source_view_name return varchar2 is
begin
return get_dba_view('dba_source');
end;


function get_objects_view_name return varchar2 is
begin
return get_dba_view('dba_objects');
end;

function user_has_execute_any_proc return boolean is
l_ut_owner varchar2(250) := ut_utils.ut_owner;
l_dummy varchar2(250);
Expand Down
12 changes: 11 additions & 1 deletion source/core/ut_metadata.pks
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,21 @@ create or replace package ut_metadata authid current_user as
procedure reset_source_definition_cache;

/**
* Returns dba_... view name if it is accessible, otherwise it returns all_xxx view
* Returns dba_... view name if it is accessible, otherwise it returns all_... view
* @param a_dba_view_name the name of dba view requested
*/
function get_dba_view(a_dba_view_name varchar2) return varchar2;

/**
* Returns dba_source if accessible otherwise returns all_source
*/
function get_source_view_name return varchar2;

/**
* Returns dba_objects if accessible otherwise returns all_objects
*/
function get_objects_view_name return varchar2;

/**
* Returns true if object is accessible to current user
* @param a_object_name fully qualified object name (with schema name)
Expand Down
9 changes: 3 additions & 6 deletions source/core/ut_suite_manager.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -268,17 +268,15 @@ create or replace package body ut_suite_manager is
c_bulk_limit constant pls_integer := 1000;
l_items_at_level t_item_levels;
l_rows tt_cached_suites;
l_logical_suite ut_logical_suite;
l_level pls_integer;
l_prev_level pls_integer;
l_idx integer;
begin
loop
fetch a_suite_data_cursor bulk collect into l_rows limit c_bulk_limit;
exit when l_rows.count = 0;

l_idx := l_rows.first;
loop
while l_idx is not null loop
l_level := length(l_rows(l_idx).path) - length( replace(l_rows(l_idx).path, '.') ) + 1;
if l_level > 1 then
if not l_items_at_level.exists(l_level) then
Expand Down Expand Up @@ -315,9 +313,8 @@ create or replace package body ut_suite_manager is
end if;
l_prev_level := l_level;
l_idx := l_rows.next(l_idx);
exit when l_idx is null;
end loop;
exit when l_rows.count < c_bulk_limit;
exit when a_suite_data_cursor%NOTFOUND;
end loop;

reverse_list_order( a_suites );
Expand All @@ -331,7 +328,7 @@ create or replace package body ut_suite_manager is
function get_missing_objects(a_object_owner varchar2) return ut_varchar2_rows 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_objects_view varchar2(200) := ut_metadata.get_objects_view_name();
l_cursor_text varchar2(32767);
l_result ut_varchar2_rows;
begin
Expand Down
1 change: 0 additions & 1 deletion source/core/ut_utils.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,6 @@ create or replace package body ut_utils is
end;

procedure append_to_list(a_list in out nocopy ut_varchar2_rows, a_item varchar2) is
l_items ut_varchar2_rows;
begin
if a_item is not null then
if a_list is null then
Expand Down
1 change: 0 additions & 1 deletion source/reporters/ut_coveralls_reporter.tpb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ create or replace type body ut_coveralls_reporter is
function get_coverage_json(
a_coverage_data ut_coverage.t_coverage
) return ut_varchar2_rows is
l_file_part varchar2(32767);
l_result ut_varchar2_rows := ut_varchar2_rows();
l_unit ut_coverage.t_full_name;
c_coverage_header constant varchar2(30) := '{"source_files":[';
Expand Down
7 changes: 2 additions & 5 deletions test/api/test_ut_runner.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,13 @@ end;';

procedure keep_an_open_transaction is
l_expected varchar2(300);
l_output_data dbms_output.chararr;
l_num_lines integer := 100000;
begin
--Arrange
create_test_spec();
create_test_body(0);
l_expected := dbms_transaction.local_transaction_id(true);
--Act
ut3.ut.run('test_cache');
dbms_output.get_lines( l_output_data, l_num_lines);
ut3.ut_runner.run(ut3.ut_varchar2_list('test_cache'),null, a_perform_rollback => false);
--Assert
ut.expect(dbms_transaction.local_transaction_id()).to_equal(l_expected);
drop_test_package();
Expand All @@ -105,7 +102,7 @@ end;';
create_test_body(0);
rollback;
--Act
ut3.ut.run('test_cache');
ut3.ut_runner.run(ut3.ut_varchar2_list('test_cache'),null);
dbms_output.get_lines( l_output_data, l_num_lines);
--Assert
ut.expect(dbms_transaction.local_transaction_id()).to_be_null();
Expand Down
12 changes: 8 additions & 4 deletions test/api/test_ut_runner.pks
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,22 @@ create or replace package test_ut_runner is
--%test(closes open transactions if no transaction was open before run)
procedure close_newly_opened_transaction;

--%test(version_compatibility_check compares major, minor and bugfix number)
--%context(version_compatibility_check)

--%test(compares major, minor and bugfix number)
procedure version_comp_check_compare;

--%test(version_compatibility_check ignores build number)
--%test(ignores build number)
procedure version_comp_check_ignore;

--%test(version_compatibility_check compares short version to a full version)
--%test(compares short version to a full version)
procedure version_comp_check_short;

--%test(version_compatibility_check raises exception when invalid version passed)
--%test(raises exception when invalid version passed)
procedure version_comp_check_exception;

--%endcontext

--%test(run resets cache of package body after every run)
procedure run_reset_package_body_cache;

Expand Down