From b9ca972d659191845f8391a7d7ca316a1ce3e16a Mon Sep 17 00:00:00 2001 From: lwasylow Date: Mon, 23 Apr 2018 19:44:15 +0100 Subject: [PATCH 001/184] Initial check in of unordered comparision --- .../data_values/ut_compound_data_helper.pkb | 54 ++++++++++- .../data_values/ut_compound_data_helper.pks | 5 + .../data_values/ut_compound_data_value.tpb | 91 +++++++++++++++++-- .../data_values/ut_compound_data_value.tps | 8 +- .../data_values/ut_data_value.tpb | 4 +- .../data_values/ut_data_value.tps | 4 +- .../data_values/ut_data_value_anydata.tps | 2 +- .../data_values/ut_data_value_refcursor.tpb | 31 ++++++- .../data_values/ut_data_value_refcursor.tps | 6 +- source/expectations/matchers/ut_equal.tpb | 21 ++++- source/expectations/matchers/ut_equal.tps | 5 + .../expectations/ut_expectation_compound.tpb | 18 ++++ .../expectations/ut_expectation_compound.tps | 5 +- 13 files changed, 227 insertions(+), 27 deletions(-) diff --git a/source/expectations/data_values/ut_compound_data_helper.pkb b/source/expectations/data_values/ut_compound_data_helper.pkb index a69741aa8..ed9e397d2 100644 --- a/source/expectations/data_values/ut_compound_data_helper.pkb +++ b/source/expectations/data_values/ut_compound_data_helper.pkb @@ -217,12 +217,10 @@ create or replace package body ut_compound_data_helper is from ut_compound_data_tmp ucd where ucd.data_id = :other_guid and ucd.item_no in (select i.item_no from diff_info i) - )act on exp.item_no = act.item_no where exp.item_no is null or act.item_no is null - order by 1, 2 -]' + order by 1, 2]' bulk collect into l_results using a_diff_id, a_max_rows, a_exclude_xpath, a_include_xpath, a_expected_dataset_guid, @@ -231,6 +229,56 @@ create or replace package body ut_compound_data_helper is return l_results; end; + function get_rows_diff_unordered( + a_expected_dataset_guid raw, a_actual_dataset_guid raw, a_diff_id raw, + a_max_rows integer, a_exclude_xpath varchar2, a_include_xpath varchar2 + ) return tt_row_diffs is + l_column_filter varchar2(32767); + l_results tt_row_diffs; + begin + l_column_filter := get_columns_filter(a_exclude_xpath,a_include_xpath); + execute immediate q'[ + select + coalesce(exp.duplicate_no, act.duplicate_no) duplicate_no, + case when exp.row_hash is null then 'Actual:' else 'Expected:' end diffed_type, + case when exp.row_hash is null then + xmlserialize(content act.row_data no indent) + else + xmlserialize(content exp.row_data no indent) + end diffed_row + from (select ucd.*, row_number() over(partition by row_hash order by row_hash) duplicate_no + from (select ucd.column_value row_data, + dbms_crypto.hash( value(ucd).getclobval(),3) row_hash + from (select ]'||l_column_filter||q'[, ucd.item_no, ucd.item_data item_data_no_filter + from ut_compound_data_tmp ucd + where ucd.data_id = :self_guid + ) r, + table( xmlsequence( extract(r.item_data,'/*') ) ) ucd + ) ucd + ) exp + full outer join + (select ucd.*, row_number() over(partition by row_hash order by row_hash) duplicate_no + from (select ucd.column_value row_data, + dbms_crypto.hash( value(ucd).getclobval(),3/*HASH_SH1*/) row_hash + from (select ]'||l_column_filter||q'[, ucd.item_no, ucd.item_data item_data_no_filter + from ut_compound_data_tmp ucd + where ucd.data_id = :other_guid + ) r, + table( xmlsequence( extract(r.item_data,'/*') ) ) ucd + ) ucd + ) act + on exp.row_hash = act.row_hash + and exp.duplicate_no = act.duplicate_no + where exp.row_hash is null or act.row_hash is null]' + bulk collect into l_results + using a_exclude_xpath, a_include_xpath, a_expected_dataset_guid, + a_exclude_xpath, a_include_xpath, a_actual_dataset_guid; + + --execute immediate 'create table test as select * from ut_compound_data_tmp'; + return l_results; + + end; + function get_hash(a_data raw, a_hash_type binary_integer := dbms_crypto.hash_sh1) return t_hash is begin return dbms_crypto.hash(a_data, a_hash_type); diff --git a/source/expectations/data_values/ut_compound_data_helper.pks b/source/expectations/data_values/ut_compound_data_helper.pks index d49db160c..ae9b2a044 100644 --- a/source/expectations/data_values/ut_compound_data_helper.pks +++ b/source/expectations/data_values/ut_compound_data_helper.pks @@ -52,6 +52,11 @@ create or replace package ut_compound_data_helper authid definer is a_max_rows integer, a_exclude_xpath varchar2, a_include_xpath varchar2 ) return tt_row_diffs; + function get_rows_diff_unordered( + a_expected_dataset_guid raw, a_actual_dataset_guid raw, a_diff_id raw, + a_max_rows integer, a_exclude_xpath varchar2, a_include_xpath varchar2 + ) return tt_row_diffs; + subtype t_hash is raw(128); function get_hash(a_data raw, a_hash_type binary_integer := dbms_crypto.hash_sh1) return t_hash; diff --git a/source/expectations/data_values/ut_compound_data_value.tpb b/source/expectations/data_values/ut_compound_data_value.tpb index b7c43d2d8..8a5fb2ab3 100644 --- a/source/expectations/data_values/ut_compound_data_value.tpb +++ b/source/expectations/data_values/ut_compound_data_value.tpb @@ -71,17 +71,61 @@ create or replace type body ut_compound_data_value as return l_result_string; end; - overriding member function diff( a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2 ) return varchar2 is + overriding member function diff( a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2, a_unordered boolean := false ) return varchar2 is l_result clob; l_result_string varchar2(32767); begin - l_result := get_data_diff(a_other, a_exclude_xpath, a_include_xpath); + l_result := get_data_diff(a_other, a_exclude_xpath, a_include_xpath, a_unordered); l_result_string := ut_utils.to_string(l_result,null); dbms_lob.freetemporary(l_result); return l_result_string; end; - member function get_data_diff( a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2 ) return clob is + member function get_data_diff( a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2, a_unordered boolean ) return clob is + c_max_rows constant integer := 20; + l_result clob; + l_results ut_utils.t_clob_tab := ut_utils.t_clob_tab(); + l_message varchar2(32767); + l_ut_owner varchar2(250) := ut_utils.ut_owner; + l_diff_row_count integer; + l_actual ut_compound_data_value; + l_diff_id ut_compound_data_helper.t_hash; + l_row_diffs ut_compound_data_helper.tt_row_diffs; + begin + if not a_other is of (ut_compound_data_value) then + raise value_error; + end if; + l_actual := treat(a_other as ut_compound_data_value); + + dbms_lob.createtemporary(l_result,true); + + --diff rows and row elements + l_diff_id := ut_compound_data_helper.get_hash(self.data_id||l_actual.data_id); + -- First tell how many rows are different + execute immediate 'select unordered_cnt from ' || l_ut_owner || '.ut_compound_data_diff_tmp where diff_id = :diff_id' into l_diff_row_count using l_diff_id; + + if l_diff_row_count > 0 then + l_row_diffs := ut_compound_data_helper.get_rows_diff_unordered( + self.data_id, l_actual.data_id, l_diff_id, c_max_rows, a_exclude_xpath, a_include_xpath + ); + l_message := chr(10) + ||'Rows: [ ' || l_diff_row_count ||' differences' + || case when l_diff_row_count > c_max_rows and l_row_diffs.count > 0 then ', showing first '||c_max_rows end + ||' ]' || chr(10) + || case when l_row_diffs.count = 0 + then ' All rows are different as the columns are not matching.' end; + ut_utils.append_to_clob( l_result, l_message ); + for i in 1 .. l_row_diffs.count loop + l_results.extend; + l_results(l_results.last) := + ' Row Appeared '||l_row_diffs(i).rn||' - '||rpad(l_row_diffs(i).diff_type,10)||l_row_diffs(i).diffed_row; + end loop; + ut_utils.append_to_clob(l_result,l_results); + end if; + return l_result; + end; + + member function get_data_diff( a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2 ) return clob is c_max_rows constant integer := 20; l_result clob; l_results ut_utils.t_clob_tab := ut_utils.t_clob_tab(); @@ -105,9 +149,9 @@ create or replace type body ut_compound_data_value as execute immediate 'select count(*) from ' || l_ut_owner || '.ut_compound_data_diff_tmp where diff_id = :diff_id' into l_diff_row_count using l_diff_id; if l_diff_row_count > 0 then - l_row_diffs := ut_compound_data_helper.get_rows_diff( - self.data_id, l_actual.data_id, l_diff_id, c_max_rows, a_exclude_xpath, a_include_xpath - ); + l_row_diffs := ut_compound_data_helper.get_rows_diff( + self.data_id, l_actual.data_id, l_diff_id, c_max_rows, a_exclude_xpath, a_include_xpath + ); l_message := chr(10) ||'Rows: [ ' || l_diff_row_count ||' differences' || case when l_diff_row_count > c_max_rows and l_row_diffs.count > 0 then ', showing first '||c_max_rows end @@ -171,7 +215,6 @@ create or replace type body ut_compound_data_value as ') != 0' using in l_diff_id, a_exclude_xpath, a_include_xpath, self.data_id, a_exclude_xpath, a_include_xpath, l_other.data_id, l_xml_data_fmt, l_xml_data_fmt; - --result is OK only if both are same if sql%rowcount = 0 and self.elements_count = l_other.elements_count then l_result := 0; @@ -181,5 +224,39 @@ create or replace type body ut_compound_data_value as return l_result; end; +member function compare_implementation(a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2, a_unordered boolean ) return integer is + l_other ut_compound_data_value; + l_ut_owner varchar2(250) := ut_utils.ut_owner; + l_column_filter varchar2(32767); + l_diff_id ut_compound_data_helper.t_hash; + l_result integer; + l_row_diffs ut_compound_data_helper.tt_row_diffs; + c_max_rows constant integer := 20; + begin + if not a_other is of (ut_compound_data_value) then + raise value_error; + end if; + + l_other := treat(a_other as ut_compound_data_value); + + l_diff_id := ut_compound_data_helper.get_hash(self.data_id||l_other.data_id); + l_column_filter := ut_compound_data_helper.get_columns_filter(a_exclude_xpath, a_include_xpath); + + -- Find differences + l_row_diffs := ut_compound_data_helper.get_rows_diff_unordered( + self.data_id, l_other.data_id, l_diff_id, c_max_rows, a_exclude_xpath, a_include_xpath + ); + + execute immediate 'insert into ' || l_ut_owner || '.ut_compound_data_diff_tmp ( diff_id, unordered_cnt ) + values (:diff_id, nvl(:unordered_cnt,0))' using l_diff_id, l_row_diffs.count; + --result is OK only if both are same + if l_row_diffs.count = 0 and self.elements_count = l_other.elements_count then + l_result := 0; + else + l_result := 1; + end if; + return l_result; + end; + end; / diff --git a/source/expectations/data_values/ut_compound_data_value.tps b/source/expectations/data_values/ut_compound_data_value.tps index e06848a1e..d2345c01e 100644 --- a/source/expectations/data_values/ut_compound_data_value.tps +++ b/source/expectations/data_values/ut_compound_data_value.tps @@ -1,4 +1,4 @@ -create or replace type ut_compound_data_value under ut_data_value( +create or replace type ut_compound_data_value force under ut_data_value( /* utPLSQL - Version 3 Copyright 2016 - 2017 utPLSQL Project @@ -42,8 +42,10 @@ create or replace type ut_compound_data_value under ut_data_value( overriding member function to_string return varchar2, overriding member function is_multi_line return boolean, overriding member function compare_implementation(a_other ut_data_value) return integer, - overriding member function diff( a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2 ) return varchar2, + overriding member function diff( a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2, a_unordered boolean := false ) return varchar2, + member function get_data_diff( a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2, a_unordered boolean ) return clob, member function get_data_diff( a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2 ) return clob, - member function compare_implementation(a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2) return integer + member function compare_implementation(a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2) return integer, + member function compare_implementation(a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2, a_unordered boolean ) return integer ) not final not instantiable / diff --git a/source/expectations/data_values/ut_data_value.tpb b/source/expectations/data_values/ut_data_value.tpb index 605f492f3..8bc3a87aa 100644 --- a/source/expectations/data_values/ut_data_value.tpb +++ b/source/expectations/data_values/ut_data_value.tpb @@ -24,8 +24,8 @@ create or replace type body ut_data_value as begin return false; end; - - member function diff( a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2 ) return varchar2 is + + member function diff( a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2, a_unordered boolean :=false ) return varchar2 is begin return null; end; diff --git a/source/expectations/data_values/ut_data_value.tps b/source/expectations/data_values/ut_data_value.tps index fba0ed3c4..c9ae28d5e 100644 --- a/source/expectations/data_values/ut_data_value.tps +++ b/source/expectations/data_values/ut_data_value.tps @@ -1,4 +1,4 @@ -create or replace type ut_data_value authid current_user as object ( +create or replace type ut_data_value force authid current_user as object ( /* utPLSQL - Version 3 Copyright 2016 - 2017 utPLSQL Project @@ -24,7 +24,7 @@ create or replace type ut_data_value authid current_user as object ( final member function to_string_report(a_add_new_line_for_multi_line boolean := false, a_with_object_info boolean := true) return varchar2, order member function compare( a_other ut_data_value ) return integer, member function is_diffable return boolean, - member function diff( a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2 ) return varchar2, + member function diff( a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2, a_unordered boolean := false ) return varchar2, not instantiable member function compare_implementation( a_other ut_data_value ) return integer ) not final not instantiable / diff --git a/source/expectations/data_values/ut_data_value_anydata.tps b/source/expectations/data_values/ut_data_value_anydata.tps index 91d66c7bd..87829cfa1 100644 --- a/source/expectations/data_values/ut_data_value_anydata.tps +++ b/source/expectations/data_values/ut_data_value_anydata.tps @@ -1,4 +1,4 @@ -create or replace type ut_data_value_anydata under ut_compound_data_value( +create or replace type ut_data_value_anydata force under ut_compound_data_value( /* utPLSQL - Version 3 Copyright 2016 - 2017 utPLSQL Project diff --git a/source/expectations/data_values/ut_data_value_refcursor.tpb b/source/expectations/data_values/ut_data_value_refcursor.tpb index ccebdb99e..5df2c76eb 100644 --- a/source/expectations/data_values/ut_data_value_refcursor.tpb +++ b/source/expectations/data_values/ut_data_value_refcursor.tpb @@ -108,7 +108,7 @@ create or replace type body ut_data_value_refcursor as return l_result_string; end; - overriding member function diff( a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2 ) return varchar2 is + overriding member function diff( a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2, a_unordered boolean := false ) return varchar2 is l_result clob; l_results ut_utils.t_clob_tab := ut_utils.t_clob_tab(); l_result_string varchar2(32767); @@ -176,8 +176,12 @@ create or replace type body ut_data_value_refcursor as end if; --diff rows and row elements - ut_utils.append_to_clob(l_result, self.get_data_diff(a_other, l_exclude_xpath, a_include_xpath)); - + if a_unordered then + ut_utils.append_to_clob(l_result, self.get_data_diff(a_other, l_exclude_xpath, a_include_xpath, a_unordered)); + else + ut_utils.append_to_clob(l_result, self.get_data_diff(a_other, l_exclude_xpath, a_include_xpath)); + end if; + l_result_string := ut_utils.to_string(l_result,null); dbms_lob.freetemporary(l_result); return l_result_string; @@ -203,5 +207,26 @@ create or replace type body ut_data_value_refcursor as return l_result; end; + overriding member function compare_implementation (a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2, a_unordered boolean) return integer is + l_result integer := 0; + l_other ut_data_value_refcursor; + begin + if not a_other is of (ut_data_value_refcursor) then + raise value_error; + end if; + + l_other := treat(a_other as ut_data_value_refcursor); + + --if column names/types are not equal - build a diff of column names and types + if ut_compound_data_helper.columns_hash( self, a_exclude_xpath, a_include_xpath ) + != ut_compound_data_helper.columns_hash( l_other, a_exclude_xpath, a_include_xpath ) + then + l_result := 1; + end if; + l_result := l_result + (self as ut_compound_data_value).compare_implementation(a_other, a_exclude_xpath, a_include_xpath, a_unordered); + return l_result; + end; + + end; / diff --git a/source/expectations/data_values/ut_data_value_refcursor.tps b/source/expectations/data_values/ut_data_value_refcursor.tps index c59bf2662..679030fe5 100644 --- a/source/expectations/data_values/ut_data_value_refcursor.tps +++ b/source/expectations/data_values/ut_data_value_refcursor.tps @@ -33,7 +33,9 @@ create or replace type ut_data_value_refcursor under ut_compound_data_value( constructor function ut_data_value_refcursor(self in out nocopy ut_data_value_refcursor, a_value sys_refcursor) return self as result, member procedure init(self in out nocopy ut_data_value_refcursor, a_value sys_refcursor), overriding member function to_string return varchar2, - overriding member function diff( a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2 ) return varchar2, - overriding member function compare_implementation(a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2) return integer + overriding member function diff( a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2, a_unordered boolean := false ) return varchar2, + overriding member function compare_implementation(a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2) return integer, + overriding member function compare_implementation(a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2, a_unordered boolean) return integer + ) / diff --git a/source/expectations/matchers/ut_equal.tpb b/source/expectations/matchers/ut_equal.tpb index 29b8f511d..09b1b7e5e 100644 --- a/source/expectations/matchers/ut_equal.tpb +++ b/source/expectations/matchers/ut_equal.tpb @@ -182,6 +182,13 @@ create or replace type body ut_equal as return l_result; end; + member function unordered return ut_equal is + l_result ut_equal := self; + begin + l_result.is_unordered := 'true'; + return l_result; + end; + member function get_include_xpath return varchar2 is begin return ut_utils.to_xpath( coalesce(include_list, ut_varchar2_list()) ); @@ -192,6 +199,12 @@ create or replace type body ut_equal as return ut_utils.to_xpath( coalesce(exclude_list, ut_varchar2_list()) ); end; + member function get_unordered return boolean is + begin + return case when is_unordered = 'true' then true else false end; + end; + + overriding member function run_matcher(self in out nocopy ut_equal, a_actual ut_data_value) return boolean is l_result boolean; begin @@ -199,7 +212,11 @@ create or replace type body ut_equal as if self.expected is of (ut_data_value_anydata) then l_result := 0 = treat(self.expected as ut_data_value_anydata).compare_implementation(a_actual, get_exclude_xpath(), get_include_xpath()); elsif self.expected is of (ut_data_value_refcursor) then - l_result := 0 = treat(self.expected as ut_data_value_refcursor).compare_implementation(a_actual, get_exclude_xpath(), get_include_xpath()); + if get_unordered then + l_result := 0 = treat(self.expected as ut_data_value_refcursor).compare_implementation(a_actual, get_exclude_xpath(), get_include_xpath(),get_unordered()); + else + l_result := 0 = treat(self.expected as ut_data_value_refcursor).compare_implementation(a_actual, get_exclude_xpath(), get_include_xpath()); + end if; else l_result := equal_with_nulls((self.expected = a_actual), a_actual); end if; @@ -216,7 +233,7 @@ create or replace type body ut_equal as if self.expected.data_type = a_actual.data_type and self.expected.is_diffable then l_result := 'Actual: '||a_actual.get_object_info()||' '||self.description()||': '||self.expected.get_object_info() - || chr(10) || 'Diff:' || expected.diff(a_actual, get_exclude_xpath(), get_include_xpath()); + || chr(10) || 'Diff:' || expected.diff(a_actual, get_exclude_xpath(), get_include_xpath(), get_unordered()); else l_result := (self as ut_matcher).failure_message(a_actual) || ': '|| self.expected.to_string_report(); end if; diff --git a/source/expectations/matchers/ut_equal.tps b/source/expectations/matchers/ut_equal.tps index 710b23f7f..a17dceb1d 100644 --- a/source/expectations/matchers/ut_equal.tps +++ b/source/expectations/matchers/ut_equal.tps @@ -25,7 +25,10 @@ create or replace type ut_equal under ut_comparison_matcher( * Holds (list of columns/attributes) to incude when comparing compound types */ include_list ut_varchar2_list, + + is_unordered varchar2(5), + member procedure init(self in out nocopy ut_equal, a_expected ut_data_value, a_nulls_are_equal boolean), member function equal_with_nulls( self in ut_equal, a_assert_result boolean, a_actual ut_data_value) return boolean, constructor function ut_equal(self in out nocopy ut_equal, a_expected anydata, a_nulls_are_equal boolean := null) return self as result, @@ -49,8 +52,10 @@ create or replace type ut_equal under ut_comparison_matcher( member function include(a_items ut_varchar2_list) return ut_equal, member function exclude(a_items varchar2) return ut_equal, member function exclude(a_items ut_varchar2_list) return ut_equal, + member function unordered return ut_equal, member function get_include_xpath return varchar2, member function get_exclude_xpath return varchar2, + member function get_unordered return boolean, overriding member function run_matcher(self in out nocopy ut_equal, a_actual ut_data_value) return boolean, overriding member function failure_message(a_actual ut_data_value) return varchar2, overriding member function failure_message_when_negated(a_actual ut_data_value) return varchar2 diff --git a/source/expectations/ut_expectation_compound.tpb b/source/expectations/ut_expectation_compound.tpb index 8665af265..d08b74186 100644 --- a/source/expectations/ut_expectation_compound.tpb +++ b/source/expectations/ut_expectation_compound.tpb @@ -146,6 +146,24 @@ create or replace type body ut_expectation_compound as self.to_( treat(matcher as ut_equal).exclude(a_items) ); end if; end; + + member function unordered return ut_expectation_compound is + l_result ut_expectation_compound; + begin + l_result := self; + l_result.matcher := treat(l_result.matcher as ut_equal).unordered; + return l_result; + end; + + member procedure unordered(self in ut_expectation_compound) is + begin + + if ut_utils.int_to_boolean(negated) then + self.not_to( treat(matcher as ut_equal).unordered ); + else + self.to_( treat(matcher as ut_equal).unordered ); + end if; + end; end; / diff --git a/source/expectations/ut_expectation_compound.tps b/source/expectations/ut_expectation_compound.tps index 66dcb91af..27a0fd22d 100644 --- a/source/expectations/ut_expectation_compound.tps +++ b/source/expectations/ut_expectation_compound.tps @@ -36,8 +36,9 @@ create or replace type ut_expectation_compound under ut_expectation( member function exclude(a_items varchar2) return ut_expectation_compound, member function exclude(a_items ut_varchar2_list) return ut_expectation_compound, member procedure exclude(self in ut_expectation_compound, a_items varchar2), - member procedure exclude(self in ut_expectation_compound, a_items ut_varchar2_list) - + member procedure exclude(self in ut_expectation_compound, a_items ut_varchar2_list), + member function unordered return ut_expectation_compound, + member procedure unordered(self in ut_expectation_compound) ) final / From 41ae0ffcae54f32af259ec712a861c701f1bbf05 Mon Sep 17 00:00:00 2001 From: lwasylow Date: Tue, 24 Apr 2018 22:21:25 +0100 Subject: [PATCH 002/184] Added methods for join_by Adding compare for join by --- .../data_values/ut_compound_data_diff_tmp.sql | 8 +- .../data_values/ut_compound_data_helper.pkb | 126 +++++++++++++++--- .../data_values/ut_compound_data_helper.pks | 6 + .../data_values/ut_compound_data_tmp.sql | 5 +- .../data_values/ut_compound_data_value.tpb | 68 +++++++--- .../data_values/ut_compound_data_value.tps | 6 +- .../data_values/ut_data_value.tpb | 2 +- .../data_values/ut_data_value.tps | 2 +- .../data_values/ut_data_value_refcursor.tpb | 20 +-- .../data_values/ut_data_value_refcursor.tps | 6 +- source/expectations/matchers/ut_equal.tpb | 29 +++- source/expectations/matchers/ut_equal.tps | 12 +- .../expectations/ut_expectation_compound.tpb | 35 +++++ .../expectations/ut_expectation_compound.tps | 10 +- 14 files changed, 271 insertions(+), 64 deletions(-) diff --git a/source/expectations/data_values/ut_compound_data_diff_tmp.sql b/source/expectations/data_values/ut_compound_data_diff_tmp.sql index 881cc8082..c10226f2c 100644 --- a/source/expectations/data_values/ut_compound_data_diff_tmp.sql +++ b/source/expectations/data_values/ut_compound_data_diff_tmp.sql @@ -14,5 +14,11 @@ create global temporary table ut_compound_data_diff_tmp( */ diff_id raw(128), item_no integer, - constraint ut_compound_data_diff_tmp_pk primary key(diff_id,item_no) + item_hash raw(128), + duplicate_no integer, + --constraint ut_compound_data_diff_tmp_uk1 unique (diff_id, item_no, item_hash, duplicate_no), + constraint ut_compound_data_diff_tmp_chk check( + item_no is not null and item_hash is null and duplicate_no is null + or item_no is null and item_hash is not null and duplicate_no is not null + ) ) on commit preserve rows; diff --git a/source/expectations/data_values/ut_compound_data_helper.pkb b/source/expectations/data_values/ut_compound_data_helper.pkb index ed9e397d2..d66c7c80f 100644 --- a/source/expectations/data_values/ut_compound_data_helper.pkb +++ b/source/expectations/data_values/ut_compound_data_helper.pkb @@ -160,6 +160,79 @@ create or replace package body ut_compound_data_helper is return l_results; end; + function get_rows_diff( + a_expected_dataset_guid raw, a_actual_dataset_guid raw, a_diff_id raw, + a_max_rows integer, a_exclude_xpath varchar2, a_include_xpath varchar2, + a_join_by_xpath varchar2 + ) return tt_row_diffs is + l_column_filter varchar2(32767); + l_results tt_row_diffs; + l_sql varchar2(32767); -- REMOVE LATER also for unorder + begin + l_column_filter := get_columns_filter(a_exclude_xpath,a_include_xpath); + + /** + * Since its unordered search we cannot select max rows from diffs as we miss some comparision records + * We will restrict output on higher level of select + */ + + l_sql := q'[ + with + diff_info as (select item_hash from ut_compound_data_diff_tmp ucdc where diff_id = :diff_guid) + select rn,diff_type,diffed_row + from (select dense_rank() over (order by pk_hash) as rn, diff_type,data_item diffed_row + from (select nvl(exp.pk_hash, act.pk_hash) pk_hash, + xmlserialize(content exp.row_data no indent) exp_item, + xmlserialize(content act.row_data no indent) act_item + from + (select ucd.*, row_number() over(partition by pk_hash order by row_hash) duplicate_no + from + (select ucd.column_value row_data, + dbms_crypto.hash( value(ucd).getclobval(),3) row_hash, + dbms_crypto.hash( extract(value(ucd),']'|| a_join_by_xpath ||q'[').getClobVal(),3/*HASH_SH1*/) pk_hash + from + (select ]'||l_column_filter||q'[, ucd.item_no, ucd.item_data item_data_no_filter + from ut_compound_data_tmp ucd + where ucd.data_id = :self_guid + and ucd.item_hash in (select i.item_hash from diff_info i) + ) r, + table( xmlsequence( extract(r.item_data,'/*') ) ) ucd + ) ucd + ) exp + join ( + select ucd.*, row_number() over(partition by pk_hash order by row_hash) duplicate_no + from + (select ucd.column_value row_data, + dbms_crypto.hash( value(ucd).getclobval(),3/*HASH_SH1*/) row_hash, + dbms_crypto.hash( extract(value(ucd),']'|| a_join_by_xpath ||q'[').getClobVal(),3/*HASH_SH1*/) pk_hash + from + (select ]'||l_column_filter||q'[, ucd.item_no, ucd.item_data item_data_no_filter + from ut_compound_data_tmp ucd + where ucd.data_id = :other_guid + and ucd.item_hash in (select i.item_hash from diff_info i) + ) r, + table( xmlsequence( extract(r.item_data,'/*') ) ) ucd + ) ucd + ) act + on exp.pk_hash = act.pk_hash and exp.duplicate_no = act.duplicate_no + where exp.row_hash != act.row_hash + or exp.row_hash is null + or act.row_hash is null + ) + unpivot ( data_item for diff_type in (exp_item as 'Expected:', act_item as 'Actual:') ) + ) + where rownum < :max_rows + order by 1, 2]'; + + execute immediate l_sql + bulk collect into l_results + using a_diff_id, + a_exclude_xpath, a_include_xpath, a_expected_dataset_guid, + a_exclude_xpath, a_include_xpath, a_actual_dataset_guid, + a_max_rows; + return l_results; + end; + function get_rows_diff( a_expected_dataset_guid raw, a_actual_dataset_guid raw, a_diff_id raw, a_max_rows integer, a_exclude_xpath varchar2, a_include_xpath varchar2 @@ -237,21 +310,36 @@ create or replace package body ut_compound_data_helper is l_results tt_row_diffs; begin l_column_filter := get_columns_filter(a_exclude_xpath,a_include_xpath); - execute immediate q'[ - select - coalesce(exp.duplicate_no, act.duplicate_no) duplicate_no, - case when exp.row_hash is null then 'Actual:' else 'Expected:' end diffed_type, - case when exp.row_hash is null then - xmlserialize(content act.row_data no indent) - else - xmlserialize(content exp.row_data no indent) - end diffed_row - from (select ucd.*, row_number() over(partition by row_hash order by row_hash) duplicate_no + + /** + * Since its unordered search we cannot select max rows from diffs as we miss some comparision records + * We will restrict output on higher level of select + */ + execute immediate q'[with + diff_info as (select item_hash from ut_compound_data_diff_tmp ucdc where diff_id = :diff_guid) + select duplicate_no, + diffed_type, + diffed_row + from + (select + coalesce(exp.duplicate_no,act.duplicate_no) duplicate_no, + case + when act.row_hash is null then + 'miss row' + else 'extra row' + end diffed_type, + case when exp.row_hash is null then + xmlserialize(content act.row_data no indent) + when act.row_hash is null then + xmlserialize(content exp.row_data no indent) + end diffed_row + from (select ucd.*, row_number() over(partition by row_hash order by row_hash) duplicate_no from (select ucd.column_value row_data, dbms_crypto.hash( value(ucd).getclobval(),3) row_hash - from (select ]'||l_column_filter||q'[, ucd.item_no, ucd.item_data item_data_no_filter + from (select ]'||l_column_filter||q'[, ucd.item_no, ucd.item_data item_data_no_filter from ut_compound_data_tmp ucd where ucd.data_id = :self_guid + and ucd.item_hash in (select i.item_hash from diff_info i) ) r, table( xmlsequence( extract(r.item_data,'/*') ) ) ucd ) ucd @@ -260,21 +348,23 @@ create or replace package body ut_compound_data_helper is (select ucd.*, row_number() over(partition by row_hash order by row_hash) duplicate_no from (select ucd.column_value row_data, dbms_crypto.hash( value(ucd).getclobval(),3/*HASH_SH1*/) row_hash - from (select ]'||l_column_filter||q'[, ucd.item_no, ucd.item_data item_data_no_filter + from (select ]'||l_column_filter||q'[, ucd.item_no, ucd.item_data item_data_no_filter from ut_compound_data_tmp ucd where ucd.data_id = :other_guid + and ucd.item_hash in (select i.item_hash from diff_info i) ) r, table( xmlsequence( extract(r.item_data,'/*') ) ) ucd ) ucd ) act - on exp.row_hash = act.row_hash - and exp.duplicate_no = act.duplicate_no - where exp.row_hash is null or act.row_hash is null]' + on exp.row_hash = act.row_hash + and exp.duplicate_no = act.duplicate_no + where exp.row_hash is null or act.row_hash is null ) where rownum < :max_rows ]' bulk collect into l_results - using a_exclude_xpath, a_include_xpath, a_expected_dataset_guid, - a_exclude_xpath, a_include_xpath, a_actual_dataset_guid; + using a_diff_id, + a_exclude_xpath, a_include_xpath, a_expected_dataset_guid, + a_exclude_xpath, a_include_xpath, a_actual_dataset_guid, + a_max_rows; - --execute immediate 'create table test as select * from ut_compound_data_tmp'; return l_results; end; diff --git a/source/expectations/data_values/ut_compound_data_helper.pks b/source/expectations/data_values/ut_compound_data_helper.pks index ae9b2a044..3f8595233 100644 --- a/source/expectations/data_values/ut_compound_data_helper.pks +++ b/source/expectations/data_values/ut_compound_data_helper.pks @@ -52,6 +52,12 @@ create or replace package ut_compound_data_helper authid definer is a_max_rows integer, a_exclude_xpath varchar2, a_include_xpath varchar2 ) return tt_row_diffs; + function get_rows_diff( + a_expected_dataset_guid raw, a_actual_dataset_guid raw, a_diff_id raw, + a_max_rows integer, a_exclude_xpath varchar2, a_include_xpath varchar2, + a_join_by_xpath varchar2 + ) return tt_row_diffs; + function get_rows_diff_unordered( a_expected_dataset_guid raw, a_actual_dataset_guid raw, a_diff_id raw, a_max_rows integer, a_exclude_xpath varchar2, a_include_xpath varchar2 diff --git a/source/expectations/data_values/ut_compound_data_tmp.sql b/source/expectations/data_values/ut_compound_data_tmp.sql index 300b0fd38..8af8083ef 100644 --- a/source/expectations/data_values/ut_compound_data_tmp.sql +++ b/source/expectations/data_values/ut_compound_data_tmp.sql @@ -15,5 +15,8 @@ create global temporary table ut_compound_data_tmp( data_id raw(32), item_no integer, item_data xmltype, - constraint ut_compound_data_tmp_pk primary key(data_id, item_no) + item_hash raw(128), + duplicate_no integer + --constraint ut_cmp_data_tmp_item_ak unique (data_id, item_no), + --constraint ut_cmp_data_tmp_hash_pk unique (data_id, item_hash , duplicate_no) ) on commit preserve rows; diff --git a/source/expectations/data_values/ut_compound_data_value.tpb b/source/expectations/data_values/ut_compound_data_value.tpb index 8a5fb2ab3..cd3af7ac4 100644 --- a/source/expectations/data_values/ut_compound_data_value.tpb +++ b/source/expectations/data_values/ut_compound_data_value.tpb @@ -71,11 +71,17 @@ create or replace type body ut_compound_data_value as return l_result_string; end; - overriding member function diff( a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2, a_unordered boolean := false ) return varchar2 is + overriding member function diff( a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2, a_join_by_xpath varchar2, a_unordered boolean := false ) return varchar2 is l_result clob; l_result_string varchar2(32767); begin - l_result := get_data_diff(a_other, a_exclude_xpath, a_include_xpath, a_unordered); + if a_join_by_xpath is not null then + l_result := get_data_diff(a_other, a_exclude_xpath, a_include_xpath, a_join_by_xpath); + elsif a_unordered then + l_result := get_data_diff(a_other, a_exclude_xpath, a_include_xpath, a_unordered); + else + l_result := get_data_diff(a_other, a_exclude_xpath, a_include_xpath, a_join_by_xpath); + end if; l_result_string := ut_utils.to_string(l_result,null); dbms_lob.freetemporary(l_result); return l_result_string; @@ -102,8 +108,8 @@ create or replace type body ut_compound_data_value as --diff rows and row elements l_diff_id := ut_compound_data_helper.get_hash(self.data_id||l_actual.data_id); -- First tell how many rows are different - execute immediate 'select unordered_cnt from ' || l_ut_owner || '.ut_compound_data_diff_tmp where diff_id = :diff_id' into l_diff_row_count using l_diff_id; - + execute immediate 'select count(*) from ' || l_ut_owner || '.ut_compound_data_diff_tmp where diff_id = :diff_id' into l_diff_row_count using l_diff_id; + if l_diff_row_count > 0 then l_row_diffs := ut_compound_data_helper.get_rows_diff_unordered( self.data_id, l_actual.data_id, l_diff_id, c_max_rows, a_exclude_xpath, a_include_xpath @@ -118,14 +124,14 @@ create or replace type body ut_compound_data_value as for i in 1 .. l_row_diffs.count loop l_results.extend; l_results(l_results.last) := - ' Row Appeared '||l_row_diffs(i).rn||' - '||rpad(l_row_diffs(i).diff_type,10)||l_row_diffs(i).diffed_row; + rpad(l_row_diffs(i).diff_type,10)||l_row_diffs(i).diffed_row; end loop; ut_utils.append_to_clob(l_result,l_results); end if; return l_result; end; - member function get_data_diff( a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2 ) return clob is + member function get_data_diff( a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2, a_join_by_xpath varchar2) return clob is c_max_rows constant integer := 20; l_result clob; l_results ut_utils.t_clob_tab := ut_utils.t_clob_tab(); @@ -149,9 +155,15 @@ create or replace type body ut_compound_data_value as execute immediate 'select count(*) from ' || l_ut_owner || '.ut_compound_data_diff_tmp where diff_id = :diff_id' into l_diff_row_count using l_diff_id; if l_diff_row_count > 0 then - l_row_diffs := ut_compound_data_helper.get_rows_diff( + if a_join_by_xpath is not null then + l_row_diffs := ut_compound_data_helper.get_rows_diff( + self.data_id, l_actual.data_id, l_diff_id, c_max_rows, a_exclude_xpath, a_include_xpath, a_join_by_xpath + ); + else + l_row_diffs := ut_compound_data_helper.get_rows_diff( self.data_id, l_actual.data_id, l_diff_id, c_max_rows, a_exclude_xpath, a_include_xpath - ); + ); + end if; l_message := chr(10) ||'Rows: [ ' || l_diff_row_count ||' differences' || case when l_diff_row_count > c_max_rows and l_row_diffs.count > 0 then ', showing first '||c_max_rows end @@ -224,7 +236,7 @@ create or replace type body ut_compound_data_value as return l_result; end; -member function compare_implementation(a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2, a_unordered boolean ) return integer is + member function compare_implementation(a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2, a_join_by_xpath varchar2, a_unordered boolean ) return integer is l_other ut_compound_data_value; l_ut_owner varchar2(250) := ut_utils.ut_owner; l_column_filter varchar2(32767); @@ -241,16 +253,36 @@ member function compare_implementation(a_other ut_data_value, a_exclude_xpath va l_diff_id := ut_compound_data_helper.get_hash(self.data_id||l_other.data_id); l_column_filter := ut_compound_data_helper.get_columns_filter(a_exclude_xpath, a_include_xpath); - - -- Find differences - l_row_diffs := ut_compound_data_helper.get_rows_diff_unordered( - self.data_id, l_other.data_id, l_diff_id, c_max_rows, a_exclude_xpath, a_include_xpath - ); - - execute immediate 'insert into ' || l_ut_owner || '.ut_compound_data_diff_tmp ( diff_id, unordered_cnt ) - values (:diff_id, nvl(:unordered_cnt,0))' using l_diff_id, l_row_diffs.count; + + -- Pre generate hash minus to leave only onese that are diffrent, for example duplicates or diffrent hash + execute immediate 'insert into ' || l_ut_owner || '.ut_compound_data_diff_tmp ( diff_id,item_hash,duplicate_no ) + select :diff_id,x.item_hash,tmp.duplicate_no + from( + ( + select item_hash,row_number() over (partition by item_hash,data_id order by 1) duplicate_no + from ut_compound_data_tmp + where data_id = :self_guid + minus + select item_hash,row_number() over (partition by item_hash,data_id order by 1) + from ut_compound_data_tmp + where data_id = :other_guid + ) + union all + ( + select item_hash,row_number() over (partition by item_hash,data_id order by 1) + from ut_compound_data_tmp + where data_id = :other_guid + minus + select item_hash,row_number() over (partition by item_hash,data_id order by 1) + from ut_compound_data_tmp + where data_id = :self_guid + ))tmp + ,ut_compound_data_tmp x + where tmp.item_hash = x.item_hash' + using l_diff_id, self.data_id, l_other.data_id + ,l_other.data_id,self.data_id; --result is OK only if both are same - if l_row_diffs.count = 0 and self.elements_count = l_other.elements_count then + if sql%rowcount = 0 and self.elements_count = l_other.elements_count then l_result := 0; else l_result := 1; diff --git a/source/expectations/data_values/ut_compound_data_value.tps b/source/expectations/data_values/ut_compound_data_value.tps index d2345c01e..cc192bbc3 100644 --- a/source/expectations/data_values/ut_compound_data_value.tps +++ b/source/expectations/data_values/ut_compound_data_value.tps @@ -42,10 +42,10 @@ create or replace type ut_compound_data_value force under ut_data_value( overriding member function to_string return varchar2, overriding member function is_multi_line return boolean, overriding member function compare_implementation(a_other ut_data_value) return integer, - overriding member function diff( a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2, a_unordered boolean := false ) return varchar2, + overriding member function diff( a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2, a_join_by_xpath varchar2, a_unordered boolean := false ) return varchar2, member function get_data_diff( a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2, a_unordered boolean ) return clob, - member function get_data_diff( a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2 ) return clob, + member function get_data_diff( a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2, a_join_by_xpath varchar2 ) return clob, member function compare_implementation(a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2) return integer, - member function compare_implementation(a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2, a_unordered boolean ) return integer + member function compare_implementation(a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2, a_join_by_xpath varchar2, a_unordered boolean ) return integer ) not final not instantiable / diff --git a/source/expectations/data_values/ut_data_value.tpb b/source/expectations/data_values/ut_data_value.tpb index 8bc3a87aa..d5ec11092 100644 --- a/source/expectations/data_values/ut_data_value.tpb +++ b/source/expectations/data_values/ut_data_value.tpb @@ -25,7 +25,7 @@ create or replace type body ut_data_value as return false; end; - member function diff( a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2, a_unordered boolean :=false ) return varchar2 is + member function diff( a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2, a_join_by_xpath varchar2, a_unordered boolean :=false ) return varchar2 is begin return null; end; diff --git a/source/expectations/data_values/ut_data_value.tps b/source/expectations/data_values/ut_data_value.tps index c9ae28d5e..79ac4eef9 100644 --- a/source/expectations/data_values/ut_data_value.tps +++ b/source/expectations/data_values/ut_data_value.tps @@ -24,7 +24,7 @@ create or replace type ut_data_value force authid current_user as object ( final member function to_string_report(a_add_new_line_for_multi_line boolean := false, a_with_object_info boolean := true) return varchar2, order member function compare( a_other ut_data_value ) return integer, member function is_diffable return boolean, - member function diff( a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2, a_unordered boolean := false ) return varchar2, + member function diff( a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2, a_join_by_xpath varchar2, a_unordered boolean := false ) return varchar2, not instantiable member function compare_implementation( a_other ut_data_value ) return integer ) not final not instantiable / diff --git a/source/expectations/data_values/ut_data_value_refcursor.tpb b/source/expectations/data_values/ut_data_value_refcursor.tpb index 5df2c76eb..cabe18011 100644 --- a/source/expectations/data_values/ut_data_value_refcursor.tpb +++ b/source/expectations/data_values/ut_data_value_refcursor.tpb @@ -60,8 +60,8 @@ create or replace type body ut_data_value_refcursor as l_xml := dbms_xmlgen.getxmltype(l_ctx); execute immediate - 'insert into ' || l_ut_owner || '.ut_compound_data_tmp(data_id, item_no, item_data) ' || - 'select :self_guid, :self_row_count + rownum, value(a) ' || + 'insert into ' || l_ut_owner || '.ut_compound_data_tmp(data_id, item_no, item_data, item_hash) ' || + 'select :self_guid, :self_row_count + rownum, value(a), dbms_crypto.hash( value(a).getclobval(),3)' || ' from table( xmlsequence( extract(:l_xml,''ROWSET/*'') ) ) a' using in self.data_id, self.elements_count, l_xml; @@ -69,7 +69,7 @@ create or replace type body ut_data_value_refcursor as self.elements_count := self.elements_count + sql%rowcount; end loop; - + ut_expectation_processor.reset_nls_params(); if l_cursor%isopen then close l_cursor; @@ -108,7 +108,7 @@ create or replace type body ut_data_value_refcursor as return l_result_string; end; - overriding member function diff( a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2, a_unordered boolean := false ) return varchar2 is + overriding member function diff( a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2, a_join_by_xpath varchar2, a_unordered boolean := false ) return varchar2 is l_result clob; l_results ut_utils.t_clob_tab := ut_utils.t_clob_tab(); l_result_string varchar2(32767); @@ -176,10 +176,12 @@ create or replace type body ut_data_value_refcursor as end if; --diff rows and row elements - if a_unordered then + if a_join_by_xpath is not null then + ut_utils.append_to_clob(l_result, self.get_data_diff(a_other, a_exclude_xpath, a_include_xpath, a_join_by_xpath)); + elsif a_unordered then ut_utils.append_to_clob(l_result, self.get_data_diff(a_other, l_exclude_xpath, a_include_xpath, a_unordered)); else - ut_utils.append_to_clob(l_result, self.get_data_diff(a_other, l_exclude_xpath, a_include_xpath)); + ut_utils.append_to_clob(l_result, self.get_data_diff(a_other, l_exclude_xpath, a_include_xpath, a_join_by_xpath)); end if; l_result_string := ut_utils.to_string(l_result,null); @@ -196,7 +198,6 @@ create or replace type body ut_data_value_refcursor as end if; l_other := treat(a_other as ut_data_value_refcursor); - --if column names/types are not equal - build a diff of column names and types if ut_compound_data_helper.columns_hash( self, a_exclude_xpath, a_include_xpath ) != ut_compound_data_helper.columns_hash( l_other, a_exclude_xpath, a_include_xpath ) @@ -207,7 +208,7 @@ create or replace type body ut_data_value_refcursor as return l_result; end; - overriding member function compare_implementation (a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2, a_unordered boolean) return integer is + overriding member function compare_implementation (a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2, a_join_by_xpath varchar2, a_unordered boolean) return integer is l_result integer := 0; l_other ut_data_value_refcursor; begin @@ -216,14 +217,13 @@ create or replace type body ut_data_value_refcursor as end if; l_other := treat(a_other as ut_data_value_refcursor); - --if column names/types are not equal - build a diff of column names and types if ut_compound_data_helper.columns_hash( self, a_exclude_xpath, a_include_xpath ) != ut_compound_data_helper.columns_hash( l_other, a_exclude_xpath, a_include_xpath ) then l_result := 1; end if; - l_result := l_result + (self as ut_compound_data_value).compare_implementation(a_other, a_exclude_xpath, a_include_xpath, a_unordered); + l_result := l_result + (self as ut_compound_data_value).compare_implementation(a_other, a_exclude_xpath, a_include_xpath, a_join_by_xpath, a_unordered); return l_result; end; diff --git a/source/expectations/data_values/ut_data_value_refcursor.tps b/source/expectations/data_values/ut_data_value_refcursor.tps index 679030fe5..af0609bb6 100644 --- a/source/expectations/data_values/ut_data_value_refcursor.tps +++ b/source/expectations/data_values/ut_data_value_refcursor.tps @@ -33,9 +33,9 @@ create or replace type ut_data_value_refcursor under ut_compound_data_value( constructor function ut_data_value_refcursor(self in out nocopy ut_data_value_refcursor, a_value sys_refcursor) return self as result, member procedure init(self in out nocopy ut_data_value_refcursor, a_value sys_refcursor), overriding member function to_string return varchar2, - overriding member function diff( a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2, a_unordered boolean := false ) return varchar2, + overriding member function diff( a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2, a_join_by_xpath varchar2, a_unordered boolean := false ) return varchar2, overriding member function compare_implementation(a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2) return integer, - overriding member function compare_implementation(a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2, a_unordered boolean) return integer + overriding member function compare_implementation(a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2, a_join_by_xpath varchar2, a_unordered boolean) return integer ) -/ +/ \ No newline at end of file diff --git a/source/expectations/matchers/ut_equal.tpb b/source/expectations/matchers/ut_equal.tpb index 09b1b7e5e..f9e6baaeb 100644 --- a/source/expectations/matchers/ut_equal.tpb +++ b/source/expectations/matchers/ut_equal.tpb @@ -23,6 +23,7 @@ create or replace type body ut_equal as self.expected := a_expected; self.include_list := ut_varchar2_list(); self.exclude_list := ut_varchar2_list(); + self.join_columns := ut_varchar2_list(); end; member function equal_with_nulls(a_assert_result boolean, a_actual ut_data_value) return boolean is @@ -185,7 +186,23 @@ create or replace type body ut_equal as member function unordered return ut_equal is l_result ut_equal := self; begin - l_result.is_unordered := 'true'; + l_result.is_unordered := ut_utils.boolean_to_int(true); + return l_result; + end; + + member function join_by(a_columns varchar2) return ut_equal is + l_result ut_equal := self; + begin + l_result.is_unordered := ut_utils.boolean_to_int(true); + ut_utils.append_to_list(l_result.join_columns, a_columns); + return l_result; + end; + + member function join_by(a_columns ut_varchar2_list) return ut_equal is + l_result ut_equal := self; + begin + l_result.is_unordered := ut_utils.boolean_to_int(true); + l_result.join_columns := l_result.join_columns multiset union all coalesce(a_columns,ut_varchar2_list()); return l_result; end; @@ -201,9 +218,13 @@ create or replace type body ut_equal as member function get_unordered return boolean is begin - return case when is_unordered = 'true' then true else false end; + return ut_utils.int_to_boolean(nvl(is_unordered,0)); end; + member function get_join_by_xpath return varchar2 is + begin + return ut_utils.to_xpath( coalesce(join_columns, ut_varchar2_list()) ); + end; overriding member function run_matcher(self in out nocopy ut_equal, a_actual ut_data_value) return boolean is l_result boolean; @@ -213,7 +234,7 @@ create or replace type body ut_equal as l_result := 0 = treat(self.expected as ut_data_value_anydata).compare_implementation(a_actual, get_exclude_xpath(), get_include_xpath()); elsif self.expected is of (ut_data_value_refcursor) then if get_unordered then - l_result := 0 = treat(self.expected as ut_data_value_refcursor).compare_implementation(a_actual, get_exclude_xpath(), get_include_xpath(),get_unordered()); + l_result := 0 = treat(self.expected as ut_data_value_refcursor).compare_implementation(a_actual, get_exclude_xpath(), get_include_xpath(), get_join_by_xpath(), get_unordered()); else l_result := 0 = treat(self.expected as ut_data_value_refcursor).compare_implementation(a_actual, get_exclude_xpath(), get_include_xpath()); end if; @@ -233,7 +254,7 @@ create or replace type body ut_equal as if self.expected.data_type = a_actual.data_type and self.expected.is_diffable then l_result := 'Actual: '||a_actual.get_object_info()||' '||self.description()||': '||self.expected.get_object_info() - || chr(10) || 'Diff:' || expected.diff(a_actual, get_exclude_xpath(), get_include_xpath(), get_unordered()); + || chr(10) || 'Diff:' || expected.diff(a_actual, get_exclude_xpath(), get_include_xpath(), get_join_by_xpath(), get_unordered()); else l_result := (self as ut_matcher).failure_message(a_actual) || ': '|| self.expected.to_string_report(); end if; diff --git a/source/expectations/matchers/ut_equal.tps b/source/expectations/matchers/ut_equal.tps index a17dceb1d..01b1d2e1e 100644 --- a/source/expectations/matchers/ut_equal.tps +++ b/source/expectations/matchers/ut_equal.tps @@ -26,8 +26,15 @@ create or replace type ut_equal under ut_comparison_matcher( */ include_list ut_varchar2_list, - is_unordered varchar2(5), + /** + * Holds value if comparision on refcursor to be performed as unordered set + */ + is_unordered number(1,0), + /** + * Holds list of columns to be used as a join PK on sys_refcursor comparision + */ + join_columns ut_varchar2_list, member procedure init(self in out nocopy ut_equal, a_expected ut_data_value, a_nulls_are_equal boolean), member function equal_with_nulls( self in ut_equal, a_assert_result boolean, a_actual ut_data_value) return boolean, @@ -53,9 +60,12 @@ create or replace type ut_equal under ut_comparison_matcher( member function exclude(a_items varchar2) return ut_equal, member function exclude(a_items ut_varchar2_list) return ut_equal, member function unordered return ut_equal, + member function join_by(a_columns varchar2) return ut_equal, + member function join_by(a_columns ut_varchar2_list) return ut_equal, member function get_include_xpath return varchar2, member function get_exclude_xpath return varchar2, member function get_unordered return boolean, + member function get_join_by_xpath return varchar2, overriding member function run_matcher(self in out nocopy ut_equal, a_actual ut_data_value) return boolean, overriding member function failure_message(a_actual ut_data_value) return varchar2, overriding member function failure_message_when_negated(a_actual ut_data_value) return varchar2 diff --git a/source/expectations/ut_expectation_compound.tpb b/source/expectations/ut_expectation_compound.tpb index d08b74186..dea146bd2 100644 --- a/source/expectations/ut_expectation_compound.tpb +++ b/source/expectations/ut_expectation_compound.tpb @@ -165,5 +165,40 @@ create or replace type body ut_expectation_compound as end if; end; + member function join_by(a_columns varchar2) return ut_expectation_compound is + l_result ut_expectation_compound; + begin + l_result := self; + l_result.matcher := treat(l_result.matcher as ut_equal).join_by(a_columns); + return l_result; + end; + + member function join_by(a_columns ut_varchar2_list) return ut_expectation_compound is + l_result ut_expectation_compound; + begin + l_result := self; + l_result.matcher := treat(l_result.matcher as ut_equal).join_by(a_columns); + return l_result; + end; + + member procedure join_by(self in ut_expectation_compound, a_columns varchar2) is + begin + if ut_utils.int_to_boolean(negated) then + self.not_to( treat(matcher as ut_equal).join_by(a_columns) ); + else + self.to_( treat(matcher as ut_equal).join_by(a_columns) ); + end if; + end; + + member procedure join_by(self in ut_expectation_compound, a_columns ut_varchar2_list) is + begin + + if ut_utils.int_to_boolean(negated) then + self.not_to( treat(matcher as ut_equal).join_by(a_columns) ); + else + self.to_( treat(matcher as ut_equal).join_by(a_columns) ); + end if; + end; + end; / diff --git a/source/expectations/ut_expectation_compound.tps b/source/expectations/ut_expectation_compound.tps index 27a0fd22d..967706a21 100644 --- a/source/expectations/ut_expectation_compound.tps +++ b/source/expectations/ut_expectation_compound.tps @@ -37,8 +37,12 @@ create or replace type ut_expectation_compound under ut_expectation( member function exclude(a_items ut_varchar2_list) return ut_expectation_compound, member procedure exclude(self in ut_expectation_compound, a_items varchar2), member procedure exclude(self in ut_expectation_compound, a_items ut_varchar2_list), - member function unordered return ut_expectation_compound, - member procedure unordered(self in ut_expectation_compound) + member function unordered return ut_expectation_compound, + member procedure unordered(self in ut_expectation_compound), + member function join_by(a_columns varchar2) return ut_expectation_compound, + member function join_by(a_columns ut_varchar2_list) return ut_expectation_compound, + member procedure join_by(self in ut_expectation_compound, a_columns varchar2), + member procedure join_by(self in ut_expectation_compound, a_columns ut_varchar2_list) ) final -/ +/ \ No newline at end of file From f504ed99479a0736056143ed4cb600bbd70098a2 Mon Sep 17 00:00:00 2001 From: Jacek Gebal Date: Sun, 29 Apr 2018 21:17:10 +0100 Subject: [PATCH 003/184] Updated version. --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 903cd9f2a..d95827c3d 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v3.1.1 +v3.1.2 From bd78b6fec31f644c75df56c22482d159a952c6c4 Mon Sep 17 00:00:00 2001 From: Travis CI Date: Sun, 29 Apr 2018 20:28:39 +0000 Subject: [PATCH 004/184] Updated project version after build [skip ci] --- VERSION | 2 +- sonar-project.properties | 2 +- source/core/ut_utils.pks | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/VERSION b/VERSION index d95827c3d..82228f380 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v3.1.2 +v3.1.2-develop diff --git a/sonar-project.properties b/sonar-project.properties index d9f7adabd..dc0f7633d 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -2,7 +2,7 @@ sonar.projectKey=utPLSQL # this is the name and version displayed in the SonarQube UI. Was mandatory prior to SonarQube 6.1. sonar.projectName=utPLSQL -sonar.projectVersion=v3.1.1 +sonar.projectVersion=v3.1.2-develop # Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. # Since SonarQube 4.2, this property is optional if sonar.modules is set. diff --git a/source/core/ut_utils.pks b/source/core/ut_utils.pks index 166ce01ec..c69d1c4fe 100644 --- a/source/core/ut_utils.pks +++ b/source/core/ut_utils.pks @@ -21,7 +21,7 @@ create or replace package ut_utils authid definer is * */ - gc_version constant varchar2(50) := 'v3.1.1.1865'; + gc_version constant varchar2(50) := 'v3.1.2.1869-develop'; /* Constants: Event names */ subtype t_event_name is varchar2(30); From a3406eec8ecc7e3d4596e7f5a25a90d829796af5 Mon Sep 17 00:00:00 2001 From: lwasylow Date: Thu, 3 May 2018 08:47:29 +0100 Subject: [PATCH 005/184] Updated JoinBy query --- .../data_values/ut_compound_data_helper.pkb | 116 ++++++++++-------- .../data_values/ut_compound_data_value.tpb | 12 +- .../data_values/ut_data_value_refcursor.tpb | 2 +- 3 files changed, 70 insertions(+), 60 deletions(-) diff --git a/source/expectations/data_values/ut_compound_data_helper.pkb b/source/expectations/data_values/ut_compound_data_helper.pkb index d66c7c80f..df5f5453b 100644 --- a/source/expectations/data_values/ut_compound_data_helper.pkb +++ b/source/expectations/data_values/ut_compound_data_helper.pkb @@ -167,68 +167,76 @@ create or replace package body ut_compound_data_helper is ) return tt_row_diffs is l_column_filter varchar2(32767); l_results tt_row_diffs; - l_sql varchar2(32767); -- REMOVE LATER also for unorder begin l_column_filter := get_columns_filter(a_exclude_xpath,a_include_xpath); /** * Since its unordered search we cannot select max rows from diffs as we miss some comparision records * We will restrict output on higher level of select - */ + **/ - l_sql := q'[ - with - diff_info as (select item_hash from ut_compound_data_diff_tmp ucdc where diff_id = :diff_guid) + execute immediate q'[ + with diff_info as (select item_hash from ut_compound_data_diff_tmp ucdc where diff_id = :diff_guid) select rn,diff_type,diffed_row - from (select dense_rank() over (order by pk_hash) as rn, diff_type,data_item diffed_row - from (select nvl(exp.pk_hash, act.pk_hash) pk_hash, - xmlserialize(content exp.row_data no indent) exp_item, - xmlserialize(content act.row_data no indent) act_item - from - (select ucd.*, row_number() over(partition by pk_hash order by row_hash) duplicate_no - from - (select ucd.column_value row_data, - dbms_crypto.hash( value(ucd).getclobval(),3) row_hash, - dbms_crypto.hash( extract(value(ucd),']'|| a_join_by_xpath ||q'[').getClobVal(),3/*HASH_SH1*/) pk_hash - from - (select ]'||l_column_filter||q'[, ucd.item_no, ucd.item_data item_data_no_filter - from ut_compound_data_tmp ucd - where ucd.data_id = :self_guid - and ucd.item_hash in (select i.item_hash from diff_info i) - ) r, - table( xmlsequence( extract(r.item_data,'/*') ) ) ucd - ) ucd - ) exp - join ( - select ucd.*, row_number() over(partition by pk_hash order by row_hash) duplicate_no - from - (select ucd.column_value row_data, - dbms_crypto.hash( value(ucd).getclobval(),3/*HASH_SH1*/) row_hash, - dbms_crypto.hash( extract(value(ucd),']'|| a_join_by_xpath ||q'[').getClobVal(),3/*HASH_SH1*/) pk_hash - from - (select ]'||l_column_filter||q'[, ucd.item_no, ucd.item_data item_data_no_filter - from ut_compound_data_tmp ucd - where ucd.data_id = :other_guid - and ucd.item_hash in (select i.item_hash from diff_info i) - ) r, - table( xmlsequence( extract(r.item_data,'/*') ) ) ucd - ) ucd - ) act - on exp.pk_hash = act.pk_hash and exp.duplicate_no = act.duplicate_no - where exp.row_hash != act.row_hash - or exp.row_hash is null - or act.row_hash is null - ) - unpivot ( data_item for diff_type in (exp_item as 'Expected:', act_item as 'Actual:') ) - ) - where rownum < :max_rows - order by 1, 2]'; - - execute immediate l_sql + from + (select dense_rank() over (order by pk_hash) as rn, diff_type,data_item diffed_row + from + (select pk_hash + ,case when exp_item is not null and act_item is not null then exp_item else null end exp_item + ,case when exp_item is not null and act_item is not null then act_item else null end act_item + ,case when exp_item is not null and act_item is null then exp_item else null end miss_item + ,case when exp_item is null and act_item is not null then act_item else null end ext_item + from + (select nvl(exp.pk_hash, act.pk_hash) pk_hash, + xmlserialize(content exp.row_data no indent) exp_item, + xmlserialize(content act.row_data no indent) act_item + from + (select ucd.*, row_number() over(partition by pk_hash order by row_hash) duplicate_no + from + (select ucd.column_value row_data, + dbms_crypto.hash( value(ucd).getclobval(),3) row_hash, + dbms_crypto.hash( extract(value(ucd), :join_by_xpath ).getClobVal(),3/*HASH_SH1*/) pk_hash + from + (select ]'||l_column_filter||q'[, ucd.item_no, ucd.item_data item_data_no_filter + from ut_compound_data_tmp ucd + where ucd.data_id = :self_guid + and ucd.item_hash in (select i.item_hash from diff_info i) + ) r, + table( xmlsequence( extract(r.item_data,'/*') ) ) ucd + ) ucd + ) exp + full outer join ( + select ucd.*, row_number() over(partition by pk_hash order by row_hash) duplicate_no + from + (select ucd.column_value row_data, + dbms_crypto.hash( value(ucd).getclobval(),3/*HASH_SH1*/) row_hash, + dbms_crypto.hash( extract(value(ucd), :join_by_xpath ).getClobVal(),3/*HASH_SH1*/) pk_hash + from + (select ]'||l_column_filter||q'[, ucd.item_no, ucd.item_data item_data_no_filter + from ut_compound_data_tmp ucd + where ucd.data_id = :other_guid + and ucd.item_hash in (select i.item_hash from diff_info i) + ) r, + table( xmlsequence( extract(r.item_data,'/*') ) ) ucd + ) ucd + ) act + on exp.pk_hash = act.pk_hash and exp.duplicate_no = act.duplicate_no + where (exp.row_hash != act.row_hash and act.pk_hash = exp.pk_hash) or + ( + (exp.pk_hash is null or act.pk_hash is null) and + (exp.row_hash is null or act.row_hash is null) + ) + ) + ) + unpivot ( data_item for diff_type in (exp_item as 'Expected:', act_item as 'Actual:' + ,miss_item as 'Missing:', ext_item as 'Extra:') ) + ) + where rownum <= :max_rows + order by 1, 2]' bulk collect into l_results using a_diff_id, - a_exclude_xpath, a_include_xpath, a_expected_dataset_guid, - a_exclude_xpath, a_include_xpath, a_actual_dataset_guid, + a_join_by_xpath,a_exclude_xpath, a_include_xpath, a_expected_dataset_guid, + a_join_by_xpath,a_exclude_xpath, a_include_xpath, a_actual_dataset_guid, a_max_rows; return l_results; end; @@ -325,8 +333,8 @@ create or replace package body ut_compound_data_helper is coalesce(exp.duplicate_no,act.duplicate_no) duplicate_no, case when act.row_hash is null then - 'miss row' - else 'extra row' + 'Missing:' + else 'Extra:' end diffed_type, case when exp.row_hash is null then xmlserialize(content act.row_data no indent) diff --git a/source/expectations/data_values/ut_compound_data_value.tpb b/source/expectations/data_values/ut_compound_data_value.tpb index cd3af7ac4..6228b31fe 100644 --- a/source/expectations/data_values/ut_compound_data_value.tpb +++ b/source/expectations/data_values/ut_compound_data_value.tpb @@ -155,10 +155,10 @@ create or replace type body ut_compound_data_value as execute immediate 'select count(*) from ' || l_ut_owner || '.ut_compound_data_diff_tmp where diff_id = :diff_id' into l_diff_row_count using l_diff_id; if l_diff_row_count > 0 then - if a_join_by_xpath is not null then + if a_join_by_xpath is not null then l_row_diffs := ut_compound_data_helper.get_rows_diff( self.data_id, l_actual.data_id, l_diff_id, c_max_rows, a_exclude_xpath, a_include_xpath, a_join_by_xpath - ); + ); else l_row_diffs := ut_compound_data_helper.get_rows_diff( self.data_id, l_actual.data_id, l_diff_id, c_max_rows, a_exclude_xpath, a_include_xpath @@ -253,7 +253,7 @@ create or replace type body ut_compound_data_value as l_diff_id := ut_compound_data_helper.get_hash(self.data_id||l_other.data_id); l_column_filter := ut_compound_data_helper.get_columns_filter(a_exclude_xpath, a_include_xpath); - + -- Pre generate hash minus to leave only onese that are diffrent, for example duplicates or diffrent hash execute immediate 'insert into ' || l_ut_owner || '.ut_compound_data_diff_tmp ( diff_id,item_hash,duplicate_no ) select :diff_id,x.item_hash,tmp.duplicate_no @@ -278,9 +278,11 @@ create or replace type body ut_compound_data_value as where data_id = :self_guid ))tmp ,ut_compound_data_tmp x - where tmp.item_hash = x.item_hash' + where tmp.item_hash = x.item_hash + and x.data_id in (:self_guid,:other_guid)' using l_diff_id, self.data_id, l_other.data_id - ,l_other.data_id,self.data_id; + ,l_other.data_id,self.data_id, + self.data_id, l_other.data_id; --result is OK only if both are same if sql%rowcount = 0 and self.elements_count = l_other.elements_count then l_result := 0; diff --git a/source/expectations/data_values/ut_data_value_refcursor.tpb b/source/expectations/data_values/ut_data_value_refcursor.tpb index cabe18011..d9edf4132 100644 --- a/source/expectations/data_values/ut_data_value_refcursor.tpb +++ b/source/expectations/data_values/ut_data_value_refcursor.tpb @@ -61,7 +61,7 @@ create or replace type body ut_data_value_refcursor as execute immediate 'insert into ' || l_ut_owner || '.ut_compound_data_tmp(data_id, item_no, item_data, item_hash) ' || - 'select :self_guid, :self_row_count + rownum, value(a), dbms_crypto.hash( value(a).getclobval(),3)' || + 'select :self_guid, :self_row_count + rownum, value(a), ut_compound_data_helper.get_hash(value(a).GetClobVal())' || ' from table( xmlsequence( extract(:l_xml,''ROWSET/*'') ) ) a' using in self.data_id, self.elements_count, l_xml; From 3ca16f7bdcb17c03eaad132c7f76d32dd4b359f5 Mon Sep 17 00:00:00 2001 From: lwasylow Date: Thu, 3 May 2018 08:47:29 +0100 Subject: [PATCH 006/184] Updated JoinBy query --- .../data_values/ut_compound_data_helper.pkb | 116 ++++++++++-------- .../data_values/ut_compound_data_value.tpb | 22 ++-- .../data_values/ut_data_value_refcursor.tpb | 10 +- .../test_expectations_cursor.pkb | 73 +++++++++++ .../test_expectations_cursor.pks | 12 ++ 5 files changed, 164 insertions(+), 69 deletions(-) diff --git a/source/expectations/data_values/ut_compound_data_helper.pkb b/source/expectations/data_values/ut_compound_data_helper.pkb index d66c7c80f..df5f5453b 100644 --- a/source/expectations/data_values/ut_compound_data_helper.pkb +++ b/source/expectations/data_values/ut_compound_data_helper.pkb @@ -167,68 +167,76 @@ create or replace package body ut_compound_data_helper is ) return tt_row_diffs is l_column_filter varchar2(32767); l_results tt_row_diffs; - l_sql varchar2(32767); -- REMOVE LATER also for unorder begin l_column_filter := get_columns_filter(a_exclude_xpath,a_include_xpath); /** * Since its unordered search we cannot select max rows from diffs as we miss some comparision records * We will restrict output on higher level of select - */ + **/ - l_sql := q'[ - with - diff_info as (select item_hash from ut_compound_data_diff_tmp ucdc where diff_id = :diff_guid) + execute immediate q'[ + with diff_info as (select item_hash from ut_compound_data_diff_tmp ucdc where diff_id = :diff_guid) select rn,diff_type,diffed_row - from (select dense_rank() over (order by pk_hash) as rn, diff_type,data_item diffed_row - from (select nvl(exp.pk_hash, act.pk_hash) pk_hash, - xmlserialize(content exp.row_data no indent) exp_item, - xmlserialize(content act.row_data no indent) act_item - from - (select ucd.*, row_number() over(partition by pk_hash order by row_hash) duplicate_no - from - (select ucd.column_value row_data, - dbms_crypto.hash( value(ucd).getclobval(),3) row_hash, - dbms_crypto.hash( extract(value(ucd),']'|| a_join_by_xpath ||q'[').getClobVal(),3/*HASH_SH1*/) pk_hash - from - (select ]'||l_column_filter||q'[, ucd.item_no, ucd.item_data item_data_no_filter - from ut_compound_data_tmp ucd - where ucd.data_id = :self_guid - and ucd.item_hash in (select i.item_hash from diff_info i) - ) r, - table( xmlsequence( extract(r.item_data,'/*') ) ) ucd - ) ucd - ) exp - join ( - select ucd.*, row_number() over(partition by pk_hash order by row_hash) duplicate_no - from - (select ucd.column_value row_data, - dbms_crypto.hash( value(ucd).getclobval(),3/*HASH_SH1*/) row_hash, - dbms_crypto.hash( extract(value(ucd),']'|| a_join_by_xpath ||q'[').getClobVal(),3/*HASH_SH1*/) pk_hash - from - (select ]'||l_column_filter||q'[, ucd.item_no, ucd.item_data item_data_no_filter - from ut_compound_data_tmp ucd - where ucd.data_id = :other_guid - and ucd.item_hash in (select i.item_hash from diff_info i) - ) r, - table( xmlsequence( extract(r.item_data,'/*') ) ) ucd - ) ucd - ) act - on exp.pk_hash = act.pk_hash and exp.duplicate_no = act.duplicate_no - where exp.row_hash != act.row_hash - or exp.row_hash is null - or act.row_hash is null - ) - unpivot ( data_item for diff_type in (exp_item as 'Expected:', act_item as 'Actual:') ) - ) - where rownum < :max_rows - order by 1, 2]'; - - execute immediate l_sql + from + (select dense_rank() over (order by pk_hash) as rn, diff_type,data_item diffed_row + from + (select pk_hash + ,case when exp_item is not null and act_item is not null then exp_item else null end exp_item + ,case when exp_item is not null and act_item is not null then act_item else null end act_item + ,case when exp_item is not null and act_item is null then exp_item else null end miss_item + ,case when exp_item is null and act_item is not null then act_item else null end ext_item + from + (select nvl(exp.pk_hash, act.pk_hash) pk_hash, + xmlserialize(content exp.row_data no indent) exp_item, + xmlserialize(content act.row_data no indent) act_item + from + (select ucd.*, row_number() over(partition by pk_hash order by row_hash) duplicate_no + from + (select ucd.column_value row_data, + dbms_crypto.hash( value(ucd).getclobval(),3) row_hash, + dbms_crypto.hash( extract(value(ucd), :join_by_xpath ).getClobVal(),3/*HASH_SH1*/) pk_hash + from + (select ]'||l_column_filter||q'[, ucd.item_no, ucd.item_data item_data_no_filter + from ut_compound_data_tmp ucd + where ucd.data_id = :self_guid + and ucd.item_hash in (select i.item_hash from diff_info i) + ) r, + table( xmlsequence( extract(r.item_data,'/*') ) ) ucd + ) ucd + ) exp + full outer join ( + select ucd.*, row_number() over(partition by pk_hash order by row_hash) duplicate_no + from + (select ucd.column_value row_data, + dbms_crypto.hash( value(ucd).getclobval(),3/*HASH_SH1*/) row_hash, + dbms_crypto.hash( extract(value(ucd), :join_by_xpath ).getClobVal(),3/*HASH_SH1*/) pk_hash + from + (select ]'||l_column_filter||q'[, ucd.item_no, ucd.item_data item_data_no_filter + from ut_compound_data_tmp ucd + where ucd.data_id = :other_guid + and ucd.item_hash in (select i.item_hash from diff_info i) + ) r, + table( xmlsequence( extract(r.item_data,'/*') ) ) ucd + ) ucd + ) act + on exp.pk_hash = act.pk_hash and exp.duplicate_no = act.duplicate_no + where (exp.row_hash != act.row_hash and act.pk_hash = exp.pk_hash) or + ( + (exp.pk_hash is null or act.pk_hash is null) and + (exp.row_hash is null or act.row_hash is null) + ) + ) + ) + unpivot ( data_item for diff_type in (exp_item as 'Expected:', act_item as 'Actual:' + ,miss_item as 'Missing:', ext_item as 'Extra:') ) + ) + where rownum <= :max_rows + order by 1, 2]' bulk collect into l_results using a_diff_id, - a_exclude_xpath, a_include_xpath, a_expected_dataset_guid, - a_exclude_xpath, a_include_xpath, a_actual_dataset_guid, + a_join_by_xpath,a_exclude_xpath, a_include_xpath, a_expected_dataset_guid, + a_join_by_xpath,a_exclude_xpath, a_include_xpath, a_actual_dataset_guid, a_max_rows; return l_results; end; @@ -325,8 +333,8 @@ create or replace package body ut_compound_data_helper is coalesce(exp.duplicate_no,act.duplicate_no) duplicate_no, case when act.row_hash is null then - 'miss row' - else 'extra row' + 'Missing:' + else 'Extra:' end diffed_type, case when exp.row_hash is null then xmlserialize(content act.row_data no indent) diff --git a/source/expectations/data_values/ut_compound_data_value.tpb b/source/expectations/data_values/ut_compound_data_value.tpb index cd3af7ac4..f27abd13b 100644 --- a/source/expectations/data_values/ut_compound_data_value.tpb +++ b/source/expectations/data_values/ut_compound_data_value.tpb @@ -155,10 +155,10 @@ create or replace type body ut_compound_data_value as execute immediate 'select count(*) from ' || l_ut_owner || '.ut_compound_data_diff_tmp where diff_id = :diff_id' into l_diff_row_count using l_diff_id; if l_diff_row_count > 0 then - if a_join_by_xpath is not null then + if a_join_by_xpath is not null then l_row_diffs := ut_compound_data_helper.get_rows_diff( self.data_id, l_actual.data_id, l_diff_id, c_max_rows, a_exclude_xpath, a_include_xpath, a_join_by_xpath - ); + ); else l_row_diffs := ut_compound_data_helper.get_rows_diff( self.data_id, l_actual.data_id, l_diff_id, c_max_rows, a_exclude_xpath, a_include_xpath @@ -253,34 +253,36 @@ create or replace type body ut_compound_data_value as l_diff_id := ut_compound_data_helper.get_hash(self.data_id||l_other.data_id); l_column_filter := ut_compound_data_helper.get_columns_filter(a_exclude_xpath, a_include_xpath); - + -- Pre generate hash minus to leave only onese that are diffrent, for example duplicates or diffrent hash execute immediate 'insert into ' || l_ut_owner || '.ut_compound_data_diff_tmp ( diff_id,item_hash,duplicate_no ) select :diff_id,x.item_hash,tmp.duplicate_no from( ( select item_hash,row_number() over (partition by item_hash,data_id order by 1) duplicate_no - from ut_compound_data_tmp + from ' || l_ut_owner || '.ut_compound_data_tmp where data_id = :self_guid minus select item_hash,row_number() over (partition by item_hash,data_id order by 1) - from ut_compound_data_tmp + from ' || l_ut_owner || '.ut_compound_data_tmp where data_id = :other_guid ) union all ( select item_hash,row_number() over (partition by item_hash,data_id order by 1) - from ut_compound_data_tmp + from ' || l_ut_owner || '.ut_compound_data_tmp where data_id = :other_guid minus select item_hash,row_number() over (partition by item_hash,data_id order by 1) - from ut_compound_data_tmp + from ' || l_ut_owner || '.ut_compound_data_tmp where data_id = :self_guid ))tmp - ,ut_compound_data_tmp x - where tmp.item_hash = x.item_hash' + , ' || l_ut_owner || '.ut_compound_data_tmp x + where tmp.item_hash = x.item_hash + and x.data_id in (:self_guid,:other_guid)' using l_diff_id, self.data_id, l_other.data_id - ,l_other.data_id,self.data_id; + ,l_other.data_id,self.data_id, + self.data_id, l_other.data_id; --result is OK only if both are same if sql%rowcount = 0 and self.elements_count = l_other.elements_count then l_result := 0; diff --git a/source/expectations/data_values/ut_data_value_refcursor.tpb b/source/expectations/data_values/ut_data_value_refcursor.tpb index cabe18011..4f0bc437b 100644 --- a/source/expectations/data_values/ut_data_value_refcursor.tpb +++ b/source/expectations/data_values/ut_data_value_refcursor.tpb @@ -15,7 +15,7 @@ create or replace type body ut_data_value_refcursor as See the License for the specific language governing permissions and limitations under the License. */ - + constructor function ut_data_value_refcursor(self in out nocopy ut_data_value_refcursor, a_value sys_refcursor) return self as result is begin init(a_value); @@ -28,8 +28,8 @@ create or replace type body ut_data_value_refcursor as l_ctx number; l_xml xmltype; l_current_date_format varchar2(4000); - l_ut_owner varchar2(250) := ut_utils.ut_owner; cursor_not_open exception; + l_ut_owner varchar2(250) := ut_utils.ut_owner; begin self.is_data_null := ut_utils.boolean_to_int(a_value is null); self.self_type := $$plsql_unit; @@ -58,10 +58,10 @@ create or replace type body ut_data_value_refcursor as loop l_xml := dbms_xmlgen.getxmltype(l_ctx); - - execute immediate + + execute immediate 'insert into ' || l_ut_owner || '.ut_compound_data_tmp(data_id, item_no, item_data, item_hash) ' || - 'select :self_guid, :self_row_count + rownum, value(a), dbms_crypto.hash( value(a).getclobval(),3)' || + 'select :self_guid, :self_row_count + rownum, value(a),'||l_ut_owner||'.ut_compound_data_helper.get_hash(value(a).GetClobVal()) ' || ' from table( xmlsequence( extract(:l_xml,''ROWSET/*'') ) ) a' using in self.data_id, self.elements_count, l_xml; diff --git a/test/core/expectations/compound_data/test_expectations_cursor.pkb b/test/core/expectations/compound_data/test_expectations_cursor.pkb index b805105e6..39842f439 100644 --- a/test/core/expectations/compound_data/test_expectations_cursor.pkb +++ b/test/core/expectations/compound_data/test_expectations_cursor.pkb @@ -1041,5 +1041,78 @@ Rows: [ 2 differences ]% end; end; + procedure cursor_unordered_compare_success is + l_actual SYS_REFCURSOR; + l_expected SYS_REFCURSOR; + begin + --Arrange + open l_actual for select username , user_id from all_users order by username asc; + open l_expected for select username , user_id from all_users order by username desc; + --Act + ut3.ut.expect(l_actual).to_equal(l_expected).unordered; + --Assert + ut.expect(expectations.failed_expectations_data()).to_be_empty(); + end; + + procedure cursor_unordered_compare_fail is + l_actual SYS_REFCURSOR; + l_expected SYS_REFCURSOR; + l_actual_message varchar2(32767); + l_expected_message varchar2(32767); + begin + --Arrange + open l_actual for select 'test1' username,-100 user_id from dual + union all + select 'test' username,-666 user_id from dual + order by 1 asc; + + open l_expected for select 'test1' username,-100 user_id from dual + union all + select 'test' username,-667 user_id from dual + order by 1 desc; + --Act + ut3.ut.expect(l_actual).to_equal(l_expected).unordered; + l_expected_message := q'[%Actual: refcursor [ count = 2 ] was expected to equal: refcursor [ count = 2 ]% +Diff:% +Rows: [ 2 differences ] +Missing: test-667% +Extra: test-666%]'; + l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; + --Assert + ut.expect(l_actual_message).to_be_like(l_expected_message); + end; + + procedure cursor_joinby_compare is + l_actual SYS_REFCURSOR; + l_expected SYS_REFCURSOR; + begin + --Arrange + open l_actual for select owner, object_name,object_type from all_objects where owner = user + order by 1,2,3 asc; + open l_expected for select owner, object_name,object_type from all_objects where owner = user + order by 1,2,3 desc; + + --Act + ut3.ut.expect(l_actual).to_equal(l_expected).join_by('OWNER'); + --Assert + ut.expect(expectations.failed_expectations_data()).to_be_empty(); + end; + + procedure cursor_joinby_compare_twocolumns is + l_actual SYS_REFCURSOR; + l_expected SYS_REFCURSOR; + begin + --Arrange + open l_actual for select owner, object_name,object_type from all_objects where owner = user + order by 1,2,3 asc; + open l_expected for select owner, object_name,object_type from all_objects where owner = user + order by 1,2,3 desc; + + --Act + ut3.ut.expect(l_actual).to_equal(l_expected).join_by(ut3.ut_varchar2_list('OWNER,OBJECT_NAME')); + --Assert + ut.expect(expectations.failed_expectations_data()).to_be_empty(); + end; + end; / diff --git a/test/core/expectations/compound_data/test_expectations_cursor.pks b/test/core/expectations/compound_data/test_expectations_cursor.pks index 4868b72ce..126c2c7e6 100644 --- a/test/core/expectations/compound_data/test_expectations_cursor.pks +++ b/test/core/expectations/compound_data/test_expectations_cursor.pks @@ -199,5 +199,17 @@ create or replace package test_expectations_cursor is --%test( Fail on passing implicit column name as exclude filter ) procedure exclude_col_name_implicit; + --%test( Compare cursors using unordered method success) + procedure cursor_unordered_compare_success; + + --%test( Compare cursors using unordered method failure) + procedure cursor_unordered_compare_fail; + + --%test( Compare cursors join by single key ) + procedure cursor_joinby_compare; + + --%test( Compare cursors join by composite key) + procedure cursor_joinby_compare_twocolumns; + end; / From 9bb79ab0d371ba6c261a9a532ed046bffcdacf9c Mon Sep 17 00:00:00 2001 From: Peter Ocelka Date: Fri, 4 May 2018 17:39:14 +0200 Subject: [PATCH 007/184] In situation when user uninstalls older version of utPLSQL table is not dropped. Then when new version is installed manually without user creation, this script failed as table already exists in the schema. --- source/core/ut_dbms_output_cache.sql | 61 +++++++++++++++++----------- 1 file changed, 38 insertions(+), 23 deletions(-) diff --git a/source/core/ut_dbms_output_cache.sql b/source/core/ut_dbms_output_cache.sql index a81f6acbe..91aba0ba5 100644 --- a/source/core/ut_dbms_output_cache.sql +++ b/source/core/ut_dbms_output_cache.sql @@ -1,23 +1,38 @@ -create global temporary table ut_dbms_output_cache( - /* - utPLSQL - Version 3 - Copyright 2016 - 2017 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. - */ - /* - * This table is not a global temporary table as it needs to allow cross-session data exchange - * It is used however as a temporary table with multiple writers. - * This is why it has very high initrans and has nologging - */ - seq_no number(20,0) not null, - text varchar2(4000), - constraint ut_dbms_output_cache_pk primary key(seq_no) -) on commit preserve rows; +/* +utPLSQL - Version 3 +Copyright 2016 - 2017 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. +*/ +/* +* This table is not a global temporary table as it needs to allow cross-session data exchange +* It is used however as a temporary table with multiple writers. +* This is why it has very high initrans and has nologging +*/ +declare + l_tab_exist number; +begin + select count(*) into l_tab_exist from + (select table_name from all_tables where table_name = 'UT_DBMS_OUTPUT_CACHE' and owner = sys_context('USERENV','CURRENT_SCHEMA') + union all + select synonym_name from all_synonyms where synonym_name = 'UT_DBMS_OUTPUT_CACHE' and owner = sys_context('USERENV','CURRENT_SCHEMA')); + if l_tab_exist = 0 then + + execute immediate q'[create global temporary table ut_dbms_output_cache + ( + seq_no number(20,0) not null, + text varchar2(4000), + constraint ut_dbms_output_cache_pk primary key(seq_no) + ) on commit preserve rows + ]'; + + end if; +end; +/ From a5e6aaee7e8eefc13e42a54ac45be54e098bc79b Mon Sep 17 00:00:00 2001 From: lwasylow Date: Fri, 4 May 2018 17:17:19 +0100 Subject: [PATCH 008/184] fixes to test name length --- .../expectations/compound_data/test_expectations_cursor.pkb | 4 ++-- .../expectations/compound_data/test_expectations_cursor.pks | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/core/expectations/compound_data/test_expectations_cursor.pkb b/test/core/expectations/compound_data/test_expectations_cursor.pkb index 39842f439..feb7f2586 100644 --- a/test/core/expectations/compound_data/test_expectations_cursor.pkb +++ b/test/core/expectations/compound_data/test_expectations_cursor.pkb @@ -1041,7 +1041,7 @@ Rows: [ 2 differences ]% end; end; - procedure cursor_unordered_compare_success is + procedure cursor_unorderd_compr_success is l_actual SYS_REFCURSOR; l_expected SYS_REFCURSOR; begin @@ -1098,7 +1098,7 @@ Extra: test-666%]'; ut.expect(expectations.failed_expectations_data()).to_be_empty(); end; - procedure cursor_joinby_compare_twocolumns is + procedure cursor_joinby_compare_twocols is l_actual SYS_REFCURSOR; l_expected SYS_REFCURSOR; begin diff --git a/test/core/expectations/compound_data/test_expectations_cursor.pks b/test/core/expectations/compound_data/test_expectations_cursor.pks index 126c2c7e6..688eb2073 100644 --- a/test/core/expectations/compound_data/test_expectations_cursor.pks +++ b/test/core/expectations/compound_data/test_expectations_cursor.pks @@ -200,7 +200,7 @@ create or replace package test_expectations_cursor is procedure exclude_col_name_implicit; --%test( Compare cursors using unordered method success) - procedure cursor_unordered_compare_success; + procedure cursor_unorderd_compr_success; --%test( Compare cursors using unordered method failure) procedure cursor_unordered_compare_fail; @@ -209,7 +209,7 @@ create or replace package test_expectations_cursor is procedure cursor_joinby_compare; --%test( Compare cursors join by composite key) - procedure cursor_joinby_compare_twocolumns; + procedure cursor_joinby_compare_twocols; end; / From 27e842e0707409b85af63977b5725884554f9222 Mon Sep 17 00:00:00 2001 From: Peter Ocelka Date: Fri, 4 May 2018 19:41:23 +0200 Subject: [PATCH 009/184] #658 file split to two --- .../create_synonyms_and_grants_for_user.sql | 178 ------------------ 1 file changed, 178 deletions(-) delete mode 100644 source/create_synonyms_and_grants_for_user.sql diff --git a/source/create_synonyms_and_grants_for_user.sql b/source/create_synonyms_and_grants_for_user.sql deleted file mode 100644 index 3044cb32f..000000000 --- a/source/create_synonyms_and_grants_for_user.sql +++ /dev/null @@ -1,178 +0,0 @@ -/* - utPLSQL - Version 3 - Copyright 2016 - 2017 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. - -Create all necessary grant for the user who owns test packages and want to execute utPLSQL framework -*/ - -@@define_ut3_owner_param.sql - -column 2 new_value 2 noprint -select null as "2" from dual where 1=0; -spool params.sql.tmp -select - case - when '&&2' is null then q'[ACCEPT ut3_user CHAR PROMPT 'Provide schema name where synonyms for the utPLSQL v3 should be created ']' - else 'define ut3_user=&&2' - end -from dual; -spool off -set termout on -@params.sql.tmp -set termout off -/* cleanup temporary sql files */ ---try running on windows -$ del params.sql.tmp ---try running on linux/unix -! rm params.sql.tmp -set termout on - -set echo off -set feedback on -set heading off -set verify off - -prompt Granting privileges on UTPLSQL objects in &&ut3_owner schema to user &&ut3_user - -whenever sqlerror exit failure rollback -whenever oserror exit failure rollback - -alter session set current_schema = &&ut3_owner; - -grant execute on &&ut3_owner..ut_be_between to &ut3_user; -grant execute on &&ut3_owner..ut_be_empty to &ut3_user; -grant execute on &&ut3_owner..ut_be_false to &ut3_user; -grant execute on &&ut3_owner..ut_be_greater_or_equal to &ut3_user; -grant execute on &&ut3_owner..ut_be_greater_than to &ut3_user; -grant execute on &&ut3_owner..ut_be_less_or_equal to &ut3_user; -grant execute on &&ut3_owner..ut_be_less_than to &ut3_user; -grant execute on &&ut3_owner..ut_be_like to &ut3_user; -grant execute on &&ut3_owner..ut_be_not_null to &ut3_user; -grant execute on &&ut3_owner..ut_be_null to &ut3_user; -grant execute on &&ut3_owner..ut_be_true to &ut3_user; -grant execute on &&ut3_owner..ut_equal to &ut3_user; -grant execute on &&ut3_owner..ut_have_count to &ut3_user; -grant execute on &&ut3_owner..ut_match to &ut3_user; -grant execute on &&ut3_owner..ut to &ut3_user; -grant execute on &&ut3_owner..ut_runner to &ut3_user; -grant execute on &&ut3_owner..ut_teamcity_reporter to &ut3_user; -grant execute on &&ut3_owner..ut_xunit_reporter to &ut3_user; -grant execute on &&ut3_owner..ut_junit_reporter to &ut3_user; -grant execute on &&ut3_owner..ut_tfs_junit_reporter to &ut3_user; -grant execute on &&ut3_owner..ut_documentation_reporter to &ut3_user; -grant execute on &&ut3_owner..ut_coverage_html_reporter to &ut3_user; -grant execute on &&ut3_owner..ut_coverage_sonar_reporter to &ut3_user; -grant execute on &&ut3_owner..ut_coveralls_reporter to &ut3_user; -grant execute on &&ut3_owner..ut_coverage_cobertura_reporter to &ut3_user; -grant execute on &&ut3_owner..ut_reporters to &ut3_user; -grant execute on &&ut3_owner..ut_varchar2_list to &ut3_user; -grant execute on &&ut3_owner..ut_varchar2_rows to &ut3_user; -grant execute on &&ut3_owner..ut_integer_list to &ut3_user; -grant execute on &&ut3_owner..ut_reporter_base to &ut3_user; -grant execute on &&ut3_owner..ut_output_reporter_base to &ut3_user; -grant execute on &&ut3_owner..ut_coverage_reporter_base to &ut3_user; -grant execute on &&ut3_owner..ut_console_reporter_base to &ut3_user; -grant execute on &&ut3_owner..ut_coverage to &ut3_user; -grant execute on &&ut3_owner..ut_coverage_options to &ut3_user; -grant execute on &&ut3_owner..ut_coverage_helper to &ut3_user; -grant execute on &&ut3_owner..ut_output_buffer_base to &ut3_user; -grant execute on &&ut3_owner..ut_output_table_buffer to &ut3_user; -grant execute on &&ut3_owner..ut_file_mappings to &ut3_user; -grant execute on &&ut3_owner..ut_file_mapping to &ut3_user; -grant execute on &&ut3_owner..ut_file_mapper to &ut3_user; -grant execute on &&ut3_owner..ut_key_value_pairs to &ut3_user; -grant execute on &&ut3_owner..ut_key_value_pair to &ut3_user; -grant select, insert, delete on &&ut3_owner..ut_compound_data_tmp to &ut3_user; -grant select, insert, delete on &&ut3_owner..ut_compound_data_diff_tmp to &ut3_user; -grant execute on &&ut3_owner..ut_sonar_test_reporter to &ut3_user; -grant execute on &&ut3_owner..ut_annotations to &ut3_user; -grant execute on &&ut3_owner..ut_annotation to &ut3_user; -grant execute on &&ut3_owner..ut_annotation_manager to &ut3_user; -grant execute on &&ut3_owner..ut_annotated_object to &ut3_user; -grant execute on &&ut3_owner..ut_annotated_objects to &ut3_user; -grant select on &&ut3_owner..ut_annotation_cache_info to &ut3_user; -grant select on &&ut3_owner..ut_annotation_cache to &ut3_user; -grant execute on &&ut3_owner..ut_annotation_cache_manager to &ut3_user; -grant execute on &&ut3_owner..ut_annotation_parser to &ut3_user; -grant execute on &&ut3_owner..ut_annotation_objs_cache_info to &ut3_user; -grant execute on &&ut3_owner..ut_annotation_obj_cache_info to &ut3_user; -begin - $if dbms_db_version.version = 12 and dbms_db_version.release >= 2 or dbms_db_version.version > 12 $then - execute immediate 'grant select, insert, delete, update on &&ut3_owner..dbmspcc_blocks to &ut3_user'; - execute immediate 'grant select, insert, delete, update on &&ut3_owner..dbmspcc_runs to &ut3_user'; - execute immediate 'grant select, insert, delete, update on &&ut3_owner..dbmspcc_units to &ut3_user'; - $else - null; - $end -end; -/ - - -prompt Creating synonyms for UTPLSQL objects in &&ut3_owner schema to user &&ut3_user - -create or replace synonym &ut3_user..be_between for &&ut3_owner..be_between; -create or replace synonym &ut3_user..be_empty for &&ut3_owner..be_empty; -create or replace synonym &ut3_user..be_false for &&ut3_owner..be_false; -create or replace synonym &ut3_user..be_greater_or_equal for &&ut3_owner..be_greater_or_equal; -create or replace synonym &ut3_user..be_greater_than for &&ut3_owner..be_greater_than; -create or replace synonym &ut3_user..be_less_or_equal for &&ut3_owner..be_less_or_equal; -create or replace synonym &ut3_user..be_less_than for &&ut3_owner..be_less_than; -create or replace synonym &ut3_user..be_like for &&ut3_owner..be_like; -create or replace synonym &ut3_user..be_not_null for &&ut3_owner..be_not_null; -create or replace synonym &ut3_user..be_null for &&ut3_owner..be_null; -create or replace synonym &ut3_user..be_true for &&ut3_owner..be_true; -create or replace synonym &ut3_user..equal for &&ut3_owner..equal; -create or replace synonym &ut3_user..have_count for &&ut3_owner..have_count; -create or replace synonym &ut3_user..match for &&ut3_owner..match; -create or replace synonym &ut3_user..ut for &&ut3_owner..ut; -create or replace synonym &ut3_user..ut_runner for &&ut3_owner..ut_runner; -create or replace synonym &ut3_user..ut_teamcity_reporter for &&ut3_owner..ut_teamcity_reporter; -create or replace synonym &ut3_user..ut_xunit_reporter for &&ut3_owner..ut_xunit_reporter; -create or replace synonym &ut3_user..ut_junit_reporter for &&ut3_owner..ut_junit_reporter; -create or replace synonym &ut3_user..ut_tfs_junit_reporter for &&ut3_owner..ut_tfs_junit_reporter; -create or replace synonym &ut3_user..ut_documentation_reporter for &&ut3_owner..ut_documentation_reporter; -create or replace synonym &ut3_user..ut_coverage_html_reporter for &&ut3_owner..ut_coverage_html_reporter; -create or replace synonym &ut3_user..ut_coverage_sonar_reporter for &&ut3_owner..ut_coverage_sonar_reporter; -create or replace synonym &ut3_user..ut_coveralls_reporter for &&ut3_owner..ut_coveralls_reporter; -create or replace synonym &ut3_user..ut_coverage_cobertura_reporter for &&ut3_owner..ut_coverage_cobertura_reporter; -create or replace synonym &ut3_user..ut_reporters for &&ut3_owner..ut_reporters; -create or replace synonym &ut3_user..ut_varchar2_list for &&ut3_owner..ut_varchar2_list; -create or replace synonym &ut3_user..ut_varchar2_rows for &&ut3_owner..ut_varchar2_rows; -create or replace synonym &ut3_user..ut_integer_list for &&ut3_owner..ut_integer_list; -create or replace synonym &ut3_user..ut_reporter_base for &&ut3_owner..ut_reporter_base; -create or replace synonym &ut3_user..ut_output_reporter_base for &&ut3_owner..ut_output_reporter_base; -create or replace synonym &ut3_user..ut_coverage for &&ut3_owner..ut_coverage; -create or replace synonym &ut3_user..ut_coverage_options for &&ut3_owner..ut_coverage_options; -create or replace synonym &ut3_user..ut_coverage_helper for &&ut3_owner..ut_coverage_helper; -create or replace synonym &ut3_user..ut_output_buffer_base for &&ut3_owner..ut_output_buffer_base; -create or replace synonym &ut3_user..ut_output_table_buffer for &&ut3_owner..ut_output_table_buffer; -create or replace synonym &ut3_user..ut_file_mappings for &&ut3_owner..ut_file_mappings; -create or replace synonym &ut3_user..ut_file_mapping for &&ut3_owner..ut_file_mapping; -create or replace synonym &ut3_user..ut_file_mapper for &&ut3_owner..ut_file_mapper; -create or replace synonym &ut3_user..ut_key_value_pairs for &&ut3_owner..ut_key_value_pairs; -create or replace synonym &ut3_user..ut_key_value_pair for &&ut3_owner..ut_key_value_pair; -create or replace synonym &ut3_user..ut_compound_data_tmp for &&ut3_owner..ut_cursor_data; -create or replace synonym &ut3_user..ut_compound_data_diff_tmp for &&ut3_owner..ut_compound_data_diff_tmp; -create or replace synonym &ut3_user..ut_sonar_test_reporter for &&ut3_owner..ut_sonar_test_reporter; -begin - $if dbms_db_version.version = 12 and dbms_db_version.release >= 2 or dbms_db_version.version > 12 $then - execute immediate 'create or replace synonym &ut3_user..dbmspcc_blocks for &&ut3_owner..dbmspcc_blocks'; - execute immediate 'create or replace synonym &ut3_user..dbmspcc_runs for &&ut3_owner..dbmspcc_runs'; - execute immediate 'create or replace synonym &ut3_user..dbmspcc_units for &&ut3_owner..dbmspcc_units'; - $else - null; - $end -end; -/ From f33dd276510c9d494c6838943f84fc0617f7358d Mon Sep 17 00:00:00 2001 From: Peter Ocelka Date: Fri, 4 May 2018 19:41:49 +0200 Subject: [PATCH 010/184] added for #658 --- source/create_user_grants.sql | 120 ++++++++++++++++++++++++++++++++ source/create_user_synonyms.sql | 109 +++++++++++++++++++++++++++++ 2 files changed, 229 insertions(+) create mode 100644 source/create_user_grants.sql create mode 100644 source/create_user_synonyms.sql diff --git a/source/create_user_grants.sql b/source/create_user_grants.sql new file mode 100644 index 000000000..76406ece9 --- /dev/null +++ b/source/create_user_grants.sql @@ -0,0 +1,120 @@ +/* + utPLSQL - Version 3 + Copyright 2016 - 2017 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. + +Create all necessary grant for the user who owns test packages and want to execute utPLSQL framework +*/ + +@@define_ut3_owner_param.sql + +column 2 new_value 2 noprint +select null as "2" from dual where 1=0; +spool params.sql.tmp +select + case + when '&&2' is null then q'[ACCEPT ut3_user CHAR PROMPT 'Provide schema to which should be granted the utPLSQL v3 ']' + else 'define ut3_user=&&2' + end +from dual; +spool off +set termout on +@params.sql.tmp +set termout off +/* cleanup temporary sql files */ +--try running on windows +$ del params.sql.tmp +--try running on linux/unix +! rm params.sql.tmp +set termout on + +set echo off +set feedback on +set heading off +set verify off + +prompt Granting privileges on UTPLSQL objects in &&ut3_owner schema to user &&ut3_user + +whenever sqlerror exit failure rollback +whenever oserror exit failure rollback + +alter session set current_schema = &&ut3_owner; + +grant execute on &&ut3_owner..ut_be_between to &ut3_user; +grant execute on &&ut3_owner..ut_be_empty to &ut3_user; +grant execute on &&ut3_owner..ut_be_false to &ut3_user; +grant execute on &&ut3_owner..ut_be_greater_or_equal to &ut3_user; +grant execute on &&ut3_owner..ut_be_greater_than to &ut3_user; +grant execute on &&ut3_owner..ut_be_less_or_equal to &ut3_user; +grant execute on &&ut3_owner..ut_be_less_than to &ut3_user; +grant execute on &&ut3_owner..ut_be_like to &ut3_user; +grant execute on &&ut3_owner..ut_be_not_null to &ut3_user; +grant execute on &&ut3_owner..ut_be_null to &ut3_user; +grant execute on &&ut3_owner..ut_be_true to &ut3_user; +grant execute on &&ut3_owner..ut_equal to &ut3_user; +grant execute on &&ut3_owner..ut_have_count to &ut3_user; +grant execute on &&ut3_owner..ut_match to &ut3_user; +grant execute on &&ut3_owner..ut to &ut3_user; +grant execute on &&ut3_owner..ut_runner to &ut3_user; +grant execute on &&ut3_owner..ut_teamcity_reporter to &ut3_user; +grant execute on &&ut3_owner..ut_xunit_reporter to &ut3_user; +grant execute on &&ut3_owner..ut_junit_reporter to &ut3_user; +grant execute on &&ut3_owner..ut_tfs_junit_reporter to &ut3_user; +grant execute on &&ut3_owner..ut_documentation_reporter to &ut3_user; +grant execute on &&ut3_owner..ut_coverage_html_reporter to &ut3_user; +grant execute on &&ut3_owner..ut_coverage_sonar_reporter to &ut3_user; +grant execute on &&ut3_owner..ut_coveralls_reporter to &ut3_user; +grant execute on &&ut3_owner..ut_coverage_cobertura_reporter to &ut3_user; +grant execute on &&ut3_owner..ut_reporters to &ut3_user; +grant execute on &&ut3_owner..ut_varchar2_list to &ut3_user; +grant execute on &&ut3_owner..ut_varchar2_rows to &ut3_user; +grant execute on &&ut3_owner..ut_integer_list to &ut3_user; +grant execute on &&ut3_owner..ut_reporter_base to &ut3_user; +grant execute on &&ut3_owner..ut_output_reporter_base to &ut3_user; +grant execute on &&ut3_owner..ut_coverage_reporter_base to &ut3_user; +grant execute on &&ut3_owner..ut_console_reporter_base to &ut3_user; +grant execute on &&ut3_owner..ut_coverage to &ut3_user; +grant execute on &&ut3_owner..ut_coverage_options to &ut3_user; +grant execute on &&ut3_owner..ut_coverage_helper to &ut3_user; +grant execute on &&ut3_owner..ut_output_buffer_base to &ut3_user; +grant execute on &&ut3_owner..ut_output_table_buffer to &ut3_user; +grant execute on &&ut3_owner..ut_file_mappings to &ut3_user; +grant execute on &&ut3_owner..ut_file_mapping to &ut3_user; +grant execute on &&ut3_owner..ut_file_mapper to &ut3_user; +grant execute on &&ut3_owner..ut_key_value_pairs to &ut3_user; +grant execute on &&ut3_owner..ut_key_value_pair to &ut3_user; +grant select, insert, delete on &&ut3_owner..ut_compound_data_tmp to &ut3_user; +grant select, insert, delete on &&ut3_owner..ut_compound_data_diff_tmp to &ut3_user; +grant execute on &&ut3_owner..ut_sonar_test_reporter to &ut3_user; +grant execute on &&ut3_owner..ut_annotations to &ut3_user; +grant execute on &&ut3_owner..ut_annotation to &ut3_user; +grant execute on &&ut3_owner..ut_annotation_manager to &ut3_user; +grant execute on &&ut3_owner..ut_annotated_object to &ut3_user; +grant execute on &&ut3_owner..ut_annotated_objects to &ut3_user; +grant select on &&ut3_owner..ut_annotation_cache_info to &ut3_user; +grant select on &&ut3_owner..ut_annotation_cache to &ut3_user; +grant execute on &&ut3_owner..ut_annotation_cache_manager to &ut3_user; +grant execute on &&ut3_owner..ut_annotation_parser to &ut3_user; +grant execute on &&ut3_owner..ut_annotation_objs_cache_info to &ut3_user; +grant execute on &&ut3_owner..ut_annotation_obj_cache_info to &ut3_user; +begin + $if dbms_db_version.version = 12 and dbms_db_version.release >= 2 or dbms_db_version.version > 12 $then + execute immediate 'grant select, insert, delete, update on &&ut3_owner..dbmspcc_blocks to &ut3_user'; + execute immediate 'grant select, insert, delete, update on &&ut3_owner..dbmspcc_runs to &ut3_user'; + execute immediate 'grant select, insert, delete, update on &&ut3_owner..dbmspcc_units to &ut3_user'; + $else + null; + $end +end; +/ diff --git a/source/create_user_synonyms.sql b/source/create_user_synonyms.sql new file mode 100644 index 000000000..729ba4002 --- /dev/null +++ b/source/create_user_synonyms.sql @@ -0,0 +1,109 @@ +/* + utPLSQL - Version 3 + Copyright 2016 - 2017 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. + +Create all necessary grant for the user who owns test packages and want to execute utPLSQL framework +*/ + +@@define_ut3_owner_param.sql + +column 2 new_value 2 noprint +select null as "2" from dual where 1=0; +spool params.sql.tmp +select + case + when '&&2' is null then q'[ACCEPT ut3_user CHAR PROMPT 'Provide schema name where synonyms for the utPLSQL v3 should be created ']' + else 'define ut3_user=&&2' + end +from dual; +spool off +set termout on +@params.sql.tmp +set termout off +/* cleanup temporary sql files */ +--try running on windows +$ del params.sql.tmp +--try running on linux/unix +! rm params.sql.tmp +set termout on + +set echo off +set feedback on +set heading off +set verify off + +prompt Granting privileges on UTPLSQL objects in &&ut3_owner schema to user &&ut3_user + +whenever sqlerror exit failure rollback +whenever oserror exit failure rollback + +alter session set current_schema = &&ut3_owner; + +prompt Creating synonyms for UTPLSQL objects in &&ut3_owner schema to user &&ut3_user + +create or replace synonym &ut3_user..be_between for &&ut3_owner..be_between; +create or replace synonym &ut3_user..be_empty for &&ut3_owner..be_empty; +create or replace synonym &ut3_user..be_false for &&ut3_owner..be_false; +create or replace synonym &ut3_user..be_greater_or_equal for &&ut3_owner..be_greater_or_equal; +create or replace synonym &ut3_user..be_greater_than for &&ut3_owner..be_greater_than; +create or replace synonym &ut3_user..be_less_or_equal for &&ut3_owner..be_less_or_equal; +create or replace synonym &ut3_user..be_less_than for &&ut3_owner..be_less_than; +create or replace synonym &ut3_user..be_like for &&ut3_owner..be_like; +create or replace synonym &ut3_user..be_not_null for &&ut3_owner..be_not_null; +create or replace synonym &ut3_user..be_null for &&ut3_owner..be_null; +create or replace synonym &ut3_user..be_true for &&ut3_owner..be_true; +create or replace synonym &ut3_user..equal for &&ut3_owner..equal; +create or replace synonym &ut3_user..have_count for &&ut3_owner..have_count; +create or replace synonym &ut3_user..match for &&ut3_owner..match; +create or replace synonym &ut3_user..ut for &&ut3_owner..ut; +create or replace synonym &ut3_user..ut_runner for &&ut3_owner..ut_runner; +create or replace synonym &ut3_user..ut_teamcity_reporter for &&ut3_owner..ut_teamcity_reporter; +create or replace synonym &ut3_user..ut_xunit_reporter for &&ut3_owner..ut_xunit_reporter; +create or replace synonym &ut3_user..ut_junit_reporter for &&ut3_owner..ut_junit_reporter; +create or replace synonym &ut3_user..ut_tfs_junit_reporter for &&ut3_owner..ut_tfs_junit_reporter; +create or replace synonym &ut3_user..ut_documentation_reporter for &&ut3_owner..ut_documentation_reporter; +create or replace synonym &ut3_user..ut_coverage_html_reporter for &&ut3_owner..ut_coverage_html_reporter; +create or replace synonym &ut3_user..ut_coverage_sonar_reporter for &&ut3_owner..ut_coverage_sonar_reporter; +create or replace synonym &ut3_user..ut_coveralls_reporter for &&ut3_owner..ut_coveralls_reporter; +create or replace synonym &ut3_user..ut_coverage_cobertura_reporter for &&ut3_owner..ut_coverage_cobertura_reporter; +create or replace synonym &ut3_user..ut_reporters for &&ut3_owner..ut_reporters; +create or replace synonym &ut3_user..ut_varchar2_list for &&ut3_owner..ut_varchar2_list; +create or replace synonym &ut3_user..ut_varchar2_rows for &&ut3_owner..ut_varchar2_rows; +create or replace synonym &ut3_user..ut_integer_list for &&ut3_owner..ut_integer_list; +create or replace synonym &ut3_user..ut_reporter_base for &&ut3_owner..ut_reporter_base; +create or replace synonym &ut3_user..ut_output_reporter_base for &&ut3_owner..ut_output_reporter_base; +create or replace synonym &ut3_user..ut_coverage for &&ut3_owner..ut_coverage; +create or replace synonym &ut3_user..ut_coverage_options for &&ut3_owner..ut_coverage_options; +create or replace synonym &ut3_user..ut_coverage_helper for &&ut3_owner..ut_coverage_helper; +create or replace synonym &ut3_user..ut_output_buffer_base for &&ut3_owner..ut_output_buffer_base; +create or replace synonym &ut3_user..ut_output_table_buffer for &&ut3_owner..ut_output_table_buffer; +create or replace synonym &ut3_user..ut_file_mappings for &&ut3_owner..ut_file_mappings; +create or replace synonym &ut3_user..ut_file_mapping for &&ut3_owner..ut_file_mapping; +create or replace synonym &ut3_user..ut_file_mapper for &&ut3_owner..ut_file_mapper; +create or replace synonym &ut3_user..ut_key_value_pairs for &&ut3_owner..ut_key_value_pairs; +create or replace synonym &ut3_user..ut_key_value_pair for &&ut3_owner..ut_key_value_pair; +create or replace synonym &ut3_user..ut_compound_data_tmp for &&ut3_owner..ut_cursor_data; +create or replace synonym &ut3_user..ut_compound_data_diff_tmp for &&ut3_owner..ut_compound_data_diff_tmp; +create or replace synonym &ut3_user..ut_sonar_test_reporter for &&ut3_owner..ut_sonar_test_reporter; +begin + $if dbms_db_version.version = 12 and dbms_db_version.release >= 2 or dbms_db_version.version > 12 $then + execute immediate 'create or replace synonym &ut3_user..dbmspcc_blocks for &&ut3_owner..dbmspcc_blocks'; + execute immediate 'create or replace synonym &ut3_user..dbmspcc_runs for &&ut3_owner..dbmspcc_runs'; + execute immediate 'create or replace synonym &ut3_user..dbmspcc_units for &&ut3_owner..dbmspcc_units'; + $else + null; + $end +end; +/ From 312138276b6de17d55f979bf75f6d690c391c13a Mon Sep 17 00:00:00 2001 From: Peter Ocelka Date: Fri, 4 May 2018 19:42:48 +0200 Subject: [PATCH 011/184] updated section for other users due to changes introduced in #658 --- docs/userguide/install.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/userguide/install.md b/docs/userguide/install.md index 88e2a2e63..fdc91b08c 100644 --- a/docs/userguide/install.md +++ b/docs/userguide/install.md @@ -135,12 +135,13 @@ Example invocation: cd source sqlplus admin/admins_password@database @create_synonyms_and_grants_for_public.sql ut3 ``` -To grant utPLSQL to an individual user, execute script `source/create_synonyms_and_grants_for_user.sql`, provide `schema_name` where utPLSQL is installed and `user_name` to grant access for. +To grant utPLSQL to an individual user, execute scripts `source/create_user_grants.sql` and `source/create_user_synonyms.sql`, provide `schema_name` where utPLSQL is installed and `user_name` to grant access for. Example invocation: ```bash cd source -sqlplus admin/admins_password@database @create_synonyms_and_grants_for_user.sql ut3 hr +sqlplus admin/admins_password@database @create_user_grants.sql ut3 hr +sqlplus user/user_password@database @create_user_synonyms.sql ut3 hr ``` The following tools that support the SQL*Plus commands can be used to run the installation script: From f43b76e29b54346b47357f1a51839aafe7e7ca24 Mon Sep 17 00:00:00 2001 From: Peter Ocelka Date: Fri, 4 May 2018 19:43:41 +0200 Subject: [PATCH 012/184] Added missing objects to avoid errors when new installation is not performed also with new user creation; Added purge for UT_OUTPUT_BUFFER_TMP$ to drop also overflow segment table --- source/uninstall.sql | 77 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 76 insertions(+), 1 deletion(-) diff --git a/source/uninstall.sql b/source/uninstall.sql index 6da0e4fd9..7d717dae8 100644 --- a/source/uninstall.sql +++ b/source/uninstall.sql @@ -242,7 +242,7 @@ drop type ut_output_buffer_base force; drop view ut_output_buffer_tmp; -drop table ut_output_buffer_tmp$; +drop table ut_output_buffer_tmp$ purge; drop view ut_output_buffer_info_tmp; @@ -276,6 +276,16 @@ drop type ut_varchar2_list force; drop type ut_varchar2_rows force; +drop package ut_coverage_profiler; + +drop package ut_compound_data_helper; + +drop package ut_coverage_helper_profiler; + +drop type ut_have_count; + +drop type ut_compound_data_value; + set echo off set feedback off declare @@ -306,6 +316,71 @@ begin dbms_output.put_line(i||' synonyms dropped'); end; / + +declare + i integer := 0; +begin + dbms_output.put_line('Dropping synonyms pointing to PL/SQL code coverage objects on 12.2 ' || upper('&&ut3_owner')); + for syn in ( + select + case when owner = 'PUBLIC' then 'public synonym ' + else 'synonym ' || owner || '.' + end || synonym_name as syn_name, + table_owner || '.' || table_name as for_object + from all_synonyms s + where 1 = 1 + and table_owner = upper('&&ut3_owner') + and synonym_name in ('DBMSPCC_BLOCKS','DBMSPCC_RUNS','DBMSPCC_UNITS') + ) + loop + + begin + + execute immediate 'drop '||syn.syn_name; + sys.dbms_output.put_line('Dropped '||syn.syn_name||' for object '||syn.for_object); + + i := i + 1; + exception + when others then + sys.dbms_output.put_line('FAILED to drop '||syn.syn_name||' for object '||syn.for_object); + end; + end loop; + sys.dbms_output.put_line('&&line_separator'); + sys.dbms_output.put_line(i||' synonyms dropped'); +end; +/ + +declare + i integer := 0; +begin + sys.dbms_output.put_line('Dropping packages created for 12.2+ ' || upper('&&ut3_owner')); + + for pkg in (select object_name, owner + from all_objects + where 1 = 1 + and owner = upper('&&ut3_owner') + and object_type = 'PACKAGE' + and object_name in ('UT_COVERAGE_HELPER_BLOCK','UT_COVERAGE_BLOCK')) + loop + + begin + execute immediate 'drop package ' || pkg.owner || '.' || pkg.object_name; + + sys.dbms_output.put_line('Dropped '|| pkg.object_name); + i := i + 1; + + exception + when others then + dbms_output.put_line('FAILED to drop ' || pkg.object_name); + end; + + end loop; + + sys.dbms_output.put_line('&&line_separator'); + sys.dbms_output.put_line(i || ' packages dropped'); +end; +/ + begin dbms_output.put_line('&&line_separator'); dbms_output.put_line('Uninstall complete'); From 8a33c25af649c75ad3c1af0dd702750a42f623f4 Mon Sep 17 00:00:00 2001 From: lwasylow Date: Fri, 4 May 2018 20:27:00 +0100 Subject: [PATCH 013/184] Update documentation Update if statement to simplify Remove synonyms for temp tables --- docs/userguide/advanced_data_comparison.md | 24 +++++++++++++++++++ .../create_synonyms_and_grants_for_public.sql | 2 -- .../create_synonyms_and_grants_for_user.sql | 1 - .../data_values/ut_compound_data_value.tpb | 6 ++--- 4 files changed, 26 insertions(+), 7 deletions(-) diff --git a/docs/userguide/advanced_data_comparison.md b/docs/userguide/advanced_data_comparison.md index e1e5ee36c..74185c3ec 100644 --- a/docs/userguide/advanced_data_comparison.md +++ b/docs/userguide/advanced_data_comparison.md @@ -23,6 +23,9 @@ Advanced data-comparison options are available for the [`equal`](expectations.md - `exclude(a_items varchar2)` - item or comma separated list of items to exclude - `include(a_items ut_varchar2_list)` - table of items to include - `exclude(a_items ut_varchar2_list)` - table of items to exclude + - `unordered` - perform compare on unordered set of data, return only missing or actual + - `join_by(a_columns varchar2)` - columns or comma seperated list of columns to join two cursors by + - `join_by(a_columns ut_varchar2_list)` - table of columns to join two cursors by Each item in the comma separated list can be: - a column name of cursor to be compared @@ -92,6 +95,27 @@ Only the columns 'RN', "A_Column" will be compared. Column 'SOME_COL' is exclude This option can be useful in scenarios where you need to narrow-down the scope of test so that the test is only focused on very specific data. +## Join By option +You can now join two cursors by defining a primary key or composite key that will be used to uniqely identify and compare rows. This option allows us to exactly show which rows are missing, extra and which are diffrent without ordering clause. + +```sql +procedure join_by_username is + l_actual sys_refcursor; + l_expected sys_refcursor; +begin + open l_expected for select username, user_id from all_users + union all + select 'TEST' username, -600 user_id from dual + order by 1 desc; + open l_actual for select username, user_id from all_users + union all + select 'TEST' username, -610 user_id from dual + order by 1 asc; + ut.expect( l_actual ).to_equal( l_expected ).join_by('USERNAME'); +end; +``` +This will show you diffrence in row 'TEST' regardless of order. + ## Defining item as XPath When using XPath expression, keep in mind the following: diff --git a/source/create_synonyms_and_grants_for_public.sql b/source/create_synonyms_and_grants_for_public.sql index 235c6806a..e34df182e 100644 --- a/source/create_synonyms_and_grants_for_public.sql +++ b/source/create_synonyms_and_grants_for_public.sql @@ -142,8 +142,6 @@ create public synonym ut_file_mapping for &&ut3_owner..ut_file_mapping; create public synonym ut_file_mapper for &&ut3_owner..ut_file_mapper; create public synonym ut_key_value_pairs for &&ut3_owner..ut_key_value_pairs; create public synonym ut_key_value_pair for &&ut3_owner..ut_key_value_pair; -create public synonym ut_compound_data_tmp for &&ut3_owner..ut_compound_data_tmp; -create public synonym ut_compound_data_diff_tmp for &&ut3_owner..ut_compound_data_diff_tmp; create public synonym ut_sonar_test_reporter for &&ut3_owner..ut_sonar_test_reporter; begin $if dbms_db_version.version = 12 and dbms_db_version.release >= 2 or dbms_db_version.version > 12 $then diff --git a/source/create_synonyms_and_grants_for_user.sql b/source/create_synonyms_and_grants_for_user.sql index 3044cb32f..ec04a4040 100644 --- a/source/create_synonyms_and_grants_for_user.sql +++ b/source/create_synonyms_and_grants_for_user.sql @@ -164,7 +164,6 @@ create or replace synonym &ut3_user..ut_file_mapper for &&ut3_owner..ut_file_map create or replace synonym &ut3_user..ut_key_value_pairs for &&ut3_owner..ut_key_value_pairs; create or replace synonym &ut3_user..ut_key_value_pair for &&ut3_owner..ut_key_value_pair; create or replace synonym &ut3_user..ut_compound_data_tmp for &&ut3_owner..ut_cursor_data; -create or replace synonym &ut3_user..ut_compound_data_diff_tmp for &&ut3_owner..ut_compound_data_diff_tmp; create or replace synonym &ut3_user..ut_sonar_test_reporter for &&ut3_owner..ut_sonar_test_reporter; begin $if dbms_db_version.version = 12 and dbms_db_version.release >= 2 or dbms_db_version.version > 12 $then diff --git a/source/expectations/data_values/ut_compound_data_value.tpb b/source/expectations/data_values/ut_compound_data_value.tpb index f27abd13b..c1626abc3 100644 --- a/source/expectations/data_values/ut_compound_data_value.tpb +++ b/source/expectations/data_values/ut_compound_data_value.tpb @@ -73,11 +73,9 @@ create or replace type body ut_compound_data_value as overriding member function diff( a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2, a_join_by_xpath varchar2, a_unordered boolean := false ) return varchar2 is l_result clob; - l_result_string varchar2(32767); + l_result_string varchar2(32767); begin - if a_join_by_xpath is not null then - l_result := get_data_diff(a_other, a_exclude_xpath, a_include_xpath, a_join_by_xpath); - elsif a_unordered then + if a_unordered then l_result := get_data_diff(a_other, a_exclude_xpath, a_include_xpath, a_unordered); else l_result := get_data_diff(a_other, a_exclude_xpath, a_include_xpath, a_join_by_xpath); From 8e8c3e6e117b2595847fd67558d7172bc19a3c5e Mon Sep 17 00:00:00 2001 From: Peter Ocelka Date: Fri, 4 May 2018 21:47:29 +0200 Subject: [PATCH 014/184] changed user to execute user grants --- docs/userguide/install.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/userguide/install.md b/docs/userguide/install.md index fdc91b08c..994aa14c0 100644 --- a/docs/userguide/install.md +++ b/docs/userguide/install.md @@ -140,7 +140,7 @@ To grant utPLSQL to an individual user, execute scripts `source/create_user_gran Example invocation: ```bash cd source -sqlplus admin/admins_password@database @create_user_grants.sql ut3 hr +sqlplus ut3_user/ut3_password@database @create_user_grants.sql ut3 hr sqlplus user/user_password@database @create_user_synonyms.sql ut3 hr ``` From 629d3c7e2e6febe6a16c5c2c47407ef414a98150 Mon Sep 17 00:00:00 2001 From: Pazus Date: Sat, 5 May 2018 08:51:03 +0300 Subject: [PATCH 015/184] Fixed installation order to eliminate compilation error warning Removed ampersand symbol as some IDEs (PLSQL Developer) recognize it as a parameter to be defined Removed unnecessary drop as ut_event_listener is already several lines before Fixes #657 --- source/expectations/data_values/ut_compound_data_value.tpb | 3 ++- source/install.sql | 3 ++- source/uninstall.sql | 2 -- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/source/expectations/data_values/ut_compound_data_value.tpb b/source/expectations/data_values/ut_compound_data_value.tpb index b7c43d2d8..164bc1129 100644 --- a/source/expectations/data_values/ut_compound_data_value.tpb +++ b/source/expectations/data_values/ut_compound_data_value.tpb @@ -132,6 +132,7 @@ create or replace type body ut_compound_data_value as l_result integer; --the XML stylesheet is applied on XML representation of data to exclude column names from comparison --column names and data-types are compared separately + --user CHR(38) instead of ampersand to eliminate define request when installing through some IDEs l_xml_data_fmt constant xmltype := xmltype( q'[ @@ -139,7 +140,7 @@ create or replace type body ut_compound_data_value as - + '||CHR(38)||'#xD; , diff --git a/source/install.sql b/source/install.sql index 4054086a6..09b601ff4 100644 --- a/source/install.sql +++ b/source/install.sql @@ -29,6 +29,7 @@ whenever oserror exit failure rollback prompt Switching current schema to &&ut3_owner prompt &&line_separator alter session set current_schema = &&ut3_owner; +alter session set PLSQL_WARNINGS='ENABLE:ALL'; --set define off --dbms_output buffer cache table @@ -166,7 +167,6 @@ prompt Installing DBMSPLSQL Tables objects into &&ut3_owner schema @@install_component.sql 'expectations/data_values/ut_compound_data_diff_tmp.sql' @@install_component.sql 'expectations/data_values/ut_data_value.tps' @@install_component.sql 'expectations/data_values/ut_compound_data_value.tps' -@@install_component.sql 'expectations/data_values/ut_compound_data_helper.pks' @@install_component.sql 'expectations/data_values/ut_data_value_anydata.tps' @@install_component.sql 'expectations/data_values/ut_data_value_collection.tps' @@install_component.sql 'expectations/data_values/ut_data_value_object.tps' @@ -182,6 +182,7 @@ prompt Installing DBMSPLSQL Tables objects into &&ut3_owner schema @@install_component.sql 'expectations/data_values/ut_data_value_timestamp_ltz.tps' @@install_component.sql 'expectations/data_values/ut_data_value_varchar2.tps' @@install_component.sql 'expectations/data_values/ut_data_value_yminterval.tps' +@@install_component.sql 'expectations/data_values/ut_compound_data_helper.pks' @@install_component.sql 'expectations/matchers/ut_matcher.tps' @@install_component.sql 'expectations/matchers/ut_comparison_matcher.tps' @@install_component.sql 'expectations/matchers/ut_be_false.tps' diff --git a/source/uninstall.sql b/source/uninstall.sql index 6da0e4fd9..c7a04c4d0 100644 --- a/source/uninstall.sql +++ b/source/uninstall.sql @@ -258,8 +258,6 @@ drop type ut_expectation_result force; drop package ut_event_manager; -drop type ut_event_listener force; - drop type ut_event_item force; drop type ut_key_value_pairs force; From 98b0401e890ebba72132023423c1c714a5a25c7a Mon Sep 17 00:00:00 2001 From: Pazus Date: Sat, 5 May 2018 11:21:27 +0300 Subject: [PATCH 016/184] Removed warnings from install script --- source/install.sql | 1 - 1 file changed, 1 deletion(-) diff --git a/source/install.sql b/source/install.sql index 09b601ff4..3050349e6 100644 --- a/source/install.sql +++ b/source/install.sql @@ -29,7 +29,6 @@ whenever oserror exit failure rollback prompt Switching current schema to &&ut3_owner prompt &&line_separator alter session set current_schema = &&ut3_owner; -alter session set PLSQL_WARNINGS='ENABLE:ALL'; --set define off --dbms_output buffer cache table From 0fc68d19f85df19fadd8ee3344a64c9314d7541f Mon Sep 17 00:00:00 2001 From: lwasylow Date: Sat, 5 May 2018 10:12:31 +0100 Subject: [PATCH 017/184] Update order by to be done before max row nums are pulled --- .../expectations/data_values/ut_compound_data_diff_tmp.sql | 2 +- .../expectations/data_values/ut_compound_data_helper.pkb | 7 ++++++- source/expectations/data_values/ut_compound_data_tmp.sql | 5 ++--- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/source/expectations/data_values/ut_compound_data_diff_tmp.sql b/source/expectations/data_values/ut_compound_data_diff_tmp.sql index c10226f2c..4f1385d54 100644 --- a/source/expectations/data_values/ut_compound_data_diff_tmp.sql +++ b/source/expectations/data_values/ut_compound_data_diff_tmp.sql @@ -16,7 +16,7 @@ create global temporary table ut_compound_data_diff_tmp( item_no integer, item_hash raw(128), duplicate_no integer, - --constraint ut_compound_data_diff_tmp_uk1 unique (diff_id, item_no, item_hash, duplicate_no), + constraint ut_compound_data_diff_tmp_uk1 unique (diff_id, item_no, item_hash, duplicate_no), constraint ut_compound_data_diff_tmp_chk check( item_no is not null and item_hash is null and duplicate_no is null or item_no is null and item_hash is not null and duplicate_no is not null diff --git a/source/expectations/data_values/ut_compound_data_helper.pkb b/source/expectations/data_values/ut_compound_data_helper.pkb index df5f5453b..e773f14df 100644 --- a/source/expectations/data_values/ut_compound_data_helper.pkb +++ b/source/expectations/data_values/ut_compound_data_helper.pkb @@ -178,6 +178,9 @@ create or replace package body ut_compound_data_helper is execute immediate q'[ with diff_info as (select item_hash from ut_compound_data_diff_tmp ucdc where diff_id = :diff_guid) select rn,diff_type,diffed_row + from + ( + select rn,diff_type,diffed_row from (select dense_rank() over (order by pk_hash) as rn, diff_type,data_item diffed_row from @@ -231,8 +234,10 @@ create or replace package body ut_compound_data_helper is unpivot ( data_item for diff_type in (exp_item as 'Expected:', act_item as 'Actual:' ,miss_item as 'Missing:', ext_item as 'Extra:') ) ) + order by 1, 2 + ) where rownum <= :max_rows - order by 1, 2]' + ]' bulk collect into l_results using a_diff_id, a_join_by_xpath,a_exclude_xpath, a_include_xpath, a_expected_dataset_guid, diff --git a/source/expectations/data_values/ut_compound_data_tmp.sql b/source/expectations/data_values/ut_compound_data_tmp.sql index 8af8083ef..ed548f0a9 100644 --- a/source/expectations/data_values/ut_compound_data_tmp.sql +++ b/source/expectations/data_values/ut_compound_data_tmp.sql @@ -16,7 +16,6 @@ create global temporary table ut_compound_data_tmp( item_no integer, item_data xmltype, item_hash raw(128), - duplicate_no integer - --constraint ut_cmp_data_tmp_item_ak unique (data_id, item_no), - --constraint ut_cmp_data_tmp_hash_pk unique (data_id, item_hash , duplicate_no) + duplicate_no integer, + constraint ut_cmp_data_tmp_hash_pk unique (data_id,item_no, item_hash , duplicate_no) ) on commit preserve rows; From 7f3d12ed31e8d9fc2cdb3c7aae967381639f7da9 Mon Sep 17 00:00:00 2001 From: lwasylow Date: Sat, 5 May 2018 14:40:14 +0100 Subject: [PATCH 018/184] Updated join by updated docs --- docs/userguide/advanced_data_comparison.md | 53 +++++++- .../data_values/ut_compound_data_diff_tmp.sql | 8 +- .../data_values/ut_compound_data_helper.pkb | 119 ++++++++++-------- .../data_values/ut_compound_data_value.tpb | 53 +++++--- 4 files changed, 155 insertions(+), 78 deletions(-) diff --git a/docs/userguide/advanced_data_comparison.md b/docs/userguide/advanced_data_comparison.md index 74185c3ec..3b0ae2460 100644 --- a/docs/userguide/advanced_data_comparison.md +++ b/docs/userguide/advanced_data_comparison.md @@ -7,7 +7,7 @@ utPLSQL expectations incorporates advanced data comparison options when comparin - nested table and varray Advanced data-comparison options are available for the [`equal`](expectations.md#equal) matcher. - + ## Syntax ``` @@ -58,7 +58,7 @@ Columns 'ignore_me' and "ADate" will get excluded from cursor comparison. The cursor data is equal, when those columns are excluded. This option is useful in scenarios, when you need to exclude incomparable/unpredictable column data like CREATE_DATE of a record that is maintained by default value on a table column. - + ## Selecting columns for data comparison Consider the following example @@ -95,8 +95,51 @@ Only the columns 'RN', "A_Column" will be compared. Column 'SOME_COL' is exclude This option can be useful in scenarios where you need to narrow-down the scope of test so that the test is only focused on very specific data. -## Join By option -You can now join two cursors by defining a primary key or composite key that will be used to uniqely identify and compare rows. This option allows us to exactly show which rows are missing, extra and which are diffrent without ordering clause. +##Unordered + +Unordered option allows for quick comparison of two cursors without need of ordering them in any way. + +Result of such comparison will be limited to only information about row existing or not existing in given set without actual information about exact differences. + + + +```sql +procedure unordered_tst is + l_actual sys_refcursor; + l_expected sys_refcursor; +begin + open l_expected for select username, user_id from all_users + union all + select 'TEST' username, -600 user_id from dual + order by 1 desc; + open l_actual for select username, user_id from all_users + union all + select 'TEST' username, -610 user_id from dual + order by 1 asc; + ut.expect( l_actual ).to_equal( l_expected ).unordered; +end; +``` + + + +Above test will result in two differences of one row extra and one row missing. + + + +```sql + Diff: + Rows: [ 2 differences ] + Missing: TEST-600 + Extra: TEST-610 +``` + + + + + +## Join by option + +You can now join two cursors by defining a primary key or composite key that will be used to uniquely identify and compare rows. This option allows us to exactly show which rows are missing, extra and which are different without ordering clause. ```sql procedure join_by_username is @@ -133,4 +176,4 @@ begin open l_actual for select rownum as rn, 'a' as "A_Column", 'x' SOME_COL, a.* from all_objects a where rownum < 4; ut.expect( l_actual ).to_equal( l_expected ).include( '/ROW/RN|/ROW/A_Column|/ROW/SOME_COL' ); end; -``` +``` diff --git a/source/expectations/data_values/ut_compound_data_diff_tmp.sql b/source/expectations/data_values/ut_compound_data_diff_tmp.sql index 4f1385d54..14d020061 100644 --- a/source/expectations/data_values/ut_compound_data_diff_tmp.sql +++ b/source/expectations/data_values/ut_compound_data_diff_tmp.sql @@ -14,11 +14,13 @@ create global temporary table ut_compound_data_diff_tmp( */ diff_id raw(128), item_no integer, - item_hash raw(128), + pk_hash raw(128), + item_hash raw(128), duplicate_no integer, - constraint ut_compound_data_diff_tmp_uk1 unique (diff_id, item_no, item_hash, duplicate_no), + constraint ut_compound_data_diff_tmp_uk1 unique (diff_id,duplicate_no,item_no,item_hash, pk_hash), constraint ut_compound_data_diff_tmp_chk check( - item_no is not null and item_hash is null and duplicate_no is null + item_no is not null and pk_hash is null and duplicate_no is null or item_no is null and item_hash is not null and duplicate_no is not null + or item_no is null and pk_hash is not null and duplicate_no is not null ) ) on commit preserve rows; diff --git a/source/expectations/data_values/ut_compound_data_helper.pkb b/source/expectations/data_values/ut_compound_data_helper.pkb index e773f14df..e8c1e4e49 100644 --- a/source/expectations/data_values/ut_compound_data_helper.pkb +++ b/source/expectations/data_values/ut_compound_data_helper.pkb @@ -176,72 +176,85 @@ create or replace package body ut_compound_data_helper is **/ execute immediate q'[ - with diff_info as (select item_hash from ut_compound_data_diff_tmp ucdc where diff_id = :diff_guid) - select rn,diff_type,diffed_row - from + with diff_info as (select item_hash,pk_hash from ut_compound_data_diff_tmp ucdc where diff_id = :diff_guid) + select rn,diff_type,diffed_row from ( - select rn,diff_type,diffed_row - from - (select dense_rank() over (order by pk_hash) as rn, diff_type,data_item diffed_row + select diff_type,diffed_row, dense_rank() over (order by pk_hash) rn from + ( + select diff_type,diffed_row,pk_hash from + (select diff_type,data_item diffed_row,pk_hash from - (select pk_hash - ,case when exp_item is not null and act_item is not null then exp_item else null end exp_item - ,case when exp_item is not null and act_item is not null then act_item else null end act_item - ,case when exp_item is not null and act_item is null then exp_item else null end miss_item - ,case when exp_item is null and act_item is not null then act_item else null end ext_item - from - (select nvl(exp.pk_hash, act.pk_hash) pk_hash, + (select nvl(exp.pk_hash, act.pk_hash) pk_hash, xmlserialize(content exp.row_data no indent) exp_item, xmlserialize(content act.row_data no indent) act_item from (select ucd.*, row_number() over(partition by pk_hash order by row_hash) duplicate_no from (select ucd.column_value row_data, - dbms_crypto.hash( value(ucd).getclobval(),3) row_hash, - dbms_crypto.hash( extract(value(ucd), :join_by_xpath ).getClobVal(),3/*HASH_SH1*/) pk_hash + r.item_hash row_hash, + r.pk_hash , + ucd.column_value.getRootElement() col_name, + ucd.column_value.getclobval() col_val from - (select ]'||l_column_filter||q'[, ucd.item_no, ucd.item_data item_data_no_filter - from ut_compound_data_tmp ucd + (select ]'||l_column_filter||q'[, ucd.item_no, ucd.item_hash, i.pk_hash + from ut_compound_data_tmp ucd, + diff_info i where ucd.data_id = :self_guid - and ucd.item_hash in (select i.item_hash from diff_info i) + and ucd.item_hash = i.item_hash ) r, - table( xmlsequence( extract(r.item_data,'/*') ) ) ucd + table( xmlsequence( extract(r.item_data,'/*/*') ) ) ucd ) ucd ) exp - full outer join ( + join ( select ucd.*, row_number() over(partition by pk_hash order by row_hash) duplicate_no from (select ucd.column_value row_data, - dbms_crypto.hash( value(ucd).getclobval(),3/*HASH_SH1*/) row_hash, - dbms_crypto.hash( extract(value(ucd), :join_by_xpath ).getClobVal(),3/*HASH_SH1*/) pk_hash + r.item_hash row_hash, + r.pk_hash , + ucd.column_value.getRootElement() col_name, + ucd.column_value.getclobval() col_val from - (select ]'||l_column_filter||q'[, ucd.item_no, ucd.item_data item_data_no_filter - from ut_compound_data_tmp ucd + (select ]'||l_column_filter||q'[, ucd.item_no, ucd.item_hash, i.pk_hash + from ut_compound_data_tmp ucd, + diff_info i where ucd.data_id = :other_guid - and ucd.item_hash in (select i.item_hash from diff_info i) + and ucd.item_hash = i.item_hash ) r, - table( xmlsequence( extract(r.item_data,'/*') ) ) ucd + table( xmlsequence( extract(r.item_data,'/*/*') ) ) ucd ) ucd ) act on exp.pk_hash = act.pk_hash and exp.duplicate_no = act.duplicate_no - where (exp.row_hash != act.row_hash and act.pk_hash = exp.pk_hash) or - ( - (exp.pk_hash is null or act.pk_hash is null) and - (exp.row_hash is null or act.row_hash is null) - ) + where dbms_lob.compare(exp.col_val, act.col_val) != 0 ) - ) - unpivot ( data_item for diff_type in (exp_item as 'Expected:', act_item as 'Actual:' - ,miss_item as 'Missing:', ext_item as 'Extra:') ) + unpivot ( data_item for diff_type in (exp_item as 'Expected:', act_item as 'Actual:') ) ) - order by 1, 2 - ) - where rownum <= :max_rows + union all + select case when exp.pk_hash is null then 'Extra:' else 'Missing:' end as diff_type, + xmlserialize(content nvl(exp.item_data, act.item_data) no indent) diffed_row, + coalesce(exp.pk_hash,act.pk_hash) pk_hash + from (select extract(ucd.item_data,'/*/*') item_data,i.pk_hash + from ut_compound_data_tmp ucd, + diff_info i + where ucd.data_id = :self_guid + and ucd.item_hash = i.item_hash + ) exp + full outer join ( + select extract(ucd.item_data,'/*/*') item_data,i.pk_hash + from ut_compound_data_tmp ucd, + diff_info i + where ucd.data_id = :other_guid + and ucd.item_hash = i.item_hash + )act + on exp.pk_hash = act.pk_hash + where exp.pk_hash is null or act.pk_hash is null + ) + ) where rn <= :max_rows ]' bulk collect into l_results using a_diff_id, - a_join_by_xpath,a_exclude_xpath, a_include_xpath, a_expected_dataset_guid, - a_join_by_xpath,a_exclude_xpath, a_include_xpath, a_actual_dataset_guid, + a_exclude_xpath, a_include_xpath, a_expected_dataset_guid, + a_exclude_xpath, a_include_xpath, a_actual_dataset_guid, + a_expected_dataset_guid, a_actual_dataset_guid, a_max_rows; return l_results; end; @@ -266,9 +279,10 @@ create or replace package body ut_compound_data_helper is s.column_value.getRootElement() col_name, s.column_value.getclobval() col_val from (select ]'||l_column_filter||q'[, ucd.item_no, ucd.item_data item_data_no_filter - from ut_compound_data_tmp ucd + from ut_compound_data_tmp ucd, + diff_info i where ucd.data_id = :self_guid - and ucd.item_no in (select i.item_no from diff_info i) + and ucd.item_no = i.item_no ) r, table( xmlsequence( extract(r.item_data,'/*/*') ) ) s ) exp @@ -277,9 +291,10 @@ create or replace package body ut_compound_data_helper is s.column_value.getRootElement() col_name, s.column_value.getclobval() col_val from (select ]'||l_column_filter||q'[, ucd.item_no, ucd.item_data item_data_no_filter - from ut_compound_data_tmp ucd + from ut_compound_data_tmp ucd, + diff_info i where ucd.data_id = :other_guid - and ucd.item_no in (select i.item_no from diff_info i) + and ucd.item_no = i.item_no ) r, table( xmlsequence( extract(r.item_data,'/*/*') ) ) s ) act @@ -348,11 +363,12 @@ create or replace package body ut_compound_data_helper is end diffed_row from (select ucd.*, row_number() over(partition by row_hash order by row_hash) duplicate_no from (select ucd.column_value row_data, - dbms_crypto.hash( value(ucd).getclobval(),3) row_hash - from (select ]'||l_column_filter||q'[, ucd.item_no, ucd.item_data item_data_no_filter - from ut_compound_data_tmp ucd + r.item_hash row_hash + from (select ]'||l_column_filter||q'[, ucd.item_no, i.item_hash + from ut_compound_data_tmp ucd, + diff_info i where ucd.data_id = :self_guid - and ucd.item_hash in (select i.item_hash from diff_info i) + and ucd.item_hash = i.item_hash ) r, table( xmlsequence( extract(r.item_data,'/*') ) ) ucd ) ucd @@ -360,11 +376,12 @@ create or replace package body ut_compound_data_helper is full outer join (select ucd.*, row_number() over(partition by row_hash order by row_hash) duplicate_no from (select ucd.column_value row_data, - dbms_crypto.hash( value(ucd).getclobval(),3/*HASH_SH1*/) row_hash - from (select ]'||l_column_filter||q'[, ucd.item_no, ucd.item_data item_data_no_filter - from ut_compound_data_tmp ucd + r.item_hash row_hash + from (select ]'||l_column_filter||q'[, ucd.item_no, i.item_hash + from ut_compound_data_tmp ucd, + diff_info i where ucd.data_id = :other_guid - and ucd.item_hash in (select i.item_hash from diff_info i) + and ucd.item_hash = i.item_hash ) r, table( xmlsequence( extract(r.item_data,'/*') ) ) ucd ) ucd diff --git a/source/expectations/data_values/ut_compound_data_value.tpb b/source/expectations/data_values/ut_compound_data_value.tpb index c1626abc3..62b720503 100644 --- a/source/expectations/data_values/ut_compound_data_value.tpb +++ b/source/expectations/data_values/ut_compound_data_value.tpb @@ -150,7 +150,9 @@ create or replace type body ut_compound_data_value as --diff rows and row elements l_diff_id := ut_compound_data_helper.get_hash(self.data_id||l_actual.data_id); -- First tell how many rows are different - execute immediate 'select count(*) from ' || l_ut_owner || '.ut_compound_data_diff_tmp where diff_id = :diff_id' into l_diff_row_count using l_diff_id; + execute immediate 'select count('||case when a_join_by_xpath is not null then 'distinct pk_hash' else '*' end||') from ' + || l_ut_owner || '.ut_compound_data_diff_tmp + where diff_id = :diff_id' into l_diff_row_count using l_diff_id; if l_diff_row_count > 0 then if a_join_by_xpath is not null then @@ -253,34 +255,47 @@ create or replace type body ut_compound_data_value as l_column_filter := ut_compound_data_helper.get_columns_filter(a_exclude_xpath, a_include_xpath); -- Pre generate hash minus to leave only onese that are diffrent, for example duplicates or diffrent hash - execute immediate 'insert into ' || l_ut_owner || '.ut_compound_data_diff_tmp ( diff_id,item_hash,duplicate_no ) - select :diff_id,x.item_hash,tmp.duplicate_no + execute immediate 'insert into ' || l_ut_owner || '.ut_compound_data_diff_tmp ( diff_id,item_hash,pk_hash,duplicate_no ) + select distinct :diff_id,tmp.item_hash,tmp.pk_hash,tmp.duplicate_no from( ( - select item_hash,row_number() over (partition by item_hash,data_id order by 1) duplicate_no - from ' || l_ut_owner || '.ut_compound_data_tmp + select t.item_hash,row_number() over (partition by t.item_hash,t.data_id order by 1,2) duplicate_no,'|| + case when a_join_by_xpath is null then ':join_by_xpath pk_hash' else + l_ut_owner||'.ut_compound_data_helper.get_hash( extract(value(ucd), :join_by_xpath ).GetClobVal()) pk_hash' + end + ||' from ' || l_ut_owner || '.ut_compound_data_tmp t, + table( xmlsequence( extract(t.item_data,''/*'') ) ) ucd where data_id = :self_guid minus - select item_hash,row_number() over (partition by item_hash,data_id order by 1) - from ' || l_ut_owner || '.ut_compound_data_tmp + select t.item_hash,row_number() over (partition by t.item_hash,t.data_id order by 1,2),'|| + case when a_join_by_xpath is null then ':join_by_xpath pk_hash' else + l_ut_owner||'.ut_compound_data_helper.get_hash( extract(value(ucd), :join_by_xpath ).GetClobVal()) pk_hash' + end + ||' from ' || l_ut_owner || '.ut_compound_data_tmp t, + table( xmlsequence( extract(t.item_data,''/*'') ) ) ucd where data_id = :other_guid - ) + ) union all ( - select item_hash,row_number() over (partition by item_hash,data_id order by 1) - from ' || l_ut_owner || '.ut_compound_data_tmp + select t.item_hash,row_number() over (partition by t.item_hash,t.data_id order by 1,2),'|| + case when a_join_by_xpath is null then ':join_by_xpath pk_hash' else + l_ut_owner||'.ut_compound_data_helper.get_hash( extract(value(ucd), :join_by_xpath ).GetClobVal()) pk_hash' + end + ||' from ' || l_ut_owner || '.ut_compound_data_tmp t, + table( xmlsequence( extract(t.item_data,''/*'') ) ) ucd where data_id = :other_guid minus - select item_hash,row_number() over (partition by item_hash,data_id order by 1) - from ' || l_ut_owner || '.ut_compound_data_tmp + select t.item_hash,row_number() over (partition by t.item_hash,t.data_id order by 1,2) ,'|| + case when a_join_by_xpath is null then ':join_by_xpath pk_hash' else + l_ut_owner||'.ut_compound_data_helper.get_hash( extract(value(ucd), :join_by_xpath ).GetClobVal()) pk_hash' + end + ||' from ' || l_ut_owner || '.ut_compound_data_tmp t, + table( xmlsequence( extract(t.item_data,''/*'') ) ) ucd where data_id = :self_guid - ))tmp - , ' || l_ut_owner || '.ut_compound_data_tmp x - where tmp.item_hash = x.item_hash - and x.data_id in (:self_guid,:other_guid)' - using l_diff_id, self.data_id, l_other.data_id - ,l_other.data_id,self.data_id, - self.data_id, l_other.data_id; + ))tmp' + using l_diff_id, + a_join_by_xpath,self.data_id,a_join_by_xpath, l_other.data_id, + a_join_by_xpath,l_other.data_id,a_join_by_xpath,self.data_id; --result is OK only if both are same if sql%rowcount = 0 and self.elements_count = l_other.elements_count then l_result := 0; From b8840a177b7e735975999d36013abf5b2ecfb35e Mon Sep 17 00:00:00 2001 From: lwasylow Date: Sat, 5 May 2018 14:40:14 +0100 Subject: [PATCH 019/184] Updated join by updated docs --- docs/userguide/advanced_data_comparison.md | 53 +++++++- .../data_values/ut_compound_data_diff_tmp.sql | 8 +- .../data_values/ut_compound_data_helper.pkb | 128 ++++++++++-------- .../data_values/ut_compound_data_tmp.sql | 1 + .../data_values/ut_compound_data_value.tpb | 83 +++++++++--- 5 files changed, 191 insertions(+), 82 deletions(-) diff --git a/docs/userguide/advanced_data_comparison.md b/docs/userguide/advanced_data_comparison.md index 74185c3ec..3b0ae2460 100644 --- a/docs/userguide/advanced_data_comparison.md +++ b/docs/userguide/advanced_data_comparison.md @@ -7,7 +7,7 @@ utPLSQL expectations incorporates advanced data comparison options when comparin - nested table and varray Advanced data-comparison options are available for the [`equal`](expectations.md#equal) matcher. - + ## Syntax ``` @@ -58,7 +58,7 @@ Columns 'ignore_me' and "ADate" will get excluded from cursor comparison. The cursor data is equal, when those columns are excluded. This option is useful in scenarios, when you need to exclude incomparable/unpredictable column data like CREATE_DATE of a record that is maintained by default value on a table column. - + ## Selecting columns for data comparison Consider the following example @@ -95,8 +95,51 @@ Only the columns 'RN', "A_Column" will be compared. Column 'SOME_COL' is exclude This option can be useful in scenarios where you need to narrow-down the scope of test so that the test is only focused on very specific data. -## Join By option -You can now join two cursors by defining a primary key or composite key that will be used to uniqely identify and compare rows. This option allows us to exactly show which rows are missing, extra and which are diffrent without ordering clause. +##Unordered + +Unordered option allows for quick comparison of two cursors without need of ordering them in any way. + +Result of such comparison will be limited to only information about row existing or not existing in given set without actual information about exact differences. + + + +```sql +procedure unordered_tst is + l_actual sys_refcursor; + l_expected sys_refcursor; +begin + open l_expected for select username, user_id from all_users + union all + select 'TEST' username, -600 user_id from dual + order by 1 desc; + open l_actual for select username, user_id from all_users + union all + select 'TEST' username, -610 user_id from dual + order by 1 asc; + ut.expect( l_actual ).to_equal( l_expected ).unordered; +end; +``` + + + +Above test will result in two differences of one row extra and one row missing. + + + +```sql + Diff: + Rows: [ 2 differences ] + Missing: TEST-600 + Extra: TEST-610 +``` + + + + + +## Join by option + +You can now join two cursors by defining a primary key or composite key that will be used to uniquely identify and compare rows. This option allows us to exactly show which rows are missing, extra and which are different without ordering clause. ```sql procedure join_by_username is @@ -133,4 +176,4 @@ begin open l_actual for select rownum as rn, 'a' as "A_Column", 'x' SOME_COL, a.* from all_objects a where rownum < 4; ut.expect( l_actual ).to_equal( l_expected ).include( '/ROW/RN|/ROW/A_Column|/ROW/SOME_COL' ); end; -``` +``` diff --git a/source/expectations/data_values/ut_compound_data_diff_tmp.sql b/source/expectations/data_values/ut_compound_data_diff_tmp.sql index 4f1385d54..14d020061 100644 --- a/source/expectations/data_values/ut_compound_data_diff_tmp.sql +++ b/source/expectations/data_values/ut_compound_data_diff_tmp.sql @@ -14,11 +14,13 @@ create global temporary table ut_compound_data_diff_tmp( */ diff_id raw(128), item_no integer, - item_hash raw(128), + pk_hash raw(128), + item_hash raw(128), duplicate_no integer, - constraint ut_compound_data_diff_tmp_uk1 unique (diff_id, item_no, item_hash, duplicate_no), + constraint ut_compound_data_diff_tmp_uk1 unique (diff_id,duplicate_no,item_no,item_hash, pk_hash), constraint ut_compound_data_diff_tmp_chk check( - item_no is not null and item_hash is null and duplicate_no is null + item_no is not null and pk_hash is null and duplicate_no is null or item_no is null and item_hash is not null and duplicate_no is not null + or item_no is null and pk_hash is not null and duplicate_no is not null ) ) on commit preserve rows; diff --git a/source/expectations/data_values/ut_compound_data_helper.pkb b/source/expectations/data_values/ut_compound_data_helper.pkb index e773f14df..83991edb9 100644 --- a/source/expectations/data_values/ut_compound_data_helper.pkb +++ b/source/expectations/data_values/ut_compound_data_helper.pkb @@ -176,72 +176,85 @@ create or replace package body ut_compound_data_helper is **/ execute immediate q'[ - with diff_info as (select item_hash from ut_compound_data_diff_tmp ucdc where diff_id = :diff_guid) - select rn,diff_type,diffed_row - from + with diff_info as (select item_hash,pk_hash from ut_compound_data_diff_tmp ucdc where diff_id = :diff_guid) + select rn,diff_type,diffed_row from ( - select rn,diff_type,diffed_row - from - (select dense_rank() over (order by pk_hash) as rn, diff_type,data_item diffed_row + select diff_type,diffed_row, dense_rank() over (order by pk_hash) rn from + ( + select diff_type,diffed_row,pk_hash from + (select diff_type,data_item diffed_row,pk_hash from - (select pk_hash - ,case when exp_item is not null and act_item is not null then exp_item else null end exp_item - ,case when exp_item is not null and act_item is not null then act_item else null end act_item - ,case when exp_item is not null and act_item is null then exp_item else null end miss_item - ,case when exp_item is null and act_item is not null then act_item else null end ext_item - from - (select nvl(exp.pk_hash, act.pk_hash) pk_hash, + (select nvl(exp.pk_hash, act.pk_hash) pk_hash, xmlserialize(content exp.row_data no indent) exp_item, xmlserialize(content act.row_data no indent) act_item from (select ucd.*, row_number() over(partition by pk_hash order by row_hash) duplicate_no from (select ucd.column_value row_data, - dbms_crypto.hash( value(ucd).getclobval(),3) row_hash, - dbms_crypto.hash( extract(value(ucd), :join_by_xpath ).getClobVal(),3/*HASH_SH1*/) pk_hash + r.item_hash row_hash, + r.pk_hash , + ucd.column_value.getRootElement() col_name, + ucd.column_value.getclobval() col_val from - (select ]'||l_column_filter||q'[, ucd.item_no, ucd.item_data item_data_no_filter - from ut_compound_data_tmp ucd + (select ]'||l_column_filter||q'[, ucd.item_no, ucd.item_hash, i.pk_hash + from ut_compound_data_tmp ucd, + diff_info i where ucd.data_id = :self_guid - and ucd.item_hash in (select i.item_hash from diff_info i) + and ucd.item_hash = i.item_hash ) r, - table( xmlsequence( extract(r.item_data,'/*') ) ) ucd + table( xmlsequence( extract(r.item_data,'/*/*') ) ) ucd ) ucd ) exp - full outer join ( + join ( select ucd.*, row_number() over(partition by pk_hash order by row_hash) duplicate_no from (select ucd.column_value row_data, - dbms_crypto.hash( value(ucd).getclobval(),3/*HASH_SH1*/) row_hash, - dbms_crypto.hash( extract(value(ucd), :join_by_xpath ).getClobVal(),3/*HASH_SH1*/) pk_hash + r.item_hash row_hash, + r.pk_hash , + ucd.column_value.getRootElement() col_name, + ucd.column_value.getclobval() col_val from - (select ]'||l_column_filter||q'[, ucd.item_no, ucd.item_data item_data_no_filter - from ut_compound_data_tmp ucd + (select ]'||l_column_filter||q'[, ucd.item_no, ucd.item_hash, i.pk_hash + from ut_compound_data_tmp ucd, + diff_info i where ucd.data_id = :other_guid - and ucd.item_hash in (select i.item_hash from diff_info i) + and ucd.item_hash = i.item_hash ) r, - table( xmlsequence( extract(r.item_data,'/*') ) ) ucd + table( xmlsequence( extract(r.item_data,'/*/*') ) ) ucd ) ucd ) act on exp.pk_hash = act.pk_hash and exp.duplicate_no = act.duplicate_no - where (exp.row_hash != act.row_hash and act.pk_hash = exp.pk_hash) or - ( - (exp.pk_hash is null or act.pk_hash is null) and - (exp.row_hash is null or act.row_hash is null) - ) + where dbms_lob.compare(exp.col_val, act.col_val) != 0 ) - ) - unpivot ( data_item for diff_type in (exp_item as 'Expected:', act_item as 'Actual:' - ,miss_item as 'Missing:', ext_item as 'Extra:') ) + unpivot ( data_item for diff_type in (exp_item as 'Expected:', act_item as 'Actual:') ) ) - order by 1, 2 - ) - where rownum <= :max_rows + union all + select case when exp.pk_hash is null then 'Extra:' else 'Missing:' end as diff_type, + xmlserialize(content nvl(exp.item_data, act.item_data) no indent) diffed_row, + coalesce(exp.pk_hash,act.pk_hash) pk_hash + from (select extract(ucd.item_data,'/*/*') item_data,i.pk_hash + from ut_compound_data_tmp ucd, + diff_info i + where ucd.data_id = :self_guid + and ucd.item_hash = i.item_hash + ) exp + full outer join ( + select extract(ucd.item_data,'/*/*') item_data,i.pk_hash + from ut_compound_data_tmp ucd, + diff_info i + where ucd.data_id = :other_guid + and ucd.item_hash = i.item_hash + )act + on exp.pk_hash = act.pk_hash + where exp.pk_hash is null or act.pk_hash is null + ) + ) where rn <= :max_rows ]' bulk collect into l_results using a_diff_id, - a_join_by_xpath,a_exclude_xpath, a_include_xpath, a_expected_dataset_guid, - a_join_by_xpath,a_exclude_xpath, a_include_xpath, a_actual_dataset_guid, + a_exclude_xpath, a_include_xpath, a_expected_dataset_guid, + a_exclude_xpath, a_include_xpath, a_actual_dataset_guid, + a_expected_dataset_guid, a_actual_dataset_guid, a_max_rows; return l_results; end; @@ -266,9 +279,10 @@ create or replace package body ut_compound_data_helper is s.column_value.getRootElement() col_name, s.column_value.getclobval() col_val from (select ]'||l_column_filter||q'[, ucd.item_no, ucd.item_data item_data_no_filter - from ut_compound_data_tmp ucd + from ut_compound_data_tmp ucd, + diff_info i where ucd.data_id = :self_guid - and ucd.item_no in (select i.item_no from diff_info i) + and ucd.item_no = i.item_no ) r, table( xmlsequence( extract(r.item_data,'/*/*') ) ) s ) exp @@ -277,9 +291,10 @@ create or replace package body ut_compound_data_helper is s.column_value.getRootElement() col_name, s.column_value.getclobval() col_val from (select ]'||l_column_filter||q'[, ucd.item_no, ucd.item_data item_data_no_filter - from ut_compound_data_tmp ucd + from ut_compound_data_tmp ucd, + diff_info i where ucd.data_id = :other_guid - and ucd.item_no in (select i.item_no from diff_info i) + and ucd.item_no = i.item_no ) r, table( xmlsequence( extract(r.item_data,'/*/*') ) ) s ) act @@ -328,8 +343,9 @@ create or replace package body ut_compound_data_helper is * Since its unordered search we cannot select max rows from diffs as we miss some comparision records * We will restrict output on higher level of select */ + execute immediate q'[with - diff_info as (select item_hash from ut_compound_data_diff_tmp ucdc where diff_id = :diff_guid) + diff_info as (select item_hash,duplicate_no from ut_compound_data_diff_tmp ucdc where diff_id = :diff_guid) select duplicate_no, diffed_type, diffed_row @@ -346,25 +362,29 @@ create or replace package body ut_compound_data_helper is when act.row_hash is null then xmlserialize(content exp.row_data no indent) end diffed_row - from (select ucd.*, row_number() over(partition by row_hash order by row_hash) duplicate_no + from (select ucd.* from (select ucd.column_value row_data, - dbms_crypto.hash( value(ucd).getclobval(),3) row_hash - from (select ]'||l_column_filter||q'[, ucd.item_no, ucd.item_data item_data_no_filter - from ut_compound_data_tmp ucd + r.item_hash row_hash, + r.duplicate_no + from (select ]'||l_column_filter||q'[, ucd.item_no, i.item_hash, i.duplicate_no + from ut_compound_data_tmp ucd, + diff_info i where ucd.data_id = :self_guid - and ucd.item_hash in (select i.item_hash from diff_info i) + and ucd.item_hash = i.item_hash ) r, table( xmlsequence( extract(r.item_data,'/*') ) ) ucd ) ucd ) exp full outer join - (select ucd.*, row_number() over(partition by row_hash order by row_hash) duplicate_no + (select ucd.* from (select ucd.column_value row_data, - dbms_crypto.hash( value(ucd).getclobval(),3/*HASH_SH1*/) row_hash - from (select ]'||l_column_filter||q'[, ucd.item_no, ucd.item_data item_data_no_filter - from ut_compound_data_tmp ucd + r.item_hash row_hash, + r.duplicate_no + from (select ]'||l_column_filter||q'[, ucd.item_no, i.item_hash, i.duplicate_no + from ut_compound_data_tmp ucd, + diff_info i where ucd.data_id = :other_guid - and ucd.item_hash in (select i.item_hash from diff_info i) + and ucd.item_hash = i.item_hash ) r, table( xmlsequence( extract(r.item_data,'/*') ) ) ucd ) ucd diff --git a/source/expectations/data_values/ut_compound_data_tmp.sql b/source/expectations/data_values/ut_compound_data_tmp.sql index ed548f0a9..827ab9066 100644 --- a/source/expectations/data_values/ut_compound_data_tmp.sql +++ b/source/expectations/data_values/ut_compound_data_tmp.sql @@ -16,6 +16,7 @@ create global temporary table ut_compound_data_tmp( item_no integer, item_data xmltype, item_hash raw(128), + pk_hash raw(128), duplicate_no integer, constraint ut_cmp_data_tmp_hash_pk unique (data_id,item_no, item_hash , duplicate_no) ) on commit preserve rows; diff --git a/source/expectations/data_values/ut_compound_data_value.tpb b/source/expectations/data_values/ut_compound_data_value.tpb index c1626abc3..961481d28 100644 --- a/source/expectations/data_values/ut_compound_data_value.tpb +++ b/source/expectations/data_values/ut_compound_data_value.tpb @@ -150,7 +150,9 @@ create or replace type body ut_compound_data_value as --diff rows and row elements l_diff_id := ut_compound_data_helper.get_hash(self.data_id||l_actual.data_id); -- First tell how many rows are different - execute immediate 'select count(*) from ' || l_ut_owner || '.ut_compound_data_diff_tmp where diff_id = :diff_id' into l_diff_row_count using l_diff_id; + execute immediate 'select count('||case when a_join_by_xpath is not null then 'distinct pk_hash' else '*' end||') from ' + || l_ut_owner || '.ut_compound_data_diff_tmp + where diff_id = :diff_id' into l_diff_row_count using l_diff_id; if l_diff_row_count > 0 then if a_join_by_xpath is not null then @@ -241,7 +243,18 @@ create or replace type body ut_compound_data_value as l_diff_id ut_compound_data_helper.t_hash; l_result integer; l_row_diffs ut_compound_data_helper.tt_row_diffs; - c_max_rows constant integer := 20; + c_max_rows constant integer := 20; + + type t_fetch_pk_hash_rec is record + ( + data_id raw(32), + item_hash raw(128), + item_data xmltype + ); + type t_fetch_pk_hash_tab is table of t_fetch_pk_hash_rec; + + l_fetch_tab t_fetch_pk_hash_tab; + l_pk_hash_cursor sys_refcursor; begin if not a_other is of (ut_compound_data_value) then raise value_error; @@ -252,35 +265,65 @@ create or replace type body ut_compound_data_value as l_diff_id := ut_compound_data_helper.get_hash(self.data_id||l_other.data_id); l_column_filter := ut_compound_data_helper.get_columns_filter(a_exclude_xpath, a_include_xpath); + /** + * Due to incompatibility issues in XML between 11 and 12.2 and 12.1 versions we will prepopulate pk_hash upfront to + * avoid optimizer incorrectly rewrite and causing NULL error or ORA-600 + **/ + + if a_join_by_xpath is not null then + + open l_pk_hash_cursor for q'[select t.data_id,t.item_hash,t.item_data + from ]'|| l_ut_owner ||q'[.ut_compound_data_tmp t + ,xmltable('*' + passing t.item_data + columns + xml_pk_hash clob path ']'|| a_join_by_xpath ||q'[' + ) ucd + where data_id = :self_guid or data_id = :other_guid ]' + using self.data_id, l_other.data_id; + fetch l_pk_hash_cursor bulk collect into l_fetch_tab; + for pks in 1..l_fetch_tab.COUNT + loop + execute immediate 'update '|| l_ut_owner ||'.ut_compound_data_tmp + set pk_hash = '|| l_ut_owner ||'.ut_compound_data_helper.get_hash(extract(:item_data,:join_by_xpath).GetClobVal()) + where item_hash = :item_hash' + using l_fetch_tab(pks).item_data,a_join_by_xpath , l_fetch_tab(pks).item_hash; + end loop; + + close l_pk_hash_cursor; + end if; + + -- Pre generate hash minus to leave only onese that are diffrent, for example duplicates or diffrent hash - execute immediate 'insert into ' || l_ut_owner || '.ut_compound_data_diff_tmp ( diff_id,item_hash,duplicate_no ) - select :diff_id,x.item_hash,tmp.duplicate_no + execute immediate 'insert into ' || l_ut_owner || '.ut_compound_data_diff_tmp ( diff_id,item_hash,pk_hash,duplicate_no ) + select distinct :diff_id,tmp.item_hash,tmp.pk_hash,tmp.duplicate_no from( ( - select item_hash,row_number() over (partition by item_hash,data_id order by 1) duplicate_no - from ' || l_ut_owner || '.ut_compound_data_tmp + select t.item_hash,row_number() over (partition by t.item_hash,t.data_id order by 1,2) duplicate_no, + pk_hash + from ' || l_ut_owner || '.ut_compound_data_tmp t where data_id = :self_guid minus - select item_hash,row_number() over (partition by item_hash,data_id order by 1) - from ' || l_ut_owner || '.ut_compound_data_tmp + select t.item_hash,row_number() over (partition by t.item_hash,t.data_id order by 1,2) duplicate_no, + pk_hash + from ' || l_ut_owner || '.ut_compound_data_tmp t where data_id = :other_guid - ) + ) union all ( - select item_hash,row_number() over (partition by item_hash,data_id order by 1) - from ' || l_ut_owner || '.ut_compound_data_tmp + select t.item_hash,row_number() over (partition by t.item_hash,t.data_id order by 1,2) duplicate_no, + pk_hash + from ' || l_ut_owner || '.ut_compound_data_tmp t where data_id = :other_guid minus - select item_hash,row_number() over (partition by item_hash,data_id order by 1) - from ' || l_ut_owner || '.ut_compound_data_tmp + select t.item_hash,row_number() over (partition by t.item_hash,t.data_id order by 1,2) duplicate_no, + pk_hash + from ' || l_ut_owner || '.ut_compound_data_tmp t where data_id = :self_guid - ))tmp - , ' || l_ut_owner || '.ut_compound_data_tmp x - where tmp.item_hash = x.item_hash - and x.data_id in (:self_guid,:other_guid)' - using l_diff_id, self.data_id, l_other.data_id - ,l_other.data_id,self.data_id, - self.data_id, l_other.data_id; + ))tmp' + using l_diff_id, + self.data_id, l_other.data_id, + l_other.data_id,self.data_id; --result is OK only if both are same if sql%rowcount = 0 and self.elements_count = l_other.elements_count then l_result := 0; From aaa0cc465eb94ab4769d49a489c5f108a5964df4 Mon Sep 17 00:00:00 2001 From: lwasylow Date: Mon, 7 May 2018 08:14:56 +0100 Subject: [PATCH 020/184] Update to sort random order cause of optimizer Capture PK Hash to improve lookup --- docs/userguide/advanced_data_comparison.md | 12 +- .../data_values/ut_compound_data_diff_tmp.sql | 3 +- .../data_values/ut_compound_data_helper.pkb | 34 +++-- .../data_values/ut_compound_data_helper.pks | 3 +- .../data_values/ut_compound_data_tmp.sql | 1 - .../data_values/ut_compound_data_value.tpb | 129 +++++++++++------- .../test_expectations_cursor.pkb | 15 +- .../test_expectations_cursor.pks | 3 + 8 files changed, 134 insertions(+), 66 deletions(-) diff --git a/docs/userguide/advanced_data_comparison.md b/docs/userguide/advanced_data_comparison.md index 3b0ae2460..e003b0c47 100644 --- a/docs/userguide/advanced_data_comparison.md +++ b/docs/userguide/advanced_data_comparison.md @@ -137,7 +137,7 @@ Above test will result in two differences of one row extra and one row missing. -## Join by option +## Join By option You can now join two cursors by defining a primary key or composite key that will be used to uniquely identify and compare rows. This option allows us to exactly show which rows are missing, extra and which are different without ordering clause. @@ -157,7 +157,15 @@ begin ut.expect( l_actual ).to_equal( l_expected ).join_by('USERNAME'); end; ``` -This will show you diffrence in row 'TEST' regardless of order. +This will show you difference in row 'TEST' regardless of order. + +```sql + Rows: [ 1 differences ] + Expected: -600 for key: TEST + Actual: -610 for key: TEST +``` + +**Please note that .join_by option will take longer to process due to need of parsing via primary keys.** ## Defining item as XPath When using XPath expression, keep in mind the following: diff --git a/source/expectations/data_values/ut_compound_data_diff_tmp.sql b/source/expectations/data_values/ut_compound_data_diff_tmp.sql index 14d020061..95cb2f1f0 100644 --- a/source/expectations/data_values/ut_compound_data_diff_tmp.sql +++ b/source/expectations/data_values/ut_compound_data_diff_tmp.sql @@ -15,7 +15,8 @@ create global temporary table ut_compound_data_diff_tmp( diff_id raw(128), item_no integer, pk_hash raw(128), - item_hash raw(128), + pk_value varchar2(4000), + item_hash raw(128), duplicate_no integer, constraint ut_compound_data_diff_tmp_uk1 unique (diff_id,duplicate_no,item_no,item_hash, pk_hash), constraint ut_compound_data_diff_tmp_chk check( diff --git a/source/expectations/data_values/ut_compound_data_helper.pkb b/source/expectations/data_values/ut_compound_data_helper.pkb index 83991edb9..1b22386dd 100644 --- a/source/expectations/data_values/ut_compound_data_helper.pkb +++ b/source/expectations/data_values/ut_compound_data_helper.pkb @@ -176,15 +176,15 @@ create or replace package body ut_compound_data_helper is **/ execute immediate q'[ - with diff_info as (select item_hash,pk_hash from ut_compound_data_diff_tmp ucdc where diff_id = :diff_guid) - select rn,diff_type,diffed_row from + with diff_info as (select item_hash,pk_hash,pk_value from ut_compound_data_diff_tmp ucdc where diff_id = :diff_guid) + select rn,diff_type,diffed_row,pk_value from ( - select diff_type,diffed_row, dense_rank() over (order by pk_hash) rn from + select diff_type,diffed_row, dense_rank() over (order by pk_hash) rn,pk_value from ( - select diff_type,diffed_row,pk_hash from - (select diff_type,data_item diffed_row,pk_hash + select diff_type,diffed_row,pk_hash,pk_value from + (select diff_type,data_item diffed_row,pk_hash,pk_value from - (select nvl(exp.pk_hash, act.pk_hash) pk_hash, + (select nvl(exp.pk_hash, act.pk_hash) pk_hash,nvl(exp.pk_value, act.pk_value) pk_value, xmlserialize(content exp.row_data no indent) exp_item, xmlserialize(content act.row_data no indent) act_item from @@ -193,10 +193,11 @@ create or replace package body ut_compound_data_helper is (select ucd.column_value row_data, r.item_hash row_hash, r.pk_hash , + r.pk_value, ucd.column_value.getRootElement() col_name, ucd.column_value.getclobval() col_val from - (select ]'||l_column_filter||q'[, ucd.item_no, ucd.item_hash, i.pk_hash + (select ]'||l_column_filter||q'[, ucd.item_no, ucd.item_hash, i.pk_hash, i.pk_value from ut_compound_data_tmp ucd, diff_info i where ucd.data_id = :self_guid @@ -211,10 +212,11 @@ create or replace package body ut_compound_data_helper is (select ucd.column_value row_data, r.item_hash row_hash, r.pk_hash , + r.pk_value, ucd.column_value.getRootElement() col_name, ucd.column_value.getclobval() col_val from - (select ]'||l_column_filter||q'[, ucd.item_no, ucd.item_hash, i.pk_hash + (select ]'||l_column_filter||q'[, ucd.item_no, ucd.item_hash, i.pk_hash, i.pk_value from ut_compound_data_tmp ucd, diff_info i where ucd.data_id = :other_guid @@ -231,7 +233,8 @@ create or replace package body ut_compound_data_helper is union all select case when exp.pk_hash is null then 'Extra:' else 'Missing:' end as diff_type, xmlserialize(content nvl(exp.item_data, act.item_data) no indent) diffed_row, - coalesce(exp.pk_hash,act.pk_hash) pk_hash + coalesce(exp.pk_hash,act.pk_hash) pk_hash, + null pk_value from (select extract(ucd.item_data,'/*/*') item_data,i.pk_hash from ut_compound_data_tmp ucd, diff_info i @@ -269,9 +272,12 @@ create or replace package body ut_compound_data_helper is l_column_filter := get_columns_filter(a_exclude_xpath,a_include_xpath); execute immediate q'[ with - diff_info as (select item_no from ut_compound_data_diff_tmp ucdc where diff_id = :diff_guid and rownum <= :max_rows) + diff_info as ( select item_no + from + (select item_no from ut_compound_data_diff_tmp ucdc where diff_id = :diff_guid order by item_no asc) + where rownum <= :max_rows) select * - from (select rn, diff_type, xmlserialize(content data_item no indent) diffed_row + from (select rn, diff_type, xmlserialize(content data_item no indent) diffed_row, null pk_value from (select nvl(exp.rn, act.rn) rn, xmlagg(exp.col order by exp.col_no) exp_item, xmlagg(act.col order by act.col_no) act_item @@ -307,7 +313,8 @@ create or replace package body ut_compound_data_helper is union all select nvl(exp.item_no, act.item_no) rn, case when exp.item_no is null then 'Extra:' else 'Missing:' end as diff_type, - xmlserialize(content nvl(exp.item_data, act.item_data) no indent) diffed_row + xmlserialize(content nvl(exp.item_data, act.item_data) no indent) diffed_row, + null pk_value from (select ucd.item_no, extract(ucd.item_data,'/*/*') item_data from ut_compound_data_tmp ucd where ucd.data_id = :self_guid @@ -348,7 +355,8 @@ create or replace package body ut_compound_data_helper is diff_info as (select item_hash,duplicate_no from ut_compound_data_diff_tmp ucdc where diff_id = :diff_guid) select duplicate_no, diffed_type, - diffed_row + diffed_row, + null pk_value from (select coalesce(exp.duplicate_no,act.duplicate_no) duplicate_no, diff --git a/source/expectations/data_values/ut_compound_data_helper.pks b/source/expectations/data_values/ut_compound_data_helper.pks index 3f8595233..d71af802d 100644 --- a/source/expectations/data_values/ut_compound_data_helper.pks +++ b/source/expectations/data_values/ut_compound_data_helper.pks @@ -31,7 +31,8 @@ create or replace package ut_compound_data_helper authid definer is type t_row_diffs is record( rn integer, diff_type varchar2(250), - diffed_row clob + diffed_row clob, + pk_value varchar2(4000) ); type tt_row_diffs is table of t_row_diffs; diff --git a/source/expectations/data_values/ut_compound_data_tmp.sql b/source/expectations/data_values/ut_compound_data_tmp.sql index 827ab9066..ed548f0a9 100644 --- a/source/expectations/data_values/ut_compound_data_tmp.sql +++ b/source/expectations/data_values/ut_compound_data_tmp.sql @@ -16,7 +16,6 @@ create global temporary table ut_compound_data_tmp( item_no integer, item_data xmltype, item_hash raw(128), - pk_hash raw(128), duplicate_no integer, constraint ut_cmp_data_tmp_hash_pk unique (data_id,item_no, item_hash , duplicate_no) ) on commit preserve rows; diff --git a/source/expectations/data_values/ut_compound_data_value.tpb b/source/expectations/data_values/ut_compound_data_value.tpb index 961481d28..ce5767e21 100644 --- a/source/expectations/data_values/ut_compound_data_value.tpb +++ b/source/expectations/data_values/ut_compound_data_value.tpb @@ -139,6 +139,7 @@ create or replace type body ut_compound_data_value as l_actual ut_compound_data_value; l_diff_id ut_compound_data_helper.t_hash; l_row_diffs ut_compound_data_helper.tt_row_diffs; + begin if not a_other is of (ut_compound_data_value) then raise value_error; @@ -173,7 +174,11 @@ create or replace type body ut_compound_data_value as ut_utils.append_to_clob( l_result, l_message ); for i in 1 .. l_row_diffs.count loop l_results.extend; - l_results(l_results.last) := ' Row No. '||l_row_diffs(i).rn||' - '||rpad(l_row_diffs(i).diff_type,10)||l_row_diffs(i).diffed_row; + if a_join_by_xpath is not null and l_row_diffs(i).pk_value is not null then + l_results(l_results.last) := ' '||rpad(l_row_diffs(i).diff_type,10)||l_row_diffs(i).diffed_row||' for key: '||l_row_diffs(i).pk_value; + else + l_results(l_results.last) := ' Row No. '||l_row_diffs(i).rn||' - '||rpad(l_row_diffs(i).diff_type,10)||l_row_diffs(i).diffed_row; + end if; end loop; ut_utils.append_to_clob(l_result,l_results); end if; @@ -245,16 +250,28 @@ create or replace type body ut_compound_data_value as l_row_diffs ut_compound_data_helper.tt_row_diffs; c_max_rows constant integer := 20; - type t_fetch_pk_hash_rec is record + type t_pk_val_rec is record ( - data_id raw(32), - item_hash raw(128), - item_data xmltype + data_id raw(32), + item_hash raw(128), + pk_hash raw(128), + pk_value varchar2(4000) ); - type t_fetch_pk_hash_tab is table of t_fetch_pk_hash_rec; - l_fetch_tab t_fetch_pk_hash_tab; - l_pk_hash_cursor sys_refcursor; + type t_pk_val_tab is table of t_pk_val_rec; + l_pk_val_tab t_pk_val_tab; + + function get_column_xpath(a_join_by_xpath varchar2) return varchar2 is + l_column varchar2(32767); + begin + if a_join_by_xpath is not null then + l_column := l_ut_owner ||'.ut_compound_data_helper.get_hash(extract(t.item_data,:join_by_xpath).GetClobVal()) pk_hash '; + else + l_column := ':join_by_xpath pk_hash '; + end if; + return l_column; + end; + begin if not a_other is of (ut_compound_data_value) then raise value_error; @@ -268,60 +285,78 @@ create or replace type body ut_compound_data_value as /** * Due to incompatibility issues in XML between 11 and 12.2 and 12.1 versions we will prepopulate pk_hash upfront to * avoid optimizer incorrectly rewrite and causing NULL error or ORA-600 - **/ + **/ + -- Pre generate hash minus to leave only onese that are diffrent, for example duplicates or diffrent hash + /*if a_join_by_xpath is not null then + execute immediate q'[select + data_id,item_hash,pk_hash, + listagg(extractvalue(tcd.column_value, '/*'), '; ') within GROUP(ORDER BY item_hash) pk_value + from + (select + ucd.column_value row_data, + ]'|| l_ut_owner ||q'[.ut_compound_data_helper.get_hash(extract(ucd.column_value,:join_xpath).GetClobVal()) pk_hash , + t.item_hash, + t.data_id + from ]' || l_ut_owner || q'[.ut_compound_data_tmp t , + table(xmlsequence(extract(t.item_data,'/*'))) ucd + where data_id = :self_guid or data_id = :other_guid ), + table(xmlsequence(extract(row_data ,:join_xpath))) tcd + group by pk_hash,item_hash,data_id]' + bulk collect into l_pk_val_tab using a_join_by_xpath,self.data_id, l_other.data_id,a_join_by_xpath; - if a_join_by_xpath is not null then - - open l_pk_hash_cursor for q'[select t.data_id,t.item_hash,t.item_data - from ]'|| l_ut_owner ||q'[.ut_compound_data_tmp t - ,xmltable('*' - passing t.item_data - columns - xml_pk_hash clob path ']'|| a_join_by_xpath ||q'[' - ) ucd - where data_id = :self_guid or data_id = :other_guid ]' - using self.data_id, l_other.data_id; - fetch l_pk_hash_cursor bulk collect into l_fetch_tab; - for pks in 1..l_fetch_tab.COUNT - loop - execute immediate 'update '|| l_ut_owner ||'.ut_compound_data_tmp - set pk_hash = '|| l_ut_owner ||'.ut_compound_data_helper.get_hash(extract(:item_data,:join_by_xpath).GetClobVal()) - where item_hash = :item_hash' - using l_fetch_tab(pks).item_data,a_join_by_xpath , l_fetch_tab(pks).item_hash; - end loop; - - close l_pk_hash_cursor; + forall pk_vals in 1..l_pk_val_tab.COUNT + update ut_compound_data_tmp + set pk_hash = l_pk_val_tab(pk_vals).pk_hash + ,pk_value = l_pk_val_tab(pk_vals).pk_value + where data_id = l_pk_val_tab(pk_vals).data_id + and item_hash = l_pk_val_tab(pk_vals).item_hash; end if; - - - -- Pre generate hash minus to leave only onese that are diffrent, for example duplicates or diffrent hash - execute immediate 'insert into ' || l_ut_owner || '.ut_compound_data_diff_tmp ( diff_id,item_hash,pk_hash,duplicate_no ) + */ + + execute immediate 'insert into ' || l_ut_owner || '.ut_compound_data_diff_tmp ( diff_id,item_hash,pk_hash,duplicate_no) + with calc_pk as + ( select data_id,item_hash, '||get_column_xpath(a_join_by_xpath)||' + from ' || l_ut_owner || '.ut_compound_data_tmp t + ) select distinct :diff_id,tmp.item_hash,tmp.pk_hash,tmp.duplicate_no from( ( select t.item_hash,row_number() over (partition by t.item_hash,t.data_id order by 1,2) duplicate_no, - pk_hash - from ' || l_ut_owner || '.ut_compound_data_tmp t - where data_id = :self_guid + pc.pk_hash + from ' || l_ut_owner || '.ut_compound_data_tmp t, + calc_pk pc + where t.data_id = :self_guid + and pc.data_id = t.data_id + and pc.item_hash = t.item_hash minus select t.item_hash,row_number() over (partition by t.item_hash,t.data_id order by 1,2) duplicate_no, - pk_hash - from ' || l_ut_owner || '.ut_compound_data_tmp t - where data_id = :other_guid + pc.pk_hash + from ' || l_ut_owner || '.ut_compound_data_tmp t, + calc_pk pc + where t.data_id = :other_guid + and pc.data_id = t.data_id + and pc.item_hash = t.item_hash ) union all ( select t.item_hash,row_number() over (partition by t.item_hash,t.data_id order by 1,2) duplicate_no, - pk_hash - from ' || l_ut_owner || '.ut_compound_data_tmp t - where data_id = :other_guid + pc.pk_hash + from ' || l_ut_owner || '.ut_compound_data_tmp t, + calc_pk pc + where t.data_id = :other_guid + and pc.data_id = t.data_id + and pc.item_hash = t.item_hash minus select t.item_hash,row_number() over (partition by t.item_hash,t.data_id order by 1,2) duplicate_no, - pk_hash - from ' || l_ut_owner || '.ut_compound_data_tmp t - where data_id = :self_guid + pc.pk_hash + from ' || l_ut_owner || '.ut_compound_data_tmp t, + calc_pk pc + where t.data_id = :self_guid + and pc.data_id = t.data_id + and pc.item_hash = t.item_hash ))tmp' - using l_diff_id, + using a_join_by_xpath, + l_diff_id, self.data_id, l_other.data_id, l_other.data_id,self.data_id; --result is OK only if both are same diff --git a/test/core/expectations/compound_data/test_expectations_cursor.pkb b/test/core/expectations/compound_data/test_expectations_cursor.pkb index feb7f2586..7f9e3986a 100644 --- a/test/core/expectations/compound_data/test_expectations_cursor.pkb +++ b/test/core/expectations/compound_data/test_expectations_cursor.pkb @@ -1113,6 +1113,19 @@ Extra: test-666%]'; --Assert ut.expect(expectations.failed_expectations_data()).to_be_empty(); end; - + + procedure cursor_joinby_compare_1000 is + l_actual SYS_REFCURSOR; + l_expected SYS_REFCURSOR; + begin + --Arrange + open l_actual for select object_name from all_objects where rownum <=1100; + open l_expected for select object_name from all_objects where rownum <=1100; + --Act + ut3.ut.expect(l_actual).to_equal(l_expected).join_by('OBJECT_NAME'); + --Assert + ut.expect(expectations.failed_expectations_data()).to_be_empty(); + end; + end; / diff --git a/test/core/expectations/compound_data/test_expectations_cursor.pks b/test/core/expectations/compound_data/test_expectations_cursor.pks index 688eb2073..3447b4a15 100644 --- a/test/core/expectations/compound_data/test_expectations_cursor.pks +++ b/test/core/expectations/compound_data/test_expectations_cursor.pks @@ -211,5 +211,8 @@ create or replace package test_expectations_cursor is --%test( Compare cursors join by composite key) procedure cursor_joinby_compare_twocols; + --%test( Compare cursors join by single key more than 1000 rows) + procedure cursor_joinby_compare_1000; + end; / From a5f33c1c8b56699aa2fdea6ac76f5b5b4309ded6 Mon Sep 17 00:00:00 2001 From: Walter Alexis Castro Date: Mon, 7 May 2018 15:39:46 -0600 Subject: [PATCH 021/184] Fixed the errors with timestamp in tests --- .../get_lines.WaitsForMoreDataToAppearForSpecifiedTime.sql | 4 ++-- .../get_lines.WaitsForTheDataToAppearForSpecifiedTime.sql | 4 ++-- test/api/test_ut_run.pkb | 3 ++- test/core/test_output_buffer.pkb | 4 ++-- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/old_tests/ut_output_buffer/get_lines.WaitsForMoreDataToAppearForSpecifiedTime.sql b/old_tests/ut_output_buffer/get_lines.WaitsForMoreDataToAppearForSpecifiedTime.sql index c8f343492..24284f38b 100644 --- a/old_tests/ut_output_buffer/get_lines.WaitsForMoreDataToAppearForSpecifiedTime.sql +++ b/old_tests/ut_output_buffer/get_lines.WaitsForMoreDataToAppearForSpecifiedTime.sql @@ -3,14 +3,14 @@ declare l_result integer; l_dummy integer; l_output ut_output_buffer_base := ut_output_table_buffer(); - l_start_time timestamp := systimestamp; + l_start_time timestamp := localtimestamp; l_wait_seconds integer := 1; begin --Act l_output.send_line(lpad('a text',4000,',a text')); select count(*) into l_dummy from table( l_output.get_lines( a_initial_timeout => 0, a_timeout_sec => l_wait_seconds )); - l_result := round(extract(second from (systimestamp - l_start_time))); + l_result := round(extract(second from (localtimestamp - l_start_time))); --Assert ut.expect(l_result).to_equal(l_wait_seconds); diff --git a/old_tests/ut_output_buffer/get_lines.WaitsForTheDataToAppearForSpecifiedTime.sql b/old_tests/ut_output_buffer/get_lines.WaitsForTheDataToAppearForSpecifiedTime.sql index 037f6db9b..20bf4ca6c 100644 --- a/old_tests/ut_output_buffer/get_lines.WaitsForTheDataToAppearForSpecifiedTime.sql +++ b/old_tests/ut_output_buffer/get_lines.WaitsForTheDataToAppearForSpecifiedTime.sql @@ -3,12 +3,12 @@ declare l_result integer; l_dummy integer; l_output ut_output_buffer_base := ut_output_table_buffer(); - l_start_time timestamp := systimestamp; + l_start_time timestamp := localtimestamp; l_wait_seconds integer := 1; begin --Act select count(1) into l_dummy from table( l_output.get_lines( a_initial_timeout => l_wait_seconds, a_timeout_sec => 0 )); - l_result := round(extract(second from (systimestamp - l_start_time))); + l_result := round(extract(second from (localtimestamp - l_start_time))); --Assert ut.expect(l_result).to_equal(l_wait_seconds); diff --git a/test/api/test_ut_run.pkb b/test/api/test_ut_run.pkb index 503239307..dfd4a529b 100644 --- a/test/api/test_ut_run.pkb +++ b/test/api/test_ut_run.pkb @@ -60,7 +60,7 @@ create or replace package body test_ut_run is g_state varchar2(3) := 'abc'; end;]'; end;/', - start_date => sysdate, + start_date => localtimestamp, enabled => TRUE, auto_drop => TRUE, comments => 'one-time job' @@ -98,6 +98,7 @@ Failures:% --Act select * bulk collect into l_results from table(ut3.ut.run('test_stateful')); + --Assert ut.fail('Expected exception but nothing was raised'); exception diff --git a/test/core/test_output_buffer.pkb b/test/core/test_output_buffer.pkb index 7d60c5213..051293c60 100644 --- a/test/core/test_output_buffer.pkb +++ b/test/core/test_output_buffer.pkb @@ -55,9 +55,9 @@ create or replace package body test_output_buffer is --Act l_expected := lpad('a text',4000,',a text'); l_buffer.send_line(l_expected); - l_start := systimestamp; + l_start := localtimestamp; select * into l_result from table(l_buffer.get_lines(1,1)); - l_duration := systimestamp - l_start; + l_duration := localtimestamp - l_start; ut.expect(l_result).to_equal(l_expected); ut.expect(l_duration).to_be_greater_than(interval '1' second); From 7f8eb65eead725c164073fcd5df20f31ba2feb88 Mon Sep 17 00:00:00 2001 From: Travis CI Date: Mon, 7 May 2018 22:15:25 +0000 Subject: [PATCH 022/184] Updated project version after build [skip ci] --- source/core/ut_utils.pks | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/core/ut_utils.pks b/source/core/ut_utils.pks index c69d1c4fe..9ea18b220 100644 --- a/source/core/ut_utils.pks +++ b/source/core/ut_utils.pks @@ -21,7 +21,7 @@ create or replace package ut_utils authid definer is * */ - gc_version constant varchar2(50) := 'v3.1.2.1869-develop'; + gc_version constant varchar2(50) := 'v3.1.2.1880-develop'; /* Constants: Event names */ subtype t_event_name is varchar2(30); From b30ce470d1e8973724c0a1ba9362860bf1261936 Mon Sep 17 00:00:00 2001 From: Travis CI Date: Mon, 7 May 2018 23:25:01 +0000 Subject: [PATCH 023/184] Updated project version after build [skip ci] --- source/core/ut_utils.pks | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/core/ut_utils.pks b/source/core/ut_utils.pks index 9ea18b220..82b834b7e 100644 --- a/source/core/ut_utils.pks +++ b/source/core/ut_utils.pks @@ -21,7 +21,7 @@ create or replace package ut_utils authid definer is * */ - gc_version constant varchar2(50) := 'v3.1.2.1880-develop'; + gc_version constant varchar2(50) := 'v3.1.2.1883-develop'; /* Constants: Event names */ subtype t_event_name is varchar2(30); From 784c509bb9ae602419f6af2d5e8d024caddb75e4 Mon Sep 17 00:00:00 2001 From: lwasylow Date: Wed, 9 May 2018 19:52:27 +0100 Subject: [PATCH 024/184] Update pk join cursor fix to get columns diff --- .../data_values/ut_compound_data_helper.pkb | 33 ++++- .../data_values/ut_compound_data_tmp.sql | 1 + .../data_values/ut_compound_data_value.tpb | 131 ++++++++---------- .../data_values/ut_data_value_refcursor.tpb | 4 +- .../test_expectations_cursor.pkb | 98 +++++++++++++ .../test_expectations_cursor.pks | 21 +++ 6 files changed, 210 insertions(+), 78 deletions(-) diff --git a/source/expectations/data_values/ut_compound_data_helper.pkb b/source/expectations/data_values/ut_compound_data_helper.pkb index 1b22386dd..85bc9fe2b 100644 --- a/source/expectations/data_values/ut_compound_data_helper.pkb +++ b/source/expectations/data_values/ut_compound_data_helper.pkb @@ -86,6 +86,32 @@ create or replace package body ut_compound_data_helper is end if; return l_filter; end; + + /** + * Current get column filter shaving off ROW tag during extract, this not working well with include and XMLTABLE option + * so when there is extract we artificially inject removed tag + **/ + function get_columns_row_filter( + a_exclude_xpath varchar2, a_include_xpath varchar2, + a_table_alias varchar2 := 'ucd', a_column_alias varchar2 := 'item_data' + ) return varchar2 is + l_filter varchar2(32767); + l_source_column varchar2(500) := a_table_alias||'.'||a_column_alias; + begin + -- this SQL statement is constructed in a way that we always get the same number and ordering of substitution variables + -- That is, we always get: l_exclude_xpath, l_include_xpath + -- regardless if the variables are NULL (not to be used) or NOT NULL and will be used for filtering + if a_exclude_xpath is null and a_include_xpath is null then + l_filter := ':l_exclude_xpath, :l_include_xpath, '||l_source_column||' as '||a_column_alias; + elsif a_exclude_xpath is not null and a_include_xpath is null then + l_filter := 'deletexml( '||l_source_column||', :l_exclude_xpath ) as '||a_column_alias||', :l_include_xpath'; + elsif a_exclude_xpath is null and a_include_xpath is not null then + l_filter := ':l_exclude_xpath, xmlelement("ROW",extract( '||l_source_column||', :l_include_xpath )) as '||a_column_alias; + elsif a_exclude_xpath is not null and a_include_xpath is not null then + l_filter := 'xmlelement("ROW",extract( deletexml( '||l_source_column||', :l_exclude_xpath ), :l_include_xpath )) as '||a_column_alias; + end if; + return l_filter; + end; function get_columns_diff( a_expected xmltype, a_actual xmltype, a_exclude_xpath varchar2, a_include_xpath varchar2 @@ -94,7 +120,7 @@ create or replace package body ut_compound_data_helper is l_sql varchar2(32767); l_results tt_column_diffs; begin - l_column_filter := get_columns_filter(a_exclude_xpath, a_include_xpath); + l_column_filter := get_columns_row_filter(a_exclude_xpath, a_include_xpath); l_sql := q'[ with expected_cols as ( select :a_expected as item_data from dual ), @@ -157,6 +183,7 @@ create or replace package body ut_compound_data_helper is execute immediate l_sql bulk collect into l_results using a_expected, a_actual, a_exclude_xpath, a_include_xpath, a_exclude_xpath, a_include_xpath; + return l_results; end; @@ -349,8 +376,8 @@ create or replace package body ut_compound_data_helper is /** * Since its unordered search we cannot select max rows from diffs as we miss some comparision records * We will restrict output on higher level of select - */ - + */ + execute immediate q'[with diff_info as (select item_hash,duplicate_no from ut_compound_data_diff_tmp ucdc where diff_id = :diff_guid) select duplicate_no, diff --git a/source/expectations/data_values/ut_compound_data_tmp.sql b/source/expectations/data_values/ut_compound_data_tmp.sql index ed548f0a9..827ab9066 100644 --- a/source/expectations/data_values/ut_compound_data_tmp.sql +++ b/source/expectations/data_values/ut_compound_data_tmp.sql @@ -16,6 +16,7 @@ create global temporary table ut_compound_data_tmp( item_no integer, item_data xmltype, item_hash raw(128), + pk_hash raw(128), duplicate_no integer, constraint ut_cmp_data_tmp_hash_pk unique (data_id,item_no, item_hash , duplicate_no) ) on commit preserve rows; diff --git a/source/expectations/data_values/ut_compound_data_value.tpb b/source/expectations/data_values/ut_compound_data_value.tpb index ce5767e21..4732df286 100644 --- a/source/expectations/data_values/ut_compound_data_value.tpb +++ b/source/expectations/data_values/ut_compound_data_value.tpb @@ -250,24 +250,32 @@ create or replace type body ut_compound_data_value as l_row_diffs ut_compound_data_helper.tt_row_diffs; c_max_rows constant integer := 20; - type t_pk_val_rec is record - ( - data_id raw(32), - item_hash raw(128), - pk_hash raw(128), - pk_value varchar2(4000) - ); - - type t_pk_val_tab is table of t_pk_val_rec; - l_pk_val_tab t_pk_val_tab; - - function get_column_xpath(a_join_by_xpath varchar2) return varchar2 is + function get_pk_value(a_join_by_xpath varchar2) return varchar2 is l_column varchar2(32767); begin + /* due to possibility of key being to columns we cannot use xmlextractvalue + usage of xmlagg is possible however it greatly complicates code and performance is impacted. + xpath to be looked at or regex + */ if a_join_by_xpath is not null then - l_column := l_ut_owner ||'.ut_compound_data_helper.get_hash(extract(t.item_data,:join_by_xpath).GetClobVal()) pk_hash '; + l_column := ' extract(t.item_data,:join_by_xpath).GetStringVal() pk_value '; else - l_column := ':join_by_xpath pk_hash '; + l_column := ' :join_by_xpath pk_value'; + end if; + return l_column; + end; + + function get_column_pk_hash(a_join_by_xpath varchar2) return varchar2 is + l_column varchar2(32767); + begin + /* due to possibility of key being to columns we cannot use xmlextractvalue + usage of xmlagg is possible however it greatly complicates code and performance is impacted. + xpath to be looked at or regex + */ + if a_join_by_xpath is not null then + l_column := l_ut_owner ||'.ut_compound_data_helper.get_hash(extract(ucd.item_data,:join_by_xpath).GetClobVal()) pk_hash'; + else + l_column := ':join_by_xpath pk_hash'; end if; return l_column; end; @@ -281,81 +289,58 @@ create or replace type body ut_compound_data_value as l_diff_id := ut_compound_data_helper.get_hash(self.data_id||l_other.data_id); l_column_filter := ut_compound_data_helper.get_columns_filter(a_exclude_xpath, a_include_xpath); - + /** * Due to incompatibility issues in XML between 11 and 12.2 and 12.1 versions we will prepopulate pk_hash upfront to * avoid optimizer incorrectly rewrite and causing NULL error or ORA-600 - **/ - -- Pre generate hash minus to leave only onese that are diffrent, for example duplicates or diffrent hash - /*if a_join_by_xpath is not null then - execute immediate q'[select - data_id,item_hash,pk_hash, - listagg(extractvalue(tcd.column_value, '/*'), '; ') within GROUP(ORDER BY item_hash) pk_value - from - (select - ucd.column_value row_data, - ]'|| l_ut_owner ||q'[.ut_compound_data_helper.get_hash(extract(ucd.column_value,:join_xpath).GetClobVal()) pk_hash , - t.item_hash, - t.data_id - from ]' || l_ut_owner || q'[.ut_compound_data_tmp t , - table(xmlsequence(extract(t.item_data,'/*'))) ucd - where data_id = :self_guid or data_id = :other_guid ), - table(xmlsequence(extract(row_data ,:join_xpath))) tcd - group by pk_hash,item_hash,data_id]' - bulk collect into l_pk_val_tab using a_join_by_xpath,self.data_id, l_other.data_id,a_join_by_xpath; + **/ + execute immediate 'merge into ' || l_ut_owner || '.ut_compound_data_tmp tgt + using ( + select '||l_ut_owner ||'.ut_compound_data_helper.get_hash(ucd.item_data.getclobval()) item_hash, + pk_hash, ucd.item_no, ucd.data_id + from + ( + select '||l_column_filter||','||get_column_pk_hash(a_join_by_xpath)||', item_no, data_id + from ' || l_ut_owner || q'[.ut_compound_data_tmp ucd + where data_id = :self_guid or data_id = :other_guid + ) ucd + ) src + on (tgt.item_no = src.item_no and tgt.data_id = src.data_id) + when matched then update + set tgt.item_hash = src.item_hash, + tgt.pk_hash = src.pk_hash ]' + using a_exclude_xpath, a_include_xpath,a_join_by_xpath,self.data_id, l_other.data_id; - forall pk_vals in 1..l_pk_val_tab.COUNT - update ut_compound_data_tmp - set pk_hash = l_pk_val_tab(pk_vals).pk_hash - ,pk_value = l_pk_val_tab(pk_vals).pk_value - where data_id = l_pk_val_tab(pk_vals).data_id - and item_hash = l_pk_val_tab(pk_vals).item_hash; - end if; - */ - - execute immediate 'insert into ' || l_ut_owner || '.ut_compound_data_diff_tmp ( diff_id,item_hash,pk_hash,duplicate_no) - with calc_pk as - ( select data_id,item_hash, '||get_column_xpath(a_join_by_xpath)||' - from ' || l_ut_owner || '.ut_compound_data_tmp t - ) - select distinct :diff_id,tmp.item_hash,tmp.pk_hash,tmp.duplicate_no + /* Peform minus on two sets two get diffrences that will be used later on to print results */ + execute immediate 'insert into ' || l_ut_owner || '.ut_compound_data_diff_tmp ( diff_id,item_hash,pk_hash,duplicate_no,pk_value) + with source_data as + ( select t.data_id,t.item_hash,row_number() over (partition by t.pk_hash,t.item_hash,t.data_id order by 1,2) duplicate_no, + pk_hash, '||get_pk_value(a_join_by_xpath)||' + from ' || l_ut_owner || '.ut_compound_data_tmp t + where data_id = :self_guid or data_id = :other_guid + ) + select distinct :diff_id,tmp.item_hash,tmp.pk_hash,tmp.duplicate_no,pk_value from( ( - select t.item_hash,row_number() over (partition by t.item_hash,t.data_id order by 1,2) duplicate_no, - pc.pk_hash - from ' || l_ut_owner || '.ut_compound_data_tmp t, - calc_pk pc + select t.item_hash,t. duplicate_no,t.pk_hash, t.pk_value + from source_data t where t.data_id = :self_guid - and pc.data_id = t.data_id - and pc.item_hash = t.item_hash minus - select t.item_hash,row_number() over (partition by t.item_hash,t.data_id order by 1,2) duplicate_no, - pc.pk_hash - from ' || l_ut_owner || '.ut_compound_data_tmp t, - calc_pk pc + select t.item_hash,t. duplicate_no,t.pk_hash, t.pk_value + from source_data t where t.data_id = :other_guid - and pc.data_id = t.data_id - and pc.item_hash = t.item_hash ) union all ( - select t.item_hash,row_number() over (partition by t.item_hash,t.data_id order by 1,2) duplicate_no, - pc.pk_hash - from ' || l_ut_owner || '.ut_compound_data_tmp t, - calc_pk pc + select t.item_hash,t. duplicate_no,t.pk_hash, t.pk_value + from source_data t where t.data_id = :other_guid - and pc.data_id = t.data_id - and pc.item_hash = t.item_hash minus - select t.item_hash,row_number() over (partition by t.item_hash,t.data_id order by 1,2) duplicate_no, - pc.pk_hash - from ' || l_ut_owner || '.ut_compound_data_tmp t, - calc_pk pc + select t.item_hash,t. duplicate_no,t.pk_hash, t.pk_value + from source_data t where t.data_id = :self_guid - and pc.data_id = t.data_id - and pc.item_hash = t.item_hash ))tmp' - using a_join_by_xpath, + using a_join_by_xpath,self.data_id, l_other.data_id, l_diff_id, self.data_id, l_other.data_id, l_other.data_id,self.data_id; diff --git a/source/expectations/data_values/ut_data_value_refcursor.tpb b/source/expectations/data_values/ut_data_value_refcursor.tpb index 4f0bc437b..480aba30c 100644 --- a/source/expectations/data_values/ut_data_value_refcursor.tpb +++ b/source/expectations/data_values/ut_data_value_refcursor.tpb @@ -60,8 +60,8 @@ create or replace type body ut_data_value_refcursor as l_xml := dbms_xmlgen.getxmltype(l_ctx); execute immediate - 'insert into ' || l_ut_owner || '.ut_compound_data_tmp(data_id, item_no, item_data, item_hash) ' || - 'select :self_guid, :self_row_count + rownum, value(a),'||l_ut_owner||'.ut_compound_data_helper.get_hash(value(a).GetClobVal()) ' || + 'insert into ' || l_ut_owner || '.ut_compound_data_tmp(data_id, item_no, item_data) ' || + 'select :self_guid, :self_row_count + rownum, value(a) ' || ' from table( xmlsequence( extract(:l_xml,''ROWSET/*'') ) ) a' using in self.data_id, self.elements_count, l_xml; diff --git a/test/core/expectations/compound_data/test_expectations_cursor.pkb b/test/core/expectations/compound_data/test_expectations_cursor.pkb index 7f9e3986a..5a0f429cc 100644 --- a/test/core/expectations/compound_data/test_expectations_cursor.pkb +++ b/test/core/expectations/compound_data/test_expectations_cursor.pkb @@ -1127,5 +1127,103 @@ Extra: test-666%]'; ut.expect(expectations.failed_expectations_data()).to_be_empty(); end; + procedure unord_incl_cols_as_list + as + l_actual sys_refcursor; + l_expected sys_refcursor; + begin + --Arrange + open l_actual for select rownum as rn, 'a' as "A_Column", 'c' as A_COLUMN, 'x' SOME_COL, 'd' "Some_Col" from dual a connect by level < 4; + open l_expected for select rownum as rn, 'a' as "A_Column", 'd' as A_COLUMN, 'x' SOME_COL, 'c' "Some_Col" from dual a connect by level < 4; + --Act + ut3.ut.expect(l_actual).to_equal(l_expected).include(ut3.ut_varchar2_list('RN','//A_Column','SOME_COL')).unordered; + --Assert + ut.expect(expectations.failed_expectations_data()).to_be_empty(); + end; + + procedure joinby_incl_cols_as_list + as + l_actual sys_refcursor; + l_expected sys_refcursor; + begin + --Arrange + open l_actual for select rownum as rn, 'a' as "A_Column", 'c' as A_COLUMN, 'x' SOME_COL, 'd' "Some_Col" from dual a connect by level < 4; + open l_expected for select rownum as rn, 'a' as "A_Column", 'd' as A_COLUMN, 'x' SOME_COL, 'c' "Some_Col" from dual a connect by level < 4; + --Act + ut3.ut.expect(l_actual).to_equal(l_expected).include(ut3.ut_varchar2_list('RN','//A_Column','SOME_COL')).join_by('SOME_COL'); + --Assert + ut.expect(expectations.failed_expectations_data()).to_be_empty(); + end; + + procedure joinby_excl_cols_as_list + as + l_actual sys_refcursor; + l_expected sys_refcursor; + begin + --Arrange + open l_actual for select rownum as rn, 'a' as "A_Column", 'c' as A_COLUMN, 'x' SOME_COL, 'd' "Some_Col" from dual a connect by level < 4; + open l_expected for select rownum as rn, 'a' as "A_Column", 'd' as A_COLUMN, 'x' SOME_COL, 'c' "Some_Col" from dual a connect by level < 4; + --Act + ut3.ut.expect(l_actual).to_equal(l_expected).exclude(ut3.ut_varchar2_list('//Some_Col','A_COLUMN')).join_by('SOME_COL'); + --Assert + ut.expect(expectations.failed_expectations_data()).to_be_empty(); + end; + + procedure unord_excl_cols_as_list + as + l_actual sys_refcursor; + l_expected sys_refcursor; + begin + --Arrange + open l_actual for select rownum as rn, 'a' as "A_Column", 'c' as A_COLUMN, 'x' SOME_COL, 'd' "Some_Col" from dual a connect by level < 4; + open l_expected for select rownum as rn, 'a' as "A_Column", 'd' as A_COLUMN, 'x' SOME_COL, 'c' "Some_Col" from dual a connect by level < 4; + --Act + ut3.ut.expect(l_actual).to_equal(l_expected).exclude(ut3.ut_varchar2_list('A_COLUMN|//Some_Col')).unordered; + --Assert + ut.expect(expectations.failed_expectations_data()).to_be_empty(); + end; + + procedure excl_dif_cols_as_list + as + l_actual sys_refcursor; + l_expected sys_refcursor; + begin + --Arrange + open l_actual for select rownum as rn, 'TEST' as A_COLUMN from dual a connect by level < 4; + open l_expected for select rownum as rn, 1 as A_COLUMN from dual a connect by level < 4; + --Act + ut3.ut.expect(l_actual).to_equal(l_expected).exclude(ut3.ut_varchar2_list('A_COLUMN')); + --Assert + ut.expect(expectations.failed_expectations_data()).to_be_empty(); + end; + + procedure inlc_dif_cols_as_list + as + l_actual sys_refcursor; + l_expected sys_refcursor; + begin + --Arrange + open l_actual for select rownum as rn, 'TEST' as A_COLUMN from dual a connect by level < 4; + open l_expected for select rownum as rn, 1 as A_COLUMN from dual a connect by level < 4; + --Act + ut3.ut.expect(l_actual).to_equal(l_expected).include(ut3.ut_varchar2_list('RN')); + --Assert + ut.expect(expectations.failed_expectations_data()).to_be_empty(); + end; + + procedure inlc_exc_dif_cols_as_list + as + l_actual sys_refcursor; + l_expected sys_refcursor; + begin + --Arrange + open l_actual for select rownum as rn, 'TEST' as A_COLUMN from dual a connect by level < 4; + open l_expected for select rownum as rn, 1 as A_COLUMN from dual a connect by level < 4; + --Act + ut3.ut.expect(l_actual).to_equal(l_expected).include(ut3.ut_varchar2_list('RN')).exclude(ut3.ut_varchar2_list('A_COLUMN')); + --Assert + ut.expect(expectations.failed_expectations_data()).to_be_empty(); + end; + end; / diff --git a/test/core/expectations/compound_data/test_expectations_cursor.pks b/test/core/expectations/compound_data/test_expectations_cursor.pks index 3447b4a15..76dc1fba8 100644 --- a/test/core/expectations/compound_data/test_expectations_cursor.pks +++ b/test/core/expectations/compound_data/test_expectations_cursor.pks @@ -214,5 +214,26 @@ create or replace package test_expectations_cursor is --%test( Compare cursors join by single key more than 1000 rows) procedure cursor_joinby_compare_1000; + --%test(Unordered List of columns to include) + procedure unord_incl_cols_as_list; + + --%test(Join By List of columns to include) + procedure joinby_incl_cols_as_list; + + --%test(Unordered List of columns to exclude) + procedure unord_excl_cols_as_list; + + --%test(Join By List of columns to exclude) + procedure joinby_excl_cols_as_list; + + --%test(Exclude columns of diffrent type) + procedure excl_dif_cols_as_list; + + --%test(Include column of same type leaving diffrent type out) + procedure inlc_dif_cols_as_list; + + --%test(Include column of same type leaving diffrent type out and exclude diffrent type) + procedure inlc_exc_dif_cols_as_list; + end; / From ac042d05403f6301dc14f908b253c70b97b6268f Mon Sep 17 00:00:00 2001 From: lwasylow Date: Thu, 10 May 2018 18:00:23 +0100 Subject: [PATCH 025/184] Added failure on missing join by key in cursor. --- .../data_values/ut_compound_data_helper.pkb | 42 +++++++++++++++++ .../data_values/ut_compound_data_helper.pks | 10 ++++ .../data_values/ut_data_value_refcursor.tpb | 47 +++++++++++++++---- 3 files changed, 91 insertions(+), 8 deletions(-) diff --git a/source/expectations/data_values/ut_compound_data_helper.pkb b/source/expectations/data_values/ut_compound_data_helper.pkb index 85bc9fe2b..e1e9c936c 100644 --- a/source/expectations/data_values/ut_compound_data_helper.pkb +++ b/source/expectations/data_values/ut_compound_data_helper.pkb @@ -464,6 +464,48 @@ create or replace package body ut_compound_data_helper is return l_cols_hash; end; + function is_pk_exists(a_expected_cursor xmltype,a_actual_cursor xmltype, a_exclude_xpath varchar2, a_include_xpath varchar2,a_join_by_xpath varchar2) + return tt_missing_pk is + l_pk_xpath_tabs ut_varchar2_list := ut_varchar2_list(); + l_column_filter varchar2(32767); + l_no_missing_keys tt_missing_pk := tt_missing_pk(); + begin + if a_join_by_xpath is not null then + l_pk_xpath_tabs := ut_utils.string_to_table(a_join_by_xpath,'|'); + l_column_filter := get_columns_row_filter(a_exclude_xpath, a_include_xpath); + + execute immediate q'[ + with xpaths_tab as (select column_value xpath from table(:xpath_tabs)), + expected_column_info as ( select :expected as item_data from dual ), + actual_column_info as ( select :actual as item_data from dual ) + select xpath,diif_type from + ( + (select xpath,'e' diif_type from xpaths_tab + minus + select xpath,'e' diif_type + from ( select ]'||l_column_filter||q'[ from expected_column_info ucd) x + ,xpaths_tab + where xmlexists (xpaths_tab.xpath passing x.item_data) + ) + union all + (select xpath,'a' diif_type from xpaths_tab + minus + select xpath,'a' diif_type + from ( select ]'||l_column_filter||q'[ from actual_column_info ucd) x + ,xpaths_tab + where xmlexists (xpaths_tab.xpath passing x.item_data) + ) + )]' bulk collect into l_no_missing_keys + using l_pk_xpath_tabs,a_expected_cursor,a_actual_cursor, + a_exclude_xpath, a_include_xpath, + a_exclude_xpath, a_include_xpath; + + end if; + + return l_no_missing_keys; + end; + + begin g_type_name_map( dbms_sql.binary_bouble_type ) := 'BINARY_DOUBLE'; g_type_name_map( dbms_sql.bfile_type ) := 'BFILE'; diff --git a/source/expectations/data_values/ut_compound_data_helper.pks b/source/expectations/data_values/ut_compound_data_helper.pks index d71af802d..99aa7c18a 100644 --- a/source/expectations/data_values/ut_compound_data_helper.pks +++ b/source/expectations/data_values/ut_compound_data_helper.pks @@ -28,6 +28,13 @@ create or replace package ut_compound_data_helper authid definer is type tt_column_diffs is table of t_column_diffs; + type t_missing_pk is record( + missingxpath varchar2(250), + diff_type varchar2(1) + ); + + type tt_missing_pk is table of t_missing_pk; + type t_row_diffs is record( rn integer, diff_type varchar2(250), @@ -72,6 +79,9 @@ create or replace package ut_compound_data_helper authid definer is a_data_value_cursor ut_data_value_refcursor, a_exclude_xpath varchar2, a_include_xpath varchar2, a_hash_type binary_integer := dbms_crypto.hash_sh1 ) return t_hash; + + function is_pk_exists(a_expected_cursor xmltype, a_actual_cursor xmltype, a_exclude_xpath varchar2, a_include_xpath varchar2,a_join_by_xpath varchar2) + return tt_missing_pk; end; / diff --git a/source/expectations/data_values/ut_data_value_refcursor.tpb b/source/expectations/data_values/ut_data_value_refcursor.tpb index 480aba30c..84746fb51 100644 --- a/source/expectations/data_values/ut_data_value_refcursor.tpb +++ b/source/expectations/data_values/ut_data_value_refcursor.tpb @@ -115,7 +115,8 @@ create or replace type body ut_data_value_refcursor as l_actual ut_data_value_refcursor; l_column_diffs ut_compound_data_helper.tt_column_diffs := ut_compound_data_helper.tt_column_diffs(); l_exclude_xpath varchar2(32767) := a_exclude_xpath; - + l_missing_pk ut_compound_data_helper.tt_missing_pk := ut_compound_data_helper.tt_missing_pk(); + function get_col_diff_text(a_col ut_compound_data_helper.t_column_diffs) return varchar2 is begin return @@ -130,7 +131,18 @@ create or replace type body ut_data_value_refcursor as ' Column <'||a_col.actual_name||'> is misplaced. Expected position: '||a_col.expected_pos||',' ||' actual position: '||a_col.actual_pos||'.' end; end; - + + function get_missing_key_message(a_missing_keys ut_compound_data_helper.t_missing_pk) return varchar2 is + begin + return + case a_missing_keys.diff_type + when 'a' then + ' Unknown key to join by in actual:'||a_missing_keys.missingxpath + when 'e' then + ' Unknown key to join by in expected:'||a_missing_keys.missingxpath + end; + end; + function add_incomparable_cols_to_xpath( a_column_diffs ut_compound_data_helper.tt_column_diffs, a_exclude_xpath varchar2 ) return varchar2 is @@ -151,6 +163,7 @@ create or replace type body ut_data_value_refcursor as end if; return l_result; end; + begin if not a_other is of (ut_data_value_refcursor) then raise value_error; @@ -176,12 +189,20 @@ create or replace type body ut_data_value_refcursor as end if; --diff rows and row elements - if a_join_by_xpath is not null then - ut_utils.append_to_clob(l_result, self.get_data_diff(a_other, a_exclude_xpath, a_include_xpath, a_join_by_xpath)); - elsif a_unordered then - ut_utils.append_to_clob(l_result, self.get_data_diff(a_other, l_exclude_xpath, a_include_xpath, a_unordered)); + if (a_join_by_xpath is not null) or not(a_unordered) then + -- Check if pk filter exists + l_missing_pk := ut_compound_data_helper.is_pk_exists(self.columns_info, l_actual.columns_info, a_exclude_xpath, a_include_xpath,a_join_by_xpath); + if l_missing_pk.count = 0 then + ut_utils.append_to_clob(l_result, self.get_data_diff(a_other, a_exclude_xpath, a_include_xpath, a_join_by_xpath)); + else + ut_utils.append_to_clob(l_result,chr(10) || 'Unable to join sets:' || chr(10)); + for i in 1 .. l_missing_pk.count loop + l_results.extend; + ut_utils.append_to_clob(l_result, get_missing_key_message(l_missing_pk(i))); + end loop; + end if; else - ut_utils.append_to_clob(l_result, self.get_data_diff(a_other, l_exclude_xpath, a_include_xpath, a_join_by_xpath)); + ut_utils.append_to_clob(l_result, self.get_data_diff(a_other, l_exclude_xpath, a_include_xpath, a_unordered)); end if; l_result_string := ut_utils.to_string(l_result,null); @@ -211,19 +232,29 @@ create or replace type body ut_data_value_refcursor as overriding member function compare_implementation (a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2, a_join_by_xpath varchar2, a_unordered boolean) return integer is l_result integer := 0; l_other ut_data_value_refcursor; + l_missing_pk ut_compound_data_helper.tt_missing_pk := ut_compound_data_helper.tt_missing_pk(); begin if not a_other is of (ut_data_value_refcursor) then raise value_error; end if; l_other := treat(a_other as ut_data_value_refcursor); + + l_missing_pk := ut_compound_data_helper.is_pk_exists(self.columns_info, l_other.columns_info, a_exclude_xpath, a_include_xpath,a_join_by_xpath); + --if we join by key and key is missing fail and report error + if a_join_by_xpath is not null and l_missing_pk.count > 0 then + l_result := 1; + return l_result; + end if; + --if column names/types are not equal - build a diff of column names and types if ut_compound_data_helper.columns_hash( self, a_exclude_xpath, a_include_xpath ) != ut_compound_data_helper.columns_hash( l_other, a_exclude_xpath, a_include_xpath ) then l_result := 1; end if; - l_result := l_result + (self as ut_compound_data_value).compare_implementation(a_other, a_exclude_xpath, a_include_xpath, a_join_by_xpath, a_unordered); + + l_result := l_result + (self as ut_compound_data_value).compare_implementation(a_other, a_exclude_xpath, a_include_xpath, a_join_by_xpath, a_unordered); return l_result; end; From 38aba4389ec6ed5d17dee930bb0abbb19dca59a5 Mon Sep 17 00:00:00 2001 From: lwasylow Date: Thu, 10 May 2018 22:15:34 +0100 Subject: [PATCH 026/184] Added unique key name as part of compare results Small fixes and optimizations --- .../data_values/ut_compound_data_diff_tmp.sql | 1 - .../data_values/ut_compound_data_helper.pkb | 54 +++++++++++++------ .../data_values/ut_compound_data_helper.pks | 2 + .../data_values/ut_compound_data_value.tpb | 31 +++-------- 4 files changed, 47 insertions(+), 41 deletions(-) diff --git a/source/expectations/data_values/ut_compound_data_diff_tmp.sql b/source/expectations/data_values/ut_compound_data_diff_tmp.sql index 95cb2f1f0..27f95907b 100644 --- a/source/expectations/data_values/ut_compound_data_diff_tmp.sql +++ b/source/expectations/data_values/ut_compound_data_diff_tmp.sql @@ -15,7 +15,6 @@ create global temporary table ut_compound_data_diff_tmp( diff_id raw(128), item_no integer, pk_hash raw(128), - pk_value varchar2(4000), item_hash raw(128), duplicate_no integer, constraint ut_compound_data_diff_tmp_uk1 unique (diff_id,duplicate_no,item_no,item_hash, pk_hash), diff --git a/source/expectations/data_values/ut_compound_data_helper.pkb b/source/expectations/data_values/ut_compound_data_helper.pkb index e1e9c936c..1cf111f80 100644 --- a/source/expectations/data_values/ut_compound_data_helper.pkb +++ b/source/expectations/data_values/ut_compound_data_helper.pkb @@ -186,7 +186,19 @@ create or replace package body ut_compound_data_helper is return l_results; end; - + + function get_pk_value (a_join_by_xpath varchar2,a_item_data xmltype) return varchar2 is + l_pk_value varchar2(4000); + begin + select listagg(extractvalue(xmlelement("ROW",column_value),a_join_by_xpath),':') within group ( order by 1) + into l_pk_value + from table(xmlsequence(extract(a_item_data,'/*/*'))); + + return l_pk_value; + exception when no_data_found then + return 'null '; + end; + function get_rows_diff( a_expected_dataset_guid raw, a_actual_dataset_guid raw, a_diff_id raw, a_max_rows integer, a_exclude_xpath varchar2, a_include_xpath varchar2, @@ -195,15 +207,15 @@ create or replace package body ut_compound_data_helper is l_column_filter varchar2(32767); l_results tt_row_diffs; begin - l_column_filter := get_columns_filter(a_exclude_xpath,a_include_xpath); + l_column_filter := get_columns_row_filter(a_exclude_xpath,a_include_xpath); /** * Since its unordered search we cannot select max rows from diffs as we miss some comparision records * We will restrict output on higher level of select **/ - + execute immediate q'[ - with diff_info as (select item_hash,pk_hash,pk_value from ut_compound_data_diff_tmp ucdc where diff_id = :diff_guid) + with diff_info as (select item_hash,pk_hash,pk_value, duplicate_no from ut_compound_data_diff_tmp ucdc where diff_id = :diff_guid) select rn,diff_type,diffed_row,pk_value from ( select diff_type,diffed_row, dense_rank() over (order by pk_hash) rn,pk_value from @@ -215,16 +227,17 @@ create or replace package body ut_compound_data_helper is xmlserialize(content exp.row_data no indent) exp_item, xmlserialize(content act.row_data no indent) act_item from - (select ucd.*, row_number() over(partition by pk_hash order by row_hash) duplicate_no + (select ucd.* from (select ucd.column_value row_data, r.item_hash row_hash, r.pk_hash , - r.pk_value, + r.duplicate_no, + ucd.column_value.getclobval() col_val, ucd.column_value.getRootElement() col_name, - ucd.column_value.getclobval() col_val + ut_compound_data_helper.get_pk_value(:join_xpath,r.item_data) pk_value from - (select ]'||l_column_filter||q'[, ucd.item_no, ucd.item_hash, i.pk_hash, i.pk_value + (select ]'||l_column_filter||q'[, ucd.item_no, ucd.item_hash, i.pk_hash, i.duplicate_no from ut_compound_data_tmp ucd, diff_info i where ucd.data_id = :self_guid @@ -234,16 +247,17 @@ create or replace package body ut_compound_data_helper is ) ucd ) exp join ( - select ucd.*, row_number() over(partition by pk_hash order by row_hash) duplicate_no + select ucd.* from (select ucd.column_value row_data, r.item_hash row_hash, r.pk_hash , - r.pk_value, + r.duplicate_no, + ucd.column_value.getclobval() col_val, ucd.column_value.getRootElement() col_name, - ucd.column_value.getclobval() col_val + ut_compound_data_helper.get_pk_value(:join_xpath,r.item_data) pk_value from - (select ]'||l_column_filter||q'[, ucd.item_no, ucd.item_hash, i.pk_hash, i.pk_value + (select ]'||l_column_filter||q'[, ucd.item_no, ucd.item_hash, i.pk_hash, i.duplicate_no from ut_compound_data_tmp ucd, diff_info i where ucd.data_id = :other_guid @@ -252,7 +266,8 @@ create or replace package body ut_compound_data_helper is table( xmlsequence( extract(r.item_data,'/*/*') ) ) ucd ) ucd ) act - on exp.pk_hash = act.pk_hash and exp.duplicate_no = act.duplicate_no + on exp.pk_hash = act.pk_hash and exp.col_name = act.col_name + and exp.duplicate_no = act.duplicate_no where dbms_lob.compare(exp.col_val, act.col_val) != 0 ) unpivot ( data_item for diff_type in (exp_item as 'Expected:', act_item as 'Actual:') ) @@ -261,15 +276,17 @@ create or replace package body ut_compound_data_helper is select case when exp.pk_hash is null then 'Extra:' else 'Missing:' end as diff_type, xmlserialize(content nvl(exp.item_data, act.item_data) no indent) diffed_row, coalesce(exp.pk_hash,act.pk_hash) pk_hash, - null pk_value - from (select extract(ucd.item_data,'/*/*') item_data,i.pk_hash + coalesce(exp.pk_value,act.pk_value) pk_value + from (select extract(ucd.item_data,'/*/*') item_data,i.pk_hash, + ut_compound_data_helper.get_pk_value(:join_by,item_data) pk_value from ut_compound_data_tmp ucd, diff_info i where ucd.data_id = :self_guid and ucd.item_hash = i.item_hash ) exp full outer join ( - select extract(ucd.item_data,'/*/*') item_data,i.pk_hash + select extract(ucd.item_data,'/*/*') item_data,i.pk_hash, + ut_compound_data_helper.get_pk_value(:join_by,item_data) pk_value from ut_compound_data_tmp ucd, diff_info i where ucd.data_id = :other_guid @@ -282,10 +299,13 @@ create or replace package body ut_compound_data_helper is ]' bulk collect into l_results using a_diff_id, + a_join_by_xpath, a_exclude_xpath, a_include_xpath, a_expected_dataset_guid, + a_join_by_xpath, a_exclude_xpath, a_include_xpath, a_actual_dataset_guid, - a_expected_dataset_guid, a_actual_dataset_guid, + a_join_by_xpath,a_expected_dataset_guid,a_join_by_xpath, a_actual_dataset_guid, a_max_rows; + return l_results; end; diff --git a/source/expectations/data_values/ut_compound_data_helper.pks b/source/expectations/data_values/ut_compound_data_helper.pks index 99aa7c18a..a73f4c26f 100644 --- a/source/expectations/data_values/ut_compound_data_helper.pks +++ b/source/expectations/data_values/ut_compound_data_helper.pks @@ -60,6 +60,8 @@ create or replace package ut_compound_data_helper authid definer is a_max_rows integer, a_exclude_xpath varchar2, a_include_xpath varchar2 ) return tt_row_diffs; + function get_pk_value (a_join_by_xpath varchar2,a_item_data xmltype) return varchar2; + function get_rows_diff( a_expected_dataset_guid raw, a_actual_dataset_guid raw, a_diff_id raw, a_max_rows integer, a_exclude_xpath varchar2, a_include_xpath varchar2, diff --git a/source/expectations/data_values/ut_compound_data_value.tpb b/source/expectations/data_values/ut_compound_data_value.tpb index efddc1c0b..889db7ee8 100644 --- a/source/expectations/data_values/ut_compound_data_value.tpb +++ b/source/expectations/data_values/ut_compound_data_value.tpb @@ -251,21 +251,6 @@ create or replace type body ut_compound_data_value as l_row_diffs ut_compound_data_helper.tt_row_diffs; c_max_rows constant integer := 20; - function get_pk_value(a_join_by_xpath varchar2) return varchar2 is - l_column varchar2(32767); - begin - /* due to possibility of key being to columns we cannot use xmlextractvalue - usage of xmlagg is possible however it greatly complicates code and performance is impacted. - xpath to be looked at or regex - */ - if a_join_by_xpath is not null then - l_column := ' extract(t.item_data,:join_by_xpath).GetStringVal() pk_value '; - else - l_column := ' :join_by_xpath pk_value'; - end if; - return l_column; - end; - function get_column_pk_hash(a_join_by_xpath varchar2) return varchar2 is l_column varchar2(32767); begin @@ -313,35 +298,35 @@ create or replace type body ut_compound_data_value as using a_exclude_xpath, a_include_xpath,a_join_by_xpath,self.data_id, l_other.data_id; /* Peform minus on two sets two get diffrences that will be used later on to print results */ - execute immediate 'insert into ' || l_ut_owner || '.ut_compound_data_diff_tmp ( diff_id,item_hash,pk_hash,duplicate_no,pk_value) + execute immediate 'insert into ' || l_ut_owner || '.ut_compound_data_diff_tmp ( diff_id,item_hash,pk_hash,duplicate_no) with source_data as ( select t.data_id,t.item_hash,row_number() over (partition by t.pk_hash,t.item_hash,t.data_id order by 1,2) duplicate_no, - pk_hash, '||get_pk_value(a_join_by_xpath)||' + pk_hash from ' || l_ut_owner || '.ut_compound_data_tmp t where data_id = :self_guid or data_id = :other_guid ) - select distinct :diff_id,tmp.item_hash,tmp.pk_hash,tmp.duplicate_no,pk_value + select distinct :diff_id,tmp.item_hash,tmp.pk_hash,tmp.duplicate_no from( ( - select t.item_hash,t. duplicate_no,t.pk_hash, t.pk_value + select t.item_hash,t. duplicate_no,t.pk_hash from source_data t where t.data_id = :self_guid minus - select t.item_hash,t. duplicate_no,t.pk_hash, t.pk_value + select t.item_hash,t. duplicate_no,t.pk_hash from source_data t where t.data_id = :other_guid ) union all ( - select t.item_hash,t. duplicate_no,t.pk_hash, t.pk_value + select t.item_hash,t. duplicate_no,t.pk_hash from source_data t where t.data_id = :other_guid minus - select t.item_hash,t. duplicate_no,t.pk_hash, t.pk_value + select t.item_hash,t. duplicate_no,t.pk_hash from source_data t where t.data_id = :self_guid ))tmp' - using a_join_by_xpath,self.data_id, l_other.data_id, + using self.data_id, l_other.data_id, l_diff_id, self.data_id, l_other.data_id, l_other.data_id,self.data_id; From 66974e000d77fc2575866109bc6e92adb24ba238 Mon Sep 17 00:00:00 2001 From: lwasylow Date: Thu, 10 May 2018 22:15:34 +0100 Subject: [PATCH 027/184] Added unique key name as part of compare results Small fixes and optimizations --- .../data_values/ut_compound_data_diff_tmp.sql | 1 - .../data_values/ut_compound_data_helper.pkb | 57 +++-- .../data_values/ut_compound_data_helper.pks | 2 + .../data_values/ut_compound_data_value.tpb | 31 +-- .../data_values/ut_data_value_refcursor.tpb | 2 +- .../test_expectations_cursor.pkb | 216 ++++++++++++++++++ .../test_expectations_cursor.pks | 35 ++- 7 files changed, 297 insertions(+), 47 deletions(-) diff --git a/source/expectations/data_values/ut_compound_data_diff_tmp.sql b/source/expectations/data_values/ut_compound_data_diff_tmp.sql index 95cb2f1f0..27f95907b 100644 --- a/source/expectations/data_values/ut_compound_data_diff_tmp.sql +++ b/source/expectations/data_values/ut_compound_data_diff_tmp.sql @@ -15,7 +15,6 @@ create global temporary table ut_compound_data_diff_tmp( diff_id raw(128), item_no integer, pk_hash raw(128), - pk_value varchar2(4000), item_hash raw(128), duplicate_no integer, constraint ut_compound_data_diff_tmp_uk1 unique (diff_id,duplicate_no,item_no,item_hash, pk_hash), diff --git a/source/expectations/data_values/ut_compound_data_helper.pkb b/source/expectations/data_values/ut_compound_data_helper.pkb index e1e9c936c..883f9a364 100644 --- a/source/expectations/data_values/ut_compound_data_helper.pkb +++ b/source/expectations/data_values/ut_compound_data_helper.pkb @@ -186,7 +186,19 @@ create or replace package body ut_compound_data_helper is return l_results; end; - + + function get_pk_value (a_join_by_xpath varchar2,a_item_data xmltype) return varchar2 is + l_pk_value varchar2(4000); + begin + select listagg(extractvalue(xmlelement("ROW",column_value),a_join_by_xpath),':') within group ( order by 1) + into l_pk_value + from table(xmlsequence(extract(a_item_data,'/*/*'))); + + return l_pk_value; + exception when no_data_found then + return 'null '; + end; + function get_rows_diff( a_expected_dataset_guid raw, a_actual_dataset_guid raw, a_diff_id raw, a_max_rows integer, a_exclude_xpath varchar2, a_include_xpath varchar2, @@ -195,15 +207,16 @@ create or replace package body ut_compound_data_helper is l_column_filter varchar2(32767); l_results tt_row_diffs; begin - l_column_filter := get_columns_filter(a_exclude_xpath,a_include_xpath); + l_column_filter := get_columns_row_filter(a_exclude_xpath,a_include_xpath); /** * Since its unordered search we cannot select max rows from diffs as we miss some comparision records * We will restrict output on higher level of select + * NO_MERGE hint was introduced to prevent optimizer from merging views and rewriting query which in some cases + * lead to second value being null depend on execution plan that been chosen **/ - execute immediate q'[ - with diff_info as (select item_hash,pk_hash,pk_value from ut_compound_data_diff_tmp ucdc where diff_id = :diff_guid) + with diff_info as (select item_hash,pk_hash,duplicate_no from ut_compound_data_diff_tmp ucdc where diff_id = :diff_guid) select rn,diff_type,diffed_row,pk_value from ( select diff_type,diffed_row, dense_rank() over (order by pk_hash) rn,pk_value from @@ -211,20 +224,21 @@ create or replace package body ut_compound_data_helper is select diff_type,diffed_row,pk_hash,pk_value from (select diff_type,data_item diffed_row,pk_hash,pk_value from - (select nvl(exp.pk_hash, act.pk_hash) pk_hash,nvl(exp.pk_value, act.pk_value) pk_value, + (select /*+NO_MERGE*/ nvl(exp.pk_hash, act.pk_hash) pk_hash,nvl(exp.pk_value, act.pk_value) pk_value, xmlserialize(content exp.row_data no indent) exp_item, xmlserialize(content act.row_data no indent) act_item from - (select ucd.*, row_number() over(partition by pk_hash order by row_hash) duplicate_no + (select ucd.* from (select ucd.column_value row_data, r.item_hash row_hash, r.pk_hash , - r.pk_value, + r.duplicate_no, + ucd.column_value.getclobval() col_val, ucd.column_value.getRootElement() col_name, - ucd.column_value.getclobval() col_val + ut_compound_data_helper.get_pk_value(:join_xpath,r.item_data) pk_value from - (select ]'||l_column_filter||q'[, ucd.item_no, ucd.item_hash, i.pk_hash, i.pk_value + (select ]'||l_column_filter||q'[, ucd.item_no, ucd.item_hash, i.pk_hash, i.duplicate_no from ut_compound_data_tmp ucd, diff_info i where ucd.data_id = :self_guid @@ -234,16 +248,17 @@ create or replace package body ut_compound_data_helper is ) ucd ) exp join ( - select ucd.*, row_number() over(partition by pk_hash order by row_hash) duplicate_no + select ucd.* from (select ucd.column_value row_data, r.item_hash row_hash, r.pk_hash , - r.pk_value, + r.duplicate_no, + ucd.column_value.getclobval() col_val, ucd.column_value.getRootElement() col_name, - ucd.column_value.getclobval() col_val + ut_compound_data_helper.get_pk_value(:join_xpath,r.item_data) pk_value from - (select ]'||l_column_filter||q'[, ucd.item_no, ucd.item_hash, i.pk_hash, i.pk_value + (select ]'||l_column_filter||q'[, ucd.item_no, ucd.item_hash, i.pk_hash, i.duplicate_no from ut_compound_data_tmp ucd, diff_info i where ucd.data_id = :other_guid @@ -252,7 +267,8 @@ create or replace package body ut_compound_data_helper is table( xmlsequence( extract(r.item_data,'/*/*') ) ) ucd ) ucd ) act - on exp.pk_hash = act.pk_hash and exp.duplicate_no = act.duplicate_no + on exp.pk_hash = act.pk_hash and exp.col_name = act.col_name + and exp.duplicate_no = act.duplicate_no where dbms_lob.compare(exp.col_val, act.col_val) != 0 ) unpivot ( data_item for diff_type in (exp_item as 'Expected:', act_item as 'Actual:') ) @@ -261,15 +277,17 @@ create or replace package body ut_compound_data_helper is select case when exp.pk_hash is null then 'Extra:' else 'Missing:' end as diff_type, xmlserialize(content nvl(exp.item_data, act.item_data) no indent) diffed_row, coalesce(exp.pk_hash,act.pk_hash) pk_hash, - null pk_value - from (select extract(ucd.item_data,'/*/*') item_data,i.pk_hash + coalesce(exp.pk_value,act.pk_value) pk_value + from (select extract(ucd.item_data,'/*/*') item_data,i.pk_hash, + ut_compound_data_helper.get_pk_value(:join_by,item_data) pk_value from ut_compound_data_tmp ucd, diff_info i where ucd.data_id = :self_guid and ucd.item_hash = i.item_hash ) exp full outer join ( - select extract(ucd.item_data,'/*/*') item_data,i.pk_hash + select extract(ucd.item_data,'/*/*') item_data,i.pk_hash, + ut_compound_data_helper.get_pk_value(:join_by,item_data) pk_value from ut_compound_data_tmp ucd, diff_info i where ucd.data_id = :other_guid @@ -282,10 +300,13 @@ create or replace package body ut_compound_data_helper is ]' bulk collect into l_results using a_diff_id, + a_join_by_xpath, a_exclude_xpath, a_include_xpath, a_expected_dataset_guid, + a_join_by_xpath, a_exclude_xpath, a_include_xpath, a_actual_dataset_guid, - a_expected_dataset_guid, a_actual_dataset_guid, + a_join_by_xpath,a_expected_dataset_guid,a_join_by_xpath, a_actual_dataset_guid, a_max_rows; + return l_results; end; diff --git a/source/expectations/data_values/ut_compound_data_helper.pks b/source/expectations/data_values/ut_compound_data_helper.pks index 99aa7c18a..a73f4c26f 100644 --- a/source/expectations/data_values/ut_compound_data_helper.pks +++ b/source/expectations/data_values/ut_compound_data_helper.pks @@ -60,6 +60,8 @@ create or replace package ut_compound_data_helper authid definer is a_max_rows integer, a_exclude_xpath varchar2, a_include_xpath varchar2 ) return tt_row_diffs; + function get_pk_value (a_join_by_xpath varchar2,a_item_data xmltype) return varchar2; + function get_rows_diff( a_expected_dataset_guid raw, a_actual_dataset_guid raw, a_diff_id raw, a_max_rows integer, a_exclude_xpath varchar2, a_include_xpath varchar2, diff --git a/source/expectations/data_values/ut_compound_data_value.tpb b/source/expectations/data_values/ut_compound_data_value.tpb index efddc1c0b..889db7ee8 100644 --- a/source/expectations/data_values/ut_compound_data_value.tpb +++ b/source/expectations/data_values/ut_compound_data_value.tpb @@ -251,21 +251,6 @@ create or replace type body ut_compound_data_value as l_row_diffs ut_compound_data_helper.tt_row_diffs; c_max_rows constant integer := 20; - function get_pk_value(a_join_by_xpath varchar2) return varchar2 is - l_column varchar2(32767); - begin - /* due to possibility of key being to columns we cannot use xmlextractvalue - usage of xmlagg is possible however it greatly complicates code and performance is impacted. - xpath to be looked at or regex - */ - if a_join_by_xpath is not null then - l_column := ' extract(t.item_data,:join_by_xpath).GetStringVal() pk_value '; - else - l_column := ' :join_by_xpath pk_value'; - end if; - return l_column; - end; - function get_column_pk_hash(a_join_by_xpath varchar2) return varchar2 is l_column varchar2(32767); begin @@ -313,35 +298,35 @@ create or replace type body ut_compound_data_value as using a_exclude_xpath, a_include_xpath,a_join_by_xpath,self.data_id, l_other.data_id; /* Peform minus on two sets two get diffrences that will be used later on to print results */ - execute immediate 'insert into ' || l_ut_owner || '.ut_compound_data_diff_tmp ( diff_id,item_hash,pk_hash,duplicate_no,pk_value) + execute immediate 'insert into ' || l_ut_owner || '.ut_compound_data_diff_tmp ( diff_id,item_hash,pk_hash,duplicate_no) with source_data as ( select t.data_id,t.item_hash,row_number() over (partition by t.pk_hash,t.item_hash,t.data_id order by 1,2) duplicate_no, - pk_hash, '||get_pk_value(a_join_by_xpath)||' + pk_hash from ' || l_ut_owner || '.ut_compound_data_tmp t where data_id = :self_guid or data_id = :other_guid ) - select distinct :diff_id,tmp.item_hash,tmp.pk_hash,tmp.duplicate_no,pk_value + select distinct :diff_id,tmp.item_hash,tmp.pk_hash,tmp.duplicate_no from( ( - select t.item_hash,t. duplicate_no,t.pk_hash, t.pk_value + select t.item_hash,t. duplicate_no,t.pk_hash from source_data t where t.data_id = :self_guid minus - select t.item_hash,t. duplicate_no,t.pk_hash, t.pk_value + select t.item_hash,t. duplicate_no,t.pk_hash from source_data t where t.data_id = :other_guid ) union all ( - select t.item_hash,t. duplicate_no,t.pk_hash, t.pk_value + select t.item_hash,t. duplicate_no,t.pk_hash from source_data t where t.data_id = :other_guid minus - select t.item_hash,t. duplicate_no,t.pk_hash, t.pk_value + select t.item_hash,t. duplicate_no,t.pk_hash from source_data t where t.data_id = :self_guid ))tmp' - using a_join_by_xpath,self.data_id, l_other.data_id, + using self.data_id, l_other.data_id, l_diff_id, self.data_id, l_other.data_id, l_other.data_id,self.data_id; diff --git a/source/expectations/data_values/ut_data_value_refcursor.tpb b/source/expectations/data_values/ut_data_value_refcursor.tpb index 84746fb51..021b493ca 100644 --- a/source/expectations/data_values/ut_data_value_refcursor.tpb +++ b/source/expectations/data_values/ut_data_value_refcursor.tpb @@ -198,7 +198,7 @@ create or replace type body ut_data_value_refcursor as ut_utils.append_to_clob(l_result,chr(10) || 'Unable to join sets:' || chr(10)); for i in 1 .. l_missing_pk.count loop l_results.extend; - ut_utils.append_to_clob(l_result, get_missing_key_message(l_missing_pk(i))); + ut_utils.append_to_clob(l_result, get_missing_key_message(l_missing_pk(i))|| chr(10)); end loop; end if; else diff --git a/test/core/expectations/compound_data/test_expectations_cursor.pkb b/test/core/expectations/compound_data/test_expectations_cursor.pkb index 5a0f429cc..12602c61f 100644 --- a/test/core/expectations/compound_data/test_expectations_cursor.pkb +++ b/test/core/expectations/compound_data/test_expectations_cursor.pkb @@ -1114,6 +1114,144 @@ Extra: test-666%]'; ut.expect(expectations.failed_expectations_data()).to_be_empty(); end; + procedure cursor_joinby_compare_nokey is + l_actual SYS_REFCURSOR; + l_expected SYS_REFCURSOR; + l_actual_message varchar2(32767); + l_expected_message varchar2(32767); + begin + --Arrange + open l_actual for select rownum as rn, 'x' SOME_COL from dual a connect by level < 4; + open l_expected for select rownum as rn, 'x' SOME_COL from dual a connect by level < 4; + + --Act + ut3.ut.expect(l_actual).to_equal(l_expected).join_by('OWNER'); + --Assert + l_expected_message := q'[%Actual: refcursor [ count = 3 ] was expected to equal: refcursor [ count = 3 ]% +Diff:% +%Unable to join sets:% +%Unknown key to join by in expected:/*/OWNER% +%Unknown key to join by in actual:/*/OWNER%]'; + l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; + --Assert + ut.expect(l_actual_message).to_be_like(l_expected_message); + end; + + procedure cur_joinby_comp_twocols_nokey is + l_actual SYS_REFCURSOR; + l_expected SYS_REFCURSOR; + l_actual_message varchar2(32767); + l_expected_message varchar2(32767); + begin + --Arrange + open l_actual for select rownum as rn, 'x' SOME_COL from dual a connect by level < 4; + open l_expected for select rownum as rn, 'x' SOME_COL from dual a connect by level < 4; + + --Act + ut3.ut.expect(l_actual).to_equal(l_expected).join_by(ut3.ut_varchar2_list('OWNER,USER_ID')); + --Assert + l_expected_message := q'[%Actual: refcursor [ count = 3 ] was expected to equal: refcursor [ count = 3 ]% +Diff:% +%Unable to join sets:% +%Unknown key to join by in expected:/*/OWNER% +%Unknown key to join by in expected:/*/USER_ID% +%Unknown key to join by in actual:/*/OWNER% +%Unknown key to join by in actual:/*/USER_ID%]'; + l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; + --Assert + ut.expect(l_actual_message).to_be_like(l_expected_message); + end; + + procedure cursor_joinby_compare_exkey is + l_actual SYS_REFCURSOR; + l_expected SYS_REFCURSOR; + l_actual_message varchar2(32767); + l_expected_message varchar2(32767); + begin + --Arrange + open l_actual for select rownum as rn, 'x' SOME_COL from dual a connect by level < 4; + open l_expected for select rownum as rn, 'x' SOME_COL from dual a connect by level < 4; + + --Act + ut3.ut.expect(l_actual).to_equal(l_expected).join_by('SOME_COL').exclude('SOME_COL'); + --Assert + l_expected_message := q'[%Actual: refcursor [ count = 3 ] was expected to equal: refcursor [ count = 3 ]% +Diff:% +%Unable to join sets:% +%Unknown key to join by in expected:/*/SOME_COL% +%Unknown key to join by in actual:/*/SOME_COL%]'; + l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; + --Assert + ut.expect(l_actual_message).to_be_like(l_expected_message); + end; + + procedure cur_joinby_comp_twocols_exkey is + l_actual SYS_REFCURSOR; + l_expected SYS_REFCURSOR; + l_actual_message varchar2(32767); + l_expected_message varchar2(32767); + begin + --Arrange + open l_actual for select rownum as rn, 'x' SOME_COL from dual a connect by level < 4; + open l_expected for select rownum as rn, 'x' SOME_COL from dual a connect by level < 4; + + --Act + ut3.ut.expect(l_actual).to_equal(l_expected).join_by(ut3.ut_varchar2_list('RN,SOME_COL')).exclude('RN'); + --Assert + l_expected_message := q'[%Actual: refcursor [ count = 3 ] was expected to equal: refcursor [ count = 3 ]% +Diff:% +%Unable to join sets:% +%Unknown key to join by in expected:/*/RN% +%Unknown key to join by in actual:/*/RN%]'; + l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; + --Assert + ut.expect(l_actual_message).to_be_like(l_expected_message); + end; + + procedure cursor_joinby_comp_nokey_ex is + l_actual SYS_REFCURSOR; + l_expected SYS_REFCURSOR; + l_actual_message varchar2(32767); + l_expected_message varchar2(32767); + begin + --Arrange + open l_actual for select rownum as rni, 'x' SOME_COL from dual a connect by level < 4; + open l_expected for select rownum as rn, 'x' SOME_COL from dual a connect by level < 4; + + --Act + ut3.ut.expect(l_actual).to_equal(l_expected).join_by('RNI'); + --Assert + l_expected_message := q'[%Actual: refcursor [ count = 3 ] was expected to equal: refcursor [ count = 3 ]% +Diff:% +%Unable to join sets:% +%Unknown key to join by in expected:/*/RNI%]'; + l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; + --Assert + ut.expect(l_actual_message).to_be_like(l_expected_message); + end; + + procedure cursor_joinby_comp_nokey_ac is + l_actual SYS_REFCURSOR; + l_expected SYS_REFCURSOR; + l_actual_message varchar2(32767); + l_expected_message varchar2(32767); + begin + --Arrange + open l_actual for select rownum as rn, 'x' SOME_COL from dual a connect by level < 4; + open l_expected for select rownum as rni, 'x' SOME_COL from dual a connect by level < 4; + + --Act + ut3.ut.expect(l_actual).to_equal(l_expected).join_by('RNI'); + --Assert + l_expected_message := q'[%Actual: refcursor [ count = 3 ] was expected to equal: refcursor [ count = 3 ]% +Diff:% +%Unable to join sets:% +%Unknown key to join by in actual:/*/RNI%]'; + l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; + --Assert + ut.expect(l_actual_message).to_be_like(l_expected_message); + end; + procedure cursor_joinby_compare_1000 is l_actual SYS_REFCURSOR; l_expected SYS_REFCURSOR; @@ -1127,6 +1265,84 @@ Extra: test-666%]'; ut.expect(expectations.failed_expectations_data()).to_be_empty(); end; + procedure cursor_joinby_compare_fail is + l_actual SYS_REFCURSOR; + l_expected SYS_REFCURSOR; + l_actual_message varchar2(32767); + l_expected_message varchar2(32767); + begin + --Arrange + open l_expected for select username, user_id from all_users union all + select 'TEST' username, -600 user_id from dual order by 1 desc; + + open l_actual for select username, user_id from all_users union all + select 'TEST' username, -610 user_id from dual order by 1 asc; + + --Act + ut3.ut.expect(l_actual).to_equal(l_expected).join_by('USERNAME'); + --Assert + l_expected_message := q'[%Actual: refcursor [ count = % ] was expected to equal: refcursor [ count = % ] +%Diff:% +%Rows: [ 1 differences ]% +%Expected: -600 for key: TEST% +%Actual: -610 for key: TEST%]'; + l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; + --Assert + ut.expect(l_actual_message).to_be_like(l_expected_message); + end; + + procedure cursor_joinby_cmp_twocol_fail is + l_actual SYS_REFCURSOR; + l_expected SYS_REFCURSOR; + l_actual_message varchar2(32767); + l_expected_message varchar2(32767); + begin + --Arrange + open l_expected for select username, user_id from all_users union all + select 'TEST' username, -600 user_id from dual order by 1 desc; + + open l_actual for select username, user_id from all_users union all + select 'TEST' username, -610 user_id from dual order by 1 asc; + + --Act + ut3.ut.expect(l_actual).to_equal(l_expected).join_by(ut3.ut_varchar2_list('USERNAME,USER_ID')); + --Assert + l_expected_message := q'[%Actual: refcursor [ count = % ] was expected to equal: refcursor [ count = % ] +%Diff:% +%Rows: [ 2 differences ]% +%Missing: TEST-600 for key: -600:TEST% +%Extra: TEST-610 for key: -610:TEST%]'; + l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; + --Assert + ut.expect(l_actual_message).to_be_like(l_expected_message); + end; + + procedure cur_joinby_cmp_threcol_fail is + l_actual SYS_REFCURSOR; + l_expected SYS_REFCURSOR; + l_actual_message varchar2(32767); + l_expected_message varchar2(32767); + begin + --Arrange + open l_expected for select username, user_id,'Y' is_valid from all_users union all + select 'TEST' username, -600 user_id,'Y' is_valid from dual order by 1 desc; + + open l_actual for select username, user_id,'Y' is_valid from all_users union all + select 'TEST' username, -610 user_id,'Y' is_valid from dual order by 1 asc; + + --Act + ut3.ut.expect(l_actual).to_equal(l_expected).join_by(ut3.ut_varchar2_list('USERNAME,IS_VALID')); + --Assert + l_expected_message := q'[%Actual: refcursor [ count = % ] was expected to equal: refcursor [ count = % ] +%Diff:% +%Rows: [ 1 differences ]% +%Expected: -600 for key: TEST:Y% +%Actual: -610 for key: TEST:Y%]'; + l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; + --Assert + ut.expect(l_actual_message).to_be_like(l_expected_message); + end; + procedure unord_incl_cols_as_list as l_actual sys_refcursor; diff --git a/test/core/expectations/compound_data/test_expectations_cursor.pks b/test/core/expectations/compound_data/test_expectations_cursor.pks index 76dc1fba8..eb5144c29 100644 --- a/test/core/expectations/compound_data/test_expectations_cursor.pks +++ b/test/core/expectations/compound_data/test_expectations_cursor.pks @@ -211,9 +211,36 @@ create or replace package test_expectations_cursor is --%test( Compare cursors join by composite key) procedure cursor_joinby_compare_twocols; + --%test( Compare cursors join by single key - key doesnt exists ) + procedure cursor_joinby_compare_nokey; + + --%test( Compare cursors join by composite key - one part of key doesnt exists ) + procedure cur_joinby_comp_twocols_nokey; + + --%test( Compare cursors join by single key - key doesnt is excluded ) + procedure cursor_joinby_compare_exkey; + + --%test( Compare cursors join by composite key - one part of key is excluded exists ) + procedure cur_joinby_comp_twocols_exkey; + + --%test( Compare cursors join by single key - key doesnt exists in expected) + procedure cursor_joinby_comp_nokey_ex; + + --%test( Compare cursors join by single key - key doesnt exists in actual) + procedure cursor_joinby_comp_nokey_ac; + --%test( Compare cursors join by single key more than 1000 rows) procedure cursor_joinby_compare_1000; + --%test( Compare two column cursors join by and fail to match ) + procedure cursor_joinby_compare_fail; + + --%test( Compare two column cursors join by two columns and fail to match ) + procedure cursor_joinby_cmp_twocol_fail; + + --%test( Compare three column cursors join by two columns and fail to match ) + procedure cur_joinby_cmp_threcol_fail; + --%test(Unordered List of columns to include) procedure unord_incl_cols_as_list; @@ -226,14 +253,14 @@ create or replace package test_expectations_cursor is --%test(Join By List of columns to exclude) procedure joinby_excl_cols_as_list; - --%test(Exclude columns of diffrent type) + --%test(Exclude columns of different type) procedure excl_dif_cols_as_list; - --%test(Include column of same type leaving diffrent type out) + --%test(Include column of same type leaving different type out) procedure inlc_dif_cols_as_list; - --%test(Include column of same type leaving diffrent type out and exclude diffrent type) + --%test(Include column of same type leaving different type out and exclude different type) procedure inlc_exc_dif_cols_as_list; - + end; / From 0fd8be8c4d4020a67e488ee57eae74b672e2606c Mon Sep 17 00:00:00 2001 From: lwasylow Date: Fri, 11 May 2018 13:22:48 +0100 Subject: [PATCH 028/184] Revert "Initial check in of unordered comparision" This reverts commit b9ca972d659191845f8391a7d7ca316a1ce3e16a. for one file --- source/expectations/data_values/ut_data_value_anydata.tps | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/expectations/data_values/ut_data_value_anydata.tps b/source/expectations/data_values/ut_data_value_anydata.tps index 87829cfa1..91d66c7bd 100644 --- a/source/expectations/data_values/ut_data_value_anydata.tps +++ b/source/expectations/data_values/ut_data_value_anydata.tps @@ -1,4 +1,4 @@ -create or replace type ut_data_value_anydata force under ut_compound_data_value( +create or replace type ut_data_value_anydata under ut_compound_data_value( /* utPLSQL - Version 3 Copyright 2016 - 2017 utPLSQL Project From 1bf5bad62e7ccaeab8fa2c077454daf06f29b086 Mon Sep 17 00:00:00 2001 From: lwasylow Date: Fri, 11 May 2018 17:23:27 +0100 Subject: [PATCH 029/184] Update blank line --- source/expectations/data_values/ut_compound_data_helper.pkb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/expectations/data_values/ut_compound_data_helper.pkb b/source/expectations/data_values/ut_compound_data_helper.pkb index 883f9a364..2d83ac634 100644 --- a/source/expectations/data_values/ut_compound_data_helper.pkb +++ b/source/expectations/data_values/ut_compound_data_helper.pkb @@ -549,4 +549,4 @@ begin g_type_name_map( dbms_sql.urowid_type ) := 'UROWID'; end; -/ \ No newline at end of file +/ From 846f76ab6e380ba44c850163fbcbd0ece9d65ae8 Mon Sep 17 00:00:00 2001 From: lwasylow Date: Sat, 12 May 2018 01:29:43 +0100 Subject: [PATCH 030/184] Fixes to bug introduced in revision Revision: c787e4793de0d89ff9770320e2e863ce25142be4 * Added support for multiple occurrences of before and after blocks. that removed a path from ut_suite_item.tpb and move to suite_builder missing a lower case transformation for object name and procedure name. --- source/core/ut_suite_builder.pkb | 4 +-- test/core/reporters/test_junit_reporter.pkb | 33 +++++++++++++++++++++ test/core/reporters/test_junit_reporter.pks | 9 ++++-- 3 files changed, 41 insertions(+), 5 deletions(-) diff --git a/source/core/ut_suite_builder.pkb b/source/core/ut_suite_builder.pkb index e39e0e33b..4d6642df8 100644 --- a/source/core/ut_suite_builder.pkb +++ b/source/core/ut_suite_builder.pkb @@ -105,7 +105,7 @@ create or replace package body ut_suite_builder is l_annotation_pos binary_integer; begin l_result.owner := a_object.object_owner; - l_result.name := a_object.object_name; + l_result.name := lower(trim(a_object.object_name)); l_annotation_no := a_object.annotations.first; while l_annotation_no is not null loop l_annotation_pos := a_object.annotations(l_annotation_no).position; @@ -113,7 +113,7 @@ create or replace package body ut_suite_builder is l_result.annotations(l_annotation_pos).name := a_object.annotations(l_annotation_no).name; l_result.annotations(l_annotation_pos).text := a_object.annotations(l_annotation_no).text; else - l_result.annotations(l_annotation_pos).procedure_name := a_object.annotations(l_annotation_no).subobject_name; + l_result.annotations(l_annotation_pos).procedure_name := lower(trim(a_object.annotations(l_annotation_no).subobject_name)); l_result.annotations(l_annotation_pos).procedure_annotations := get_procedure_annotations(a_object.annotations, l_annotation_no); end if; l_annotation_no := a_object.annotations.next(l_annotation_no); diff --git a/test/core/reporters/test_junit_reporter.pkb b/test/core/reporters/test_junit_reporter.pkb index 280431aa3..d93e6a263 100644 --- a/test/core/reporters/test_junit_reporter.pkb +++ b/test/core/reporters/test_junit_reporter.pkb @@ -62,6 +62,18 @@ create or replace package body test_junit_reporter as procedure test1 is begin ut.expect(1).to_equal(1); end; end;]'; + + execute immediate q'[create or replace package Tst_Fix_Case_Sensitive as + --%suite + + --%test(bugfix) + procedure bUgFiX; + end;]'; + + execute immediate q'[create or replace package body Tst_Fix_Case_Sensitive as + procedure bUgFiX is begin ut.expect(1).to_equal(1); end; + end;]'; + reporters.reporters_setup; end; @@ -267,6 +279,27 @@ create or replace package body test_junit_reporter as ut.expect(l_actual).to_be_like(l_expected); end; + procedure check_classname_is_populated is + l_results ut3.ut_varchar2_list; + l_actual clob; + l_expected varchar2(32767):= q'[ + + + + + + + + +]'; + begin + select * + bulk collect into l_results + from table(ut3.ut.run('Tst_Fix_Case_Sensitive',ut3.ut_junit_reporter())); + l_actual := ut3.ut_utils.table_to_clob(l_results); + ut.expect(l_actual).to_be_like(l_expected); + end; + procedure remove_test_package is pragma autonomous_transaction; begin diff --git a/test/core/reporters/test_junit_reporter.pks b/test/core/reporters/test_junit_reporter.pks index 91bc03f31..2a94dcc28 100644 --- a/test/core/reporters/test_junit_reporter.pks +++ b/test/core/reporters/test_junit_reporter.pks @@ -27,14 +27,17 @@ create or replace package test_junit_reporter as --%test(Reports duration according to XML specification for numbers) procedure check_nls_number_formatting; - --%test(Report on test without description) + --%test(Report on test without description) procedure report_test_without_desc; - --%test(Report on suite without description) + --%test(Report on suite without description) procedure report_suite_without_desc; - --%test(Report produces expected output) + --%test(Report produces expected output) procedure reporort_produces_expected_out; + + --%test( Test for bug #659) + procedure check_classname_is_populated; --%afterall procedure remove_test_package; From ed952ebd7fe658d7b5d9b17fcc7f900d49f0f5f1 Mon Sep 17 00:00:00 2001 From: lwasylow Date: Sat, 12 May 2018 08:52:35 +0100 Subject: [PATCH 031/184] Added cleanup for test --- test/core/reporters/test_junit_reporter.pkb | 1 + 1 file changed, 1 insertion(+) diff --git a/test/core/reporters/test_junit_reporter.pkb b/test/core/reporters/test_junit_reporter.pkb index d93e6a263..1b418db93 100644 --- a/test/core/reporters/test_junit_reporter.pkb +++ b/test/core/reporters/test_junit_reporter.pkb @@ -307,6 +307,7 @@ create or replace package body test_junit_reporter as execute immediate 'drop package check_junit_rep_suitepath'; execute immediate 'drop package tst_package_junit_nodesc'; execute immediate 'drop package tst_package_junit_nosuite'; + execute immediate 'drop package Tst_Fix_Case_Sensitive'; reporters.reporters_cleanup; end; end; From e5449210c426c654068c2d1c209a0749e483cadf Mon Sep 17 00:00:00 2001 From: lwasylow Date: Sat, 12 May 2018 08:53:36 +0100 Subject: [PATCH 032/184] Updated test name --- test/core/reporters/test_junit_reporter.pks | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/core/reporters/test_junit_reporter.pks b/test/core/reporters/test_junit_reporter.pks index 2a94dcc28..54f748598 100644 --- a/test/core/reporters/test_junit_reporter.pks +++ b/test/core/reporters/test_junit_reporter.pks @@ -36,7 +36,7 @@ create or replace package test_junit_reporter as --%test(Report produces expected output) procedure reporort_produces_expected_out; - --%test( Test for bug #659) + --%test( Check classname is populated when procedure is mixed cased - bug #659) procedure check_classname_is_populated; --%afterall From d9f09f0f800b27bdd930458d39710e1b2db508ae Mon Sep 17 00:00:00 2001 From: Travis CI Date: Sat, 12 May 2018 08:44:04 +0000 Subject: [PATCH 033/184] Updated project version after build [skip ci] --- source/core/ut_utils.pks | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/core/ut_utils.pks b/source/core/ut_utils.pks index 82b834b7e..da1e78fb5 100644 --- a/source/core/ut_utils.pks +++ b/source/core/ut_utils.pks @@ -21,7 +21,7 @@ create or replace package ut_utils authid definer is * */ - gc_version constant varchar2(50) := 'v3.1.2.1883-develop'; + gc_version constant varchar2(50) := 'v3.1.2.1894-develop'; /* Constants: Event names */ subtype t_event_name is varchar2(30); From d1dc6e1ffe4980a549070f971cc8a5b3707043ff Mon Sep 17 00:00:00 2001 From: lwasylow Date: Sat, 12 May 2018 11:34:50 +0100 Subject: [PATCH 034/184] Fixes issue when in failure message appears a special characters or a tag like CDDATA. --- source/reporters/ut_junit_reporter.tpb | 2 +- source/reporters/ut_sonar_test_reporter.tpb | 2 +- source/reporters/ut_tfs_junit_reporter.tpb | 2 +- test/core/reporters/test_junit_reporter.pkb | 34 ++++++++++++++++++ test/core/reporters/test_junit_reporter.pks | 9 +++-- .../reporters/test_tfs_junit_reporter.pkb | 36 +++++++++++++++++++ .../reporters/test_tfs_junit_reporter.pks | 3 ++ 7 files changed, 82 insertions(+), 6 deletions(-) diff --git a/source/reporters/ut_junit_reporter.tpb b/source/reporters/ut_junit_reporter.tpb index e1a6d7dca..6c18463f6 100644 --- a/source/reporters/ut_junit_reporter.tpb +++ b/source/reporters/ut_junit_reporter.tpb @@ -59,7 +59,7 @@ create or replace type body ut_junit_reporter is l_lines := a_test.failed_expectations(i).get_result_lines(); for j in 1 .. l_lines.count loop - self.print_text(l_lines(j)); + self.print_text(dbms_xmlgen.convert(l_lines(j))); end loop; self.print_text(a_test.failed_expectations(i).caller_info); end loop; diff --git a/source/reporters/ut_sonar_test_reporter.tpb b/source/reporters/ut_sonar_test_reporter.tpb index 66d82fedc..ed73ea3de 100644 --- a/source/reporters/ut_sonar_test_reporter.tpb +++ b/source/reporters/ut_sonar_test_reporter.tpb @@ -60,7 +60,7 @@ create or replace type body ut_sonar_test_reporter is for i in 1 .. a_test.failed_expectations.count loop l_lines := a_test.failed_expectations(i).get_result_lines(); for i in 1 .. l_lines.count loop - self.print_text(l_lines(i)); + self.print_text(dbms_xmlgen.convert(l_lines(i))); end loop; end loop; self.print_text(']]>'); diff --git a/source/reporters/ut_tfs_junit_reporter.tpb b/source/reporters/ut_tfs_junit_reporter.tpb index 42da37f05..b23bf2595 100644 --- a/source/reporters/ut_tfs_junit_reporter.tpb +++ b/source/reporters/ut_tfs_junit_reporter.tpb @@ -80,7 +80,7 @@ create or replace type body ut_tfs_junit_reporter is for i in 1 .. a_test.failed_expectations.count loop l_lines := a_test.failed_expectations(i).get_result_lines(); for j in 1 .. l_lines.count loop - self.print_text(l_lines(j)); + self.print_text(dbms_xmlgen.convert(l_lines(j))); end loop; self.print_text(a_test.failed_expectations(i).caller_info); end loop; diff --git a/test/core/reporters/test_junit_reporter.pkb b/test/core/reporters/test_junit_reporter.pkb index 280431aa3..ae92f9d5a 100644 --- a/test/core/reporters/test_junit_reporter.pkb +++ b/test/core/reporters/test_junit_reporter.pkb @@ -62,6 +62,23 @@ create or replace package body test_junit_reporter as procedure test1 is begin ut.expect(1).to_equal(1); end; end;]'; + execute immediate q'[create or replace package check_fail_escape is + --%suitepath(core) + --%suite(checkfailedescape) + --%displayname(Check JUNIT XML failure is escaped) + + --%test(Fail Miserably) + procedure fail_miserably; + + end;]'; + + execute immediate q'[create or replace package body check_fail_escape is + procedure fail_miserably is + begin + ut3.ut.expect('test').to_equal(''); + end; + end;]'; + reporters.reporters_setup; end; @@ -267,6 +284,22 @@ create or replace package body test_junit_reporter as ut.expect(l_actual).to_be_like(l_expected); end; + + procedure check_failure_escaped is + l_results ut3.ut_varchar2_list; + l_actual clob; + begin + --Act + select * + bulk collect into l_results + from table(ut3.ut.run('check_fail_escape',ut3.ut_junit_reporter())); + l_actual := ut3.ut_utils.table_to_clob(l_results); + --Assert + ut.expect(l_actual).to_be_like('%%'); + end; + procedure remove_test_package is pragma autonomous_transaction; begin @@ -274,6 +307,7 @@ create or replace package body test_junit_reporter as execute immediate 'drop package check_junit_rep_suitepath'; execute immediate 'drop package tst_package_junit_nodesc'; execute immediate 'drop package tst_package_junit_nosuite'; + execute immediate 'drop package check_fail_escape'; reporters.reporters_cleanup; end; end; diff --git a/test/core/reporters/test_junit_reporter.pks b/test/core/reporters/test_junit_reporter.pks index 91bc03f31..d3bc8f0b6 100644 --- a/test/core/reporters/test_junit_reporter.pks +++ b/test/core/reporters/test_junit_reporter.pks @@ -27,15 +27,18 @@ create or replace package test_junit_reporter as --%test(Reports duration according to XML specification for numbers) procedure check_nls_number_formatting; - --%test(Report on test without description) + --%test(Report on test without description) procedure report_test_without_desc; - --%test(Report on suite without description) + --%test(Report on suite without description) procedure report_suite_without_desc; - --%test(Report produces expected output) + --%test(Report produces expected output) procedure reporort_produces_expected_out; + --%test( Validate that fail with special char are escaped ) + procedure check_failure_escaped; + --%afterall procedure remove_test_package; end; diff --git a/test/core/reporters/test_tfs_junit_reporter.pkb b/test/core/reporters/test_tfs_junit_reporter.pkb index cf2ec95b8..8cecf2849 100644 --- a/test/core/reporters/test_tfs_junit_reporter.pkb +++ b/test/core/reporters/test_tfs_junit_reporter.pkb @@ -48,8 +48,28 @@ create or replace package body test_tfs_junit_reporter as null; end; end;]'; + + + execute immediate q'[create or replace package check_fail_escape is + --%suitepath(core) + --%suite(checkfailedescape) + --%displayname(Check JUNIT XML failure is escaped) + + --%test(Fail Miserably) + procedure fail_miserably; + + end;]'; + + execute immediate q'[create or replace package body check_fail_escape is + procedure fail_miserably is + begin + ut3.ut.expect('test').to_equal(''); + end; + end;]'; + end; + procedure escapes_special_chars is l_results ut3.ut_varchar2_list; l_actual clob; @@ -143,6 +163,21 @@ create or replace package body test_tfs_junit_reporter as execute immediate 'alter session set NLS_NUMERIC_CHARACTERS='''||l_nls_numeric_characters||''''; end; + procedure check_failure_escaped is + l_results ut3.ut_varchar2_list; + l_actual clob; + begin + --Act + select * + bulk collect into l_results + from table(ut3.ut.run('check_fail_escape',ut3.ut_tfs_junit_reporter())); + l_actual := ut3.ut_utils.table_to_clob(l_results); + --Assert + ut.expect(l_actual).to_be_like('%%'); + end; + procedure check_classname_suitepath is l_results ut3.ut_varchar2_list; l_actual clob; @@ -161,6 +196,7 @@ create or replace package body test_tfs_junit_reporter as execute immediate 'drop package check_junit_reporting'; execute immediate 'drop package check_junit_rep_suitepath'; execute immediate 'drop package check_junit_flat_suitepath'; + execute immediate 'drop package check_fail_escape'; end; end; / diff --git a/test/core/reporters/test_tfs_junit_reporter.pks b/test/core/reporters/test_tfs_junit_reporter.pks index c01feb36a..8716fdf14 100644 --- a/test/core/reporters/test_tfs_junit_reporter.pks +++ b/test/core/reporters/test_tfs_junit_reporter.pks @@ -27,6 +27,9 @@ create or replace package test_tfs_junit_reporter as --%test(Reports duration according to XML specification for numbers) procedure check_nls_number_formatting; + --%test( Validate that failures with special char are escaped ) + procedure check_failure_escaped; + --%afterall procedure remove_test_package; end; From f59b62f4deb278f934c5deca6388fbd686c79a28 Mon Sep 17 00:00:00 2001 From: Travis CI Date: Sat, 12 May 2018 13:09:55 +0000 Subject: [PATCH 035/184] Updated project version after build [skip ci] --- source/core/ut_utils.pks | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/core/ut_utils.pks b/source/core/ut_utils.pks index da1e78fb5..094e2ad04 100644 --- a/source/core/ut_utils.pks +++ b/source/core/ut_utils.pks @@ -21,7 +21,7 @@ create or replace package ut_utils authid definer is * */ - gc_version constant varchar2(50) := 'v3.1.2.1894-develop'; + gc_version constant varchar2(50) := 'v3.1.2.1899-develop'; /* Constants: Event names */ subtype t_event_name is varchar2(30); From 5244887ba876e6459113dc9ba1ff24798caba3b0 Mon Sep 17 00:00:00 2001 From: lwasylow Date: Sat, 12 May 2018 15:20:30 +0100 Subject: [PATCH 036/184] Update issue with xml special chars in failure. Remove CDDATA and replace with xml convert --- source/reporters/ut_junit_reporter.tpb | 4 +--- source/reporters/ut_sonar_test_reporter.tpb | 2 -- source/reporters/ut_tfs_junit_reporter.tpb | 4 +--- test/core/reporters/test_junit_reporter.pkb | 6 ++---- test/core/reporters/test_tfs_junit_reporter.pkb | 6 ++---- 5 files changed, 6 insertions(+), 16 deletions(-) diff --git a/source/reporters/ut_junit_reporter.tpb b/source/reporters/ut_junit_reporter.tpb index 6c18463f6..5833b53c6 100644 --- a/source/reporters/ut_junit_reporter.tpb +++ b/source/reporters/ut_junit_reporter.tpb @@ -53,7 +53,6 @@ create or replace type body ut_junit_reporter is self.print_text(''); elsif a_test.result > ut_utils.gc_success then self.print_text(''); - self.print_text(c_cddata_tag_start); for i in 1 .. a_test.failed_expectations.count loop l_lines := a_test.failed_expectations(i).get_result_lines(); @@ -61,9 +60,8 @@ create or replace type body ut_junit_reporter is for j in 1 .. l_lines.count loop self.print_text(dbms_xmlgen.convert(l_lines(j))); end loop; - self.print_text(a_test.failed_expectations(i).caller_info); + self.print_text(dbms_xmlgen.convert(a_test.failed_expectations(i).caller_info)); end loop; - self.print_text(c_cddata_tag_end); self.print_text(''); end if; -- TODO - decide if we need/want to use the tag too diff --git a/source/reporters/ut_sonar_test_reporter.tpb b/source/reporters/ut_sonar_test_reporter.tpb index ed73ea3de..1152c87d3 100644 --- a/source/reporters/ut_sonar_test_reporter.tpb +++ b/source/reporters/ut_sonar_test_reporter.tpb @@ -56,14 +56,12 @@ create or replace type body ut_sonar_test_reporter is self.print_text(''); elsif a_test.result > ut_utils.gc_success then self.print_text(''); - self.print_text(''); self.print_text(''); end if; self.print_text(''); diff --git a/source/reporters/ut_tfs_junit_reporter.tpb b/source/reporters/ut_tfs_junit_reporter.tpb index b23bf2595..b2a777c9f 100644 --- a/source/reporters/ut_tfs_junit_reporter.tpb +++ b/source/reporters/ut_tfs_junit_reporter.tpb @@ -76,15 +76,13 @@ create or replace type body ut_tfs_junit_reporter is -- Do not count error as failure elsif a_test.result = ut_utils.gc_failure then self.print_text(''); - self.print_text(''); self.print_text(''); end if; diff --git a/test/core/reporters/test_junit_reporter.pkb b/test/core/reporters/test_junit_reporter.pkb index bba6adc38..3e60b31c6 100644 --- a/test/core/reporters/test_junit_reporter.pkb +++ b/test/core/reporters/test_junit_reporter.pkb @@ -146,7 +146,7 @@ create or replace package body test_junit_reporter as from table(ut3.ut.run('check_junit_reporting',ut3.ut_junit_reporter())); l_actual := ut3.ut_utils.table_to_clob(l_results); --Assert - ut.expect(l_actual).to_be_like('%at "%.CHECK_JUNIT_REPORTING%", line %'); + ut.expect(l_actual).to_be_like('%at "%.CHECK_JUNIT_REPORTING%", line %'); end; procedure check_classname_suite is @@ -305,9 +305,7 @@ create or replace package body test_junit_reporter as from table(ut3.ut.run('check_fail_escape',ut3.ut_junit_reporter())); l_actual := ut3.ut_utils.table_to_clob(l_results); --Assert - ut.expect(l_actual).to_be_like('%%'); + ut.expect(l_actual).to_be_like('%Actual: 'test' (varchar2) was expected to equal: '<![CDATA[some stuff]]>' (varchar2)%'); end; procedure check_classname_is_populated is diff --git a/test/core/reporters/test_tfs_junit_reporter.pkb b/test/core/reporters/test_tfs_junit_reporter.pkb index 8cecf2849..ff77cff5e 100644 --- a/test/core/reporters/test_tfs_junit_reporter.pkb +++ b/test/core/reporters/test_tfs_junit_reporter.pkb @@ -108,7 +108,7 @@ create or replace package body test_tfs_junit_reporter as from table(ut3.ut.run('check_junit_reporting',ut3.ut_tfs_junit_reporter())); l_actual := ut3.ut_utils.table_to_clob(l_results); --Assert - ut.expect(l_actual).to_be_like('%at "%.CHECK_JUNIT_REPORTING%", line %'); + ut.expect(l_actual).to_be_like('%at "%.CHECK_JUNIT_REPORTING%", line %'); end; procedure check_classname_suite is @@ -173,9 +173,7 @@ create or replace package body test_tfs_junit_reporter as from table(ut3.ut.run('check_fail_escape',ut3.ut_tfs_junit_reporter())); l_actual := ut3.ut_utils.table_to_clob(l_results); --Assert - ut.expect(l_actual).to_be_like('%%'); + ut.expect(l_actual).to_be_like('%Actual: 'test' (varchar2) was expected to equal: '<![CDATA[some stuff]]>' (varchar2)%'); end; procedure check_classname_suitepath is From e7663b6f96cdd14144f870189979854d2b75c31d Mon Sep 17 00:00:00 2001 From: Travis CI Date: Sat, 12 May 2018 17:24:35 +0000 Subject: [PATCH 037/184] Updated project version after build [skip ci] --- source/core/ut_utils.pks | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/core/ut_utils.pks b/source/core/ut_utils.pks index 094e2ad04..f9fc302c1 100644 --- a/source/core/ut_utils.pks +++ b/source/core/ut_utils.pks @@ -21,7 +21,7 @@ create or replace package ut_utils authid definer is * */ - gc_version constant varchar2(50) := 'v3.1.2.1899-develop'; + gc_version constant varchar2(50) := 'v3.1.2.1901-develop'; /* Constants: Event names */ subtype t_event_name is varchar2(30); From 347de211b600c7372de36b6dd7099a4256f0ed5d Mon Sep 17 00:00:00 2001 From: lwasylow Date: Sat, 12 May 2018 19:27:00 +0100 Subject: [PATCH 038/184] Added option to run invalid package specs due to broken dependencies or rebuild Signed-off-by: lwasylow --- .../annotations/ut_annotation_manager.pkb | 4 +- source/core/types/ut_executable.tpb | 62 ++++++++++++++----- source/core/types/ut_executable.tps | 5 +- source/core/ut_utils.pks | 4 ++ 4 files changed, 57 insertions(+), 18 deletions(-) diff --git a/source/core/annotations/ut_annotation_manager.pkb b/source/core/annotations/ut_annotation_manager.pkb index 051c3679e..c3dfb5151 100644 --- a/source/core/annotations/ut_annotation_manager.pkb +++ b/source/core/annotations/ut_annotation_manager.pkb @@ -36,8 +36,7 @@ create or replace package body ut_annotation_manager as 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 where o.owner = :a_object_owner - and o.object_type = :a_object_type - and o.status = 'VALID' ]'; + and o.object_type = :a_object_type]'; open l_result for l_cursor_text using a_object_owner, a_object_type; return l_result; end; @@ -190,6 +189,7 @@ create or replace package body ut_annotation_manager as 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; diff --git a/source/core/types/ut_executable.tpb b/source/core/types/ut_executable.tpb index e51440408..9947e6b05 100644 --- a/source/core/types/ut_executable.tpb +++ b/source/core/types/ut_executable.tpb @@ -29,26 +29,41 @@ create or replace type body ut_executable is return; end; - member function is_valid(self in out nocopy ut_executable) return boolean is + member function is_defined(self in out nocopy ut_executable) return boolean is l_result boolean := false; l_message_part varchar2(4000) := 'Call params for ' || self.associated_event_name || ' are not valid: '; begin if self.object_name is null then self.error_stack := l_message_part || 'package is not defined'; - elsif not ut_metadata.package_valid(self.owner_name, self.object_name) then - self.error_stack := l_message_part || 'package does not exist or is invalid: ' ||upper(self.owner_name||'.'||self.object_name); elsif self.procedure_name is null then self.error_stack := l_message_part || 'procedure is not defined'; + else + l_result := true; + end if; + + return l_result; + end is_defined; + + /** + * We will check if error raised because package was invalid if not we let it propagate. + **/ + member function is_invalid(self in out nocopy ut_executable) return boolean is + l_result boolean := true; + l_message_part varchar2(4000) := 'Call params for ' || self.associated_event_name || ' are not valid: '; + begin + + if not ut_metadata.package_valid(self.owner_name, self.object_name) then + self.error_stack := l_message_part || 'package does not exist or is invalid: ' ||upper(self.owner_name||'.'||self.object_name); elsif not ut_metadata.procedure_exists(self.owner_name, self.object_name, self.procedure_name) then self.error_stack := l_message_part || 'procedure does not exist ' || upper(self.owner_name || '.' || self.object_name || '.' ||self.procedure_name); else - l_result := true; + l_result := false; end if; return l_result; - end is_valid; + end is_invalid; member function form_name return varchar2 is begin @@ -66,6 +81,7 @@ create or replace type body ut_executable is l_status number; l_cursor_number number; l_completed_without_errors boolean := true; + l_failed_with_invalid_pck boolean := true; l_start_transaction_id varchar2(250); l_end_transaction_id varchar2(250); @@ -95,7 +111,7 @@ create or replace type body ut_executable is --listener - before call to executable ut_event_manager.trigger_event('before_'||self.associated_event_name, self); - l_completed_without_errors := self.is_valid(); + l_completed_without_errors := self.is_defined(); if l_completed_without_errors then l_statement := 'declare' || chr(10) || @@ -117,15 +133,32 @@ create or replace type body ut_executable is ut_utils.debug_log('ut_executable.do_execute l_statement: ' || l_statement); l_cursor_number := dbms_sql.open_cursor; - dbms_sql.parse(l_cursor_number, statement => l_statement, language_flag => dbms_sql.native); - dbms_sql.bind_variable(l_cursor_number, 'a_error_stack', to_char(null), 32767); - dbms_sql.bind_variable(l_cursor_number, 'a_error_backtrace', to_char(null), 32767); - - l_status := dbms_sql.execute(l_cursor_number); - dbms_sql.variable_value(l_cursor_number, 'a_error_stack', self.error_stack); - dbms_sql.variable_value(l_cursor_number, 'a_error_backtrace', self.error_backtrace); - dbms_sql.close_cursor(l_cursor_number); + /** + * The code will allow to execute once we check if packages are defined + * If it fail with 6550 (usually invalid package) it will check if because of invalid state or missing + * if for any other reason we will propagate it up as we didnt expected. + **/ + begin + dbms_sql.parse(l_cursor_number, statement => l_statement, language_flag => dbms_sql.native); + dbms_sql.bind_variable(l_cursor_number, 'a_error_stack', to_char(null), 32767); + dbms_sql.bind_variable(l_cursor_number, 'a_error_backtrace', to_char(null), 32767); + l_status := dbms_sql.execute(l_cursor_number); + dbms_sql.variable_value(l_cursor_number, 'a_error_stack', self.error_stack); + dbms_sql.variable_value(l_cursor_number, 'a_error_backtrace', self.error_backtrace); + dbms_sql.close_cursor(l_cursor_number); + exception + when ut_utils.ex_invalid_package then + l_failed_with_invalid_pck := self.is_invalid(); + dbms_sql.close_cursor(l_cursor_number); + if not l_failed_with_invalid_pck then + raise; + end if; + when others then + dbms_sql.close_cursor(l_cursor_number); + raise; + end; + save_dbms_output; l_completed_without_errors := (self.error_stack||self.error_backtrace) is null; @@ -144,6 +177,7 @@ create or replace type body ut_executable is ut_utils.set_client_info(null); return l_completed_without_errors; + end do_execute; member function get_error_stack_trace return varchar2 is diff --git a/source/core/types/ut_executable.tps b/source/core/types/ut_executable.tps index 79813c391..044ef6719 100644 --- a/source/core/types/ut_executable.tps +++ b/source/core/types/ut_executable.tps @@ -1,4 +1,4 @@ -create or replace type ut_executable under ut_event_item( +create or replace type ut_executable force under ut_event_item( /* utPLSQL - Version 3 Copyright 2016 - 2017 utPLSQL Project @@ -26,7 +26,8 @@ create or replace type ut_executable under ut_event_item( error_stack varchar2(4000), serveroutput clob, constructor function ut_executable( self in out nocopy ut_executable, a_owner varchar2, a_package varchar2, a_procedure_name varchar2, a_associated_event_name varchar2) return self as result, - member function is_valid(self in out nocopy ut_executable) return boolean, + member function is_invalid(self in out nocopy ut_executable) return boolean, + member function is_defined(self in out nocopy ut_executable) return boolean, member function form_name return varchar2, member procedure do_execute(self in out nocopy ut_executable, a_item in out nocopy ut_suite_item), /** diff --git a/source/core/ut_utils.pks b/source/core/ut_utils.pks index 094e2ad04..df0b1dbe3 100644 --- a/source/core/ut_utils.pks +++ b/source/core/ut_utils.pks @@ -110,6 +110,10 @@ create or replace package ut_utils authid definer is gc_invalid_version_no constant pls_integer := -20214; pragma exception_init(ex_invalid_version_no, -20214); + ex_invalid_package exception; + gc_invalid_package constant pls_integer := -6550; + pragma exception_init(ex_invalid_package, -6550); + gc_max_storage_varchar2_len constant integer := 4000; gc_max_output_string_length constant integer := 4000; gc_max_input_string_length constant integer := gc_max_output_string_length - 2; --we need to remove 2 chars for quotes around string From 23d3b8642ec272b2cdbc076a81841fbf95b5c6b3 Mon Sep 17 00:00:00 2001 From: lwasylow Date: Sun, 13 May 2018 08:28:11 +0100 Subject: [PATCH 039/184] Added tests to cover invalid specs scenarios --- test/api/test_ut_run.pkb | 102 +++++++++++++++++++++++++++++++ test/api/test_ut_run.pks | 15 +++++ test/core/test_suite_manager.pkb | 27 ++++++-- test/core/test_suite_manager.pks | 8 ++- 4 files changed, 147 insertions(+), 5 deletions(-) diff --git a/test/api/test_ut_run.pkb b/test/api/test_ut_run.pkb index dfd4a529b..1e8dbaa33 100644 --- a/test/api/test_ut_run.pkb +++ b/test/api/test_ut_run.pkb @@ -114,5 +114,107 @@ Failures:% execute immediate 'drop package test_stateful'; end; + procedure run_in_invalid_state is + l_results ut3.ut_varchar2_list; + l_actual clob; + l_expected varchar2(32767); + begin + select * + bulk collect into l_results + from table(ut3.ut.run('failing_invalid_spec')); + + l_actual := ut3.ut_utils.table_to_clob(l_results); + ut.expect(l_actual).to_be_like('%Call params for % are not valid: package does not exist or is invalid: %FAILING_INVALID_SPEC%'); + + end; + + procedure compile_invalid_package is + ex_compilation_error exception; + pragma exception_init(ex_compilation_error,-24344); + pragma autonomous_transaction; + begin + begin + execute immediate q'[create or replace package failing_invalid_spec as + --%suite + gv_glob_val non_existing_table.id%type := 0; + + --%test + procedure test1; +end;]'; + exception when ex_compilation_error then null; + end; + begin + execute immediate q'[create or replace package body failing_invalid_spec as + procedure test1 is begin ut.expect(1).to_equal(1); end; +end;]'; + exception when ex_compilation_error then null; + end; + end; + procedure drop_invalid_package is + pragma autonomous_transaction; + begin + execute immediate 'drop package failing_invalid_spec'; + end; + + procedure run_and_revalidate_specs is + l_results ut3.ut_varchar2_list; + l_actual clob; + l_is_invalid number; + begin + execute immediate q'[select count(1) from all_objects o where o.owner = :object_owner and o.object_type = 'PACKAGE' + and o.status = 'INVALID' and o.object_name= :object_name]' into l_is_invalid + using user,'FAILING_INVALID_SPEC'; + + select * + bulk collect into l_results + from table(ut3.ut.run('failing_invalid_spec')); + + l_actual := ut3.ut_utils.table_to_clob(l_results); + ut.expect(1).to_equal(l_is_invalid); + ut.expect(l_actual).to_be_like('%failing_invalid_spec%invalidspecs [% sec]% +%Finished in % seconds% +%1 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)%'); + + end; + + procedure generate_invalid_spec is + ex_compilation_error exception; + pragma exception_init(ex_compilation_error,-24344); + pragma autonomous_transaction; + begin + + execute immediate q'[create or replace package parent_specs as + c_test constant varchar2(1) := 'Y'; +end;]'; + + execute immediate q'[create or replace package failing_invalid_spec as + --%suite + g_var varchar2(1) := parent_specs.c_test; + + --%test(invalidspecs) + procedure test1; +end;]'; + + execute immediate q'[create or replace package body failing_invalid_spec as + procedure test1 is begin ut.expect('Y').to_equal(g_var); end; +end;]'; + + -- That should invalidate test package and we can then revers + execute immediate q'[create or replace package parent_specs as + c_test_error constant varchar2(1) := 'Y'; +end;]'; + + execute immediate q'[create or replace package parent_specs as + c_test constant varchar2(1) := 'Y'; +end;]'; + + end; + procedure drop_test_package is + pragma autonomous_transaction; + begin + execute immediate 'drop package failing_invalid_spec'; + execute immediate 'drop package parent_specs'; + end; + end; / diff --git a/test/api/test_ut_run.pks b/test/api/test_ut_run.pks index 1bc3555a4..12c9e7fe0 100644 --- a/test/api/test_ut_run.pks +++ b/test/api/test_ut_run.pks @@ -8,5 +8,20 @@ create or replace package test_ut_run is --%beforetest(create_test_suite) --%aftertest(drop_test_suite) procedure raise_in_invalid_state; + + --%test(ut.run - run invalid package and fail expectation) + --%beforetest(compile_invalid_package) + --%aftertest(drop_invalid_package) + procedure run_in_invalid_state; + procedure compile_invalid_package; + procedure drop_invalid_package; + + --%test( Invalidate package specs via rebuild but still execute package) + --%beforetest(generate_invalid_spec) + --%aftertest(drop_test_package) + procedure run_and_revalidate_specs; + procedure generate_invalid_spec; + procedure drop_test_package; + end; / diff --git a/test/core/test_suite_manager.pkb b/test/core/test_suite_manager.pkb index 827812f98..25f42ab11 100644 --- a/test/core/test_suite_manager.pkb +++ b/test/core/test_suite_manager.pkb @@ -872,10 +872,9 @@ end test_package_3;]'; l_objects_to_run ut3.ut_suite_items; begin l_objects_to_run := ut3.ut_suite_manager.configure_execution_by_path(ut3.ut_varchar2_list('failing_invalid_spec')); - ut.fail('Invalid package didnt raised exception'); - exception - when others then - ut.expect(sqlerrm).to_be_like('%failing_invalid_spec%'); + + ut3.ut.expect(l_objects_to_run.count).to_be_greater_than(0); + ut3.ut.expect(l_objects_to_run(l_objects_to_run.first).object_name).to_equal('failing_invalid_spec'); end; procedure compile_invalid_package is @@ -912,6 +911,26 @@ end;]'; execute immediate 'drop package failing_invalid_spec'; end; + procedure test_search_nonexisting_pck is + l_objects_to_run ut3.ut_suite_items; + begin + l_objects_to_run := ut3.ut_suite_manager.configure_execution_by_path(ut3.ut_varchar2_list('ut3.failing_non_existing')); + ut.fail('Non existing package didnt raised exception'); + exception + when others then + ut.expect(sqlerrm).to_be_like('%failing_non_existing%'); + end; + + procedure test_search_nonexist_sch_pck is + l_objects_to_run ut3.ut_suite_items; + begin + l_objects_to_run := ut3.ut_suite_manager.configure_execution_by_path(ut3.ut_varchar2_list('failing_non_existing')); + ut.fail('Non existing package without schema didnt raised exception'); + exception + when others then + ut.expect(sqlerrm).to_be_like('%ORA-44001: invalid schema%'); + end; + procedure test_desc_with_comma is l_objects_to_run ut3.ut_suite_items; l_suite ut3.ut_suite; diff --git a/test/core/test_suite_manager.pks b/test/core/test_suite_manager.pks index 8585a86aa..495f317a6 100644 --- a/test/core/test_suite_manager.pks +++ b/test/core/test_suite_manager.pks @@ -65,12 +65,18 @@ create or replace package test_suite_manager is --%test(Prepare runner for the suites package by path for current user) procedure test_top_subpck_by_path_cu; - --%test(Prepare runner for invalid package) + --%test(Prepare runner for invalid package - it will add to suite but fail on exec ) --%beforetest(compile_invalid_package) --%aftertest(drop_invalid_package) procedure test_search_invalid_pck; procedure compile_invalid_package; procedure drop_invalid_package; + + --%test(Prepare runner for nonexisting package with schema) + procedure test_search_nonexisting_pck; + + --%test(Prepare runner for nonexisting package without schema) + procedure test_search_nonexist_sch_pck; --%test(Test description with comma) --%beforetest(setup_desc_with_comma) From 85f17aad396af18d32b2c929720f1cdf772f0040 Mon Sep 17 00:00:00 2001 From: lwasylow Date: Sun, 13 May 2018 08:45:47 +0100 Subject: [PATCH 040/184] Old Tests been moved already to new test and is no longer valid as package will no longer fail --- old_tests/RunAll.sql | 1 - ...ntFindTheSuiteWhenPackageSpecIsInvalid.sql | 42 ------------------- 2 files changed, 43 deletions(-) delete mode 100644 old_tests/ut_suite_manager/ut_suite_manager.DoesntFindTheSuiteWhenPackageSpecIsInvalid.sql diff --git a/old_tests/RunAll.sql b/old_tests/RunAll.sql index 936789bd3..434d8574f 100644 --- a/old_tests/RunAll.sql +++ b/old_tests/RunAll.sql @@ -129,7 +129,6 @@ exec ut_coverage.set_develop_mode(true); @@lib/RunTest.sql ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageProcedureByPathCurUser.sql @@lib/RunTest.sql ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTop2PackageProcedureByPath.sql @@lib/RunTest.sql ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTop2PackageProcedureByPathCurUser.sql -@@lib/RunTest.sql ut_suite_manager/ut_suite_manager.DoesntFindTheSuiteWhenPackageSpecIsInvalid.sql @@lib/RunTest.sql ut_suite_manager/ut_suite_manager.emptySuitePath.sql @@lib/RunTest.sql ut_suite_manager/ut_suite_manager.get_schema_ut_packages.IncludesPackagesWithSutePath.sql @@lib/RunTest.sql ut_suite_manager/ut_suite_manager.IncludesInvalidPackageBodiesInTheRun.sql diff --git a/old_tests/ut_suite_manager/ut_suite_manager.DoesntFindTheSuiteWhenPackageSpecIsInvalid.sql b/old_tests/ut_suite_manager/ut_suite_manager.DoesntFindTheSuiteWhenPackageSpecIsInvalid.sql deleted file mode 100644 index dd859ad3c..000000000 --- a/old_tests/ut_suite_manager/ut_suite_manager.DoesntFindTheSuiteWhenPackageSpecIsInvalid.sql +++ /dev/null @@ -1,42 +0,0 @@ -set termout off -create or replace package failing_invalid_spec as - --%suite - gv_glob_val non_existing_table.id%type := 0; - - --%beforeall - procedure before_all; - --%test - procedure test1; - --%test - procedure test2; -end; -/ -create or replace package body failing_invalid_spec as - procedure before_all is begin gv_glob_val := 1; end; - procedure test1 is begin ut.expect(1).to_equal(1); end; - procedure test2 is begin ut.expect(1).to_equal(1); end; -end; -/ -set termout on - -declare - l_objects_to_run ut_suite_items; -begin - begin - --act - l_objects_to_run := ut_suite_manager.configure_execution_by_path(ut_varchar2_list('failing_invalid_spec')); - exception - when others then - if sqlerrm like '%failing_invalid_spec%' then - :test_result := ut_utils.gc_success; - end if; - end; - - if :test_result != ut_utils.gc_success or :test_result is null then - dbms_output.put_line('Failed: Expected exception with text like ''%failing_invalid_spec%'' but got:'''||sqlerrm||''''); - end if; -end; -/ - -drop package failing_invalid_spec -/ From 95cf9f9e07cd5d94a63183bf1f2377420c26c19c Mon Sep 17 00:00:00 2001 From: Philipp Salvisberg Date: Tue, 15 May 2018 14:01:50 +0200 Subject: [PATCH 041/184] fix typos in test descriptions ("tested" instead of "tesed") --- docs/userguide/annotations.md | 48 +++++++++++++++++------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/docs/userguide/annotations.md b/docs/userguide/annotations.md index d1c495eb2..86adc9463 100644 --- a/docs/userguide/annotations.md +++ b/docs/userguide/annotations.md @@ -173,7 +173,7 @@ Test procedure with description. create or replace package test_package as --%suite(Tests for a package) - --%test(Description of tesed behavior) + --%test(Description of tested behavior) procedure some_test; end; / @@ -188,7 +188,7 @@ exec ut.run('test_package'); ``` ``` Tests for a package - Description of tesed behavior [.005 sec] + Description of tested behavior [.005 sec] Finished in .006828 seconds 1 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s) @@ -199,7 +199,7 @@ When multiple `--%test` annotations are specified for a procedure, the first ann create or replace package test_package as --%suite(Tests for a package) - --%test(Description of tesed behavior) + --%test(Description of tested behavior) --%test(Duplicate description) procedure some_test; end; @@ -215,7 +215,7 @@ exec ut.run('test_package'); ``` ``` Tests for a package - Description of tesed behavior [.007 sec] + Description of tested behavior [.007 sec] Warnings: @@ -237,7 +237,7 @@ create or replace package test_package as --%suite(Tests for a package) --%disabled - --%test(Description of tesed behavior) + --%test(Description of tested behavior) procedure some_test; --%test(Description of another behavior) @@ -258,7 +258,7 @@ exec ut.run('test_package'); ``` ``` Tests for a package - Description of tesed behavior [0 sec] (DISABLED) + Description of tested behavior [0 sec] (DISABLED) Description of another behavior [0 sec] (DISABLED) Finished in .001441 seconds @@ -270,7 +270,7 @@ Disabling individual test(s). create or replace package test_package as --%suite(Tests for a package) - --%test(Description of tesed behavior) + --%test(Description of tested behavior) procedure some_test; --%test(Description of another behavior) @@ -292,7 +292,7 @@ exec ut.run('test_package'); ``` ``` Tests for a package - Description of tesed behavior [.004 sec] + Description of tested behavior [.004 sec] Description of another behavior [0 sec] (DISABLED) Finished in .005868 seconds @@ -320,7 +320,7 @@ For multiple `--%beforeall` procedures order of execution is defined by annotati create or replace package test_package as --%suite(Tests for a package) - --%test(Description of tesed behavior) + --%test(Description of tested behavior) procedure some_test; --%test(Description of another behavior) @@ -350,7 +350,7 @@ exec ut.run('test_package'); ``` Tests for a package --- SETUP_STUFF invoked --- - Description of tesed behavior [.004 sec] + Description of tested behavior [.004 sec] Description of another behavior [.003 sec] Finished in .012292 seconds @@ -366,7 +366,7 @@ The `another_setup` still gets invoked before any test from that suite package i --%beforeall procedure initial_setup; - --%test(Description of tesed behavior) + --%test(Description of tested behavior) procedure some_test; --%test(Description of another behavior) @@ -402,7 +402,7 @@ The `another_setup` still gets invoked before any test from that suite package i Tests for a package --- INITIAL_SETUP invoked --- --- ANOTHER_SETUP invoked --- - Description of tesed behavior [.004 sec] + Description of tested behavior [.004 sec] Description of another behavior [.004 sec] Finished in .016672 seconds @@ -419,7 +419,7 @@ When procedure is annotated as both `--%beforeall` and `--%test`, the procedure --%beforeall procedure initial_setup; - --%test(Description of tesed behavior) + --%test(Description of tested behavior) --%beforeall procedure some_test; @@ -448,7 +448,7 @@ When procedure is annotated as both `--%beforeall` and `--%test`, the procedure ``` Tests for a package --- INITIAL_SETUP invoked --- - Description of tesed behavior [.003 sec] + Description of tested behavior [.003 sec] Description of another behavior [.004 sec] @@ -487,7 +487,7 @@ All rules defined for `--%beforeall` also apply for `--%afterall` annotation. Se create or replace package test_package as --%suite(Tests for a package) - --%test(Description of tesed behavior) + --%test(Description of tested behavior) procedure some_test; --%test(Description of another behavior) @@ -516,7 +516,7 @@ exec ut.run('test_package'); ``` ``` Tests for a package - Description of tesed behavior [.003 sec] + Description of tested behavior [.003 sec] Description of another behavior [.005 sec] ---CLEANUP_STUFF invoked --- @@ -550,7 +550,7 @@ For multiple `--%beforeeach` procedures order of execution is defined by annotat create or replace package test_package as --%suite(Tests for a package) - --%test(Description of tesed behavior) + --%test(Description of tested behavior) procedure some_test; --%test(Description of another behavior) @@ -593,7 +593,7 @@ exec ut.run('test_package'); ``` Tests for a package ---SETUP_STUFF invoked --- - Description of tesed behavior [.004 sec] + Description of tested behavior [.004 sec] ---SETUP_FOR_TEST invoked --- ---SOME_TEST invoked --- Description of another behavior [.006 sec] @@ -630,7 +630,7 @@ As a rule, the `--%aftereach` gets executed even if the associated `--%beforeeac create or replace package test_package as --%suite(Tests for a package) - --%test(Description of tesed behavior) + --%test(Description of tested behavior) procedure some_test; --%test(Description of another behavior) @@ -671,7 +671,7 @@ exec ut.run('test_package'); ``` ``` Tests for a package - Description of tesed behavior [.006 sec] + Description of tested behavior [.006 sec] ---SOME_TEST invoked --- ---CLEANUP_FOR_TEST invoked --- Description of another behavior [.006 sec] @@ -709,7 +709,7 @@ As a rule, the `--%beforetest` execution gets aborted if preceding `--%beforeeac create or replace package test_package as --%suite(Tests for a package) - --%test(Description of tesed behavior) + --%test(Description of tested behavior) --%beforetest(setup_for_a_test) --%beforetest(another_setup_for_a_test) procedure some_test; @@ -752,7 +752,7 @@ exec ut.run('test_package'); ``` ``` Tests for a package - Description of tesed behavior [.011 sec] + Description of tested behavior [.011 sec] ---SETUP_FOR_A_TEST invoked --- ---ANOTHER_SETUP_FOR_A_TEST invoked --- ---SOME_TEST invoked --- @@ -790,7 +790,7 @@ As a rule, the `--%aftertest` gets executed even if the associated `--%beforeeac create or replace package test_package as --%suite(Tests for a package) - --%test(Description of tesed behavior) + --%test(Description of tested behavior) --%aftertest(cleanup_for_a_test) --%aftertest(another_cleanup_for_a_test) procedure some_test; @@ -833,7 +833,7 @@ exec ut.run('test_package'); ``` ``` Tests for a package - Description of tesed behavior [.01 sec] + Description of tested behavior [.01 sec] ---SOME_TEST invoked --- ---CLEANUP_FOR_A_TEST invoked --- ---ANOTHER_CLEANUP_FOR_A_TEST invoked --- From 9795992d448d3614b55792e5169c64a01fb8361f Mon Sep 17 00:00:00 2001 From: Travis CI Date: Tue, 15 May 2018 13:53:02 +0000 Subject: [PATCH 042/184] Updated project version after build [skip ci] --- source/core/ut_utils.pks | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/core/ut_utils.pks b/source/core/ut_utils.pks index f9fc302c1..288c25ce4 100644 --- a/source/core/ut_utils.pks +++ b/source/core/ut_utils.pks @@ -21,7 +21,7 @@ create or replace package ut_utils authid definer is * */ - gc_version constant varchar2(50) := 'v3.1.2.1901-develop'; + gc_version constant varchar2(50) := 'v3.1.2.1913-develop'; /* Constants: Event names */ subtype t_event_name is varchar2(30); From cc718d9c74f4fd550601a1d2bfc65283a2d9ec35 Mon Sep 17 00:00:00 2001 From: lwasylow Date: Thu, 17 May 2018 23:55:00 +0100 Subject: [PATCH 043/184] Added changes to cater for nested tables Updated documentation Shift packages around for current user id --- docs/userguide/advanced_data_comparison.md | 4 +- source/core/types/ut_key_anyval_pair.tps | 20 ++ source/core/types/ut_key_anyval_pairs.tps | 19 ++ source/core/types/ut_key_value_pair.tps | 2 +- .../core/types/ut_key_varcharvalue_pair.tps | 20 ++ source/core/types/ut_key_xmlvalue_pair.tps | 20 ++ .../data_values/ut_compound_data_helper.pkb | 91 ++------- .../data_values/ut_compound_data_helper.pks | 2 +- .../ut_curr_usr_compound_helper.pkb | 186 ++++++++++++++++++ .../ut_curr_usr_compound_helper.pks | 8 + .../data_values/ut_data_value_refcursor.tpb | 11 +- .../data_values/ut_data_value_refcursor.tps | 9 +- source/install.sql | 6 + source/uninstall.sql | 8 + .../test_expectations_cursor.pkb | 135 +++++++++++-- .../test_expectations_cursor.pks | 20 +- 16 files changed, 466 insertions(+), 95 deletions(-) create mode 100644 source/core/types/ut_key_anyval_pair.tps create mode 100644 source/core/types/ut_key_anyval_pairs.tps create mode 100644 source/core/types/ut_key_varcharvalue_pair.tps create mode 100644 source/core/types/ut_key_xmlvalue_pair.tps create mode 100644 source/expectations/data_values/ut_curr_usr_compound_helper.pkb create mode 100644 source/expectations/data_values/ut_curr_usr_compound_helper.pks diff --git a/docs/userguide/advanced_data_comparison.md b/docs/userguide/advanced_data_comparison.md index e003b0c47..1edc39b7c 100644 --- a/docs/userguide/advanced_data_comparison.md +++ b/docs/userguide/advanced_data_comparison.md @@ -139,7 +139,9 @@ Above test will result in two differences of one row extra and one row missing. ## Join By option -You can now join two cursors by defining a primary key or composite key that will be used to uniquely identify and compare rows. This option allows us to exactly show which rows are missing, extra and which are different without ordering clause. +You can now join two cursors by defining a primary key or composite key that will be used to uniquely identify and compare rows. This option allows us to exactly show which rows are missing, extra and which are different without ordering clause. In the situation where the join key is not unique, join will partition set over rows with a same key and join on row number as well as given join key. The extra rows or missing will be presented to user as well as not matching rows. + +Join by option can be used in conjunction with include or exclude options. However if any of the join keys is part of exclude set, comparison will fail and report to user that sets could not be joined on specific key (excluded). ```sql procedure join_by_username is diff --git a/source/core/types/ut_key_anyval_pair.tps b/source/core/types/ut_key_anyval_pair.tps new file mode 100644 index 000000000..5188bdda5 --- /dev/null +++ b/source/core/types/ut_key_anyval_pair.tps @@ -0,0 +1,20 @@ +create or replace type ut_key_anyval_pair force as object( + /* + utPLSQL - Version 3 + Copyright 2016 - 2017 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. + */ + key varchar2(4000) +) not final +/ diff --git a/source/core/types/ut_key_anyval_pairs.tps b/source/core/types/ut_key_anyval_pairs.tps new file mode 100644 index 000000000..ccf4ce047 --- /dev/null +++ b/source/core/types/ut_key_anyval_pairs.tps @@ -0,0 +1,19 @@ +create or replace type ut_key_anyval_pairs as + /* + utPLSQL - Version 3 + Copyright 2016 - 2017 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_key_anyval_pair +/ diff --git a/source/core/types/ut_key_value_pair.tps b/source/core/types/ut_key_value_pair.tps index 45bc53157..a23df4a7b 100644 --- a/source/core/types/ut_key_value_pair.tps +++ b/source/core/types/ut_key_value_pair.tps @@ -1,4 +1,4 @@ -create or replace type ut_key_value_pair as object( +create or replace type ut_key_value_pair force as object( /* utPLSQL - Version 3 Copyright 2016 - 2017 utPLSQL Project diff --git a/source/core/types/ut_key_varcharvalue_pair.tps b/source/core/types/ut_key_varcharvalue_pair.tps new file mode 100644 index 000000000..fdce93cf0 --- /dev/null +++ b/source/core/types/ut_key_varcharvalue_pair.tps @@ -0,0 +1,20 @@ +create or replace type ut_key_varcharvalue_pair under ut_key_anyval_pair ( + /* + utPLSQL - Version 3 + Copyright 2016 - 2017 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. + */ + value varchar2(4000) +) +/ diff --git a/source/core/types/ut_key_xmlvalue_pair.tps b/source/core/types/ut_key_xmlvalue_pair.tps new file mode 100644 index 000000000..1f5462861 --- /dev/null +++ b/source/core/types/ut_key_xmlvalue_pair.tps @@ -0,0 +1,20 @@ +create or replace type ut_key_xmlvalue_pair under ut_key_anyval_pair ( + /* + utPLSQL - Version 3 + Copyright 2016 - 2017 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. + */ + value xmltype +) +/ diff --git a/source/expectations/data_values/ut_compound_data_helper.pkb b/source/expectations/data_values/ut_compound_data_helper.pkb index 3528b4ec8..71963263f 100644 --- a/source/expectations/data_values/ut_compound_data_helper.pkb +++ b/source/expectations/data_values/ut_compound_data_helper.pkb @@ -16,55 +16,23 @@ create or replace package body ut_compound_data_helper is limitations under the License. */ - type t_type_name_map is table of varchar2(100) index by binary_integer; - g_type_name_map t_type_name_map; - - function get_column_type(a_desc_rec dbms_sql.desc_rec3) return varchar2 is - l_result varchar2(500) := 'unknown datatype'; - begin - if g_type_name_map.exists(a_desc_rec.col_type) then - l_result := g_type_name_map(a_desc_rec.col_type); - elsif a_desc_rec.col_schema_name is not null and a_desc_rec.col_type_name is not null then - l_result := a_desc_rec.col_schema_name||'.'||a_desc_rec.col_type_name; - end if; - return l_result; - end; - - function get_columns_info(a_columns_tab dbms_sql.desc_tab3, a_columns_count integer) return ut_key_value_pairs is - l_result ut_key_value_pairs := ut_key_value_pairs(); - begin - for i in 1 .. a_columns_count loop - l_result.extend; - l_result(l_result.last) := ut_key_value_pair(a_columns_tab(i).col_name, get_column_type(a_columns_tab(i))); - end loop; - return l_result; - end; - - function get_columns_info(a_cursor in out nocopy sys_refcursor) return xmltype is - l_cursor_number integer; - l_columns_count pls_integer; - l_columns_desc dbms_sql.desc_tab3; - l_result xmltype; - l_columns_tab ut_key_value_pairs; - begin - if a_cursor is null or not a_cursor%isopen then - return null; - end if; - l_cursor_number := dbms_sql.to_cursor_number( a_cursor ); - dbms_sql.describe_columns3( l_cursor_number, l_columns_count, l_columns_desc ); - a_cursor := dbms_sql.to_refcursor( l_cursor_number ); - l_columns_tab := get_columns_info( l_columns_desc, l_columns_count); - - select - XMLELEMENT("ROW", xmlagg(xmlelement(evalname ut_utils.xmlgen_escaped_string(key), - XMLATTRIBUTES(key AS "xml_valid_name"), - value))) - into l_result - from table(l_columns_tab ); - - return l_result; - end; - + g_user_defined_type pls_integer := dbms_sql.user_defined_type; + + function get_column_info_xml(a_column_details ut_key_anyval_pair) return xmltype is + l_result varchar2(4000); + l_res xmltype; + begin + l_result := '<'||ut_utils.xmlgen_escaped_string(a_column_details.KEY)||' xml_valid_name="'||ut_utils.xmlgen_escaped_string(a_column_details.KEY)||'">'; + if a_column_details is of(ut_key_xmlvalue_pair) then + l_result := l_result || (treat(a_column_details as ut_key_xmlvalue_pair).value.getstringval()); + else + l_result := l_result || ut_utils.xmlgen_escaped_string((treat(a_column_details as ut_key_varcharvalue_pair).value)); + end if; + l_result := l_result ||''; + + return xmltype(l_result); + end; + function get_columns_filter( a_exclude_xpath varchar2, a_include_xpath varchar2, a_table_alias varchar2 := 'ucd', a_column_alias varchar2 := 'item_data' @@ -524,6 +492,7 @@ create or replace package body ut_compound_data_helper is l_pk_xpath_tabs ut_varchar2_list := ut_varchar2_list(); l_column_filter varchar2(32767); l_no_missing_keys tt_missing_pk := tt_missing_pk(); + begin if a_join_by_xpath is not null then l_pk_xpath_tabs := ut_utils.string_to_table(a_join_by_xpath,'|'); @@ -559,28 +528,6 @@ create or replace package body ut_compound_data_helper is return l_no_missing_keys; end; - - -begin - g_type_name_map( dbms_sql.binary_bouble_type ) := 'BINARY_DOUBLE'; - g_type_name_map( dbms_sql.bfile_type ) := 'BFILE'; - g_type_name_map( dbms_sql.binary_float_type ) := 'BINARY_FLOAT'; - g_type_name_map( dbms_sql.blob_type ) := 'BLOB'; - g_type_name_map( dbms_sql.long_raw_type ) := 'LONG RAW'; - g_type_name_map( dbms_sql.char_type ) := 'CHAR'; - g_type_name_map( dbms_sql.clob_type ) := 'CLOB'; - g_type_name_map( dbms_sql.long_type ) := 'LONG'; - g_type_name_map( dbms_sql.date_type ) := 'DATE'; - g_type_name_map( dbms_sql.interval_day_to_second_type ) := 'INTERVAL DAY TO SECOND'; - g_type_name_map( dbms_sql.interval_year_to_month_type ) := 'INTERVAL YEAR TO MONTH'; - g_type_name_map( dbms_sql.raw_type ) := 'RAW'; - g_type_name_map( dbms_sql.timestamp_type ) := 'TIMESTAMP'; - g_type_name_map( dbms_sql.timestamp_with_tz_type ) := 'TIMESTAMP WITH TIME ZONE'; - g_type_name_map( dbms_sql.timestamp_with_local_tz_type ) := 'TIMESTAMP WITH LOCAL TIME ZONE'; - g_type_name_map( dbms_sql.varchar2_type ) := 'VARCHAR2'; - g_type_name_map( dbms_sql.number_type ) := 'NUMBER'; - g_type_name_map( dbms_sql.rowid_type ) := 'ROWID'; - g_type_name_map( dbms_sql.urowid_type ) := 'UROWID'; - + end; / diff --git a/source/expectations/data_values/ut_compound_data_helper.pks b/source/expectations/data_values/ut_compound_data_helper.pks index e497d7223..6558182ae 100644 --- a/source/expectations/data_values/ut_compound_data_helper.pks +++ b/source/expectations/data_values/ut_compound_data_helper.pks @@ -48,7 +48,7 @@ create or replace package ut_compound_data_helper authid definer is type tt_row_diffs is table of t_row_diffs; - function get_columns_info(a_cursor in out nocopy sys_refcursor) return xmltype; + function get_column_info_xml(a_column_details ut_key_anyval_pair) return xmltype; function get_columns_filter( a_exclude_xpath varchar2, a_include_xpath varchar2, diff --git a/source/expectations/data_values/ut_curr_usr_compound_helper.pkb b/source/expectations/data_values/ut_curr_usr_compound_helper.pkb new file mode 100644 index 000000000..357a1122b --- /dev/null +++ b/source/expectations/data_values/ut_curr_usr_compound_helper.pkb @@ -0,0 +1,186 @@ +create or replace package body ut_curr_usr_compound_helper is + + type t_type_name_map is table of varchar2(100) index by binary_integer; + g_type_name_map t_type_name_map; + g_anytype_name_map t_type_name_map; + g_user_defined_type pls_integer := dbms_sql.user_defined_type; + + + function get_column_type(a_desc_rec dbms_sql.desc_rec3,a_desc_user_types boolean := false) return ut_key_anyval_pair is + l_result ut_key_anyval_pair; + l_data_type varchar2(500) := 'unknown datatype'; + begin + if g_type_name_map.exists(a_desc_rec.col_type) then + l_result := ut_key_varcharvalue_pair(a_desc_rec.col_name,g_type_name_map(a_desc_rec.col_type)); + elsif a_desc_rec.col_type = g_user_defined_type and a_desc_user_types then + l_result := ut_key_xmlvalue_pair(a_desc_rec.col_name, + get_user_defined_type(a_desc_rec.col_schema_name,a_desc_rec.col_type_name)); + elsif a_desc_rec.col_schema_name is not null and a_desc_rec.col_type_name is not null then + l_result := ut_key_varcharvalue_pair(a_desc_rec.col_name,a_desc_rec.col_schema_name||'.'||a_desc_rec.col_type_name); + end if; + return l_result; + end; + + function get_columns_info(a_columns_tab dbms_sql.desc_tab3, a_columns_count integer,a_desc_user_types boolean := false) return ut_key_anyval_pairs is + l_result ut_key_anyval_pairs := ut_key_anyval_pairs(); + begin + for i in 1 .. a_columns_count loop + l_result.extend; + l_result(l_result.last) := get_column_type(a_columns_tab(i),a_desc_user_types); + end loop; + return l_result; + end; + + function get_descr_cursor(a_cursor in out nocopy sys_refcursor,a_desc_user_types boolean := false) return ut_key_anyval_pairs is + l_cursor_number integer; + l_columns_count pls_integer; + l_columns_desc dbms_sql.desc_tab3; + l_columns_tab ut_key_anyval_pairs; + begin + if a_cursor is null or not a_cursor%isopen then + return null; + end if; + l_cursor_number := dbms_sql.to_cursor_number( a_cursor ); + dbms_sql.describe_columns3( l_cursor_number, l_columns_count, l_columns_desc ); + a_cursor := dbms_sql.to_refcursor( l_cursor_number ); + l_columns_tab := get_columns_info( l_columns_desc, l_columns_count,a_desc_user_types); + return l_columns_tab; + end; + + function get_columns_info(a_cursor in out nocopy sys_refcursor,a_desc_user_types boolean := false) return xmltype is + l_result xmltype; + l_result_tmp xmltype; + l_columns_tab ut_key_anyval_pairs; + begin + l_columns_tab := get_descr_cursor(a_cursor,a_desc_user_types); + + for i in 1..l_columns_tab.COUNT + loop + l_result_tmp := ut_compound_data_helper.get_column_info_xml(l_columns_tab(i)); + select xmlconcat(l_result,l_result_tmp) into l_result from dual; + end loop; + + select XMLELEMENT("ROW",l_result ) + into l_result from dual; + + return l_result; + end; + + function get_anytype_attribute_count (a_anytype anytype) return pls_integer is + l_attribute_typecode pls_integer; + l_schema_name varchar2(32767); + l_version varchar2(32767); + l_type_name varchar2(32767); + l_attributes pls_integer; + l_prec pls_integer; + l_scale pls_integer; + l_len pls_integer; + l_csid pls_integer; + l_csfrm pls_integer; + begin + l_attribute_typecode := a_anytype.getinfo( + prec => l_prec, + scale => l_scale, + len => l_len, + csid => l_csid, + csfrm => l_csfrm, + schema_name => l_schema_name, + type_name => l_type_name, + version => l_version, + numelems => l_attributes); + return l_attributes; + end; + + function get_anytype_attributes_info (a_anytype anytype) return ut_key_value_pairs is + l_result ut_key_value_pairs := ut_key_value_pairs(); + l_attribute_typecode pls_integer; + l_aname varchar2(32767); + l_prec pls_integer; + l_scale pls_integer; + l_len pls_integer; + l_csid pls_integer; + l_csfrm pls_integer; + l_attr_elt_type anytype; + begin + for i in 1..get_anytype_attribute_count(a_anytype) loop + l_attribute_typecode := a_anytype.getAttrElemInfo( + pos => i, --First attribute + prec => l_prec, + scale => l_scale, + len => l_len, + csid => l_csid, + csfrm => l_csfrm, + attr_elt_type => l_attr_elt_type, + aname => l_aname); + + l_result.extend; + l_result(l_result.last) := ut_key_value_pair(l_aname, g_anytype_name_map(l_attribute_typecode)); + + end loop; + return l_result; + end; + + function get_user_defined_type(a_owner varchar2,a_type_name varchar2) return xmltype is + l_anydata anydata; + l_anytype anytype; + l_typecode pls_integer; + l_result xmltype; + l_columns_tab ut_key_value_pairs := ut_key_value_pairs(); + begin + execute immediate 'declare + l_v '||a_owner||'.'||a_type_name||'; + begin + :anydata := anydata.convertobject(l_v); + end;' USING IN OUT l_anydata; + + l_typecode := l_anydata.gettype(l_anytype); + l_columns_tab := get_anytype_attributes_info(l_anytype); + + select xmlagg(xmlelement(evalname key,value)) + into l_result from table(l_columns_tab); + + return l_result; + + end; + + begin + g_anytype_name_map(dbms_types.typecode_date) :=' DATE'; + g_anytype_name_map(dbms_types.typecode_number) := 'NUMBER'; + g_anytype_name_map(dbms_types.typecode_raw) := 'RAW'; + g_anytype_name_map(dbms_types.typecode_char) := 'CHAR'; + g_anytype_name_map(dbms_types.typecode_varchar2) := 'VARCHAR2'; + g_anytype_name_map(dbms_types.typecode_varchar) := 'VARCHAR'; + g_anytype_name_map(dbms_types.typecode_blob) := 'BLOB'; + g_anytype_name_map(dbms_types.typecode_bfile) := 'BFILE'; + g_anytype_name_map(dbms_types.typecode_clob) := 'CLOB'; + g_anytype_name_map(dbms_types.typecode_timestamp) := 'TIMESTAMP'; + g_anytype_name_map(dbms_types.typecode_timestamp_tz) := 'TIMESTAMP WITH TIME ZONE'; + g_anytype_name_map(dbms_types.typecode_timestamp_ltz) := 'TIMESTAMP WITH LOCAL TIME ZONE'; + g_anytype_name_map(dbms_types.typecode_interval_ym) := 'INTERVAL YEAR TO MONTH'; + g_anytype_name_map(dbms_types.typecode_interval_ds) := 'INTERVAL DAY TO SECOND'; + g_anytype_name_map(dbms_types.typecode_bfloat) := 'BINARY_FLOAT'; + g_anytype_name_map(dbms_types.typecode_bdouble) := 'BINARY_DOUBLE'; + g_anytype_name_map(dbms_types.typecode_urowid) := 'UROWID'; + + g_type_name_map( dbms_sql.binary_bouble_type ) := 'BINARY_DOUBLE'; + g_type_name_map( dbms_sql.bfile_type ) := 'BFILE'; + g_type_name_map( dbms_sql.binary_float_type ) := 'BINARY_FLOAT'; + g_type_name_map( dbms_sql.blob_type ) := 'BLOB'; + g_type_name_map( dbms_sql.long_raw_type ) := 'LONG RAW'; + g_type_name_map( dbms_sql.char_type ) := 'CHAR'; + g_type_name_map( dbms_sql.clob_type ) := 'CLOB'; + g_type_name_map( dbms_sql.long_type ) := 'LONG'; + g_type_name_map( dbms_sql.date_type ) := 'DATE'; + g_type_name_map( dbms_sql.interval_day_to_second_type ) := 'INTERVAL DAY TO SECOND'; + g_type_name_map( dbms_sql.interval_year_to_month_type ) := 'INTERVAL YEAR TO MONTH'; + g_type_name_map( dbms_sql.raw_type ) := 'RAW'; + g_type_name_map( dbms_sql.timestamp_type ) := 'TIMESTAMP'; + g_type_name_map( dbms_sql.timestamp_with_tz_type ) := 'TIMESTAMP WITH TIME ZONE'; + g_type_name_map( dbms_sql.timestamp_with_local_tz_type ) := 'TIMESTAMP WITH LOCAL TIME ZONE'; + g_type_name_map( dbms_sql.varchar2_type ) := 'VARCHAR2'; + g_type_name_map( dbms_sql.number_type ) := 'NUMBER'; + g_type_name_map( dbms_sql.rowid_type ) := 'ROWID'; + g_type_name_map( dbms_sql.urowid_type ) := 'UROWID'; + +end; +/ diff --git a/source/expectations/data_values/ut_curr_usr_compound_helper.pks b/source/expectations/data_values/ut_curr_usr_compound_helper.pks new file mode 100644 index 000000000..3955f49c8 --- /dev/null +++ b/source/expectations/data_values/ut_curr_usr_compound_helper.pks @@ -0,0 +1,8 @@ +create or replace package ut_curr_usr_compound_helper authid current_user is + + function get_columns_info(a_cursor in out nocopy sys_refcursor,a_desc_user_types boolean := false) return xmltype; + + function get_user_defined_type(a_owner varchar2,a_type_name varchar2) return xmltype; + +end; +/ diff --git a/source/expectations/data_values/ut_data_value_refcursor.tpb b/source/expectations/data_values/ut_data_value_refcursor.tpb index c36b37f69..fe8c1f443 100644 --- a/source/expectations/data_values/ut_data_value_refcursor.tpb +++ b/source/expectations/data_values/ut_data_value_refcursor.tpb @@ -37,7 +37,8 @@ create or replace type body ut_data_value_refcursor as self.data_type := 'refcursor'; if l_cursor is not null then if l_cursor%isopen then - self.columns_info := ut_compound_data_helper.get_columns_info(l_cursor); + self.columns_info := ut_curr_usr_compound_helper.get_columns_info(l_cursor); + self.key_info := ut_curr_usr_compound_helper.get_columns_info(l_cursor,true); self.elements_count := 0; -- We use DBMS_XMLGEN in order to: -- 1) be able to process data in bulks (set of rows) @@ -137,9 +138,9 @@ create or replace type body ut_data_value_refcursor as return case a_missing_keys.diff_type when 'a' then - ' Unknown key to join by in actual:'||a_missing_keys.missingxpath + ' Join key '||a_missing_keys.missingxpath||' does not exists in actual' when 'e' then - ' Unknown key to join by in expected:'||a_missing_keys.missingxpath + ' Join key '||a_missing_keys.missingxpath||' does not exists in expected' end; end; @@ -190,7 +191,7 @@ create or replace type body ut_data_value_refcursor as --check for missing pk if (a_join_by_xpath is not null) then - l_missing_pk := ut_compound_data_helper.is_pk_exists(self.columns_info, l_actual.columns_info, a_exclude_xpath, a_include_xpath,a_join_by_xpath); + l_missing_pk := ut_compound_data_helper.is_pk_exists(self.key_info, l_actual.key_info, a_exclude_xpath, a_include_xpath,a_join_by_xpath); end if; --diff rows and row elements if the pk is not missing @@ -239,7 +240,7 @@ create or replace type body ut_data_value_refcursor as l_other := treat(a_other as ut_data_value_refcursor); - l_missing_pk := ut_compound_data_helper.is_pk_exists(self.columns_info, l_other.columns_info, a_exclude_xpath, a_include_xpath,a_join_by_xpath); + l_missing_pk := ut_compound_data_helper.is_pk_exists(self.key_info, l_other.key_info, a_exclude_xpath, a_include_xpath,a_join_by_xpath); --if we join by key and key is missing fail and report error if a_join_by_xpath is not null and l_missing_pk.count > 0 then l_result := 1; diff --git a/source/expectations/data_values/ut_data_value_refcursor.tps b/source/expectations/data_values/ut_data_value_refcursor.tps index af0609bb6..c73aaa538 100644 --- a/source/expectations/data_values/ut_data_value_refcursor.tps +++ b/source/expectations/data_values/ut_data_value_refcursor.tps @@ -29,7 +29,12 @@ create or replace type ut_data_value_refcursor under ut_compound_data_value( * Holds information about column names and column data-types */ columns_info xmltype, - + + /** + * Holds more detailed information regarding the pk joins + */ + key_info xmltype, + constructor function ut_data_value_refcursor(self in out nocopy ut_data_value_refcursor, a_value sys_refcursor) return self as result, member procedure init(self in out nocopy ut_data_value_refcursor, a_value sys_refcursor), overriding member function to_string return varchar2, @@ -38,4 +43,4 @@ create or replace type ut_data_value_refcursor under ut_compound_data_value( overriding member function compare_implementation(a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2, a_join_by_xpath varchar2, a_unordered boolean) return integer ) -/ \ No newline at end of file +/ diff --git a/source/install.sql b/source/install.sql index 3050349e6..6d7bba6d9 100644 --- a/source/install.sql +++ b/source/install.sql @@ -43,6 +43,10 @@ alter session set current_schema = &&ut3_owner; @@install_component.sql 'core/types/ut_object_names.tps' @@install_component.sql 'core/types/ut_key_value_pair.tps' @@install_component.sql 'core/types/ut_key_value_pairs.tps' +@@install_component.sql 'core/types/ut_key_anyval_pair.tps' +@@install_component.sql 'core/types/ut_key_anyval_pairs.tps' +@@install_component.sql 'core/types/ut_key_varcharvalue_pair.tps' +@@install_component.sql 'core/types/ut_key_xmlvalue_pair.tps' @@install_component.sql 'core/ut_utils.pks' @@install_component.sql 'core/ut_metadata.pks' @@install_component.sql 'core/ut_utils.pkb' @@ -182,6 +186,7 @@ prompt Installing DBMSPLSQL Tables objects into &&ut3_owner schema @@install_component.sql 'expectations/data_values/ut_data_value_varchar2.tps' @@install_component.sql 'expectations/data_values/ut_data_value_yminterval.tps' @@install_component.sql 'expectations/data_values/ut_compound_data_helper.pks' +@@install_component.sql 'expectations/data_values/ut_curr_usr_compound_helper.pks' @@install_component.sql 'expectations/matchers/ut_matcher.tps' @@install_component.sql 'expectations/matchers/ut_comparison_matcher.tps' @@install_component.sql 'expectations/matchers/ut_be_false.tps' @@ -203,6 +208,7 @@ prompt Installing DBMSPLSQL Tables objects into &&ut3_owner schema @@install_component.sql 'expectations/data_values/ut_data_value.tpb' @@install_component.sql 'expectations/data_values/ut_compound_data_value.tpb' @@install_component.sql 'expectations/data_values/ut_compound_data_helper.pkb' +@@install_component.sql 'expectations/data_values/ut_curr_usr_compound_helper.pkb' @@install_component.sql 'expectations/data_values/ut_data_value_anydata.tpb' @@install_component.sql 'expectations/data_values/ut_data_value_object.tpb' @@install_component.sql 'expectations/data_values/ut_data_value_collection.tpb' diff --git a/source/uninstall.sql b/source/uninstall.sql index 7b2ad4f66..d8796464c 100644 --- a/source/uninstall.sql +++ b/source/uninstall.sql @@ -260,6 +260,14 @@ drop package ut_event_manager; drop type ut_event_item force; +drop type ut_key_anyval_pair force; + +drop type ut_key_anyval_pairs force; + +drop type ut_key_varcharvalue_pair force; + +drop type ut_key_xmlvalue_pair force; + drop type ut_key_value_pairs force; drop type ut_key_value_pair force; diff --git a/test/core/expectations/compound_data/test_expectations_cursor.pkb b/test/core/expectations/compound_data/test_expectations_cursor.pkb index 12602c61f..489732947 100644 --- a/test/core/expectations/compound_data/test_expectations_cursor.pkb +++ b/test/core/expectations/compound_data/test_expectations_cursor.pkb @@ -1130,8 +1130,8 @@ Extra: test-666%]'; l_expected_message := q'[%Actual: refcursor [ count = 3 ] was expected to equal: refcursor [ count = 3 ]% Diff:% %Unable to join sets:% -%Unknown key to join by in expected:/*/OWNER% -%Unknown key to join by in actual:/*/OWNER%]'; +%Join key /*/OWNER does not exists in expected% +%Join key /*/OWNER does not exists in actual%]'; l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); @@ -1153,10 +1153,10 @@ Diff:% l_expected_message := q'[%Actual: refcursor [ count = 3 ] was expected to equal: refcursor [ count = 3 ]% Diff:% %Unable to join sets:% -%Unknown key to join by in expected:/*/OWNER% -%Unknown key to join by in expected:/*/USER_ID% -%Unknown key to join by in actual:/*/OWNER% -%Unknown key to join by in actual:/*/USER_ID%]'; +%Join key /*/OWNER does not exists in expected% +%Join key /*/USER_ID does not exists in expected% +%Join key /*/OWNER does not exists in actual% +%Join key /*/USER_ID does not exists in actual%]'; l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); @@ -1178,8 +1178,8 @@ Diff:% l_expected_message := q'[%Actual: refcursor [ count = 3 ] was expected to equal: refcursor [ count = 3 ]% Diff:% %Unable to join sets:% -%Unknown key to join by in expected:/*/SOME_COL% -%Unknown key to join by in actual:/*/SOME_COL%]'; +%Join key /*/SOME_COL does not exists in expected% +%Join key /*/SOME_COL does not exists in actual%]'; l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); @@ -1201,8 +1201,8 @@ Diff:% l_expected_message := q'[%Actual: refcursor [ count = 3 ] was expected to equal: refcursor [ count = 3 ]% Diff:% %Unable to join sets:% -%Unknown key to join by in expected:/*/RN% -%Unknown key to join by in actual:/*/RN%]'; +%Join key /*/RN does not exists in expected% +%Join key /*/RN does not exists in actual%]'; l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); @@ -1224,7 +1224,7 @@ Diff:% l_expected_message := q'[%Actual: refcursor [ count = 3 ] was expected to equal: refcursor [ count = 3 ]% Diff:% %Unable to join sets:% -%Unknown key to join by in expected:/*/RNI%]'; +%Join key /*/RNI does not exists in expected%]'; l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); @@ -1246,7 +1246,7 @@ Diff:% l_expected_message := q'[%Actual: refcursor [ count = 3 ] was expected to equal: refcursor [ count = 3 ]% Diff:% %Unable to join sets:% -%Unknown key to join by in actual:/*/RNI%]'; +%Join key /*/RNI does not exists in actual%]'; l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); @@ -1440,6 +1440,117 @@ Diff:% --Assert ut.expect(expectations.failed_expectations_data()).to_be_empty(); end; + + procedure compare_nested_tab_col_un is + l_actual sys_refcursor; + l_expected sys_refcursor; + begin + --Arrange + open l_actual for select test_dummy_object( rownum, 'Something '||rownum, rownum) as colval + from dual connect by level <=2 order by rownum asc; + + open l_expected for select test_dummy_object( rownum, 'Something '||rownum, rownum) as colval + from dual connect by level <=2 order by rownum desc; + + --Act + ut3.ut.expect(l_actual).to_equal(l_expected).unordered; + --Assert + ut.expect(expectations.failed_expectations_data()).to_be_empty(); + end; + + procedure compare_nested_tab_col_jb is + l_actual sys_refcursor; + l_expected sys_refcursor; + begin + --Arrange + open l_actual for select test_dummy_object( rownum, 'Something '||rownum, rownum) as colval + from dual connect by level <=2 order by rownum asc; + + open l_expected for select test_dummy_object( rownum, 'Something '||rownum, rownum) as colval + from dual connect by level <=2 order by rownum desc; + + --Act + ut3.ut.expect(l_actual).to_equal(l_expected).join_by('COLVAL/ID'); + --Assert + ut.expect(expectations.failed_expectations_data()).to_be_empty(); + end; + + procedure comp_nest_tab_col_un_fail is + l_actual sys_refcursor; + l_expected sys_refcursor; + begin + --Arrange + open l_actual for select test_dummy_object( rownum, 'Something '||rownum, rownum) as colval + from dual connect by level <=2 order by rownum asc; + + open l_expected for select test_dummy_object( rownum, 'Somethings '||rownum, rownum) as colval + from dual connect by level <=3 order by rownum desc; + + --Act + ut3.ut.expect(l_actual).to_equal(l_expected).unordered; + --Assert + ut.expect(expectations.failed_expectations_data()).to_be_not_null(); + end; + + procedure comp_nest_tab_col_jb_fail is + l_actual sys_refcursor; + l_expected sys_refcursor; + begin + --Arrange + open l_actual for select test_dummy_object( rownum, 'Something '||rownum, rownum) as colval + from dual connect by level <=2 order by rownum asc; + + open l_expected for select test_dummy_object( rownum, 'Somethings '||rownum, rownum) as colval + from dual connect by level <=2 order by rownum desc; + + --Act + ut3.ut.expect(l_actual).to_equal(l_expected).join_by('COLVAL/ID'); + --Assert + ut.expect(expectations.failed_expectations_data()).to_be_not_null(); + end; + + procedure comp_nest_tab_col_jb_multi is + l_actual sys_refcursor; + l_expected sys_refcursor; + begin + --Arrange + open l_actual for select rownum as rn,test_dummy_object( rownum, 'Something '||rownum, rownum) as colval + from dual connect by level <=2 order by rownum asc; + + open l_expected for select rownum as rn,test_dummy_object( rownum, 'Something '||rownum, rownum) as colval + from dual connect by level <=2 order by rownum desc; + + --Act + ut3.ut.expect(l_actual).to_equal(l_expected).join_by(ut3.ut_varchar2_list('RN,COLVAL/ID')); + --Assert + ut.expect(expectations.failed_expectations_data()).to_be_empty(); + end; + procedure comp_nest_tab_col_jb_nokey is + l_actual sys_refcursor; + l_expected sys_refcursor; + l_expected_message varchar2(32767); + l_actual_message varchar2(32767); + begin + --Arrange + open l_actual for select test_dummy_object( rownum, 'Something '||rownum, rownum) as colval + from dual connect by level <=2 order by rownum asc; + + open l_expected for select test_dummy_object( rownum, 'Something '||rownum, rownum) as colval + from dual connect by level <=2 order by rownum desc; + + --Act + ut3.ut.expect(l_actual).to_equal(l_expected).join_by('COLVAL/IDS'); + --Assert + --Assert + l_expected_message := q'[%Actual: refcursor [ count = 2 ] was expected to equal: refcursor [ count = 2 ]% +Diff:% +%Unable to join sets:% +%Join key /*/COLVAL/IDS does not exists in expected% +%Join key /*/COLVAL/IDS does not exists in actual%]'; + l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; + --Assert + ut.expect(l_actual_message).to_be_like(l_expected_message); + end; end; / diff --git a/test/core/expectations/compound_data/test_expectations_cursor.pks b/test/core/expectations/compound_data/test_expectations_cursor.pks index eb5144c29..340047d3a 100644 --- a/test/core/expectations/compound_data/test_expectations_cursor.pks +++ b/test/core/expectations/compound_data/test_expectations_cursor.pks @@ -26,7 +26,7 @@ create or replace package test_expectations_cursor is --%test(Gives success on to_be_null if cursor is null) procedure success_to_be_null; - --%test(Gives succes on not_to_be_not_null if cursor is null) + --%test(Gives success on not_to_be_not_null if cursor is null) procedure success_not_to_be_not_null; --%test(Gives success on not_to_be_null if cursor is not null) @@ -262,5 +262,23 @@ create or replace package test_expectations_cursor is --%test(Include column of same type leaving different type out and exclude different type) procedure inlc_exc_dif_cols_as_list; + --%test(Compare nested table type unordered) + procedure compare_nested_tab_col_un; + + --%test(Compare nested table type join by) + procedure compare_nested_tab_col_jb; + + --%test(Compare nested table type unordered fail) + procedure comp_nest_tab_col_un_fail; + + --%test(Compare nested table type join by fail) + procedure comp_nest_tab_col_jb_fail; + + --%test(Compare nested table type join by multi key) + procedure comp_nest_tab_col_jb_multi; + + --%test(Compare nested table type join by missing nested key) + procedure comp_nest_tab_col_jb_nokey; + end; / From 77e446830a12353b91877817670942ed56a7fcad Mon Sep 17 00:00:00 2001 From: lwasylow Date: Tue, 22 May 2018 07:00:21 +0100 Subject: [PATCH 044/184] Updated code with a new display update tests to include table type Update key value pairs type --- docs/userguide/advanced_data_comparison.md | 8 +- source/core/types/ut_key_xmlvalue_pair.tps | 20 -- .../data_values/ut_compound_data_helper.pkb | 35 ++- .../data_values/ut_compound_data_helper.pks | 2 +- .../data_values/ut_compound_data_value.tpb | 2 +- .../ut_curr_usr_compound_helper.pkb | 12 +- .../data_values/ut_data_value_xmltype.tpb | 50 +++++ .../data_values/ut_data_value_xmltype.tps} | 8 +- .../data_values}/ut_key_anyval_pair.tps | 3 +- .../data_values}/ut_key_anyval_pairs.tps | 0 source/install.sql | 8 +- source/uninstall.sql | 6 +- .../test_expectations_cursor.pkb | 204 +++++++++++++++--- .../test_expectations_cursor.pks | 34 ++- 14 files changed, 292 insertions(+), 100 deletions(-) delete mode 100644 source/core/types/ut_key_xmlvalue_pair.tps create mode 100644 source/expectations/data_values/ut_data_value_xmltype.tpb rename source/{core/types/ut_key_varcharvalue_pair.tps => expectations/data_values/ut_data_value_xmltype.tps} (59%) rename source/{core/types => expectations/data_values}/ut_key_anyval_pair.tps (93%) rename source/{core/types => expectations/data_values}/ut_key_anyval_pairs.tps (100%) diff --git a/docs/userguide/advanced_data_comparison.md b/docs/userguide/advanced_data_comparison.md index 1edc39b7c..cc488da11 100644 --- a/docs/userguide/advanced_data_comparison.md +++ b/docs/userguide/advanced_data_comparison.md @@ -163,10 +163,14 @@ This will show you difference in row 'TEST' regardless of order. ```sql Rows: [ 1 differences ] - Expected: -600 for key: TEST - Actual: -610 for key: TEST + PK TEST - Expected: -600 + PK TEST - Actual: -610 ``` +Assumption is that join by is made by column name so that what will be displayed as part of results. + + + **Please note that .join_by option will take longer to process due to need of parsing via primary keys.** ## Defining item as XPath diff --git a/source/core/types/ut_key_xmlvalue_pair.tps b/source/core/types/ut_key_xmlvalue_pair.tps deleted file mode 100644 index 1f5462861..000000000 --- a/source/core/types/ut_key_xmlvalue_pair.tps +++ /dev/null @@ -1,20 +0,0 @@ -create or replace type ut_key_xmlvalue_pair under ut_key_anyval_pair ( - /* - utPLSQL - Version 3 - Copyright 2016 - 2017 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. - */ - value xmltype -) -/ diff --git a/source/expectations/data_values/ut_compound_data_helper.pkb b/source/expectations/data_values/ut_compound_data_helper.pkb index 71963263f..a89258c19 100644 --- a/source/expectations/data_values/ut_compound_data_helper.pkb +++ b/source/expectations/data_values/ut_compound_data_helper.pkb @@ -21,15 +21,17 @@ create or replace package body ut_compound_data_helper is function get_column_info_xml(a_column_details ut_key_anyval_pair) return xmltype is l_result varchar2(4000); l_res xmltype; + l_data ut_data_value := a_column_details.value; + l_key varchar2(4000) := ut_utils.xmlgen_escaped_string(a_column_details.KEY); begin - l_result := '<'||ut_utils.xmlgen_escaped_string(a_column_details.KEY)||' xml_valid_name="'||ut_utils.xmlgen_escaped_string(a_column_details.KEY)||'">'; - if a_column_details is of(ut_key_xmlvalue_pair) then - l_result := l_result || (treat(a_column_details as ut_key_xmlvalue_pair).value.getstringval()); + l_result := '<'||l_key||' xml_valid_name="'||l_key||'">'; + if l_data is of(ut_data_value_xmltype) then + l_result := l_result || (treat(l_data as ut_data_value_xmltype).to_string); else - l_result := l_result || ut_utils.xmlgen_escaped_string((treat(a_column_details as ut_key_varcharvalue_pair).value)); + l_result := l_result || ut_utils.xmlgen_escaped_string((treat(l_data as ut_data_value_varchar2).data_value)); end if; - l_result := l_result ||''; + l_result := l_result ||''; return xmltype(l_result); end; @@ -155,16 +157,13 @@ create or replace package body ut_compound_data_helper is return l_results; end; - function get_pk_value (a_join_by_xpath varchar2,a_item_data xmltype) return varchar2 is - l_pk_value varchar2(4000); + function get_pk_value (a_join_by_xpath varchar2,a_item_data xmltype) return clob is + l_pk_value clob; begin - select listagg(extractvalue(xmlelement("ROW",column_value),a_join_by_xpath),':') within group ( order by 1) - into l_pk_value - from table(xmlsequence(extract(a_item_data,'/*/*'))); - - return l_pk_value; + select extract(a_item_data,a_join_by_xpath).getclobval() into l_pk_value from dual; + return l_pk_value; exception when no_data_found then - return 'null '; + return 'null'; end; function get_rows_diff( @@ -242,11 +241,11 @@ create or replace package body ut_compound_data_helper is unpivot ( data_item for diff_type in (exp_item as 'Expected:', act_item as 'Actual:') ) ) union all - select case when exp.pk_hash is null then 'Extra:' else 'Missing:' end as diff_type, + select case when exp.pk_hash is null then 'Extra' else 'Missing' end as diff_type, xmlserialize(content nvl(exp.item_data, act.item_data) no indent) diffed_row, coalesce(exp.pk_hash,act.pk_hash) pk_hash, coalesce(exp.pk_value,act.pk_value) pk_value - from (select extract(ucd.item_data,'/*/*') item_data,i.pk_hash, + from (select extract(deletexml(ucd.item_data, :join_by),'/*/*') item_data,i.pk_hash, ut_compound_data_helper.get_pk_value(:join_by,item_data) pk_value from ut_compound_data_tmp ucd, diff_info i @@ -254,7 +253,7 @@ create or replace package body ut_compound_data_helper is and ucd.item_hash = i.item_hash ) exp full outer join ( - select extract(ucd.item_data,'/*/*') item_data,i.pk_hash, + select extract(deletexml(ucd.item_data, :join_by),'/*/*') item_data,i.pk_hash, ut_compound_data_helper.get_pk_value(:join_by,item_data) pk_value from ut_compound_data_tmp ucd, diff_info i @@ -272,7 +271,7 @@ create or replace package body ut_compound_data_helper is a_exclude_xpath, a_include_xpath, a_expected_dataset_guid, a_join_by_xpath, a_exclude_xpath, a_include_xpath, a_actual_dataset_guid, - a_join_by_xpath,a_expected_dataset_guid,a_join_by_xpath, a_actual_dataset_guid, + a_join_by_xpath,a_join_by_xpath,a_expected_dataset_guid,a_join_by_xpath,a_join_by_xpath, a_actual_dataset_guid, a_max_rows; return l_results; @@ -502,7 +501,7 @@ create or replace package body ut_compound_data_helper is with xpaths_tab as (select column_value xpath from table(:xpath_tabs)), expected_column_info as ( select :expected as item_data from dual ), actual_column_info as ( select :actual as item_data from dual ) - select xpath,diif_type from + select REGEXP_SUBSTR (xpath,'[^(/\*/)](.+)$'),diif_type from ( (select xpath,'e' diif_type from xpaths_tab minus diff --git a/source/expectations/data_values/ut_compound_data_helper.pks b/source/expectations/data_values/ut_compound_data_helper.pks index 6558182ae..da2863667 100644 --- a/source/expectations/data_values/ut_compound_data_helper.pks +++ b/source/expectations/data_values/ut_compound_data_helper.pks @@ -59,7 +59,7 @@ create or replace package ut_compound_data_helper authid definer is a_expected xmltype, a_actual xmltype, a_exclude_xpath varchar2, a_include_xpath varchar2 ) return tt_column_diffs; - function get_pk_value (a_join_by_xpath varchar2,a_item_data xmltype) return varchar2; + function get_pk_value (a_join_by_xpath varchar2,a_item_data xmltype) return clob; function compare_type(a_join_by_xpath in varchar2,a_unordered boolean) return varchar2; diff --git a/source/expectations/data_values/ut_compound_data_value.tpb b/source/expectations/data_values/ut_compound_data_value.tpb index 76f22e60f..45841e5a9 100644 --- a/source/expectations/data_values/ut_compound_data_value.tpb +++ b/source/expectations/data_values/ut_compound_data_value.tpb @@ -97,7 +97,7 @@ create or replace type body ut_compound_data_value as function get_diff_message (a_row_diff ut_compound_data_helper.t_row_diffs,a_compare_type varchar2) return varchar2 is begin if a_compare_type = ut_compound_data_helper.gc_compare_join_by and a_row_diff.pk_value is not null then - return ' '||rpad(a_row_diff.diff_type,10)||a_row_diff.diffed_row||' for key: '||a_row_diff.pk_value; + return ' PK '||a_row_diff.pk_value||' - '||rpad(a_row_diff.diff_type,10)||a_row_diff.diffed_row; elsif a_compare_type = ut_compound_data_helper.gc_compare_join_by or a_compare_type = ut_compound_data_helper.gc_compare_normal then return ' Row No. '||a_row_diff.rn||' - '||rpad(a_row_diff.diff_type,10)||a_row_diff.diffed_row; elsif a_compare_type = ut_compound_data_helper.gc_compare_unordered then diff --git a/source/expectations/data_values/ut_curr_usr_compound_helper.pkb b/source/expectations/data_values/ut_curr_usr_compound_helper.pkb index 357a1122b..7885b15fe 100644 --- a/source/expectations/data_values/ut_curr_usr_compound_helper.pkb +++ b/source/expectations/data_values/ut_curr_usr_compound_helper.pkb @@ -7,18 +7,18 @@ create or replace package body ut_curr_usr_compound_helper is function get_column_type(a_desc_rec dbms_sql.desc_rec3,a_desc_user_types boolean := false) return ut_key_anyval_pair is + l_data ut_data_value; l_result ut_key_anyval_pair; l_data_type varchar2(500) := 'unknown datatype'; - begin + begin if g_type_name_map.exists(a_desc_rec.col_type) then - l_result := ut_key_varcharvalue_pair(a_desc_rec.col_name,g_type_name_map(a_desc_rec.col_type)); + l_data := ut_data_value_varchar2(g_type_name_map(a_desc_rec.col_type)); elsif a_desc_rec.col_type = g_user_defined_type and a_desc_user_types then - l_result := ut_key_xmlvalue_pair(a_desc_rec.col_name, - get_user_defined_type(a_desc_rec.col_schema_name,a_desc_rec.col_type_name)); + l_data :=ut_data_value_xmltype(get_user_defined_type(a_desc_rec.col_schema_name,a_desc_rec.col_type_name)); elsif a_desc_rec.col_schema_name is not null and a_desc_rec.col_type_name is not null then - l_result := ut_key_varcharvalue_pair(a_desc_rec.col_name,a_desc_rec.col_schema_name||'.'||a_desc_rec.col_type_name); + l_data := ut_data_value_varchar2(a_desc_rec.col_schema_name||'.'||a_desc_rec.col_type_name); end if; - return l_result; + return ut_key_anyval_pair(a_desc_rec.col_name,l_data); end; function get_columns_info(a_columns_tab dbms_sql.desc_tab3, a_columns_count integer,a_desc_user_types boolean := false) return ut_key_anyval_pairs is diff --git a/source/expectations/data_values/ut_data_value_xmltype.tpb b/source/expectations/data_values/ut_data_value_xmltype.tpb new file mode 100644 index 000000000..237a7e592 --- /dev/null +++ b/source/expectations/data_values/ut_data_value_xmltype.tpb @@ -0,0 +1,50 @@ +create or replace type body ut_data_value_xmltype as + /* + utPLSQL - Version 3 + Copyright 2016 - 2017 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. + */ + + constructor function ut_data_value_xmltype(self in out nocopy ut_data_value_xmltype, a_value xmltype) return self as result is + begin + self.data_value := a_value; + self.self_type := $$plsql_unit; + self.data_type := 'xmltype'; + return; + end; + + overriding member function is_null return boolean is + begin + return (self.data_value is null); + end; + + overriding member function to_string return varchar2 is + begin + return ut_utils.to_string(self.data_value.getClobVal()); + end; + + overriding member function compare_implementation(a_other ut_data_value) return integer is + l_result integer; + l_other ut_data_value_xmltype; + begin + if a_other is of (ut_data_value_xmltype) then + l_other := treat(a_other as ut_data_value_xmltype); + l_result := dbms_lob.compare(self.data_value.getClobVal(),l_other.data_value.getClobVal()); + end if; + + return l_result; + end; + +end; +/ diff --git a/source/core/types/ut_key_varcharvalue_pair.tps b/source/expectations/data_values/ut_data_value_xmltype.tps similarity index 59% rename from source/core/types/ut_key_varcharvalue_pair.tps rename to source/expectations/data_values/ut_data_value_xmltype.tps index fdce93cf0..2bc4ae985 100644 --- a/source/core/types/ut_key_varcharvalue_pair.tps +++ b/source/expectations/data_values/ut_data_value_xmltype.tps @@ -1,4 +1,4 @@ -create or replace type ut_key_varcharvalue_pair under ut_key_anyval_pair ( +create or replace type ut_data_value_xmltype under ut_data_value( /* utPLSQL - Version 3 Copyright 2016 - 2017 utPLSQL Project @@ -15,6 +15,10 @@ create or replace type ut_key_varcharvalue_pair under ut_key_anyval_pair ( See the License for the specific language governing permissions and limitations under the License. */ - value varchar2(4000) + data_value xmltype, + constructor function ut_data_value_xmltype(self in out nocopy ut_data_value_xmltype, a_value xmltype) return self as result, + overriding member function is_null return boolean, + overriding member function to_string return varchar2, + overriding member function compare_implementation(a_other ut_data_value) return integer ) / diff --git a/source/core/types/ut_key_anyval_pair.tps b/source/expectations/data_values/ut_key_anyval_pair.tps similarity index 93% rename from source/core/types/ut_key_anyval_pair.tps rename to source/expectations/data_values/ut_key_anyval_pair.tps index 5188bdda5..8fb4831c0 100644 --- a/source/core/types/ut_key_anyval_pair.tps +++ b/source/expectations/data_values/ut_key_anyval_pair.tps @@ -15,6 +15,7 @@ create or replace type ut_key_anyval_pair force as object( See the License for the specific language governing permissions and limitations under the License. */ - key varchar2(4000) + key varchar2(4000), + value ut_data_value ) not final / diff --git a/source/core/types/ut_key_anyval_pairs.tps b/source/expectations/data_values/ut_key_anyval_pairs.tps similarity index 100% rename from source/core/types/ut_key_anyval_pairs.tps rename to source/expectations/data_values/ut_key_anyval_pairs.tps diff --git a/source/install.sql b/source/install.sql index 6d7bba6d9..0bd30222c 100644 --- a/source/install.sql +++ b/source/install.sql @@ -43,10 +43,6 @@ alter session set current_schema = &&ut3_owner; @@install_component.sql 'core/types/ut_object_names.tps' @@install_component.sql 'core/types/ut_key_value_pair.tps' @@install_component.sql 'core/types/ut_key_value_pairs.tps' -@@install_component.sql 'core/types/ut_key_anyval_pair.tps' -@@install_component.sql 'core/types/ut_key_anyval_pairs.tps' -@@install_component.sql 'core/types/ut_key_varcharvalue_pair.tps' -@@install_component.sql 'core/types/ut_key_xmlvalue_pair.tps' @@install_component.sql 'core/ut_utils.pks' @@install_component.sql 'core/ut_metadata.pks' @@install_component.sql 'core/ut_utils.pkb' @@ -166,6 +162,8 @@ prompt Installing DBMSPLSQL Tables objects into &&ut3_owner schema @@install_component.sql 'core/types/ut_console_reporter_base.tpb' --expectations and matchers +@@install_component.sql 'expectations/data_values/ut_key_anyval_pair.tps' +@@install_component.sql 'expectations/data_values/ut_key_anyval_pairs.tps' @@install_component.sql 'expectations/data_values/ut_compound_data_tmp.sql' @@install_component.sql 'expectations/data_values/ut_compound_data_diff_tmp.sql' @@install_component.sql 'expectations/data_values/ut_data_value.tps' @@ -185,6 +183,7 @@ prompt Installing DBMSPLSQL Tables objects into &&ut3_owner schema @@install_component.sql 'expectations/data_values/ut_data_value_timestamp_ltz.tps' @@install_component.sql 'expectations/data_values/ut_data_value_varchar2.tps' @@install_component.sql 'expectations/data_values/ut_data_value_yminterval.tps' +@@install_component.sql 'expectations/data_values/ut_data_value_xmltype.tps' @@install_component.sql 'expectations/data_values/ut_compound_data_helper.pks' @@install_component.sql 'expectations/data_values/ut_curr_usr_compound_helper.pks' @@install_component.sql 'expectations/matchers/ut_matcher.tps' @@ -224,6 +223,7 @@ prompt Installing DBMSPLSQL Tables objects into &&ut3_owner schema @@install_component.sql 'expectations/data_values/ut_data_value_timestamp_ltz.tpb' @@install_component.sql 'expectations/data_values/ut_data_value_varchar2.tpb' @@install_component.sql 'expectations/data_values/ut_data_value_yminterval.tpb' +@@install_component.sql 'expectations/data_values/ut_data_value_xmltype.tpb' @@install_component.sql 'expectations/matchers/ut_matcher.tpb' @@install_component.sql 'expectations/matchers/ut_comparison_matcher.tpb' @@install_component.sql 'expectations/matchers/ut_be_false.tpb' diff --git a/source/uninstall.sql b/source/uninstall.sql index d8796464c..0a8540592 100644 --- a/source/uninstall.sql +++ b/source/uninstall.sql @@ -152,6 +152,8 @@ drop type ut_data_value_collection force; drop type ut_data_value_anydata force; +drop type ut_data_value_xmltype force; + drop type ut_data_value force; drop table ut_compound_data_tmp; @@ -264,10 +266,6 @@ drop type ut_key_anyval_pair force; drop type ut_key_anyval_pairs force; -drop type ut_key_varcharvalue_pair force; - -drop type ut_key_xmlvalue_pair force; - drop type ut_key_value_pairs force; drop type ut_key_value_pair force; diff --git a/test/core/expectations/compound_data/test_expectations_cursor.pkb b/test/core/expectations/compound_data/test_expectations_cursor.pkb index 489732947..7a87aab87 100644 --- a/test/core/expectations/compound_data/test_expectations_cursor.pkb +++ b/test/core/expectations/compound_data/test_expectations_cursor.pkb @@ -1130,8 +1130,8 @@ Extra: test-666%]'; l_expected_message := q'[%Actual: refcursor [ count = 3 ] was expected to equal: refcursor [ count = 3 ]% Diff:% %Unable to join sets:% -%Join key /*/OWNER does not exists in expected% -%Join key /*/OWNER does not exists in actual%]'; +%Join key OWNER does not exists in expected% +%Join key OWNER does not exists in actual%]'; l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); @@ -1153,10 +1153,10 @@ Diff:% l_expected_message := q'[%Actual: refcursor [ count = 3 ] was expected to equal: refcursor [ count = 3 ]% Diff:% %Unable to join sets:% -%Join key /*/OWNER does not exists in expected% -%Join key /*/USER_ID does not exists in expected% -%Join key /*/OWNER does not exists in actual% -%Join key /*/USER_ID does not exists in actual%]'; +%Join key OWNER does not exists in expected% +%Join key USER_ID does not exists in expected% +%Join key OWNER does not exists in actual% +%Join key USER_ID does not exists in actual%]'; l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); @@ -1178,8 +1178,8 @@ Diff:% l_expected_message := q'[%Actual: refcursor [ count = 3 ] was expected to equal: refcursor [ count = 3 ]% Diff:% %Unable to join sets:% -%Join key /*/SOME_COL does not exists in expected% -%Join key /*/SOME_COL does not exists in actual%]'; +%Join key SOME_COL does not exists in expected% +%Join key SOME_COL does not exists in actual%]'; l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); @@ -1201,8 +1201,8 @@ Diff:% l_expected_message := q'[%Actual: refcursor [ count = 3 ] was expected to equal: refcursor [ count = 3 ]% Diff:% %Unable to join sets:% -%Join key /*/RN does not exists in expected% -%Join key /*/RN does not exists in actual%]'; +%Join key RN does not exists in expected% +%Join key RN does not exists in actual%]'; l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); @@ -1224,7 +1224,7 @@ Diff:% l_expected_message := q'[%Actual: refcursor [ count = 3 ] was expected to equal: refcursor [ count = 3 ]% Diff:% %Unable to join sets:% -%Join key /*/RNI does not exists in expected%]'; +%Join key RNI does not exists in expected%]'; l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); @@ -1246,7 +1246,7 @@ Diff:% l_expected_message := q'[%Actual: refcursor [ count = 3 ] was expected to equal: refcursor [ count = 3 ]% Diff:% %Unable to join sets:% -%Join key /*/RNI does not exists in actual%]'; +%Join key RNI does not exists in actual%]'; l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); @@ -1284,8 +1284,8 @@ Diff:% l_expected_message := q'[%Actual: refcursor [ count = % ] was expected to equal: refcursor [ count = % ] %Diff:% %Rows: [ 1 differences ]% -%Expected: -600 for key: TEST% -%Actual: -610 for key: TEST%]'; +%PK TEST - Expected:%-600% +%PK TEST - Actual:%-610%]'; l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); @@ -1310,8 +1310,8 @@ Diff:% l_expected_message := q'[%Actual: refcursor [ count = % ] was expected to equal: refcursor [ count = % ] %Diff:% %Rows: [ 2 differences ]% -%Missing: TEST-600 for key: -600:TEST% -%Extra: TEST-610 for key: -610:TEST%]'; +%PK TEST-600 - Missing % +%PK TEST-610 - Extra %]'; l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); @@ -1336,8 +1336,8 @@ Diff:% l_expected_message := q'[%Actual: refcursor [ count = % ] was expected to equal: refcursor [ count = % ] %Diff:% %Rows: [ 1 differences ]% -%Expected: -600 for key: TEST:Y% -%Actual: -610 for key: TEST:Y%]'; +%PK TESTY - Expected:%-600% +%PK TESTY - Actual:%-610%]'; l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); @@ -1441,7 +1441,7 @@ Diff:% ut.expect(expectations.failed_expectations_data()).to_be_empty(); end; - procedure compare_nested_tab_col_un is + procedure compare_obj_typ_col_un is l_actual sys_refcursor; l_expected sys_refcursor; begin @@ -1458,7 +1458,7 @@ Diff:% ut.expect(expectations.failed_expectations_data()).to_be_empty(); end; - procedure compare_nested_tab_col_jb is + procedure compare_obj_typ_col_jb is l_actual sys_refcursor; l_expected sys_refcursor; begin @@ -1475,9 +1475,11 @@ Diff:% ut.expect(expectations.failed_expectations_data()).to_be_empty(); end; - procedure comp_nest_tab_col_un_fail is + procedure comp_obj_typ_col_un_fail is l_actual sys_refcursor; l_expected sys_refcursor; + l_expected_message varchar2(32767); + l_actual_message varchar2(32767); begin --Arrange open l_actual for select test_dummy_object( rownum, 'Something '||rownum, rownum) as colval @@ -1488,11 +1490,20 @@ Diff:% --Act ut3.ut.expect(l_actual).to_equal(l_expected).unordered; + l_expected_message := q'[%Actual: refcursor [ count = 2 ] was expected to equal: refcursor [ count = 3 ]% +Diff:% +Rows: [ 5 differences ] +Missing: 1Somethings 11% +Missing: 2Somethings 22% +Missing: 3Somethings 33% +Extra: 1Something 11% +Extra: 2Something 22%]'; + l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; --Assert - ut.expect(expectations.failed_expectations_data()).to_be_not_null(); + ut.expect(l_actual_message).to_be_like(l_expected_message); end; - procedure comp_nest_tab_col_jb_fail is + procedure comp_obj_typ_col_jb_fail is l_actual sys_refcursor; l_expected sys_refcursor; begin @@ -1509,7 +1520,7 @@ Diff:% ut.expect(expectations.failed_expectations_data()).to_be_not_null(); end; - procedure comp_nest_tab_col_jb_multi is + procedure comp_obj_typ_col_jb_multi is l_actual sys_refcursor; l_expected sys_refcursor; begin @@ -1526,7 +1537,7 @@ Diff:% ut.expect(expectations.failed_expectations_data()).to_be_empty(); end; - procedure comp_nest_tab_col_jb_nokey is + procedure comp_obj_typ_col_jb_nokey is l_actual sys_refcursor; l_expected sys_refcursor; l_expected_message varchar2(32767); @@ -1540,17 +1551,150 @@ Diff:% from dual connect by level <=2 order by rownum desc; --Act - ut3.ut.expect(l_actual).to_equal(l_expected).join_by('COLVAL/IDS'); - --Assert - --Assert + ut3.ut.expect(l_actual).to_equal(l_expected).join_by('COLVAL/IDS'); + l_expected_message := q'[%Actual: refcursor [ count = 2 ] was expected to equal: refcursor [ count = 2 ]% Diff:% %Unable to join sets:% -%Join key /*/COLVAL/IDS does not exists in expected% -%Join key /*/COLVAL/IDS does not exists in actual%]'; +%Join key COLVAL/IDS does not exists in expected% +%Join key COLVAL/IDS does not exists in actual%]'; l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); end; + + procedure compare_nest_tab_col_jb is + l_actual sys_refcursor; + l_expected sys_refcursor; + l_actual_tab ut3.ut_key_value_pairs := ut3.ut_key_value_pairs(); + l_expected_tab ut3.ut_key_value_pairs := ut3.ut_key_value_pairs(); + l_expected_message varchar2(32767); + l_actual_message varchar2(32767); + begin + select ut3.ut_key_value_pair(rownum,'Something '||rownum) + bulk collect into l_actual_tab + from dual connect by level <=2; + + select ut3.ut_key_value_pair(rownum,'Something '||rownum) + bulk collect into l_expected_tab + from dual connect by level <=2; + + --Arrange + open l_actual for select key,value + from table(l_actual_tab) order by 1 asc; + + open l_expected for select key,value + from table(l_expected_tab) order by 1 desc; + + --Act + ut3.ut.expect(l_actual).to_equal(l_expected).join_by('KEY'); + + --Assert + ut.expect(expectations.failed_expectations_data()).to_be_empty(); + end; + + procedure compare_nest_tab_col_jb_fail is + l_actual sys_refcursor; + l_expected sys_refcursor; + l_actual_tab ut3.ut_key_value_pairs := ut3.ut_key_value_pairs(); + l_expected_tab ut3.ut_key_value_pairs := ut3.ut_key_value_pairs(); + l_expected_message varchar2(32767); + l_actual_message varchar2(32767); + begin + select ut3.ut_key_value_pair(rownum,'Something '||rownum) + bulk collect into l_actual_tab + from dual connect by level <=2; + + select ut3.ut_key_value_pair(rownum,'Somethings '||rownum) + bulk collect into l_expected_tab + from dual connect by level <=2; + + --Arrange + open l_actual for select key,value + from table(l_actual_tab) order by 1 asc; + + open l_expected for select key,value + from table(l_expected_tab) order by 1 desc; + + --Act + ut3.ut.expect(l_actual).to_equal(l_expected).join_by('KEY'); + l_expected_message := q'[%Actual: refcursor [ count = 2 ] was expected to equal: refcursor [ count = 2 ]% +%Diff:% +%Rows: [ 2 differences ]% +%PK 1 - Expected: Somethings 1% +%PK 1 - Actual: Something 1% +%PK 2 - Expected: Somethings 2% +%PK 2 - Actual: Something 2%]'; + l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; + --Assert + ut.expect(l_actual_message).to_be_like(l_expected_message); + end; + + procedure compare_nest_tab_cols_jb is + l_actual sys_refcursor; + l_expected sys_refcursor; + l_actual_tab ut3.ut_key_value_pairs := ut3.ut_key_value_pairs(); + l_expected_tab ut3.ut_key_value_pairs := ut3.ut_key_value_pairs(); + l_expected_message varchar2(32767); + l_actual_message varchar2(32767); + begin + select ut3.ut_key_value_pair(rownum,'Something '||rownum) + bulk collect into l_actual_tab + from dual connect by level <=2; + + select ut3.ut_key_value_pair(rownum,'Something '||rownum) + bulk collect into l_expected_tab + from dual connect by level <=2; + + --Arrange + open l_actual for select key,value + from table(l_actual_tab) order by 1 asc; + + open l_expected for select key,value + from table(l_expected_tab) order by 1 desc; + + --Act + ut3.ut.expect(l_actual).to_equal(l_expected).join_by(ut3.ut_varchar2_list('KEY,VALUE')); + + --Assert + ut.expect(expectations.failed_expectations_data()).to_be_empty(); + end; + + procedure compare_nest_tab_cols_jb_fail is + l_actual sys_refcursor; + l_expected sys_refcursor; + l_actual_tab ut3.ut_key_value_pairs := ut3.ut_key_value_pairs(); + l_expected_tab ut3.ut_key_value_pairs := ut3.ut_key_value_pairs(); + l_expected_message varchar2(32767); + l_actual_message varchar2(32767); + begin + select ut3.ut_key_value_pair(rownum,'Something '||rownum) + bulk collect into l_actual_tab + from dual connect by level <=2; + + select ut3.ut_key_value_pair(rownum,'Somethings '||rownum) + bulk collect into l_expected_tab + from dual connect by level <=2; + + --Arrange + open l_actual for select key,value + from table(l_actual_tab) order by 1 asc; + + open l_expected for select key,value + from table(l_expected_tab) order by 1 desc; + + --Act + ut3.ut.expect(l_actual).to_equal(l_expected).join_by(ut3.ut_varchar2_list('KEY,VALUE')); + l_expected_message := q'[%Actual: refcursor [ count = 2 ] was expected to equal: refcursor [ count = 2 ]% +%Diff:% +%Rows: [ 4 differences ]% +%PK 1Somethings 1 - Missing% +%PK 2Somethings 2 - Missing% +%PK 2Something 2 - Extra% +%PK 1Something 1 - Extra%]'; + l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; + --Assert + ut.expect(l_actual_message).to_be_like(l_expected_message); + end; end; / diff --git a/test/core/expectations/compound_data/test_expectations_cursor.pks b/test/core/expectations/compound_data/test_expectations_cursor.pks index 340047d3a..185697cf8 100644 --- a/test/core/expectations/compound_data/test_expectations_cursor.pks +++ b/test/core/expectations/compound_data/test_expectations_cursor.pks @@ -262,23 +262,35 @@ create or replace package test_expectations_cursor is --%test(Include column of same type leaving different type out and exclude different type) procedure inlc_exc_dif_cols_as_list; - --%test(Compare nested table type unordered) - procedure compare_nested_tab_col_un; + --%test(Compare object type unordered) + procedure compare_obj_typ_col_un; - --%test(Compare nested table type join by) - procedure compare_nested_tab_col_jb; + --%test(Compare object type join by) + procedure compare_obj_typ_col_jb; --%test(Compare nested table type unordered fail) - procedure comp_nest_tab_col_un_fail; + procedure comp_obj_typ_col_un_fail; - --%test(Compare nested table type join by fail) - procedure comp_nest_tab_col_jb_fail; + --%test(Compare object type join by fail) + procedure comp_obj_typ_col_jb_fail; - --%test(Compare nested table type join by multi key) - procedure comp_nest_tab_col_jb_multi; + --%test(Compare object type join by multi key) + procedure comp_obj_typ_col_jb_multi; - --%test(Compare nested table type join by missing nested key) - procedure comp_nest_tab_col_jb_nokey; + --%test(Compare object type join by missing nested key) + procedure comp_obj_typ_col_jb_nokey; + + --%test(Compare table type join by) + procedure compare_nest_tab_col_jb; + + --%test(Compare table type join by - Failure) + procedure compare_nest_tab_col_jb_fail; + + --%test(Compare table type join by mulitple columns) + procedure compare_nest_tab_cols_jb; + + --%test(Compare table type join by multiple columns- Failure) + procedure compare_nest_tab_cols_jb_fail; end; / From a7f167c93dc46b84b22d54bc5c54cec41cb46caf Mon Sep 17 00:00:00 2001 From: lwasylow Date: Tue, 22 May 2018 21:09:25 +0100 Subject: [PATCH 045/184] Update to handle new line in xmltype that caused pk value being returned with new lines char in 11g --- source/expectations/data_values/ut_compound_data_helper.pkb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/expectations/data_values/ut_compound_data_helper.pkb b/source/expectations/data_values/ut_compound_data_helper.pkb index a89258c19..ef96116d9 100644 --- a/source/expectations/data_values/ut_compound_data_helper.pkb +++ b/source/expectations/data_values/ut_compound_data_helper.pkb @@ -160,7 +160,7 @@ create or replace package body ut_compound_data_helper is function get_pk_value (a_join_by_xpath varchar2,a_item_data xmltype) return clob is l_pk_value clob; begin - select extract(a_item_data,a_join_by_xpath).getclobval() into l_pk_value from dual; + select replace((extract(a_item_data,a_join_by_xpath).getclobval()),chr(10)) into l_pk_value from dual; return l_pk_value; exception when no_data_found then return 'null'; From 9d5b9157dcea514dfb339160cd4d9652ceb4648e Mon Sep 17 00:00:00 2001 From: Walter Alexis Castro Date: Tue, 22 May 2018 16:46:13 -0600 Subject: [PATCH 046/184] ut_suite_builder modified to allow multi call to procedures in the befotest annotation --- source/core/ut_suite_builder.pkb | 43 ++++-- .../test_before_after_test_annotation.pkb | 138 ++++++++++++++++++ .../test_before_after_test_annotation.pks | 18 +++ test/install_tests.sql | 2 + 4 files changed, 192 insertions(+), 9 deletions(-) create mode 100644 test/core/annotations/test_before_after_test_annotation.pkb create mode 100644 test/core/annotations/test_before_after_test_annotation.pks diff --git a/source/core/ut_suite_builder.pkb b/source/core/ut_suite_builder.pkb index 4d6642df8..bd7e52bdd 100644 --- a/source/core/ut_suite_builder.pkb +++ b/source/core/ut_suite_builder.pkb @@ -62,7 +62,7 @@ create or replace package body ut_suite_builder is ); --holds a list of package and procedure level annotations indexed (order) by position. - --procedure level annotations are grouped under procedure name + --procedure level annotations are grouped under procedure name type tt_package_annotations is table of t_package_annotation index by t_annotation_position; --holds all annotations for object @@ -237,14 +237,39 @@ create or replace package body ut_suite_builder is a_annotation_texts tt_annotation_texts, a_event_name ut_utils.t_event_name ) is + l_string_buffer varchar2(32767); l_annotation_pos binary_integer; - begin - l_annotation_pos := a_annotation_texts.first; - while l_annotation_pos is not null loop - add_to_list(a_executables, a_owner, a_package_name, a_annotation_texts(l_annotation_pos), a_event_name ); - l_annotation_pos := a_annotation_texts.next( l_annotation_pos); - end loop; - end; + l_procedures_list ut_varchar2_list; + l_procedures_pos binary_integer; + l_components_list ut_varchar2_list; + begin + l_annotation_pos := a_annotation_texts.first; + while l_annotation_pos is not null loop + l_string_buffer := l_string_buffer||','||a_annotation_texts(l_annotation_pos); + l_annotation_pos := a_annotation_texts.next(l_annotation_pos); + end loop; + + l_procedures_list := ut_utils.trim_list_elements(ut_utils.string_to_table(l_string_buffer, ',')); + l_procedures_list := ut_utils.filter_list(l_procedures_list, '[[:alpha:]]+'); + + l_procedures_pos := l_procedures_list.first; + while l_procedures_pos is not null loop + l_components_list := ut_utils.string_to_table(l_procedures_list(l_procedures_pos), '.'); + + case(l_components_list.count()) + when 1 then + add_to_list(a_executables, a_owner, a_package_name, l_components_list(1), a_event_name ); + when 2 then + add_to_list(a_executables, a_owner, l_components_list(1), l_components_list(2), a_event_name ); + when 3 then + add_to_list(a_executables, l_components_list(1), l_components_list(2), l_components_list(3), a_event_name ); + else + null; + end case; + + l_procedures_pos := l_procedures_list.next(l_procedures_pos); + end loop; + end; procedure warning_on_duplicate_annot( a_suite in out nocopy ut_suite_item, @@ -399,7 +424,7 @@ create or replace package body ut_suite_builder is warning_on_duplicate_annot(a_suite, a_procedure_name, a_proc_annotations, gc_beforeeach); warning_on_duplicate_annot(a_suite, a_procedure_name, a_proc_annotations, gc_afterall); warning_on_duplicate_annot(a_suite, a_procedure_name, a_proc_annotations, gc_aftereach); - + if a_proc_annotations.exists(gc_test) then add_test( a_suite, a_procedure_name, a_proc_annotations); diff --git a/test/core/annotations/test_before_after_test_annotation.pkb b/test/core/annotations/test_before_after_test_annotation.pkb new file mode 100644 index 000000000..98a73450a --- /dev/null +++ b/test/core/annotations/test_before_after_test_annotation.pkb @@ -0,0 +1,138 @@ +create or replace package body test_before_after_annotations is + g_tests_results clob; + + procedure create_tests_results is + pragma autonomous_transaction; + + l_test_package_spec varchar2(32737); + l_test_package_body varchar2(32737); + l_dummy_utility_pkg_spec varchar2(32737); + l_dummy_utility_pkg_body varchar2(32737); + l_test_results ut3.ut_varchar2_list; + + procedure drop_package(a_package_name varchar2) + is + begin + execute immediate 'drop package '||a_package_name; + end; + begin + l_test_package_spec := ' + create or replace package dummy_before_after_test is + --%suite(Package to test annotations beforetest and aftertest) + + l_dummy_1 integer; + l_dummy_2 integer; + l_dummy_3 integer; + + --%beforeeach + procedure clean_global_variables; + + --%test(Beforetest with call to procedure external to the test package) + --%beforetest(dummy_utility_pkg_1.test1) + procedure beforetest_one_ext_procedure; + + + --%test(Beforetest with call to multi procedures external and interal to the test package) + --%beforetest(dummy_utility_pkg_1.test1, test2, ut3_tester.dummy_utility_pkg_1.test3) + procedure beforetest_multi_ext_procedure; + + --%test(Beforetest with call to multi procedures where one does not exist) + --%beforetest(dummy_utility_pkg_1.test1, non_existent_procedure, ut3_tester.dummy_utility_pkg_1.test3) + procedure beforetest_one_err_procedure; + + procedure test2; + end; + '; + + l_test_package_body := ' + create or replace package body dummy_before_after_test is + procedure clean_global_variables is + begin + l_dummy_1 := null; + l_dummy_2 := null; + l_dummy_3 := null; + end; + + procedure beforetest_one_ext_procedure is + begin + ut3.ut.expect(l_dummy_1).to_equal(1); + end; + + procedure beforetest_multi_ext_procedure + is + begin + ut3.ut.expect(l_dummy_1).to_equal(1); + ut3.ut.expect(l_dummy_2).to_equal(2); + ut3.ut.expect(l_dummy_3).to_equal(3); + end; + + procedure beforetest_one_err_procedure + is + begin + null; + end; + + procedure test2 is + begin + l_dummy_2 := 2; + end; + end; + '; + + l_dummy_utility_pkg_spec := ' + create or replace package dummy_utility_pkg_1 is + procedure test1; + + procedure test3; + end; + '; + + l_dummy_utility_pkg_body := ' + create or replace package body dummy_utility_pkg_1 is + procedure test1 is + begin + dummy_before_after_test.l_dummy_1 := 1; + end; + + procedure test3 is + begin + dummy_before_after_test.l_dummy_3 := 3; + end; + end; + '; + + execute immediate l_test_package_spec; + execute immediate l_test_package_body; + execute immediate l_dummy_utility_pkg_spec; + execute immediate l_dummy_utility_pkg_body; + + --Execute the tests and recolect the results + select * bulk collect into l_test_results from table(ut3.ut.run(('dummy_before_after_test'))); + + drop_package('dummy_utility_pkg_1'); + drop_package('dummy_before_after_test'); + + g_tests_results := ut3.ut_utils.table_to_clob(l_test_results); + end; + + procedure beforetest_one_ext_procedure + is + begin + ut.expect(g_tests_results).to_match('^\s*Beforetest with call to procedure external to the test package \[[\.0-9]+ sec\]\s*$','m'); + ut.expect(g_tests_results).not_to_match('beforetest_one_ext_procedure'); + end; + + procedure beforetest_multi_ext_procedure + is + begin + ut.expect(g_tests_results).to_match('^\s*Beforetest with call to multi procedures external and interal to the test package \[[\.0-9]+ sec\]\s*$','m'); + ut.expect(g_tests_results).not_to_match('beforetest_multi_ext_procedure'); + end; + + procedure beforetest_one_err_procedure + is + begin + ut.expect(g_tests_results).not_to_match('^\s*Beforetest with call to multi procedures where one does not exist \[[\.0-9]+ sec\]\s*$','m'); + ut.expect(g_tests_results).to_match('beforetest_one_err_procedure'); + end; +end; \ No newline at end of file diff --git a/test/core/annotations/test_before_after_test_annotation.pks b/test/core/annotations/test_before_after_test_annotation.pks new file mode 100644 index 000000000..aebab1495 --- /dev/null +++ b/test/core/annotations/test_before_after_test_annotation.pks @@ -0,0 +1,18 @@ +create or replace package test_before_after_annotations is + + --%suite(annotations - beforetest and aftertest) + --%suitepath(utplsql.core.annotations) + + --%beforeall + procedure create_tests_results; + + + --%test(Beforetest with call to procedure external to the test package) + procedure beforetest_one_ext_procedure; + + --%test(Beforetest with call to multi procedures external and interal to the test package) + procedure beforetest_multi_ext_procedure; + + --%test(Beforetest with call to multi procedure where one does not exist) + procedure beforetest_one_err_procedure; +end; \ No newline at end of file diff --git a/test/install_tests.sql b/test/install_tests.sql index 282e8b440..9826b2483 100644 --- a/test/install_tests.sql +++ b/test/install_tests.sql @@ -22,6 +22,8 @@ whenever oserror exit failure rollback @@core/test_ut_test.pks @@core/annotations/test_annotation_parser.pks @@core/annotations/test_annotation_manager.pks +@@core/annotations/test_before_after_test_annotation.pks +@@core/annotations/test_before_after_test_annotation.pkb @@core/expectations/test_matchers.pks @@core/test_output_buffer.pks @@core/test_file_mapper.pks From b457d69dc38ea310c4dbd2743f4c129857801875 Mon Sep 17 00:00:00 2001 From: lwasylow Date: Wed, 23 May 2018 13:11:19 +0100 Subject: [PATCH 047/184] Updates to the ordering of sets to get consistent results. --- .../data_values/ut_compound_data_helper.pkb | 15 +++++- .../test_expectations_cursor.pkb | 46 +++++++++---------- 2 files changed, 36 insertions(+), 25 deletions(-) diff --git a/source/expectations/data_values/ut_compound_data_helper.pkb b/source/expectations/data_values/ut_compound_data_helper.pkb index ef96116d9..0e8eba809 100644 --- a/source/expectations/data_values/ut_compound_data_helper.pkb +++ b/source/expectations/data_values/ut_compound_data_helper.pkb @@ -186,7 +186,14 @@ create or replace package body ut_compound_data_helper is with diff_info as (select item_hash,pk_hash,duplicate_no from ut_compound_data_diff_tmp ucdc where diff_id = :diff_guid) select rn,diff_type,diffed_row,pk_value from ( - select diff_type,diffed_row, dense_rank() over (order by pk_hash) rn,pk_value from + select + diff_type, diffed_row, + dense_rank() over (order by case when diff_type in ('Extra','Missing') then diff_type end, + case when diff_type in ('Actual','Expected') then pk_hash end, + case when diff_type in ('Extra','Missing') then pk_hash end, + case when diff_type in ('Actual','Expected') then diff_type end) rn, + pk_value, pk_hash + from ( select diff_type,diffed_row,pk_hash,pk_value from (select diff_type,data_item diffed_row,pk_hash,pk_value @@ -264,6 +271,7 @@ create or replace package body ut_compound_data_helper is where exp.pk_hash is null or act.pk_hash is null ) ) where rn <= :max_rows + order by rn, pk_hash, diff_type ]' bulk collect into l_results using a_diff_id, @@ -414,7 +422,10 @@ create or replace package body ut_compound_data_helper is ) act on exp.row_hash = act.row_hash and exp.duplicate_no = act.duplicate_no - where exp.row_hash is null or act.row_hash is null ) where rownum < :max_rows ]' + where exp.row_hash is null or act.row_hash is null + order by diffed_type, coalesce(exp.row_hash,act.row_hash), duplicate_no + ) + where rownum < :max_rows ]' bulk collect into l_results using a_diff_id, a_exclude_xpath, a_include_xpath, a_expected_dataset_guid, diff --git a/test/core/expectations/compound_data/test_expectations_cursor.pkb b/test/core/expectations/compound_data/test_expectations_cursor.pkb index 7a87aab87..130f55380 100644 --- a/test/core/expectations/compound_data/test_expectations_cursor.pkb +++ b/test/core/expectations/compound_data/test_expectations_cursor.pkb @@ -1073,10 +1073,10 @@ Rows: [ 2 differences ]% --Act ut3.ut.expect(l_actual).to_equal(l_expected).unordered; l_expected_message := q'[%Actual: refcursor [ count = 2 ] was expected to equal: refcursor [ count = 2 ]% -Diff:% -Rows: [ 2 differences ] -Missing: test-667% -Extra: test-666%]'; +%Diff:% +%Rows: [ 2 differences ]% +%Extra: test-666% +%Missing: test-667%]'; l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); @@ -1284,8 +1284,8 @@ Diff:% l_expected_message := q'[%Actual: refcursor [ count = % ] was expected to equal: refcursor [ count = % ] %Diff:% %Rows: [ 1 differences ]% -%PK TEST - Expected:%-600% -%PK TEST - Actual:%-610%]'; +%PK TEST - Actual:%-610% +%PK TEST - Expected:%-600%]'; l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); @@ -1310,8 +1310,8 @@ Diff:% l_expected_message := q'[%Actual: refcursor [ count = % ] was expected to equal: refcursor [ count = % ] %Diff:% %Rows: [ 2 differences ]% -%PK TEST-600 - Missing % -%PK TEST-610 - Extra %]'; +%PK TEST-610 - Extra% +%PK TEST-600 - Missing%]'; l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); @@ -1336,8 +1336,8 @@ Diff:% l_expected_message := q'[%Actual: refcursor [ count = % ] was expected to equal: refcursor [ count = % ] %Diff:% %Rows: [ 1 differences ]% -%PK TESTY - Expected:%-600% -%PK TESTY - Actual:%-610%]'; +%PK TESTY - Actual:%-610% +%PK TESTY - Expected:%-600%]'; l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); @@ -1493,11 +1493,11 @@ Diff:% l_expected_message := q'[%Actual: refcursor [ count = 2 ] was expected to equal: refcursor [ count = 3 ]% Diff:% Rows: [ 5 differences ] -Missing: 1Somethings 11% -Missing: 2Somethings 22% -Missing: 3Somethings 33% -Extra: 1Something 11% -Extra: 2Something 22%]'; +%Extra: 2Something 22% +%Extra: 1Something 11% +%Missing: 1Somethings 11% +%Missing: 2Somethings 22% +%Missing: 3Somethings 33%]'; l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); @@ -1621,10 +1621,10 @@ Diff:% l_expected_message := q'[%Actual: refcursor [ count = 2 ] was expected to equal: refcursor [ count = 2 ]% %Diff:% %Rows: [ 2 differences ]% -%PK 1 - Expected: Somethings 1% -%PK 1 - Actual: Something 1% -%PK 2 - Expected: Somethings 2% -%PK 2 - Actual: Something 2%]'; +%PK % - Actual: %% +%PK % - Expected: %% +%PK % - Actual: %% +%PK % - Expected: %%]'; l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); @@ -1688,10 +1688,10 @@ Diff:% l_expected_message := q'[%Actual: refcursor [ count = 2 ] was expected to equal: refcursor [ count = 2 ]% %Diff:% %Rows: [ 4 differences ]% -%PK 1Somethings 1 - Missing% -%PK 2Somethings 2 - Missing% -%PK 2Something 2 - Extra% -%PK 1Something 1 - Extra%]'; +%PK %% - Extra% +%PK %% - Extra% +%PK %% - Missing% +%PK %% - Missing%]'; l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); From 7577a952efe0409a96e816a2d82cae8f191efa8a Mon Sep 17 00:00:00 2001 From: lwasylow Date: Wed, 23 May 2018 19:28:00 +0100 Subject: [PATCH 048/184] Revert "Updates to the ordering of sets to get consistent results." This reverts commit b457d69dc38ea310c4dbd2743f4c129857801875. --- .../data_values/ut_compound_data_helper.pkb | 15 +----- .../test_expectations_cursor.pkb | 46 +++++++++---------- 2 files changed, 25 insertions(+), 36 deletions(-) diff --git a/source/expectations/data_values/ut_compound_data_helper.pkb b/source/expectations/data_values/ut_compound_data_helper.pkb index 0e8eba809..ef96116d9 100644 --- a/source/expectations/data_values/ut_compound_data_helper.pkb +++ b/source/expectations/data_values/ut_compound_data_helper.pkb @@ -186,14 +186,7 @@ create or replace package body ut_compound_data_helper is with diff_info as (select item_hash,pk_hash,duplicate_no from ut_compound_data_diff_tmp ucdc where diff_id = :diff_guid) select rn,diff_type,diffed_row,pk_value from ( - select - diff_type, diffed_row, - dense_rank() over (order by case when diff_type in ('Extra','Missing') then diff_type end, - case when diff_type in ('Actual','Expected') then pk_hash end, - case when diff_type in ('Extra','Missing') then pk_hash end, - case when diff_type in ('Actual','Expected') then diff_type end) rn, - pk_value, pk_hash - from + select diff_type,diffed_row, dense_rank() over (order by pk_hash) rn,pk_value from ( select diff_type,diffed_row,pk_hash,pk_value from (select diff_type,data_item diffed_row,pk_hash,pk_value @@ -271,7 +264,6 @@ create or replace package body ut_compound_data_helper is where exp.pk_hash is null or act.pk_hash is null ) ) where rn <= :max_rows - order by rn, pk_hash, diff_type ]' bulk collect into l_results using a_diff_id, @@ -422,10 +414,7 @@ create or replace package body ut_compound_data_helper is ) act on exp.row_hash = act.row_hash and exp.duplicate_no = act.duplicate_no - where exp.row_hash is null or act.row_hash is null - order by diffed_type, coalesce(exp.row_hash,act.row_hash), duplicate_no - ) - where rownum < :max_rows ]' + where exp.row_hash is null or act.row_hash is null ) where rownum < :max_rows ]' bulk collect into l_results using a_diff_id, a_exclude_xpath, a_include_xpath, a_expected_dataset_guid, diff --git a/test/core/expectations/compound_data/test_expectations_cursor.pkb b/test/core/expectations/compound_data/test_expectations_cursor.pkb index 130f55380..7a87aab87 100644 --- a/test/core/expectations/compound_data/test_expectations_cursor.pkb +++ b/test/core/expectations/compound_data/test_expectations_cursor.pkb @@ -1073,10 +1073,10 @@ Rows: [ 2 differences ]% --Act ut3.ut.expect(l_actual).to_equal(l_expected).unordered; l_expected_message := q'[%Actual: refcursor [ count = 2 ] was expected to equal: refcursor [ count = 2 ]% -%Diff:% -%Rows: [ 2 differences ]% -%Extra: test-666% -%Missing: test-667%]'; +Diff:% +Rows: [ 2 differences ] +Missing: test-667% +Extra: test-666%]'; l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); @@ -1284,8 +1284,8 @@ Diff:% l_expected_message := q'[%Actual: refcursor [ count = % ] was expected to equal: refcursor [ count = % ] %Diff:% %Rows: [ 1 differences ]% -%PK TEST - Actual:%-610% -%PK TEST - Expected:%-600%]'; +%PK TEST - Expected:%-600% +%PK TEST - Actual:%-610%]'; l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); @@ -1310,8 +1310,8 @@ Diff:% l_expected_message := q'[%Actual: refcursor [ count = % ] was expected to equal: refcursor [ count = % ] %Diff:% %Rows: [ 2 differences ]% -%PK TEST-610 - Extra% -%PK TEST-600 - Missing%]'; +%PK TEST-600 - Missing % +%PK TEST-610 - Extra %]'; l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); @@ -1336,8 +1336,8 @@ Diff:% l_expected_message := q'[%Actual: refcursor [ count = % ] was expected to equal: refcursor [ count = % ] %Diff:% %Rows: [ 1 differences ]% -%PK TESTY - Actual:%-610% -%PK TESTY - Expected:%-600%]'; +%PK TESTY - Expected:%-600% +%PK TESTY - Actual:%-610%]'; l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); @@ -1493,11 +1493,11 @@ Diff:% l_expected_message := q'[%Actual: refcursor [ count = 2 ] was expected to equal: refcursor [ count = 3 ]% Diff:% Rows: [ 5 differences ] -%Extra: 2Something 22% -%Extra: 1Something 11% -%Missing: 1Somethings 11% -%Missing: 2Somethings 22% -%Missing: 3Somethings 33%]'; +Missing: 1Somethings 11% +Missing: 2Somethings 22% +Missing: 3Somethings 33% +Extra: 1Something 11% +Extra: 2Something 22%]'; l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); @@ -1621,10 +1621,10 @@ Diff:% l_expected_message := q'[%Actual: refcursor [ count = 2 ] was expected to equal: refcursor [ count = 2 ]% %Diff:% %Rows: [ 2 differences ]% -%PK % - Actual: %% -%PK % - Expected: %% -%PK % - Actual: %% -%PK % - Expected: %%]'; +%PK 1 - Expected: Somethings 1% +%PK 1 - Actual: Something 1% +%PK 2 - Expected: Somethings 2% +%PK 2 - Actual: Something 2%]'; l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); @@ -1688,10 +1688,10 @@ Diff:% l_expected_message := q'[%Actual: refcursor [ count = 2 ] was expected to equal: refcursor [ count = 2 ]% %Diff:% %Rows: [ 4 differences ]% -%PK %% - Extra% -%PK %% - Extra% -%PK %% - Missing% -%PK %% - Missing%]'; +%PK 1Somethings 1 - Missing% +%PK 2Somethings 2 - Missing% +%PK 2Something 2 - Extra% +%PK 1Something 1 - Extra%]'; l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); From 890c1d2ff4f95e6022c3c104dbc6db3b77a40b4e Mon Sep 17 00:00:00 2001 From: lwasylow Date: Wed, 23 May 2018 19:44:49 +0100 Subject: [PATCH 049/184] Refactoring to simplify code --- .../data_values/ut_data_value_refcursor.tpb | 49 +++++++------------ .../data_values/ut_data_value_refcursor.tps | 2 - source/expectations/matchers/ut_equal.tpb | 6 +-- 3 files changed, 20 insertions(+), 37 deletions(-) diff --git a/source/expectations/data_values/ut_data_value_refcursor.tpb b/source/expectations/data_values/ut_data_value_refcursor.tpb index fe8c1f443..5b8ab8463 100644 --- a/source/expectations/data_values/ut_data_value_refcursor.tpb +++ b/source/expectations/data_values/ut_data_value_refcursor.tpb @@ -210,29 +210,13 @@ create or replace type body ut_data_value_refcursor as return l_result_string; end; - overriding member function compare_implementation(a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2) return integer is - l_result integer := 0; - l_other ut_data_value_refcursor; - begin - if not a_other is of (ut_data_value_refcursor) then - raise value_error; - end if; - - l_other := treat(a_other as ut_data_value_refcursor); - --if column names/types are not equal - build a diff of column names and types - if ut_compound_data_helper.columns_hash( self, a_exclude_xpath, a_include_xpath ) - != ut_compound_data_helper.columns_hash( l_other, a_exclude_xpath, a_include_xpath ) - then - l_result := 1; - end if; - l_result := l_result + (self as ut_compound_data_value).compare_implementation(a_other, a_exclude_xpath, a_include_xpath); - return l_result; - end; - overriding member function compare_implementation (a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2, a_join_by_xpath varchar2, a_unordered boolean) return integer is l_result integer := 0; l_other ut_data_value_refcursor; - l_missing_pk ut_compound_data_helper.tt_missing_pk := ut_compound_data_helper.tt_missing_pk(); + function is_pk_missing (a_pk_missing_tab ut_compound_data_helper.tt_missing_pk) return integer is + begin + return case when a_pk_missing_tab.count > 0 then 1 else 0 end; + end; begin if not a_other is of (ut_data_value_refcursor) then raise value_error; @@ -240,21 +224,26 @@ create or replace type body ut_data_value_refcursor as l_other := treat(a_other as ut_data_value_refcursor); - l_missing_pk := ut_compound_data_helper.is_pk_exists(self.key_info, l_other.key_info, a_exclude_xpath, a_include_xpath,a_join_by_xpath); --if we join by key and key is missing fail and report error - if a_join_by_xpath is not null and l_missing_pk.count > 0 then - l_result := 1; - return l_result; + if a_join_by_xpath is not null then + l_result := is_pk_missing(ut_compound_data_helper.is_pk_exists(self.key_info, l_other.key_info, a_exclude_xpath, a_include_xpath,a_join_by_xpath)); end if; - --if column names/types are not equal - build a diff of column names and types - if ut_compound_data_helper.columns_hash( self, a_exclude_xpath, a_include_xpath ) - != ut_compound_data_helper.columns_hash( l_other, a_exclude_xpath, a_include_xpath ) - then - l_result := 1; + if l_result = 0 then + --if column names/types are not equal - build a diff of column names and types + if ut_compound_data_helper.columns_hash( self, a_exclude_xpath, a_include_xpath ) + != ut_compound_data_helper.columns_hash( l_other, a_exclude_xpath, a_include_xpath ) + then + l_result := 1; + end if; + + if a_unordered then + l_result := l_result + (self as ut_compound_data_value).compare_implementation(a_other, a_exclude_xpath, a_include_xpath, a_join_by_xpath, a_unordered); + else + l_result := l_result + (self as ut_compound_data_value).compare_implementation(a_other, a_exclude_xpath, a_include_xpath); + end if; end if; - l_result := l_result + (self as ut_compound_data_value).compare_implementation(a_other, a_exclude_xpath, a_include_xpath, a_join_by_xpath, a_unordered); return l_result; end; diff --git a/source/expectations/data_values/ut_data_value_refcursor.tps b/source/expectations/data_values/ut_data_value_refcursor.tps index c73aaa538..4e175ce6b 100644 --- a/source/expectations/data_values/ut_data_value_refcursor.tps +++ b/source/expectations/data_values/ut_data_value_refcursor.tps @@ -39,8 +39,6 @@ create or replace type ut_data_value_refcursor under ut_compound_data_value( member procedure init(self in out nocopy ut_data_value_refcursor, a_value sys_refcursor), overriding member function to_string return varchar2, overriding member function diff( a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2, a_join_by_xpath varchar2, a_unordered boolean := false ) return varchar2, - overriding member function compare_implementation(a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2) return integer, overriding member function compare_implementation(a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2, a_join_by_xpath varchar2, a_unordered boolean) return integer - ) / diff --git a/source/expectations/matchers/ut_equal.tpb b/source/expectations/matchers/ut_equal.tpb index f9e6baaeb..3a163e9c9 100644 --- a/source/expectations/matchers/ut_equal.tpb +++ b/source/expectations/matchers/ut_equal.tpb @@ -233,11 +233,7 @@ create or replace type body ut_equal as if self.expected is of (ut_data_value_anydata) then l_result := 0 = treat(self.expected as ut_data_value_anydata).compare_implementation(a_actual, get_exclude_xpath(), get_include_xpath()); elsif self.expected is of (ut_data_value_refcursor) then - if get_unordered then - l_result := 0 = treat(self.expected as ut_data_value_refcursor).compare_implementation(a_actual, get_exclude_xpath(), get_include_xpath(), get_join_by_xpath(), get_unordered()); - else - l_result := 0 = treat(self.expected as ut_data_value_refcursor).compare_implementation(a_actual, get_exclude_xpath(), get_include_xpath()); - end if; + l_result := 0 = treat(self.expected as ut_data_value_refcursor).compare_implementation(a_actual, get_exclude_xpath(), get_include_xpath(), get_join_by_xpath(), get_unordered()); else l_result := equal_with_nulls((self.expected = a_actual), a_actual); end if; From 4d8b964a9df6ca1488219d59989ea9106bf6f708 Mon Sep 17 00:00:00 2001 From: lwasylow Date: Wed, 23 May 2018 19:55:08 +0100 Subject: [PATCH 050/184] Revert "Revert "Updates to the ordering of sets to get consistent results."" This reverts commit 7577a952efe0409a96e816a2d82cae8f191efa8a. --- .../data_values/ut_compound_data_helper.pkb | 15 +++++- .../test_expectations_cursor.pkb | 46 +++++++++---------- 2 files changed, 36 insertions(+), 25 deletions(-) diff --git a/source/expectations/data_values/ut_compound_data_helper.pkb b/source/expectations/data_values/ut_compound_data_helper.pkb index ef96116d9..0e8eba809 100644 --- a/source/expectations/data_values/ut_compound_data_helper.pkb +++ b/source/expectations/data_values/ut_compound_data_helper.pkb @@ -186,7 +186,14 @@ create or replace package body ut_compound_data_helper is with diff_info as (select item_hash,pk_hash,duplicate_no from ut_compound_data_diff_tmp ucdc where diff_id = :diff_guid) select rn,diff_type,diffed_row,pk_value from ( - select diff_type,diffed_row, dense_rank() over (order by pk_hash) rn,pk_value from + select + diff_type, diffed_row, + dense_rank() over (order by case when diff_type in ('Extra','Missing') then diff_type end, + case when diff_type in ('Actual','Expected') then pk_hash end, + case when diff_type in ('Extra','Missing') then pk_hash end, + case when diff_type in ('Actual','Expected') then diff_type end) rn, + pk_value, pk_hash + from ( select diff_type,diffed_row,pk_hash,pk_value from (select diff_type,data_item diffed_row,pk_hash,pk_value @@ -264,6 +271,7 @@ create or replace package body ut_compound_data_helper is where exp.pk_hash is null or act.pk_hash is null ) ) where rn <= :max_rows + order by rn, pk_hash, diff_type ]' bulk collect into l_results using a_diff_id, @@ -414,7 +422,10 @@ create or replace package body ut_compound_data_helper is ) act on exp.row_hash = act.row_hash and exp.duplicate_no = act.duplicate_no - where exp.row_hash is null or act.row_hash is null ) where rownum < :max_rows ]' + where exp.row_hash is null or act.row_hash is null + order by diffed_type, coalesce(exp.row_hash,act.row_hash), duplicate_no + ) + where rownum < :max_rows ]' bulk collect into l_results using a_diff_id, a_exclude_xpath, a_include_xpath, a_expected_dataset_guid, diff --git a/test/core/expectations/compound_data/test_expectations_cursor.pkb b/test/core/expectations/compound_data/test_expectations_cursor.pkb index 7a87aab87..130f55380 100644 --- a/test/core/expectations/compound_data/test_expectations_cursor.pkb +++ b/test/core/expectations/compound_data/test_expectations_cursor.pkb @@ -1073,10 +1073,10 @@ Rows: [ 2 differences ]% --Act ut3.ut.expect(l_actual).to_equal(l_expected).unordered; l_expected_message := q'[%Actual: refcursor [ count = 2 ] was expected to equal: refcursor [ count = 2 ]% -Diff:% -Rows: [ 2 differences ] -Missing: test-667% -Extra: test-666%]'; +%Diff:% +%Rows: [ 2 differences ]% +%Extra: test-666% +%Missing: test-667%]'; l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); @@ -1284,8 +1284,8 @@ Diff:% l_expected_message := q'[%Actual: refcursor [ count = % ] was expected to equal: refcursor [ count = % ] %Diff:% %Rows: [ 1 differences ]% -%PK TEST - Expected:%-600% -%PK TEST - Actual:%-610%]'; +%PK TEST - Actual:%-610% +%PK TEST - Expected:%-600%]'; l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); @@ -1310,8 +1310,8 @@ Diff:% l_expected_message := q'[%Actual: refcursor [ count = % ] was expected to equal: refcursor [ count = % ] %Diff:% %Rows: [ 2 differences ]% -%PK TEST-600 - Missing % -%PK TEST-610 - Extra %]'; +%PK TEST-610 - Extra% +%PK TEST-600 - Missing%]'; l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); @@ -1336,8 +1336,8 @@ Diff:% l_expected_message := q'[%Actual: refcursor [ count = % ] was expected to equal: refcursor [ count = % ] %Diff:% %Rows: [ 1 differences ]% -%PK TESTY - Expected:%-600% -%PK TESTY - Actual:%-610%]'; +%PK TESTY - Actual:%-610% +%PK TESTY - Expected:%-600%]'; l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); @@ -1493,11 +1493,11 @@ Diff:% l_expected_message := q'[%Actual: refcursor [ count = 2 ] was expected to equal: refcursor [ count = 3 ]% Diff:% Rows: [ 5 differences ] -Missing: 1Somethings 11% -Missing: 2Somethings 22% -Missing: 3Somethings 33% -Extra: 1Something 11% -Extra: 2Something 22%]'; +%Extra: 2Something 22% +%Extra: 1Something 11% +%Missing: 1Somethings 11% +%Missing: 2Somethings 22% +%Missing: 3Somethings 33%]'; l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); @@ -1621,10 +1621,10 @@ Diff:% l_expected_message := q'[%Actual: refcursor [ count = 2 ] was expected to equal: refcursor [ count = 2 ]% %Diff:% %Rows: [ 2 differences ]% -%PK 1 - Expected: Somethings 1% -%PK 1 - Actual: Something 1% -%PK 2 - Expected: Somethings 2% -%PK 2 - Actual: Something 2%]'; +%PK % - Actual: %% +%PK % - Expected: %% +%PK % - Actual: %% +%PK % - Expected: %%]'; l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); @@ -1688,10 +1688,10 @@ Diff:% l_expected_message := q'[%Actual: refcursor [ count = 2 ] was expected to equal: refcursor [ count = 2 ]% %Diff:% %Rows: [ 4 differences ]% -%PK 1Somethings 1 - Missing% -%PK 2Somethings 2 - Missing% -%PK 2Something 2 - Extra% -%PK 1Something 1 - Extra%]'; +%PK %% - Extra% +%PK %% - Extra% +%PK %% - Missing% +%PK %% - Missing%]'; l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); From 0d87f4fcf61228ee246ee701408bfb157e6988d2 Mon Sep 17 00:00:00 2001 From: lwasylow Date: Thu, 24 May 2018 18:56:13 +0100 Subject: [PATCH 051/184] Update to tests --- source/core/types/ut_executable.tps | 2 +- test/api/test_ut_run.pkb | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/source/core/types/ut_executable.tps b/source/core/types/ut_executable.tps index 044ef6719..8cbebf6bd 100644 --- a/source/core/types/ut_executable.tps +++ b/source/core/types/ut_executable.tps @@ -1,4 +1,4 @@ -create or replace type ut_executable force under ut_event_item( +create or replace type ut_executable under ut_event_item( /* utPLSQL - Version 3 Copyright 2016 - 2017 utPLSQL Project diff --git a/test/api/test_ut_run.pkb b/test/api/test_ut_run.pkb index 1e8dbaa33..9c00fcc93 100644 --- a/test/api/test_ut_run.pkb +++ b/test/api/test_ut_run.pkb @@ -163,15 +163,15 @@ end;]'; begin execute immediate q'[select count(1) from all_objects o where o.owner = :object_owner and o.object_type = 'PACKAGE' and o.status = 'INVALID' and o.object_name= :object_name]' into l_is_invalid - using user,'FAILING_INVALID_SPEC'; + using user,'INVALID_PCKAG_THAT_REVALIDATES'; select * bulk collect into l_results - from table(ut3.ut.run('failing_invalid_spec')); + from table(ut3.ut.run('invalid_pckag_that_revalidates')); l_actual := ut3.ut_utils.table_to_clob(l_results); ut.expect(1).to_equal(l_is_invalid); - ut.expect(l_actual).to_be_like('%failing_invalid_spec%invalidspecs [% sec]% + ut.expect(l_actual).to_be_like('%invalid_pckag_that_revalidates%invalidspecs [% sec]% %Finished in % seconds% %1 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)%'); @@ -187,7 +187,7 @@ end;]'; c_test constant varchar2(1) := 'Y'; end;]'; - execute immediate q'[create or replace package failing_invalid_spec as + execute immediate q'[create or replace package invalid_pckag_that_revalidates as --%suite g_var varchar2(1) := parent_specs.c_test; @@ -195,7 +195,7 @@ end;]'; procedure test1; end;]'; - execute immediate q'[create or replace package body failing_invalid_spec as + execute immediate q'[create or replace package body invalid_pckag_that_revalidates as procedure test1 is begin ut.expect('Y').to_equal(g_var); end; end;]'; @@ -212,7 +212,7 @@ end;]'; procedure drop_test_package is pragma autonomous_transaction; begin - execute immediate 'drop package failing_invalid_spec'; + execute immediate 'drop package invalid_pckag_that_revalidates'; execute immediate 'drop package parent_specs'; end; From c8bea7daa412db3c397f60810e98909d9327da51 Mon Sep 17 00:00:00 2001 From: Travis CI Date: Thu, 24 May 2018 18:30:28 +0000 Subject: [PATCH 052/184] Updated project version after build [skip ci] --- source/core/ut_utils.pks | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/core/ut_utils.pks b/source/core/ut_utils.pks index 203e4a091..b0055a98d 100644 --- a/source/core/ut_utils.pks +++ b/source/core/ut_utils.pks @@ -21,7 +21,7 @@ create or replace package ut_utils authid definer is * */ - gc_version constant varchar2(50) := 'v3.1.2.1913-develop'; + gc_version constant varchar2(50) := 'v3.1.2.1928-develop'; /* Constants: Event names */ subtype t_event_name is varchar2(30); From f77f13abdeb33f7c2ad1e3d77cb0f269a292f0c2 Mon Sep 17 00:00:00 2001 From: lwasylow Date: Thu, 24 May 2018 20:33:19 +0100 Subject: [PATCH 053/184] Update to test and docs --- docs/userguide/advanced_data_comparison.md | 2 ++ .../test_expectations_cursor.pkb | 35 +++++++++++++++++++ .../test_expectations_cursor.pks | 3 ++ 3 files changed, 40 insertions(+) diff --git a/docs/userguide/advanced_data_comparison.md b/docs/userguide/advanced_data_comparison.md index cc488da11..c776f8596 100644 --- a/docs/userguide/advanced_data_comparison.md +++ b/docs/userguide/advanced_data_comparison.md @@ -143,6 +143,8 @@ You can now join two cursors by defining a primary key or composite key that wil Join by option can be used in conjunction with include or exclude options. However if any of the join keys is part of exclude set, comparison will fail and report to user that sets could not be joined on specific key (excluded). +Join by options currently doesn't support nested table inside cursor. + ```sql procedure join_by_username is l_actual sys_refcursor; diff --git a/test/core/expectations/compound_data/test_expectations_cursor.pkb b/test/core/expectations/compound_data/test_expectations_cursor.pkb index 130f55380..efb1ca845 100644 --- a/test/core/expectations/compound_data/test_expectations_cursor.pkb +++ b/test/core/expectations/compound_data/test_expectations_cursor.pkb @@ -1696,5 +1696,40 @@ Diff:% --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); end; + + procedure comparet_tabtype_as_cols_jb is + l_actual sys_refcursor; + l_expected sys_refcursor; + l_actual_tab ut3.ut_key_value_pairs := ut3.ut_key_value_pairs(); + l_expected_tab ut3.ut_key_value_pairs := ut3.ut_key_value_pairs(); + l_expected_message varchar2(32767); + l_actual_message varchar2(32767); + begin + select ut3.ut_key_value_pair(rownum,'Something '||rownum) + bulk collect into l_actual_tab + from dual connect by level <=2; + + select ut3.ut_key_value_pair(rownum,'Somethings '||rownum) + bulk collect into l_expected_tab + from dual connect by level <=2; + + --Arrange + open l_actual for select rownum rn, l_actual_tab + from dual connect by level <=2; + + open l_expected for select key,value + from table(l_expected_tab) order by 1 desc; + + --Act + ut3.ut.expect(l_actual).to_equal(l_expected).join_by(ut3.ut_varchar2_list('RN,L_ACTUAL_TAB/KEY')); + ut3.ut.fail('Expected Exception'); + exception + when others then + l_expected_message := q'[%PLS-00306: wrong number or types of arguments in call to 'CONVERTOBJECT'%]'; + l_actual_message := SQLERRM; + --Assert + ut.expect(l_actual_message).to_be_like(l_expected_message); + end; + end; / diff --git a/test/core/expectations/compound_data/test_expectations_cursor.pks b/test/core/expectations/compound_data/test_expectations_cursor.pks index 185697cf8..bd8cf45a0 100644 --- a/test/core/expectations/compound_data/test_expectations_cursor.pks +++ b/test/core/expectations/compound_data/test_expectations_cursor.pks @@ -292,5 +292,8 @@ create or replace package test_expectations_cursor is --%test(Compare table type join by multiple columns- Failure) procedure compare_nest_tab_cols_jb_fail; + --%test(Compare table type as column join by multiple columns - PLS Failure) + procedure comparet_tabtype_as_cols_jb; + end; / From 46ac6a248076c8678c975542156ad776fa3b5514 Mon Sep 17 00:00:00 2001 From: Travis CI Date: Fri, 25 May 2018 20:54:52 +0000 Subject: [PATCH 054/184] Updated project version after build [skip ci] --- source/core/ut_utils.pks | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/core/ut_utils.pks b/source/core/ut_utils.pks index b0055a98d..b8b9de64f 100644 --- a/source/core/ut_utils.pks +++ b/source/core/ut_utils.pks @@ -21,7 +21,7 @@ create or replace package ut_utils authid definer is * */ - gc_version constant varchar2(50) := 'v3.1.2.1928-develop'; + gc_version constant varchar2(50) := 'v3.1.2.1933-develop'; /* Constants: Event names */ subtype t_event_name is varchar2(30); From 86a4f0980e7c39c7b92f72be4c150b0d6c13d3ae Mon Sep 17 00:00:00 2001 From: lwasylow Date: Sun, 27 May 2018 09:19:34 +0100 Subject: [PATCH 055/184] Fixes to compare when it trying to get anydata out of collection Updated documentation --- docs/userguide/advanced_data_comparison.md | 53 +++- .../ut_curr_usr_compound_helper.pkb | 100 ++++++- .../ut_curr_usr_compound_helper.pks | 8 +- .../data_values/ut_data_value_refcursor.tpb | 30 +- .../data_values/ut_data_value_refcursor.tps | 7 +- .../test_expectations_cursor.pkb | 278 +++++++++++++++++- .../test_expectations_cursor.pks | 25 +- 7 files changed, 465 insertions(+), 36 deletions(-) diff --git a/docs/userguide/advanced_data_comparison.md b/docs/userguide/advanced_data_comparison.md index c776f8596..3eb45fe50 100644 --- a/docs/userguide/advanced_data_comparison.md +++ b/docs/userguide/advanced_data_comparison.md @@ -143,8 +143,6 @@ You can now join two cursors by defining a primary key or composite key that wil Join by option can be used in conjunction with include or exclude options. However if any of the join keys is part of exclude set, comparison will fail and report to user that sets could not be joined on specific key (excluded). -Join by options currently doesn't support nested table inside cursor. - ```sql procedure join_by_username is l_actual sys_refcursor; @@ -171,6 +169,57 @@ This will show you difference in row 'TEST' regardless of order. Assumption is that join by is made by column name so that what will be displayed as part of results. +Join by options currently doesn't support nested table inside cursor comparison, however is still possible to compare a collection as a whole. + +Example. + +```sql + procedure compare_collection_in_rec is + l_actual sys_refcursor; + l_expected sys_refcursor; + l_actual_tab ut3.ut_annotated_object; + l_expected_tab ut3.ut_annotated_object; + l_expected_message varchar2(32767); + l_actual_message varchar2(32767); + begin + select ut3.ut_annotated_object('TEST','TEST','TEST', + ut3.ut_annotations(ut3.ut_annotation(1,'test','test','test'), + ut3.ut_annotation(2,'test','test','test')) + ) + into l_actual_tab from dual; + + select ut3.ut_annotated_object('TEST','TEST','TEST', + ut3.ut_annotations(ut3.ut_annotation(1,'test','test','test'), + ut3.ut_annotation(2,'test','test','test')) + ) + into l_expected_tab from dual; + + --Arrange + open l_actual for select l_actual_tab as nested_table from dual; + + open l_expected for select l_expected_tab as nested_table from dual; + + --Act + ut3.ut.expect(l_actual).to_equal(l_expected).join_by('NESTED_TABLE/ANNOTATIONS'); + + end; +``` + + + +In case when a there is detected collection inside cursor and we cannot join key. Comparison will present a failed joins and also a message about collection being detected. + +```sql +Actual: refcursor [ count = 1 ] was expected to equal: refcursor [ count = 1 ] +Diff: + Unable to join sets: + Join key NESTED_TABLE/ANNOTATIONS/TEXT does not exists in expected + Join key NESTED_TABLE/ANNOTATIONS/TEXT does not exists in actual + Please make sure that your join clause is not refferring to collection element +``` + + + **Please note that .join_by option will take longer to process due to need of parsing via primary keys.** diff --git a/source/expectations/data_values/ut_curr_usr_compound_helper.pkb b/source/expectations/data_values/ut_curr_usr_compound_helper.pkb index 7885b15fe..c07b2801b 100644 --- a/source/expectations/data_values/ut_curr_usr_compound_helper.pkb +++ b/source/expectations/data_values/ut_curr_usr_compound_helper.pkb @@ -1,18 +1,44 @@ create or replace package body ut_curr_usr_compound_helper is type t_type_name_map is table of varchar2(100) index by binary_integer; - g_type_name_map t_type_name_map; - g_anytype_name_map t_type_name_map; - g_user_defined_type pls_integer := dbms_sql.user_defined_type; - + g_type_name_map t_type_name_map; + g_anytype_name_map t_type_name_map; + g_anytype_collection_name t_type_name_map; + g_user_defined_type pls_integer := dbms_sql.user_defined_type; + g_is_collection boolean := false; + + procedure set_collection_state(a_is_collection boolean) is + begin + --Make sure that we set a g_is_collection only once so we dont reset from true to false. + if not g_is_collection then + g_is_collection := a_is_collection; + end if; + end; function get_column_type(a_desc_rec dbms_sql.desc_rec3,a_desc_user_types boolean := false) return ut_key_anyval_pair is l_data ut_data_value; l_result ut_key_anyval_pair; - l_data_type varchar2(500) := 'unknown datatype'; + l_data_type varchar2(500) := 'unknown datatype'; + + function is_collection (a_owner varchar2,a_type_name varchar2) return boolean is + l_type_view varchar2(200) := ut_metadata.get_dba_view('dba_types'); + l_typecode varchar2(100); + begin + execute immediate 'select typecode from '||l_type_view ||' + where owner = :owner and type_name = :typename' + into l_typecode using a_owner,a_type_name; + + return l_typecode = 'COLLECTION'; + end; + begin if g_type_name_map.exists(a_desc_rec.col_type) then l_data := ut_data_value_varchar2(g_type_name_map(a_desc_rec.col_type)); + /*If its a collection regardless is we want to describe user defined types we will return just a name + and capture that name */ + elsif a_desc_rec.col_type = g_user_defined_type and is_collection(a_desc_rec.col_schema_name,a_desc_rec.col_type_name) then + l_data := ut_data_value_varchar2(a_desc_rec.col_schema_name||'.'||a_desc_rec.col_type_name); + set_collection_state(true); elsif a_desc_rec.col_type = g_user_defined_type and a_desc_user_types then l_data :=ut_data_value_xmltype(get_user_defined_type(a_desc_rec.col_schema_name,a_desc_rec.col_type_name)); elsif a_desc_rec.col_schema_name is not null and a_desc_rec.col_type_name is not null then @@ -47,6 +73,52 @@ create or replace package body ut_curr_usr_compound_helper is return l_columns_tab; end; + procedure get_descr_cursor(a_cursor in out nocopy sys_refcursor,a_columns_tab in out ut_key_anyval_pairs, + a_join_by_tab in out ut_key_anyval_pairs) is + l_cursor_number integer; + l_columns_count pls_integer; + l_columns_desc dbms_sql.desc_tab3; + begin + if a_cursor is null or not a_cursor%isopen then + a_columns_tab := null; + a_join_by_tab := null; + end if; + l_cursor_number := dbms_sql.to_cursor_number( a_cursor ); + dbms_sql.describe_columns3( l_cursor_number, l_columns_count, l_columns_desc ); + a_cursor := dbms_sql.to_refcursor( l_cursor_number ); + a_columns_tab := get_columns_info( l_columns_desc, l_columns_count,false); + a_join_by_tab := get_columns_info( l_columns_desc, l_columns_count,true); + end; + + procedure get_columns_info(a_cursor in out nocopy sys_refcursor,a_columns_info out xmltype, + a_join_by_info out xmltype, a_contains_collection out number) is + l_columns_info xmltype; + l_join_by_info xmltype; + l_result_tmp xmltype; + l_columns_tab ut_key_anyval_pairs; + l_join_by_tab ut_key_anyval_pairs; + begin + + get_descr_cursor(a_cursor,l_columns_tab,l_join_by_tab); + + for i in 1..l_columns_tab.COUNT + loop + l_result_tmp := ut_compound_data_helper.get_column_info_xml(l_columns_tab(i)); + select xmlconcat(l_columns_info,l_result_tmp) into l_columns_info from dual; + end loop; + + for i in 1..l_join_by_tab.COUNT + loop + l_result_tmp := ut_compound_data_helper.get_column_info_xml(l_join_by_tab(i)); + select xmlconcat(l_join_by_info,l_result_tmp) into l_join_by_info from dual; + end loop; + + select XMLELEMENT("ROW",l_columns_info ),XMLELEMENT("ROW",l_join_by_info ) + into a_columns_info,a_join_by_info from dual; + + a_contains_collection := ut_utils.boolean_to_int(g_is_collection); + end; + function get_columns_info(a_cursor in out nocopy sys_refcursor,a_desc_user_types boolean := false) return xmltype is l_result xmltype; l_result_tmp xmltype; @@ -115,7 +187,10 @@ create or replace package body ut_curr_usr_compound_helper is l_result.extend; l_result(l_result.last) := ut_key_value_pair(l_aname, g_anytype_name_map(l_attribute_typecode)); - + --check for collection + if g_anytype_collection_name.exists(l_attribute_typecode) then + set_collection_state(true); + end if; end loop; return l_result; end; @@ -126,7 +201,8 @@ create or replace package body ut_curr_usr_compound_helper is l_typecode pls_integer; l_result xmltype; l_columns_tab ut_key_value_pairs := ut_key_value_pairs(); - begin + + begin execute immediate 'declare l_v '||a_owner||'.'||a_type_name||'; begin @@ -138,7 +214,7 @@ create or replace package body ut_curr_usr_compound_helper is select xmlagg(xmlelement(evalname key,value)) into l_result from table(l_columns_tab); - + return l_result; end; @@ -161,6 +237,14 @@ create or replace package body ut_curr_usr_compound_helper is g_anytype_name_map(dbms_types.typecode_bfloat) := 'BINARY_FLOAT'; g_anytype_name_map(dbms_types.typecode_bdouble) := 'BINARY_DOUBLE'; g_anytype_name_map(dbms_types.typecode_urowid) := 'UROWID'; + g_anytype_name_map(dbms_types.typecode_varray) := 'VARRRAY'; + g_anytype_name_map(dbms_types.typecode_table) := 'TABLE'; + g_anytype_name_map(dbms_types.typecode_namedcollection) := 'NAMEDCOLLECTION'; + + g_anytype_collection_name(dbms_types.typecode_varray) := 'VARRRAY'; + g_anytype_collection_name(dbms_types.typecode_table) := 'TABLE'; + g_anytype_collection_name(dbms_types.typecode_namedcollection) := 'NAMEDCOLLECTION'; + g_type_name_map( dbms_sql.binary_bouble_type ) := 'BINARY_DOUBLE'; g_type_name_map( dbms_sql.bfile_type ) := 'BFILE'; diff --git a/source/expectations/data_values/ut_curr_usr_compound_helper.pks b/source/expectations/data_values/ut_curr_usr_compound_helper.pks index 3955f49c8..7c622f0c2 100644 --- a/source/expectations/data_values/ut_curr_usr_compound_helper.pks +++ b/source/expectations/data_values/ut_curr_usr_compound_helper.pks @@ -1,8 +1,12 @@ create or replace package ut_curr_usr_compound_helper authid current_user is - function get_columns_info(a_cursor in out nocopy sys_refcursor,a_desc_user_types boolean := false) return xmltype; + procedure get_columns_info(a_cursor in out nocopy sys_refcursor,a_columns_info out xmltype, + a_join_by_info out xmltype, a_contains_collection out number); - function get_user_defined_type(a_owner varchar2,a_type_name varchar2) return xmltype; + function get_columns_info(a_cursor in out nocopy sys_refcursor, + a_desc_user_types boolean := false) return xmltype; + + function get_user_defined_type(a_owner varchar2,a_type_name varchar2) return xmltype; end; / diff --git a/source/expectations/data_values/ut_data_value_refcursor.tpb b/source/expectations/data_values/ut_data_value_refcursor.tpb index 5b8ab8463..18b49bd73 100644 --- a/source/expectations/data_values/ut_data_value_refcursor.tpb +++ b/source/expectations/data_values/ut_data_value_refcursor.tpb @@ -37,8 +37,11 @@ create or replace type body ut_data_value_refcursor as self.data_type := 'refcursor'; if l_cursor is not null then if l_cursor%isopen then - self.columns_info := ut_curr_usr_compound_helper.get_columns_info(l_cursor); - self.key_info := ut_curr_usr_compound_helper.get_columns_info(l_cursor,true); + --Get some more info regarding cursor, including if it containts collection columns and what is their name + + ut_curr_usr_compound_helper.get_columns_info(l_cursor,self.columns_info,self.key_info, + self.contain_collection); + self.elements_count := 0; -- We use DBMS_XMLGEN in order to: -- 1) be able to process data in bulks (set of rows) @@ -134,14 +137,16 @@ create or replace type body ut_data_value_refcursor as end; function get_missing_key_message(a_missing_keys ut_compound_data_helper.t_missing_pk) return varchar2 is + l_message varchar2(200); begin - return - case a_missing_keys.diff_type - when 'a' then - ' Join key '||a_missing_keys.missingxpath||' does not exists in actual' - when 'e' then - ' Join key '||a_missing_keys.missingxpath||' does not exists in expected' - end; + + if a_missing_keys.diff_type = 'a' then + l_message := ' Join key '||a_missing_keys.missingxpath||' does not exists in actual'; + elsif a_missing_keys.diff_type = 'e' then + l_message := ' Join key '||a_missing_keys.missingxpath||' does not exists in expected'; + end if; + + return l_message; end; function add_incomparable_cols_to_xpath( @@ -202,7 +207,12 @@ create or replace type body ut_data_value_refcursor as for i in 1 .. l_missing_pk.count loop l_results.extend; ut_utils.append_to_clob(l_result, get_missing_key_message(l_missing_pk(i))|| chr(10)); - end loop; + end loop; + + if ut_utils.int_to_boolean(self.contain_collection) or ut_utils.int_to_boolean(l_actual.contain_collection) then + ut_utils.append_to_clob(l_result,' Please make sure that your join clause is not refferring to collection element'|| chr(10)); + end if; + end if; l_result_string := ut_utils.to_string(l_result,null); diff --git a/source/expectations/data_values/ut_data_value_refcursor.tps b/source/expectations/data_values/ut_data_value_refcursor.tps index 4e175ce6b..701272581 100644 --- a/source/expectations/data_values/ut_data_value_refcursor.tps +++ b/source/expectations/data_values/ut_data_value_refcursor.tps @@ -24,7 +24,12 @@ create or replace type ut_data_value_refcursor under ut_compound_data_value( * Determines if the cursor is null */ is_cursor_null integer, - + + /** + * hold information if the cursor contains collection object + */ + contain_collection number(1,0), + /** * Holds information about column names and column data-types */ diff --git a/test/core/expectations/compound_data/test_expectations_cursor.pkb b/test/core/expectations/compound_data/test_expectations_cursor.pkb index efb1ca845..ac059c039 100644 --- a/test/core/expectations/compound_data/test_expectations_cursor.pkb +++ b/test/core/expectations/compound_data/test_expectations_cursor.pkb @@ -1697,7 +1697,7 @@ Diff:% ut.expect(l_actual_message).to_be_like(l_expected_message); end; - procedure comparet_tabtype_as_cols_jb is + procedure compare_tabtype_as_cols_jb is l_actual sys_refcursor; l_expected sys_refcursor; l_actual_tab ut3.ut_key_value_pairs := ut3.ut_key_value_pairs(); @@ -1714,22 +1714,278 @@ Diff:% from dual connect by level <=2; --Arrange - open l_actual for select rownum rn, l_actual_tab + open l_actual for select rownum rn, l_actual_tab as nested_table from dual connect by level <=2; - open l_expected for select key,value - from table(l_expected_tab) order by 1 desc; + open l_expected for select rownum rn, l_expected_tab as nested_table + from dual connect by level <=2; --Act - ut3.ut.expect(l_actual).to_equal(l_expected).join_by(ut3.ut_varchar2_list('RN,L_ACTUAL_TAB/KEY')); - ut3.ut.fail('Expected Exception'); - exception - when others then - l_expected_message := q'[%PLS-00306: wrong number or types of arguments in call to 'CONVERTOBJECT'%]'; - l_actual_message := SQLERRM; + ut3.ut.expect(l_actual).to_equal(l_expected).join_by('NESTED_TABLE'); + + --Assert + l_expected_message := q'[%Actual: refcursor [ count = 2 ] was expected to equal: refcursor [ count = 2 ]% +%Diff:% +%Rows: [ 2 differences ]% +%PK %%1%Something 1%%%2%Something 2% - Extra%1% +%PK %%1%Something 1%%%2%Something 2% - Extra%2% +%PK %%1%Somethings 1%%%2%Somethings 2% - Missing%2% +%PK %%1%Somethings 1%%%2%Somethings 2% - Missing%1%]'; + l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; + --Assert + ut.expect(l_actual_message).to_be_like(l_expected_message); + + end; + + procedure compare_tabtype_as_cols is + l_actual sys_refcursor; + l_expected sys_refcursor; + l_actual_tab ut3.ut_key_value_pairs := ut3.ut_key_value_pairs(); + l_expected_tab ut3.ut_key_value_pairs := ut3.ut_key_value_pairs(); + l_expected_message varchar2(32767); + l_actual_message varchar2(32767); + begin + select ut3.ut_key_value_pair(rownum,'Something '||rownum) + bulk collect into l_actual_tab + from dual connect by level <=2 order by rownum asc; + + select ut3.ut_key_value_pair(rownum,'Something '||rownum) + bulk collect into l_expected_tab + from dual connect by level <=2 order by rownum asc; + + --Arrange + open l_actual for select rownum rn, l_actual_tab as nested_table + from dual connect by level <=2; + + open l_expected for select rownum rn, l_expected_tab as nested_table + from dual connect by level <=2; + + --Act + ut3.ut.expect(l_actual).to_equal(l_expected); --Assert - ut.expect(l_actual_message).to_be_like(l_expected_message); + ut.expect(expectations.failed_expectations_data()).to_be_empty(); + end; + + procedure compare_tabtype_as_cols_coll is + l_actual sys_refcursor; + l_expected sys_refcursor; + l_actual_tab ut3.ut_key_value_pairs := ut3.ut_key_value_pairs(); + l_expected_tab ut3.ut_key_value_pairs := ut3.ut_key_value_pairs(); + l_expected_message varchar2(32767); + l_actual_message varchar2(32767); + begin + select ut3.ut_key_value_pair(rownum,'Something '||rownum) + bulk collect into l_actual_tab + from dual connect by level <=2; + + select ut3.ut_key_value_pair(rownum,'Somethings '||rownum) + bulk collect into l_expected_tab + from dual connect by level <=2; + + --Arrange + open l_actual for select rownum rn, l_actual_tab as nested_table + from dual connect by level <=2; + + open l_expected for select rownum rn, l_expected_tab as nested_table + from dual connect by level <=2; + + --Act + ut3.ut.expect(l_actual).to_equal(l_expected).join_by('NESTED_TABLE/UT_KEY_VALUE_PAIR'); + + --Assert + l_expected_message := q'[%Actual: refcursor [ count = 2 ] was expected to equal: refcursor [ count = 2 ] +%Diff: +%Unable to join sets: +%Join key NESTED_TABLE/UT_KEY_VALUE_PAIR does not exists in expected% +%Join key NESTED_TABLE/UT_KEY_VALUE_PAIR does not exists in actual% +%Please make sure that your join clause is not refferring to collection element%]'; + l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; + --Assert + ut.expect(l_actual_message).to_be_like(l_expected_message); + + end; + + procedure compare_rec_colltype_as_cols is + l_actual sys_refcursor; + l_expected sys_refcursor; + l_actual_tab ut3.ut_annotated_object; + l_expected_tab ut3.ut_annotated_object; + l_expected_message varchar2(32767); + l_actual_message varchar2(32767); + begin + select ut3.ut_annotated_object('TEST','TEST','TEST', + ut3.ut_annotations(ut3.ut_annotation(1,'test','test','test'), + ut3.ut_annotation(2,'test','test','test')) + ) + into l_actual_tab from dual; + + select ut3.ut_annotated_object('TEST','TEST','TEST', + ut3.ut_annotations(ut3.ut_annotation(1,'test','test','test'), + ut3.ut_annotation(2,'test','test','test')) + ) + into l_expected_tab from dual; + + --Arrange + open l_actual for select l_actual_tab as nested_table from dual; + + open l_expected for select l_expected_tab as nested_table from dual; + + --Act + ut3.ut.expect(l_actual).to_equal(l_expected).join_by('NESTED_TABLE'); + --Assert + ut.expect(expectations.failed_expectations_data()).to_be_empty(); + + end; + + procedure compare_rec_colltype_as_attr is + l_actual sys_refcursor; + l_expected sys_refcursor; + l_actual_tab ut3.ut_annotated_object; + l_expected_tab ut3.ut_annotated_object; + l_expected_message varchar2(32767); + l_actual_message varchar2(32767); + begin + select ut3.ut_annotated_object('TEST','TEST','TEST', + ut3.ut_annotations(ut3.ut_annotation(1,'test','test','test'), + ut3.ut_annotation(2,'test','test','test')) + ) + into l_actual_tab from dual; + + select ut3.ut_annotated_object('TEST','TEST','TEST', + ut3.ut_annotations(ut3.ut_annotation(1,'test','test','test'), + ut3.ut_annotation(2,'test','test','test')) + ) + into l_expected_tab from dual; + + --Arrange + open l_actual for select l_actual_tab as nested_table from dual; + + open l_expected for select l_expected_tab as nested_table from dual; + + --Act + ut3.ut.expect(l_actual).to_equal(l_expected).join_by('NESTED_TABLE/OBJECT_OWNER'); + --Assert + ut.expect(expectations.failed_expectations_data()).to_be_empty(); + + end; + + procedure compare_collection_in_rec is + l_actual sys_refcursor; + l_expected sys_refcursor; + l_actual_tab ut3.ut_annotated_object; + l_expected_tab ut3.ut_annotated_object; + l_expected_message varchar2(32767); + l_actual_message varchar2(32767); + begin + select ut3.ut_annotated_object('TEST','TEST','TEST', + ut3.ut_annotations(ut3.ut_annotation(1,'test','test','test'), + ut3.ut_annotation(2,'test','test','test')) + ) + into l_actual_tab from dual; + + select ut3.ut_annotated_object('TEST','TEST','TEST', + ut3.ut_annotations(ut3.ut_annotation(1,'test','test','test'), + ut3.ut_annotation(2,'test','test','test')) + ) + into l_expected_tab from dual; + + --Arrange + open l_actual for select l_actual_tab as nested_table from dual; + + open l_expected for select l_expected_tab as nested_table from dual; + + --Act + ut3.ut.expect(l_actual).to_equal(l_expected).join_by('NESTED_TABLE/ANNOTATIONS'); + --Assert + ut.expect(expectations.failed_expectations_data()).to_be_empty(); + + end; + + procedure compare_rec_coll_as_cols_fl is + l_actual sys_refcursor; + l_expected sys_refcursor; + l_actual_tab ut3.ut_annotated_object; + l_expected_tab ut3.ut_annotated_object; + l_expected_message varchar2(32767); + l_actual_message varchar2(32767); + begin + select ut3.ut_annotated_object('TEST','TEST','TEST', + ut3.ut_annotations(ut3.ut_annotation(1,'test','test','test'), + ut3.ut_annotation(2,'test','test','test')) + ) + into l_actual_tab + from dual; + + select ut3.ut_annotated_object('TEST','TEST','TEST', + ut3.ut_annotations(ut3.ut_annotation(1,'1test','test','test'), + ut3.ut_annotation(2,'test','test','test')) + ) + into l_expected_tab + from dual; + + --Arrange + open l_actual for select rownum rn, l_actual_tab as nested_table + from dual; + + open l_expected for select rownum rn, l_expected_tab as nested_table + from dual; + + --Act + ut3.ut.expect(l_actual).to_equal(l_expected).join_by('NESTED_TABLE/OBJECT_OWNER'); + + --Assert + l_expected_message := q'[%Actual: refcursor [ count = 1 ] was expected to equal: refcursor [ count = 1 ] +%Diff: +%Rows: [ 1 differences ] +%PK TEST - Actual: TESTTESTTEST1testtesttest2testtesttest% +%PK TEST - Expected: TESTTESTTEST11testtesttest2testtesttest%]'; + l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; + --Assert + ut.expect(l_actual_message).to_be_like(l_expected_message); + --ut.expect(expectations.failed_expectations_data()).not_to_be_empty(); + end; + + procedure compare_rec_coll_as_join is + l_actual sys_refcursor; + l_expected sys_refcursor; + l_actual_tab ut3.ut_annotated_object; + l_expected_tab ut3.ut_annotated_object; + l_expected_message varchar2(32767); + l_actual_message varchar2(32767); + begin + select ut3.ut_annotated_object('TEST','TEST','TEST', + ut3.ut_annotations(ut3.ut_annotation(1,'1test','test','test'), + ut3.ut_annotation(2,'test','test','test')) + ) + into l_actual_tab from dual; + + select ut3.ut_annotated_object('TEST','TEST','TEST', + ut3.ut_annotations(ut3.ut_annotation(1,'test','test','test'), + ut3.ut_annotation(2,'test','test','test')) + ) + into l_expected_tab from dual; + + --Arrange + open l_actual for select l_actual_tab as nested_table from dual; + + open l_expected for select l_expected_tab as nested_table from dual; + + --Act + ut3.ut.expect(l_actual).to_equal(l_expected).join_by('NESTED_TABLE/ANNOTATIONS/TEXT'); + + --Assert + l_expected_message := q'[%Actual: refcursor [ count = 1 ] was expected to equal: refcursor [ count = 1 ]% +%Diff:% +%Unable to join sets:% +%Join key NESTED_TABLE/ANNOTATIONS/TEXT does not exists in expected% +%Join key NESTED_TABLE/ANNOTATIONS/TEXT does not exists in actual% +%Please make sure that your join clause is not refferring to collection element%]'; + l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; + --Assert + ut.expect(l_actual_message).to_be_like(l_expected_message); + + end; end; / diff --git a/test/core/expectations/compound_data/test_expectations_cursor.pks b/test/core/expectations/compound_data/test_expectations_cursor.pks index bd8cf45a0..b95c73735 100644 --- a/test/core/expectations/compound_data/test_expectations_cursor.pks +++ b/test/core/expectations/compound_data/test_expectations_cursor.pks @@ -292,8 +292,29 @@ create or replace package test_expectations_cursor is --%test(Compare table type join by multiple columns- Failure) procedure compare_nest_tab_cols_jb_fail; - --%test(Compare table type as column join by multiple columns - PLS Failure) - procedure comparet_tabtype_as_cols_jb; + --%test(Compare table type as column join by multiple columns - Cannot find match) + procedure compare_tabtype_as_cols_jb; + + --%test(Compare table type as column normal compare ) + procedure compare_tabtype_as_cols; + + --%test(Compare table type as column join on collection element ) + procedure compare_tabtype_as_cols_coll; + + --%test(Compare same content on record with collections join on record) + procedure compare_rec_colltype_as_cols; + + --%test(Compare same content record with collection join on record attribute) + procedure compare_rec_colltype_as_attr; + + --%test(Compare same content record with collection join on whole collection) + procedure compare_collection_in_rec; + + --%test(Compare diffrent content record with collection join on record attribute) + procedure compare_rec_coll_as_cols_fl; + + --%test(Trying to join on collection element inside record ) + procedure compare_rec_coll_as_join; end; / From 48cfc2a914f2509539d4a5db689112205090fe1a Mon Sep 17 00:00:00 2001 From: lwasylow Date: Sun, 27 May 2018 09:48:35 +0100 Subject: [PATCH 056/184] update to test as it order diffrent in xml between versions 11 and 12.2 --- .../compound_data/test_expectations_cursor.pkb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/core/expectations/compound_data/test_expectations_cursor.pkb b/test/core/expectations/compound_data/test_expectations_cursor.pkb index ac059c039..aa0615e4a 100644 --- a/test/core/expectations/compound_data/test_expectations_cursor.pkb +++ b/test/core/expectations/compound_data/test_expectations_cursor.pkb @@ -1727,10 +1727,10 @@ Diff:% l_expected_message := q'[%Actual: refcursor [ count = 2 ] was expected to equal: refcursor [ count = 2 ]% %Diff:% %Rows: [ 2 differences ]% -%PK %%1%Something 1%%%2%Something 2% - Extra%1% -%PK %%1%Something 1%%%2%Something 2% - Extra%2% -%PK %%1%Somethings 1%%%2%Somethings 2% - Missing%2% -%PK %%1%Somethings 1%%%2%Somethings 2% - Missing%1%]'; +%PK %%%%%%%%%%%%%Extra%%% +%PK %%%%%%%%%%%%%Extra%%% +%PK %%%%%%%%%%%%%Missing%%% +%PK %%%%%%%%%%%%%Missing%%%]'; l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); From 3273b2f377113665d12a3d1963c1c5f3d66944e2 Mon Sep 17 00:00:00 2001 From: lwasylow Date: Sun, 27 May 2018 11:17:27 +0100 Subject: [PATCH 057/184] Switching build to run tests on itself. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 2293bf983..5b109533c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -46,7 +46,7 @@ env: - DOCKHER_HUB_REPO="${DOCKER_BASE_TAG:-$UT3_DOCKER_REPO}" #utPLSQL released version directory - UTPLSQL_DIR="utPLSQL_latest_release" - - SELFTESTING_BRANCH="develop" + - SELFTESTING_BRANCH=${TRAVIS_BRANCH} - UTPLSQL_CLI_VERSION="3.1.0" # Maven - MAVEN_HOME=/usr/local/maven From 8e0f65b16ffdf9d23ca0cf5d6cb7587cd10a7188 Mon Sep 17 00:00:00 2001 From: Travis CI Date: Mon, 28 May 2018 07:08:11 +0000 Subject: [PATCH 058/184] Updated project version after build [skip ci] --- source/core/ut_utils.pks | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/core/ut_utils.pks b/source/core/ut_utils.pks index b8b9de64f..12c11f158 100644 --- a/source/core/ut_utils.pks +++ b/source/core/ut_utils.pks @@ -21,7 +21,7 @@ create or replace package ut_utils authid definer is * */ - gc_version constant varchar2(50) := 'v3.1.2.1933-develop'; + gc_version constant varchar2(50) := 'v3.1.2.1939-develop'; /* Constants: Event names */ subtype t_event_name is varchar2(30); From 004b14cf874f88ebc89402a05bdb91a8d0ed0b09 Mon Sep 17 00:00:00 2001 From: lwasylow Date: Tue, 29 May 2018 23:36:16 +0100 Subject: [PATCH 059/184] Updated html tags --- source/reporters/ut_coverage_report_html_helper.pkb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/reporters/ut_coverage_report_html_helper.pkb b/source/reporters/ut_coverage_report_html_helper.pkb index 4ea8c6eb1..4b815435d 100644 --- a/source/reporters/ut_coverage_report_html_helper.pkb +++ b/source/reporters/ut_coverage_report_html_helper.pkb @@ -308,7 +308,7 @@ function get_details_file_content(a_object_id varchar2, a_unit ut_object_name, a '' || '' || '' || '' || + 'application.css'' media=''screen, projection, print'' rel=''stylesheet'' type=''text/css''/>' || '' || '' || '' || @@ -339,7 +339,7 @@ function get_details_file_content(a_object_id varchar2, a_unit ut_object_name, a l_unit := a_coverage_data.objects.next(l_unit); end loop; - l_file_part := ''; + l_file_part := ''; ut_utils.append_to_clob(l_result, l_file_part); return l_result; From 1175203bf6cf49baa13baad1c9b4d7138fc04aca Mon Sep 17 00:00:00 2001 From: Jacek Gebal Date: Wed, 30 May 2018 20:52:58 +0100 Subject: [PATCH 060/184] Document a bug with capturing DBMS_OUTPUT before test run. --- test/api/test_ut_runner.pkb | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/test/api/test_ut_runner.pkb b/test/api/test_ut_runner.pkb index e957d3719..fa3121bfa 100644 --- a/test/api/test_ut_runner.pkb +++ b/test/api/test_ut_runner.pkb @@ -180,25 +180,35 @@ end;'; procedure run_keep_dbms_output_buffer is l_expected dbmsoutput_linesarray; l_actual dbmsoutput_linesarray; - l_lines number := 100; + l_results ut3.ut_varchar2_list; + l_lines number := 10000; begin --Arrange create_test_spec(); create_test_body(0); + l_expected := dbmsoutput_linesarray( 'A text placed into DBMS_OUTPUT', 'Another line', lpad('A very long line',10000,'a') ); - dbms_output.put_line(l_expected(1)); - dbms_output.put_line(l_expected(2)); - dbms_output.put_line(l_expected(3)); + for i in 1 .. 300 loop + l_expected.extend; + l_expected(l_expected.last) := 'line '||i; + end loop; + + for i in 1 .. l_expected.count loop + dbms_output.put_line(l_expected(i)); + end loop; + --Act - ut3.ut.run('test_cache'); + select * + bulk collect into l_results + from table(ut3.ut.run('test_cache')); --Assert dbms_output.get_lines(lines => l_actual, numlines => l_lines); - for i in 1 .. l_expected.count loop + for i in 1 .. l_lines loop ut.expect(l_actual(i)).to_equal(l_expected(i)); end loop; drop_test_package(); From e53b01ec88340a7f8f405dd2d4eec0f3a3244f11 Mon Sep 17 00:00:00 2001 From: Jacek Gebal Date: Wed, 30 May 2018 21:38:43 +0100 Subject: [PATCH 061/184] Fixed a bug with capturing DBMS_OUTPUT before test run. --- source/core/ut_utils.pkb | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/source/core/ut_utils.pkb b/source/core/ut_utils.pkb index 438d32c60..4964848e7 100644 --- a/source/core/ut_utils.pkb +++ b/source/core/ut_utils.pkb @@ -437,17 +437,16 @@ procedure append_to_clob(a_src_clob in out nocopy clob, a_clob_table t_clob_tab, procedure save_dbms_output_to_cache is l_status number; l_line varchar2(32767); - l_line_no integer := 1; + l_offset integer := 0; l_lines ut_varchar2_rows := ut_varchar2_rows(); c_lines_limit constant integer := 100; pragma autonomous_transaction; - procedure flush_lines is + procedure flush_lines(a_lines ut_varchar2_rows, a_offset integer) is begin insert into ut_dbms_output_cache (seq_no,text) - select rownum, column_value - from table(l_lines); - l_lines.delete; + select rownum+a_offset, column_value + from table(a_lines); end; begin loop @@ -455,10 +454,12 @@ procedure append_to_clob(a_src_clob in out nocopy clob, a_clob_table t_clob_tab, exit when l_status = 1; l_lines := l_lines multiset union all ut_utils.convert_collection(ut_utils.clob_to_table(l_line||chr(7),4000)); if l_lines.count > c_lines_limit then - flush_lines(); + flush_lines(l_lines, l_offset); + l_offset := l_offset + l_lines.count; + l_lines.delete; end if; end loop; - flush_lines(); + flush_lines(l_lines, l_offset); commit; end; From 30dc6f8e9b9cf79177d899d9cef4698e67de2465 Mon Sep 17 00:00:00 2001 From: lwasylow Date: Thu, 31 May 2018 12:51:24 +0100 Subject: [PATCH 062/184] Adding validation to html doc and fixing some minor issues around html reporter --- .travis.yml | 1 + .travis/validate_report_files.sh | 24 +++++++++++++++++++ .../ut_coverage_report_html_helper.pkb | 6 ++--- 3 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 .travis/validate_report_files.sh diff --git a/.travis.yml b/.travis.yml index 5b109533c..c1e329913 100644 --- a/.travis.yml +++ b/.travis.yml @@ -97,6 +97,7 @@ before_script: script: - if [[ ! $TRAVIS_TAG ]]; then bash test/install_and_run_tests.sh; fi + - if [[ ! $TRAVIS_TAG ]]; then bash .travis/validate_report_files.sh - if [[ ! $TRAVIS_TAG ]] && [ "${TRAVIS_REPO_SLUG}" = "${UTPLSQL_REPO}" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then sonar-scanner; fi - if [[ ! $TRAVIS_TAG ]]; then bash .travis/coveralls_uploader.sh; fi - bash .travis/build_docs.sh diff --git a/.travis/validate_report_files.sh b/.travis/validate_report_files.sh new file mode 100644 index 000000000..0dd4f69bd --- /dev/null +++ b/.travis/validate_report_files.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +echo "validate html" + +HTML_FILENAME="coverage.html" +#Exclude existing issue with OL nested in PRE +EXCLUSION_REGEX=".*Element\s.?ol.?\snot\sallowed\sas\schild\sof\selement\s.?pre.*" +HTML_VALIDATOR_URL="https://validator.w3.org/nu/" +VALIDATOR_OUT="gnu" +WARNING_REGEX="info warning:" +ERROR_REGEX="error:" + +VALIDATION_RESULTS=$(curl -H "Content-Type: text/html; charset=utf-8" --data-binary @$HTML_FILENAME "$HTML_VALIDATOR_URL?out=$VALIDATOR_OUT&filterpattern=$EXCLUSION_REGEX") + +ERROR_COUNT=`echo $VALIDATION_RESULTS | grep -c "$ERROR_REGEX"` +WARNING_COUNT=`echo $VALIDATION_RESULTS | grep -c "$WARNING_REGEX"` + +echo "There are $ERROR_COUNT errors, $WARNING_COUNT warning in $HTML_FILENAME" + +if [ $ERROR_COUNT -gt 0 ]; then + exit 1 +else + exit 0 +fi \ No newline at end of file diff --git a/source/reporters/ut_coverage_report_html_helper.pkb b/source/reporters/ut_coverage_report_html_helper.pkb index 4b815435d..34e241d17 100644 --- a/source/reporters/ut_coverage_report_html_helper.pkb +++ b/source/reporters/ut_coverage_report_html_helper.pkb @@ -241,7 +241,7 @@ function get_details_file_content(a_object_id varchar2, a_unit ut_object_name, a '' || executions_per_line(a_coverage.executions, a_coverage.uncovered_lines + a_coverage.covered_lines) - || ' hits/line)' || '' || '
' || + || ' hits/line)' || '' || '
' || a_coverage.objects.count || ' files in total.
' || '' || (a_coverage.uncovered_lines + a_coverage.covered_lines) || ' relevant lines. ' || '' || a_coverage.covered_lines || @@ -306,9 +306,9 @@ function get_details_file_content(a_object_id varchar2, a_unit ut_object_name, a --TODO - build main file containing total run data and per schema data l_file_part := '' || '' || l_title || '' || '' || - '' || + '' || '' || + 'application.css'' media=''screen, print'' rel=''stylesheet'' type=''text/css''/>' || '' || '' || '' || From ec82192adc1c6b80ef1814a2b04b88aa34821a0e Mon Sep 17 00:00:00 2001 From: Lukasz Date: Thu, 31 May 2018 13:05:55 +0100 Subject: [PATCH 063/184] Update with missing FI --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c1e329913..379888de4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -97,7 +97,7 @@ before_script: script: - if [[ ! $TRAVIS_TAG ]]; then bash test/install_and_run_tests.sh; fi - - if [[ ! $TRAVIS_TAG ]]; then bash .travis/validate_report_files.sh + - if [[ ! $TRAVIS_TAG ]]; then bash .travis/validate_report_files.sh fi - if [[ ! $TRAVIS_TAG ]] && [ "${TRAVIS_REPO_SLUG}" = "${UTPLSQL_REPO}" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then sonar-scanner; fi - if [[ ! $TRAVIS_TAG ]]; then bash .travis/coveralls_uploader.sh; fi - bash .travis/build_docs.sh From b94cae85435f492576f89d44842984ad52b5a6c5 Mon Sep 17 00:00:00 2001 From: Travis CI Date: Thu, 31 May 2018 12:13:43 +0000 Subject: [PATCH 064/184] Updated project version after build [skip ci] --- source/core/ut_utils.pks | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/core/ut_utils.pks b/source/core/ut_utils.pks index 12c11f158..09a673dc8 100644 --- a/source/core/ut_utils.pks +++ b/source/core/ut_utils.pks @@ -21,7 +21,7 @@ create or replace package ut_utils authid definer is * */ - gc_version constant varchar2(50) := 'v3.1.2.1939-develop'; + gc_version constant varchar2(50) := 'v3.1.2.1946-develop'; /* Constants: Event names */ subtype t_event_name is varchar2(30); From 6017d094a58909cf9ae936dbb5e015e91c6e51c2 Mon Sep 17 00:00:00 2001 From: Lukasz Date: Thu, 31 May 2018 13:25:36 +0100 Subject: [PATCH 065/184] Syntax error --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 379888de4..cf4abb857 100644 --- a/.travis.yml +++ b/.travis.yml @@ -97,7 +97,7 @@ before_script: script: - if [[ ! $TRAVIS_TAG ]]; then bash test/install_and_run_tests.sh; fi - - if [[ ! $TRAVIS_TAG ]]; then bash .travis/validate_report_files.sh fi + - if [[ ! $TRAVIS_TAG ]]; then bash .travis/validate_report_files.sh; fi - if [[ ! $TRAVIS_TAG ]] && [ "${TRAVIS_REPO_SLUG}" = "${UTPLSQL_REPO}" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then sonar-scanner; fi - if [[ ! $TRAVIS_TAG ]]; then bash .travis/coveralls_uploader.sh; fi - bash .travis/build_docs.sh From 4918699500023f6ded65fa4700c504634715dcbd Mon Sep 17 00:00:00 2001 From: Lukasz Date: Thu, 31 May 2018 14:02:33 +0100 Subject: [PATCH 066/184] Display errors in console --- .travis/validate_report_files.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis/validate_report_files.sh b/.travis/validate_report_files.sh index 0dd4f69bd..306c5f9e1 100644 --- a/.travis/validate_report_files.sh +++ b/.travis/validate_report_files.sh @@ -18,7 +18,8 @@ WARNING_COUNT=`echo $VALIDATION_RESULTS | grep -c "$WARNING_REGEX"` echo "There are $ERROR_COUNT errors, $WARNING_COUNT warning in $HTML_FILENAME" if [ $ERROR_COUNT -gt 0 ]; then + echo $VALIDATION_RESULTS | grep -c "$ERROR_REGEX" exit 1 else exit 0 -fi \ No newline at end of file +fi From aba71146770bdfdc99e7c83ec83fa0d8209d24b7 Mon Sep 17 00:00:00 2001 From: Lukasz Date: Thu, 31 May 2018 14:03:08 +0100 Subject: [PATCH 067/184] Display errors in console --- .travis/validate_report_files.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis/validate_report_files.sh b/.travis/validate_report_files.sh index 306c5f9e1..3ae29fe01 100644 --- a/.travis/validate_report_files.sh +++ b/.travis/validate_report_files.sh @@ -18,7 +18,7 @@ WARNING_COUNT=`echo $VALIDATION_RESULTS | grep -c "$WARNING_REGEX"` echo "There are $ERROR_COUNT errors, $WARNING_COUNT warning in $HTML_FILENAME" if [ $ERROR_COUNT -gt 0 ]; then - echo $VALIDATION_RESULTS | grep -c "$ERROR_REGEX" + echo $VALIDATION_RESULTS | grep "$ERROR_REGEX" exit 1 else exit 0 From ffd23f7729388727e0b6acf61b2fe6a799d04954 Mon Sep 17 00:00:00 2001 From: Lukasz Date: Thu, 31 May 2018 15:26:27 +0100 Subject: [PATCH 068/184] Wrap into quote to keep new lines --- .travis/validate_report_files.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis/validate_report_files.sh b/.travis/validate_report_files.sh index 3ae29fe01..4f500f3e6 100644 --- a/.travis/validate_report_files.sh +++ b/.travis/validate_report_files.sh @@ -12,13 +12,13 @@ ERROR_REGEX="error:" VALIDATION_RESULTS=$(curl -H "Content-Type: text/html; charset=utf-8" --data-binary @$HTML_FILENAME "$HTML_VALIDATOR_URL?out=$VALIDATOR_OUT&filterpattern=$EXCLUSION_REGEX") -ERROR_COUNT=`echo $VALIDATION_RESULTS | grep -c "$ERROR_REGEX"` -WARNING_COUNT=`echo $VALIDATION_RESULTS | grep -c "$WARNING_REGEX"` +ERROR_COUNT=`echo "$VALIDATION_RESULTS" | grep -c "$ERROR_REGEX"` +WARNING_COUNT=`echo "$VALIDATION_RESULTS" | grep -c "$WARNING_REGEX"` echo "There are $ERROR_COUNT errors, $WARNING_COUNT warning in $HTML_FILENAME" if [ $ERROR_COUNT -gt 0 ]; then - echo $VALIDATION_RESULTS | grep "$ERROR_REGEX" + echo "$VALIDATION_RESULTS" | grep "$ERROR_REGEX" exit 1 else exit 0 From b691505dc96bb9cc564ec3801f130efefa24e3d3 Mon Sep 17 00:00:00 2001 From: Travis CI Date: Thu, 31 May 2018 15:22:46 +0000 Subject: [PATCH 069/184] Updated project version after build [skip ci] --- source/core/ut_utils.pks | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/core/ut_utils.pks b/source/core/ut_utils.pks index 09a673dc8..83b48c7cb 100644 --- a/source/core/ut_utils.pks +++ b/source/core/ut_utils.pks @@ -21,7 +21,7 @@ create or replace package ut_utils authid definer is * */ - gc_version constant varchar2(50) := 'v3.1.2.1946-develop'; + gc_version constant varchar2(50) := 'v3.1.2.1959-develop'; /* Constants: Event names */ subtype t_event_name is varchar2(30); From 5e5fea4639618ae84b3308df5c2b9ae66f17ebda Mon Sep 17 00:00:00 2001 From: Walter Alexis Castro Date: Thu, 31 May 2018 14:37:13 -0600 Subject: [PATCH 070/184] tests improved --- .../test_before_after_test_annotation.pkb | 128 ++++++++++++------ .../test_before_after_test_annotation.pks | 6 +- 2 files changed, 92 insertions(+), 42 deletions(-) diff --git a/test/core/annotations/test_before_after_test_annotation.pkb b/test/core/annotations/test_before_after_test_annotation.pkb index 98a73450a..27d787b79 100644 --- a/test/core/annotations/test_before_after_test_annotation.pkb +++ b/test/core/annotations/test_before_after_test_annotation.pkb @@ -16,15 +16,65 @@ create or replace package body test_before_after_annotations is execute immediate 'drop package '||a_package_name; end; begin + l_dummy_utility_pkg_spec := ' + create or replace package dummy_utility_pkg_1 is + g_executed_procedures ut_varchar2_list; + g_test4_executed boolean := false; + g_test5_executed boolean := false; + g_beforetest_one_err_procedure boolean := false; + + procedure insert_executed_procedure(a_procedure_name varchar2); + + procedure test1; + + procedure test3; + + procedure test4; + + procedure test5; + end; + '; + + l_dummy_utility_pkg_body := ' + create or replace package body dummy_utility_pkg_1 is + procedure insert_executed_procedure(a_procedure_name varchar2) + is + begin + if g_executed_procedures is null then + g_executed_procedures := ut_varchar2_list(a_procedure_name); + else + g_executed_procedures.extend; + g_executed_procedures(g_executed_procedures.count) := a_procedure_name; + end if; + end; + + procedure test1 is + begin + insert_executed_procedure(''test1''); + end; + + procedure test3 is + begin + insert_executed_procedure(''test3''); + end; + + procedure test4 is + begin + g_test4_executed := true; + end; + + procedure test5 is + begin + g_test4_executed := true; + end; + end; + '; + l_test_package_spec := ' create or replace package dummy_before_after_test is --%suite(Package to test annotations beforetest and aftertest) - l_dummy_1 integer; - l_dummy_2 integer; - l_dummy_3 integer; - - --%beforeeach + --%aftereach procedure clean_global_variables; --%test(Beforetest with call to procedure external to the test package) @@ -37,9 +87,12 @@ create or replace package body test_before_after_annotations is procedure beforetest_multi_ext_procedure; --%test(Beforetest with call to multi procedures where one does not exist) - --%beforetest(dummy_utility_pkg_1.test1, non_existent_procedure, ut3_tester.dummy_utility_pkg_1.test3) + --%beforetest(dummy_utility_pkg_1.test4, non_existent_procedure, ut3_tester.dummy_utility_pkg_1.test5) procedure beforetest_one_err_procedure; + --%test(Test which beforetest procedures were executed) + procedure test_executed_beforetests; + procedure test2; end; '; @@ -48,63 +101,47 @@ create or replace package body test_before_after_annotations is create or replace package body dummy_before_after_test is procedure clean_global_variables is begin - l_dummy_1 := null; - l_dummy_2 := null; - l_dummy_3 := null; + dummy_utility_pkg_1.g_executed_procedures := null; end; procedure beforetest_one_ext_procedure is begin - ut3.ut.expect(l_dummy_1).to_equal(1); + ut3.ut.expect(dummy_utility_pkg_1.g_executed_procedures(1)).to_equal(''test1''); end; procedure beforetest_multi_ext_procedure is begin - ut3.ut.expect(l_dummy_1).to_equal(1); - ut3.ut.expect(l_dummy_2).to_equal(2); - ut3.ut.expect(l_dummy_3).to_equal(3); + ut3.ut.expect(dummy_utility_pkg_1.g_executed_procedures(1)).to_equal(''test1''); + ut3.ut.expect(dummy_utility_pkg_1.g_executed_procedures(2)).to_equal(''test2''); + ut3.ut.expect(dummy_utility_pkg_1.g_executed_procedures(3)).to_equal(''test3''); end; procedure beforetest_one_err_procedure is begin - null; + dummy_utility_pkg_1.g_beforetest_one_err_procedure := true; + end; + + procedure test_executed_beforetests + is + begin + ut3.ut.expect(dummy_utility_pkg_1.g_test4_executed).to_be_true; + ut3.ut.expect(dummy_utility_pkg_1.g_test5_executed).to_be_false; + ut3.ut.expect(dummy_utility_pkg_1.g_beforetest_one_err_procedure).to_be_false; end; procedure test2 is begin - l_dummy_2 := 2; + dummy_utility_pkg_1.insert_executed_procedure(''test2''); end; end; '; - l_dummy_utility_pkg_spec := ' - create or replace package dummy_utility_pkg_1 is - procedure test1; - - procedure test3; - end; - '; - - l_dummy_utility_pkg_body := ' - create or replace package body dummy_utility_pkg_1 is - procedure test1 is - begin - dummy_before_after_test.l_dummy_1 := 1; - end; - - procedure test3 is - begin - dummy_before_after_test.l_dummy_3 := 3; - end; - end; - '; - - execute immediate l_test_package_spec; - execute immediate l_test_package_body; execute immediate l_dummy_utility_pkg_spec; execute immediate l_dummy_utility_pkg_body; + execute immediate l_test_package_spec; + execute immediate l_test_package_body; --Execute the tests and recolect the results select * bulk collect into l_test_results from table(ut3.ut.run(('dummy_before_after_test'))); @@ -125,6 +162,7 @@ create or replace package body test_before_after_annotations is procedure beforetest_multi_ext_procedure is begin + --Also test the execution order of the beforetest procedures ut.expect(g_tests_results).to_match('^\s*Beforetest with call to multi procedures external and interal to the test package \[[\.0-9]+ sec\]\s*$','m'); ut.expect(g_tests_results).not_to_match('beforetest_multi_ext_procedure'); end; @@ -132,7 +170,15 @@ create or replace package body test_before_after_annotations is procedure beforetest_one_err_procedure is begin + ut.expect(g_tests_results).to_match('^\s*Call params for before_test are not valid: procedure does not exist\s*[^.]+\.DUMMY_BEFORE_AFTER_TEST\.NON_EXISTENT_PROCEDURE\s*$', 'm'); ut.expect(g_tests_results).not_to_match('^\s*Beforetest with call to multi procedures where one does not exist \[[\.0-9]+ sec\]\s*$','m'); - ut.expect(g_tests_results).to_match('beforetest_one_err_procedure'); end; -end; \ No newline at end of file + + procedure test_executed_beforetests + is + begin + ut.expect(g_tests_results).to_match('^\s*Test which beforetest procedures were executed \[[\.0-9]+ sec\]\s*$','m'); + ut.expect(g_tests_results).not_to_match('test_executed_beforetests'); + end; +end; +/ \ No newline at end of file diff --git a/test/core/annotations/test_before_after_test_annotation.pks b/test/core/annotations/test_before_after_test_annotation.pks index aebab1495..bb1216f2c 100644 --- a/test/core/annotations/test_before_after_test_annotation.pks +++ b/test/core/annotations/test_before_after_test_annotation.pks @@ -15,4 +15,8 @@ create or replace package test_before_after_annotations is --%test(Beforetest with call to multi procedure where one does not exist) procedure beforetest_one_err_procedure; -end; \ No newline at end of file + + --%test(Test which beforetest procedures were executed) + procedure test_executed_beforetests; +end; +/ \ No newline at end of file From 87b22845ef868551c310df2698022f867e0b5314 Mon Sep 17 00:00:00 2001 From: Jacek Gebal Date: Fri, 1 Jun 2018 09:25:57 +0100 Subject: [PATCH 071/184] Fixed a gap in documentation - grants needed for DBMS_CRYPTO Resolves #687 --- docs/userguide/install.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/userguide/install.md b/docs/userguide/install.md index 994aa14c0..0b9bec462 100644 --- a/docs/userguide/install.md +++ b/docs/userguide/install.md @@ -70,7 +70,7 @@ cd source sqlplus sys/sys_pass@db as sysdba @install_headless.sql utp3 my_verySecret_password utp3_tablespace ``` -The script needs to be executed by SYSDBA, in order to grant access to DBMS_LOCK system package. +The script needs to be executed by `SYSDBA`, in order to grant access to `DBMS_LOCK` and `DBMS_CRYPTO` system packages. # Recommended Schema @@ -88,7 +88,7 @@ If the installation and utPLSQL owner user is one and the same, the user must ha - CREATE SYNONYM - ALTER SESSION -In addition the user must be granted the execute privilege on `DBMS_LOCK` package. +In addition the user must be granted the execute privilege on `DBMS_LOCK` and `DBMS_CRYPTO` packages. utPLSQL is using [DBMS_PROFILER tables](https://docs.oracle.com/cd/E18283_01/appdev.112/e16760/d_profil.htm#i999476) for code coverage. The tables required by DBMS_PROFILER will be created in the installation schema unless they already exist. The uninstall process will **not** drop profiler tables, as they can potentially be shared and reused for profiling PLSQL code. From c5bc73ee88fd04261c44bde0fa098eca17df92b6 Mon Sep 17 00:00:00 2001 From: Travis CI Date: Fri, 1 Jun 2018 08:48:08 +0000 Subject: [PATCH 072/184] Updated project version after build [skip ci] --- source/core/ut_utils.pks | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/core/ut_utils.pks b/source/core/ut_utils.pks index 83b48c7cb..9176b1e07 100644 --- a/source/core/ut_utils.pks +++ b/source/core/ut_utils.pks @@ -21,7 +21,7 @@ create or replace package ut_utils authid definer is * */ - gc_version constant varchar2(50) := 'v3.1.2.1959-develop'; + gc_version constant varchar2(50) := 'v3.1.2.1964-develop'; /* Constants: Event names */ subtype t_event_name is varchar2(30); From 76dab88a53c5224fbd9c0ebf88eb9e68d652db5b Mon Sep 17 00:00:00 2001 From: Walter Alexis Castro Date: Fri, 1 Jun 2018 09:16:15 -0600 Subject: [PATCH 073/184] Change installation test order --- test/install_tests.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/install_tests.sql b/test/install_tests.sql index 9826b2483..d7b2b5b39 100644 --- a/test/install_tests.sql +++ b/test/install_tests.sql @@ -23,7 +23,6 @@ whenever oserror exit failure rollback @@core/annotations/test_annotation_parser.pks @@core/annotations/test_annotation_manager.pks @@core/annotations/test_before_after_test_annotation.pks -@@core/annotations/test_before_after_test_annotation.pkb @@core/expectations/test_matchers.pks @@core/test_output_buffer.pks @@core/test_file_mapper.pks @@ -68,6 +67,7 @@ set define off @@core/annotations/test_annotation_parser.pkb @@core/annotations/test_annotation_manager.pkb @@core/expectations/test_matchers.pkb +@@core/annotations/test_before_after_test_annotation.pkb @@core/test_output_buffer.pkb @@core/test_file_mapper.pkb @@core/test_suite_manager.pkb From b44e8799db902181b4a0929477880e454b25a4d6 Mon Sep 17 00:00:00 2001 From: lwasylow Date: Fri, 1 Jun 2018 20:16:12 +0100 Subject: [PATCH 074/184] Enable new throws by exception , variable etc. --- source/core/ut_suite_builder.pkb | 84 +++++++++- .../test_annot_throws_exception.pkb | 144 +++++++++++++++++- .../test_annot_throws_exception.pks | 27 +++- 3 files changed, 251 insertions(+), 4 deletions(-) diff --git a/source/core/ut_suite_builder.pkb b/source/core/ut_suite_builder.pkb index 4d6642df8..7f0fd0921 100644 --- a/source/core/ut_suite_builder.pkb +++ b/source/core/ut_suite_builder.pkb @@ -186,14 +186,96 @@ create or replace package body ut_suite_builder is return l_rollback_type; end; + function check_exception_type(a_exception_name in varchar2) return varchar2 is + l_a varchar2(250); + l_b varchar2(250); + l_c varchar2(250); + l_dblink varchar2(250); + l_next_pos pls_integer; + l_exception_type varchar2(50) := 'NUMBER'; + begin + + begin + --check if it is a number first + dbms_utility.name_tokenize(a_exception_name, l_a, l_b, l_c, l_dblink, l_next_pos); + --check if it is a predefined exception + begin + execute immediate 'begin null; exception when '||a_exception_name||' then null; end;'; + l_exception_type := 'NAMED'; + exception + when others then + if dbms_utility.format_error_stack() like '%PLS-00485%' then + execute immediate 'declare x positiven := -('||a_exception_name||'); begin null; end;'; + l_exception_type := 'NUMBER'; + else + l_exception_type := 'UNKNOWN'; + end if; + end; + exception when others then + null; + end; + return l_exception_type; + end; + + + function get_exception_number (a_exception_var in varchar2) return number is + l_exception_no number; + l_exception_type varchar2(50); + begin + l_exception_type := check_exception_type(a_exception_var); + if l_exception_type = 'NUMBER' then + execute immediate 'declare + l_exception number; + begin + :l_exception := '||a_exception_var||'; + exception + when others then + :l_exception := null; + end;' using in out l_exception_no; + + elsif l_exception_type = 'NAMED' then + execute immediate 'begin + raise '||a_exception_var||'; + exception + when others then + :l_exception := sqlcode; + end;' using in out l_exception_no; + end if; + return l_exception_no; + end; + + function is_valid_qualified_name (a_name varchar2) return boolean is + l_name varchar2(500); + begin + l_name:=dbms_assert.qualified_sql_name(a_name); + return true; + exception when others then + return false; + end; + function build_exception_numbers_list(a_annotation_text in varchar2) return ut_integer_list is l_throws_list ut_varchar2_list; l_exception_number_list ut_integer_list := ut_integer_list(); l_regexp_for_excep_nums varchar2(30) := '^-?[[:digit:]]{1,5}$'; begin /*the a_expected_error_codes is converted to a ut_varchar2_list after that is trimmed and filtered to left only valid exception numbers*/ - l_throws_list := ut_utils.string_to_table(a_annotation_text, ',', 'Y'); + l_throws_list := ut_utils.trim_list_elements(ut_utils.string_to_table(a_annotation_text, ',', 'Y')); + + for i in 1..l_throws_list.count + loop + /** + * First check if its a valid qualified name and if so try to resolve to number + * If not check if it matches the ora regex number pattern. + */ + if is_valid_qualified_name(l_throws_list(i)) then + l_throws_list(i) := get_exception_number(l_throws_list(i)); + else + l_throws_list(i) := l_throws_list(i); + end if; + end loop; + l_throws_list := ut_utils.filter_list( ut_utils.trim_list_elements(l_throws_list), l_regexp_for_excep_nums); + l_exception_number_list.extend(l_throws_list.count); for i in 1 .. l_throws_list.count loop l_exception_number_list(i) := l_throws_list(i); diff --git a/test/core/annotations/test_annot_throws_exception.pkb b/test/core/annotations/test_annot_throws_exception.pkb index 26dbc6613..68cba3636 100644 --- a/test/core/annotations/test_annot_throws_exception.pkb +++ b/test/core/annotations/test_annot_throws_exception.pkb @@ -7,8 +7,24 @@ is l_package_spec varchar2(32737); l_package_body varchar2(32737); + l_exception_spec varchar2(32737); l_test_results ut3.ut_varchar2_list; begin + l_exception_spec := q'[ + create or replace package exc_pkg is + c_e_single_exc constant number := -20200; + c_e_varch_exc constant varchar2(10) := '-20201'; + c_e_list_1 number := -20202; + c_e_list_2 constant number := -20203; + c_e_diff_exc constant number := -20204; + c_e_mix_list constant number := -20205; + c_e_mix_missin constant number := -20206; + + e_some_exception exception; + pragma exception_init(e_some_exception, -20207); + + end;]'; + l_package_spec := ' create package annotated_package_with_throws is --%suite(Dummy package to test annotation throws) @@ -45,9 +61,42 @@ is --%throws(7894562, operaqk, -=1, -1, pow74d, posdfk3) procedure one_valid_exception_number; - --%test(Givess failure when a exception is expected and nothing is thrown) + --%test(Gives failure when a exception is expected and nothing is thrown) --%throws(-20459, -20136, -20145) procedure nothing_thrown; + + --%test(Single exception defined as a constant number in package) + --%throws(exc_pkg.c_e_single_exc) + procedure single_exc_const_pkg; + + --%test(Gives success when one of annotated exception using constant is thrown) + --%throws(exc_pkg.c_e_list_1,exc_pkg.c_e_list_2) + procedure list_of_exc_constant; + + --%test(Gives failure when the raised exception is different that the annotated one using variable) + --%throws(exc_pkg.c_e_diff_exc) + procedure fail_not_match_exc; + + --%test(Success when one of exception from mixed list of number and constant is thrown) + --%throws(exc_pkg.c_e_mix_list,-20105) + procedure mixed_exc_list; + + --%test(Success when match exception even if other variable on list dont exists) + --%throws(exc_pkg.c_e_mix_missin,utter_rubbish) + procedure mixed_list_notexi; + + --%test(Success resolve and match named exception defined in pragma exception init) + --%throws(exc_pkg.e_some_exception) + procedure named_exc_pragma; + + --%test(Success resolve and match oracle named exception) + --%throws(NO_DATA_FOUND) + procedure named_exc_ora; + + --%test(Success resolve and match oracle named exception dup val index) + --%throws(DUP_VAL_ON_INDEX) + procedure named_exc_ora_dup_ind; + end; '; @@ -98,12 +147,55 @@ is begin null; end; + + procedure single_exc_const_pkg is + begin + raise_application_error(exc_pkg.c_e_single_exc,''Test''); + end; + + procedure list_of_exc_constant is + begin + raise_application_error(exc_pkg.c_e_list_1,''Test''); + end; + + procedure fail_not_match_exc is + begin + raise NO_DATA_FOUND; + end; + + procedure mixed_exc_list is + begin + raise_application_error(exc_pkg.c_e_mix_list,''Test''); + end; + + procedure mixed_list_notexi is + begin + raise_application_error(exc_pkg.c_e_mix_missin,''Test''); + end; + + procedure named_exc_pragma is + begin + raise exc_pkg.e_some_exception; + end; + + procedure named_exc_ora is + begin + raise NO_DATA_FOUND; + end; + + procedure named_exc_ora_dup_ind is + begin + raise DUP_VAL_ON_INDEX; + end; + end; '; + execute immediate l_exception_spec; execute immediate l_package_spec; execute immediate l_package_body; + select * bulk collect into l_test_results from table(ut3.ut.run(('annotated_package_with_throws'))); g_tests_results := ut3.ut_utils.table_to_clob(l_test_results); @@ -159,15 +251,63 @@ is procedure nothing_thrown is begin - ut.expect(g_tests_results).to_match('^\s*Givess failure when a exception is expected and nothing is thrown \[[\.0-9]+ sec\] \(FAILED - [0-9]+\)\s*$','m'); + ut.expect(g_tests_results).to_match('^\s*Gives failure when a exception is expected and nothing is thrown \[[\.0-9]+ sec\] \(FAILED - [0-9]+\)\s*$','m'); ut.expect(g_tests_results).to_match('nothing_thrown\s*Expected one of exceptions \(-20459, -20136, -20145\) but nothing was raised.'); end; + procedure single_exc_const_pkg is + begin + ut.expect(g_tests_results).to_match('^\s*Single exception defined as a constant number in package \[[\.0-9]+ sec\]\s*$','m'); + ut.expect(g_tests_results).not_to_match('single_exc_const_pkg'); + end; + + procedure list_of_exc_constant is + begin + ut.expect(g_tests_results).to_match('^\s*Gives success when one of annotated exception using constant is thrown \[[\.0-9]+ sec\]\s*$','m'); + ut.expect(g_tests_results).not_to_match('list_of_exc_constant'); + end; + + procedure fail_not_match_exc is + begin + ut.expect(g_tests_results).to_match('^\s*Gives failure when the raised exception is different that the annotated one using variable \[[\.0-9]+ sec\] \(FAILED - [0-9]+\)\s*$','m'); + ut.expect(g_tests_results).to_match('fail_not_match_exc\s+Actual: -1403 was expected to equal: -20204\s+ORA-01403: no data found\s+ORA-06512: at "UT3_TESTER.ANNOTATED_PACKAGE_WITH_THROWS"'); + end; + procedure mixed_exc_list is + begin + ut.expect(g_tests_results).to_match('^\s*Success when one of exception from mixed list of number and constant is thrown \[[\.0-9]+ sec\]\s*$','m'); + ut.expect(g_tests_results).not_to_match('mixed_exc_list'); + end; + + procedure mixed_list_notexi is + begin + ut.expect(g_tests_results).to_match('^\s*Success when match exception even if other variable on list dont exists \[[\.0-9]+ sec\]\s*$','m'); + ut.expect(g_tests_results).not_to_match('mixed_list_notexi'); + end; + + procedure named_exc_pragma is + begin + ut.expect(g_tests_results).to_match('^\s*Success resolve and match named exception defined in pragma exception init \[[\.0-9]+ sec\]\s*$','m'); + ut.expect(g_tests_results).not_to_match('mixed_list_notexi'); + end; + + procedure named_exc_ora is + begin + ut.expect(g_tests_results).to_match('^\s*Success resolve and match oracle named exception \[[\.0-9]+ sec\]\s*$','m'); + ut.expect(g_tests_results).not_to_match('named_exc_ora'); + end; + + procedure named_exc_ora_dup_ind is + begin + ut.expect(g_tests_results).to_match('^\s*Success resolve and match oracle named exception dup val index \[[\.0-9]+ sec\]\s*$','m'); + ut.expect(g_tests_results).not_to_match('named_exc_ora_dup_ind'); + end; + procedure drop_test_package is pragma autonomous_transaction; begin execute immediate 'drop package annotated_package_with_throws'; + execute immediate 'drop package exc_pkg'; end; end; diff --git a/test/core/annotations/test_annot_throws_exception.pks b/test/core/annotations/test_annot_throws_exception.pks index 272f89252..b0a70419f 100644 --- a/test/core/annotations/test_annot_throws_exception.pks +++ b/test/core/annotations/test_annot_throws_exception.pks @@ -30,9 +30,34 @@ is --%test(Detects a valid exception number within many invalid ones) procedure one_valid_exception_number; - --%test(Givess failure when a exception is expected and nothing is thrown) + --%test(Gives failure when a exception is expected and nothing is thrown) procedure nothing_thrown; + --%test(Single exception defined as a constant number in package) + procedure single_exc_const_pkg; + + --%test(Gives success when one of annotated exception using constant is thrown) + procedure list_of_exc_constant; + + --%test(Gives failure when the raised exception is different that the annotated one using variable) + procedure fail_not_match_exc; + + --%test(Success when one of exception from mixed list of number and constant is thrown) + procedure mixed_exc_list; + + --%test(Success when match exception even if other variable on list dont exists) + procedure mixed_list_notexi; + + --%test(Success resolve and match named exception defined in pragma exception init) + procedure named_exc_pragma; + + --%test(Success resolve and match oracle named exception) + --%disabled + procedure named_exc_ora; + + --%test(Success resolve and match oracle named exception dup val index) + procedure named_exc_ora_dup_ind; + --%afterall procedure drop_test_package; From 2427a3a4bdf5006c5ce8a25bc4d56973921e373d Mon Sep 17 00:00:00 2001 From: lwasylow Date: Fri, 1 Jun 2018 22:57:34 +0100 Subject: [PATCH 075/184] Added additional tests --- source/core/ut_suite_builder.pkb | 67 +++++++++++-------- .../test_annot_throws_exception.pkb | 63 ++++++++++++++++- .../test_annot_throws_exception.pks | 15 ++++- 3 files changed, 114 insertions(+), 31 deletions(-) diff --git a/source/core/ut_suite_builder.pkb b/source/core/ut_suite_builder.pkb index 7f0fd0921..df7e31dde 100644 --- a/source/core/ut_suite_builder.pkb +++ b/source/core/ut_suite_builder.pkb @@ -38,6 +38,10 @@ create or replace package body ut_suite_builder is gc_endcontext constant t_annotation_name := 'endcontext'; gc_placeholder constant varchar2(3) := '\\%'; + + gc_int_exception constant varchar2(1) := 'I'; + gc_name_exception constant varchar2(1) := 'N'; + gc_unk_exception constant varchar2(1) := 'U'; --list of annotation texts for a given annotation indexed by annotation position: --This would hold: ('some', 'other') for a single annotation name recurring in a single procedure example @@ -192,23 +196,23 @@ create or replace package body ut_suite_builder is l_c varchar2(250); l_dblink varchar2(250); l_next_pos pls_integer; - l_exception_type varchar2(50) := 'NUMBER'; + l_exception_type varchar2(50) := gc_int_exception; begin begin - --check if it is a number first + --check if it is a number first dbms_utility.name_tokenize(a_exception_name, l_a, l_b, l_c, l_dblink, l_next_pos); --check if it is a predefined exception begin execute immediate 'begin null; exception when '||a_exception_name||' then null; end;'; - l_exception_type := 'NAMED'; + l_exception_type := gc_name_exception; exception when others then if dbms_utility.format_error_stack() like '%PLS-00485%' then execute immediate 'declare x positiven := -('||a_exception_name||'); begin null; end;'; - l_exception_type := 'NUMBER'; + l_exception_type := gc_int_exception; else - l_exception_type := 'UNKNOWN'; + l_exception_type := gc_unk_exception; end if; end; exception when others then @@ -217,31 +221,38 @@ create or replace package body ut_suite_builder is return l_exception_type; end; - - function get_exception_number (a_exception_var in varchar2) return number is - l_exception_no number; - l_exception_type varchar2(50); + function get_exception_number (a_exception_var in varchar2) return integer is + l_exc_no integer; + l_exc_type varchar2(50); + l_sql varchar2(32767); + function remap_no_data (a_number integer) return integer is + begin + return case a_number when 100 then -1403 else a_number end; + end; begin - l_exception_type := check_exception_type(a_exception_var); - if l_exception_type = 'NUMBER' then - execute immediate 'declare - l_exception number; - begin - :l_exception := '||a_exception_var||'; - exception - when others then - :l_exception := null; - end;' using in out l_exception_no; - - elsif l_exception_type = 'NAMED' then - execute immediate 'begin - raise '||a_exception_var||'; - exception - when others then - :l_exception := sqlcode; - end;' using in out l_exception_no; + l_exc_type := check_exception_type(a_exception_var); + + if l_exc_type in (gc_int_exception,gc_name_exception) then + + execute immediate case l_exc_type + when gc_int_exception then + 'declare + l_exception number; + begin + :l_exception := '||a_exception_var||'; ' + when gc_name_exception then + 'begin + raise '||a_exception_var||'; ' + end || + 'exception + when others then + :l_exception := '|| case l_exc_type + when gc_int_exception then 'null;' + when gc_name_exception then 'sqlcode;' + end||' + end;' using in out l_exc_no; end if; - return l_exception_no; + return remap_no_data(l_exc_no); end; function is_valid_qualified_name (a_name varchar2) return boolean is diff --git a/test/core/annotations/test_annot_throws_exception.pkb b/test/core/annotations/test_annot_throws_exception.pkb index 68cba3636..2c8c3be2c 100644 --- a/test/core/annotations/test_annot_throws_exception.pkb +++ b/test/core/annotations/test_annot_throws_exception.pkb @@ -13,6 +13,7 @@ is l_exception_spec := q'[ create or replace package exc_pkg is c_e_single_exc constant number := -20200; + c_e_dummy constant varchar2(10) := 'dummy'; c_e_varch_exc constant varchar2(10) := '-20201'; c_e_list_1 number := -20202; c_e_list_2 constant number := -20203; @@ -97,6 +98,22 @@ is --%throws(DUP_VAL_ON_INDEX) procedure named_exc_ora_dup_ind; + --%test(Success map no data 100 to -1403) + --%throws(-1403) + procedure nodata_exc_ora; + + --%test(Success for exception defined as varchar) + --%throws(exc_pkg.c_e_varch_exc) + procedure defined_varchar_exc; + + --%test(Non existing constant exception) + --%throws(dummy.c_dummy); + procedure non_existing_const; + + --%test(Bad exception constant) + --%throws(exc_pkg.c_e_dummy); + procedure bad_exc_const; + end; '; @@ -187,6 +204,26 @@ is begin raise DUP_VAL_ON_INDEX; end; + + procedure nodata_exc_ora is + begin + raise NO_DATA_FOUND; + end; + + procedure defined_varchar_exc is + begin + raise_application_error(exc_pkg.c_e_varch_exc,''Test''); + end; + + procedure non_existing_const is + begin + raise_application_error(-20143, ''Test error''); + end; + + procedure bad_exc_const is + begin + raise_application_error(-20143, ''Test error''); + end; end; '; @@ -302,7 +339,31 @@ is ut.expect(g_tests_results).to_match('^\s*Success resolve and match oracle named exception dup val index \[[\.0-9]+ sec\]\s*$','m'); ut.expect(g_tests_results).not_to_match('named_exc_ora_dup_ind'); end; - + + procedure nodata_exc_ora is + begin + ut.expect(g_tests_results).to_match('^\s*Success map no data 100 to -1403 \[[\.0-9]+ sec\]\s*$','m'); + ut.expect(g_tests_results).not_to_match('nodata_exc_ora'); + end; + + procedure defined_varchar_exc is + begin + ut.expect(g_tests_results).to_match('^\s*Success for exception defined as varchar \[[\.0-9]+ sec\]\s*$','m'); + ut.expect(g_tests_results).not_to_match('defined_varchar_exc'); + end; + + procedure non_existing_const is + begin + ut.expect(g_tests_results).to_match('^\s*Non existing constant exception \[[\.0-9]+ sec\] \(FAILED - [0-9]+\)\s*$','m'); + ut.expect(g_tests_results).to_match('non_existing_const\s*ORA-20143: Test error\s*ORA-06512: at "UT3_TESTER.ANNOTATED_PACKAGE_WITH_THROWS"'); + end; + + procedure bad_exc_const is + begin + ut.expect(g_tests_results).to_match('^\s*Bad exception constant \[[\.0-9]+ sec\] \(FAILED - [0-9]+\)\s*$','m'); + ut.expect(g_tests_results).to_match('bad_exc_const\s*ORA-20143: Test error\s*ORA-06512: at "UT3_TESTER.ANNOTATED_PACKAGE_WITH_THROWS"'); + end; + procedure drop_test_package is pragma autonomous_transaction; begin diff --git a/test/core/annotations/test_annot_throws_exception.pks b/test/core/annotations/test_annot_throws_exception.pks index b0a70419f..54e814b55 100644 --- a/test/core/annotations/test_annot_throws_exception.pks +++ b/test/core/annotations/test_annot_throws_exception.pks @@ -51,13 +51,24 @@ is --%test(Success resolve and match named exception defined in pragma exception init) procedure named_exc_pragma; - --%test(Success resolve and match oracle named exception) - --%disabled + --%test(Success resolve and match oracle named exception no data) procedure named_exc_ora; --%test(Success resolve and match oracle named exception dup val index) procedure named_exc_ora_dup_ind; + --%test(Success map no data 100 to -1403) + procedure nodata_exc_ora; + + --%test(Success for exception defined as varchar) + procedure defined_varchar_exc; + + --%test(Non existing constant exception) + procedure non_existing_const; + + --%test(Bad exception constant) + procedure bad_exc_const; + --%afterall procedure drop_test_package; From f4b16923f2965586faa8a8c8a1aaade1242afb7c Mon Sep 17 00:00:00 2001 From: lwasylow Date: Sat, 2 Jun 2018 00:00:52 +0100 Subject: [PATCH 076/184] Update docs --- docs/userguide/annotations.md | 127 ++++++++++++++++++++++++++-------- 1 file changed, 98 insertions(+), 29 deletions(-) diff --git a/docs/userguide/annotations.md b/docs/userguide/annotations.md index 86adc9463..c51ac2f5e 100644 --- a/docs/userguide/annotations.md +++ b/docs/userguide/annotations.md @@ -65,7 +65,7 @@ test_package Finished in .002415 seconds 0 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s) -``` +``` Suite package with description. ```sql @@ -82,7 +82,7 @@ Tests for a package Finished in .001646 seconds 0 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s) -``` +``` When multiple `--%suite` annotations are specified in package, the first annotation will be used and a warning message will appear indicating duplicate annotation. ```sql @@ -107,7 +107,7 @@ Warnings: Finished in .003318 seconds 0 tests, 0 failed, 0 errored, 0 disabled, 1 warning(s) -``` +``` When `--%suite` annotation is bound to procedure, it is ignored and results in package not getting recognized as test suite. ```sql @@ -127,7 +127,7 @@ ORA-06512: at "UT3.UT", line 115 ORA-06512: at "UT3.UT", line 306 ORA-06512: at "UT3.UT", line 364 ORA-06512: at line 1 -``` +``` ### Test @@ -166,7 +166,7 @@ Tests for a package Finished in .004109 seconds 1 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s) -``` +``` Test procedure with description. ```sql @@ -192,7 +192,7 @@ Tests for a package Finished in .006828 seconds 1 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s) -``` +``` When multiple `--%test` annotations are specified for a procedure, the first annotation will be used and a warning message will appear indicating duplicate annotation. ```sql @@ -226,7 +226,7 @@ Warnings: Finished in .008815 seconds 1 tests, 0 failed, 0 errored, 0 disabled, 1 warning(s) -``` +``` ### Disabled Marks annotated suite package or test procedure as disabled. @@ -263,7 +263,7 @@ Tests for a package Finished in .001441 seconds 2 tests, 0 failed, 0 errored, 2 disabled, 0 warning(s) -``` +``` Disabling individual test(s). ```sql @@ -393,8 +393,8 @@ The `another_setup` still gets invoked before any test from that suite package i procedure other_test is begin null; end; end; / -``` - + ``` + ```sql exec ut.run('test_package'); ``` @@ -441,7 +441,7 @@ When procedure is annotated as both `--%beforeall` and `--%test`, the procedure end; / ``` - + ```sql exec ut.run('test_package'); ``` @@ -463,8 +463,8 @@ Warnings: Finished in .012158 seconds 2 tests, 0 failed, 0 errored, 0 disabled, 2 warning(s) -``` - + ``` + ### Afterall @@ -532,7 +532,7 @@ The procedure annotated as `--%beforeeach` is getting executed before each test That means that the procedure will be executed as many times as there are test in suite package. If a test is marked as disabled the `--%beforeeach` procedure is not invoked for that test. - + If `--%beforeeach` raises an unhandled exception the following will happen: - the following `--%beforeeach` as well as all `--%beforetest` for that test **will not be executed** - the test will be marked as errored and exception stack trace will be captured and reported @@ -613,7 +613,7 @@ The procedure annotated as `--%aftereach` is getting executed after each test in That means that the procedure will be executed as many times as there are test in suite package. If a test is marked as disabled the `--%aftereach` procedure is not invoked for that test. - + If `--%aftereach` raises an unhandled exception the following will happen: - the test will be marked as errored and exception stack trace will be captured and reported - the `--%aftertest`, `--%aftereach` procedures **will be executed** for the errored test @@ -691,7 +691,7 @@ Used alongside `--%test` annotation. Indicates procedure name to be executed bef The `--%beforetest` procedures are executed after invoking all `--%beforeeach` for a test. If a test is marked as disabled the `--%beforetest` procedure is not invoked for that test. - + If `--%beforetest` raises an unhandled exception the following will happen: - the following `--%beforetest` for that test **will not be executed** - the test will be marked as errored and exception stack trace will be captured and reported @@ -773,7 +773,7 @@ Used alongside `--%test` annotation. Indicates procedure name to be executed aft The `--%aftertest` procedures are executed before invoking any `--%aftereach` for a test. If a test is marked as disabled the `--%aftertest` procedure is not invoked for that test. - + If `--%aftertest` raises an unhandled exception the following will happen: - the test will be marked as errored and exception stack trace will be captured and reported - the following `--%aftertest` and all `--%aftereach` procedures **will be executed** for the errored test @@ -858,7 +858,7 @@ With this comes a challenge. How to group tests, related to one tested procedure This is where utPLSQL contexts come handy. Contexts allow for creating sub-suites within a suite package and they allow for grouping of tests that are somehow related. - + In essence, context behaves like a suite within a suite. Context have following characteristics: @@ -869,10 +869,10 @@ Context have following characteristics: - `--%beforeall`, `--%beforeeach`, `--%afterall` and `--%aftereach` procedures defined at suite level, propagate to context - test suite package can have multiple contexts in it - contexts cannot be nested - + The below example illustrates usage of `--%context` for separating tests for individual procedures of package. - + Tested tables and code ```sql create table rooms ( @@ -1179,15 +1179,30 @@ Keep in mind that when your test runs as autonomous transaction it will not see ### Throws -The `--%throws` annotation allows you to specify a list of exception numbers that can be expected from a test. +The `--%throws` annotation allows you to specify a list of exception either by numbers or by exception type that can be expected from a test. If `--%throws(-20001,-20002)` is specified and no exception is raised or the exception raised is not on the list of provided exception numbers, the test is marked as failed. The framework ignores bad arguments. `--%throws(7894562, operaqk, -=1, -20496, pow74d, posdfk3)` will be interpreted as `--%throws(-20496)`. The annotation is ignored, when no valid arguments are provided `--%throws()`,`--%throws`, `--%throws(abe, 723pf)`. +The framework allows to pass exception defined in variables for example constants in other packages or as exceptions `--%throws(exc_pkg.c_exc_variable)` + +Please note that NO_DATA_FOUND is a special case and it will be translated into -1403. + Example: ```sql +create or replace package exc_pkg is + c_e_option1 constant number := -20200; + c_e_option2 constant varchar2(10) := '-20201'; + c_e_option3 number := -20202; + + e_option4 exception; + pragma exception_init(e_option4, -20203); + +end; +/ + create or replace package example_pgk as --%suite(Example Throws Annotation) @@ -1207,6 +1222,26 @@ create or replace package example_pgk as --%test(Gives failure when an exception is expected and nothing is thrown) --%throws(-20459, -20136, -20145) procedure nothing_thrown; + + --%test(Throws package exception option1) + --%throws(exc_pkg.c_e_option1) + procedure raised_option1_exception; + + --%test(Throws package exception option2) + --%throws(exc_pkg.c_e_option2) + procedure raised_option2_exception; + + --%test(Throws package exception option3) + --%throws(exc_pkg.c_e_option3) + procedure raised_option3_exception; + + --%test(Throws package exception option4) + --%throws(exc_pkg.e_option4) + procedure raised_option4_exception; + + --%test(Raise name exception) + --%throws(DUP_VAL_ON_INDEX) + procedure raise_named_exc; end; / @@ -1230,19 +1265,50 @@ create or replace package body example_pgk is begin ut.expect(1).to_equal(1); end; + + procedure raised_option1_exception is + begin + raise_application_error(exc_pkg.c_e_option1, 'Test error'); + end; + + procedure raised_option2_exception is + begin + raise_application_error(exc_pkg.c_e_option2, 'Test error'); + end; + + procedure raised_option3_exception is + begin + raise_application_error(exc_pkg.c_e_option3, 'Test error'); + end; + + procedure raised_option4_exception is + begin + raise exc_pkg.e_option4; + end; + + procedure raise_named_exc is + begin + raise DUP_VAL_ON_INDEX; + end; + end; / - + exec ut.run('example_pgk'); ``` Running the test will give report: ``` Example Throws Annotation - Throws one of the listed exceptions [.018 sec] - Throws different exception than expected [.008 sec] (FAILED - 1) - Throws different exception than listed [.007 sec] (FAILED - 2) - Gives failure when an exception is expected and nothing is thrown [.002 sec] (FAILED - 3) + Throws one of the listed exceptions [.003 sec] + Throws different exception than expected [.003 sec] (FAILED - 1) + Throws different exception than listed [.004 sec] (FAILED - 2) + Gives failure when an exception is expected and nothing is thrown [.004 sec] (FAILED - 3) + Throws package exception option1 [.003 sec] + Throws package exception option2 [.003 sec] + Throws package exception option3 [.003 sec] + Throws package exception option4 [.003 sec] + Raise name exception [.003 sec] Failures: @@ -1250,19 +1316,22 @@ Failures: Actual: -20143 was expected to equal: -20144 ORA-20143: Test error ORA-06512: at "UT3.EXAMPLE_PGK", line 9 + ORA-06512: at "UT3.EXAMPLE_PGK", line 9 ORA-06512: at line 6 2) raised_unlisted_exception Actual: -20143 was expected to be one of: (-20144, -1, -20145) ORA-20143: Test error ORA-06512: at "UT3.EXAMPLE_PGK", line 14 + ORA-06512: at "UT3.EXAMPLE_PGK", line 14 ORA-06512: at line 6 3) nothing_thrown Expected one of exceptions (-20459, -20136, -20145) but nothing was raised. -Finished in .038692 seconds -4 tests, 3 failed, 0 errored, 0 disabled, 0 warning(s) +Finished in .033843 seconds +9 tests, 3 failed, 0 errored, 0 disabled, 0 warning(s) + ``` ## Order of execution @@ -1335,7 +1404,7 @@ end test_employee_pkg; ``` When processing the test suite `test_employee_pkg` defined in [Example of annotated test package](#example), the order of execution will be as follows. - + ``` create a savepoint 'before-suite' execute setup_employees (--%beforeall) From c7e7eb2ab5348d2d3547c3d17a75a9a6361968cc Mon Sep 17 00:00:00 2001 From: Jacek Gebal Date: Mon, 4 Jun 2018 11:26:09 +0100 Subject: [PATCH 077/184] Refactored code. --- source/core/ut_suite_builder.pkb | 121 ++++++++++++++----------------- source/core/ut_utils.pkb | 2 +- 2 files changed, 56 insertions(+), 67 deletions(-) diff --git a/source/core/ut_suite_builder.pkb b/source/core/ut_suite_builder.pkb index df7e31dde..192ed8142 100644 --- a/source/core/ut_suite_builder.pkb +++ b/source/core/ut_suite_builder.pkb @@ -39,9 +39,8 @@ create or replace package body ut_suite_builder is gc_placeholder constant varchar2(3) := '\\%'; - gc_int_exception constant varchar2(1) := 'I'; - gc_name_exception constant varchar2(1) := 'N'; - gc_unk_exception constant varchar2(1) := 'U'; + gc_integer_exception constant varchar2(1) := 'I'; + gc_named_exception constant varchar2(1) := 'N'; --list of annotation texts for a given annotation indexed by annotation position: --This would hold: ('some', 'other') for a single annotation name recurring in a single procedure example @@ -160,7 +159,7 @@ create or replace package body ut_suite_builder is -- Processing annotations ----------------------------------------------- - procedure add_annotation_warning( + procedure add_annotation_ignored_warning( a_suite in out nocopy ut_suite_item, a_annotation t_annotation_name, a_message varchar2, @@ -191,32 +190,25 @@ create or replace package body ut_suite_builder is end; function check_exception_type(a_exception_name in varchar2) return varchar2 is - l_a varchar2(250); - l_b varchar2(250); - l_c varchar2(250); - l_dblink varchar2(250); - l_next_pos pls_integer; - l_exception_type varchar2(50) := gc_int_exception; + l_exception_type varchar2(50); begin - + --check if it is a predefined exception begin - --check if it is a number first - dbms_utility.name_tokenize(a_exception_name, l_a, l_b, l_c, l_dblink, l_next_pos); - --check if it is a predefined exception - begin - execute immediate 'begin null; exception when '||a_exception_name||' then null; end;'; - l_exception_type := gc_name_exception; - exception - when others then - if dbms_utility.format_error_stack() like '%PLS-00485%' then + execute immediate 'begin null; exception when '||a_exception_name||' then null; end;'; + l_exception_type := gc_named_exception; + exception + when others then + if dbms_utility.format_error_stack() like '%PLS-00485%' then + begin execute immediate 'declare x positiven := -('||a_exception_name||'); begin null; end;'; - l_exception_type := gc_int_exception; - else - l_exception_type := gc_unk_exception; - end if; - end; - exception when others then - null; + l_exception_type := gc_integer_exception; + exception + when others then + --invalid exception number (positive) + --TODO add warning for this value + null; + end; + end if; end; return l_exception_type; end; @@ -225,34 +217,34 @@ create or replace package body ut_suite_builder is l_exc_no integer; l_exc_type varchar2(50); l_sql varchar2(32767); - function remap_no_data (a_number integer) return integer is + function remap_no_data_found (a_number integer) return integer is begin return case a_number when 100 then -1403 else a_number end; end; begin l_exc_type := check_exception_type(a_exception_var); - if l_exc_type in (gc_int_exception,gc_name_exception) then + if l_exc_type is not null then - execute immediate case l_exc_type - when gc_int_exception then - 'declare - l_exception number; - begin - :l_exception := '||a_exception_var||'; ' - when gc_name_exception then - 'begin - raise '||a_exception_var||'; ' - end || - 'exception - when others then - :l_exception := '|| case l_exc_type - when gc_int_exception then 'null;' - when gc_name_exception then 'sqlcode;' - end||' - end;' using in out l_exc_no; + execute immediate + case l_exc_type + when gc_integer_exception then + 'declare + l_exception number; + begin + :l_exception := '||a_exception_var||'; ' + when gc_named_exception then + 'begin + raise '||a_exception_var||'; + exception + when others then + :l_exception := sqlcode; ' + end || + 'end;' + using out l_exc_no; + end if; - return remap_no_data(l_exc_no); + return remap_no_data_found(l_exc_no); end; function is_valid_qualified_name (a_name varchar2) return boolean is @@ -265,27 +257,24 @@ create or replace package body ut_suite_builder is end; function build_exception_numbers_list(a_annotation_text in varchar2) return ut_integer_list is - l_throws_list ut_varchar2_list; - l_exception_number_list ut_integer_list := ut_integer_list(); - l_regexp_for_excep_nums varchar2(30) := '^-?[[:digit:]]{1,5}$'; + l_throws_list ut_varchar2_list; + l_exception_number_list ut_integer_list := ut_integer_list(); + l_regexp_for_exception_no varchar2(30) := '^-?[[:digit:]]{1,5}$'; begin /*the a_expected_error_codes is converted to a ut_varchar2_list after that is trimmed and filtered to left only valid exception numbers*/ l_throws_list := ut_utils.trim_list_elements(ut_utils.string_to_table(a_annotation_text, ',', 'Y')); - for i in 1..l_throws_list.count + for i in 1 .. l_throws_list.count loop /** - * First check if its a valid qualified name and if so try to resolve to number - * If not check if it matches the ora regex number pattern. + * Check if its a valid qualified name and if so try to resolve name to an exception number */ if is_valid_qualified_name(l_throws_list(i)) then l_throws_list(i) := get_exception_number(l_throws_list(i)); - else - l_throws_list(i) := l_throws_list(i); end if; end loop; - l_throws_list := ut_utils.filter_list( ut_utils.trim_list_elements(l_throws_list), l_regexp_for_excep_nums); + l_throws_list := ut_utils.filter_list( ut_utils.trim_list_elements(l_throws_list), l_regexp_for_exception_no); l_exception_number_list.extend(l_throws_list.count); for i in 1 .. l_throws_list.count loop @@ -352,7 +341,7 @@ create or replace package body ut_suite_builder is --start from second occurrence of annotation l_line_no := a_annotations(a_for_annotation).next( a_annotations(a_for_annotation).first ); while l_line_no is not null loop - add_annotation_warning( a_suite, a_for_annotation, 'Duplicate annotation %%%.', l_line_no ); + add_annotation_ignored_warning( a_suite, a_for_annotation, 'Duplicate annotation %%%.', l_line_no ); l_line_no := a_annotations(a_for_annotation).next( l_line_no ); end loop; end if; @@ -373,7 +362,7 @@ create or replace package body ut_suite_builder is --start from second occurrence of annotation l_line_no := a_annotations(a_for_annotation).next( a_annotations(a_for_annotation).first ); while l_line_no is not null loop - add_annotation_warning( a_suite, a_for_annotation, 'Duplicate annotation %%%.', l_line_no, a_procedure_name ); + add_annotation_ignored_warning( a_suite, a_for_annotation, 'Duplicate annotation %%%.', l_line_no, a_procedure_name ); l_line_no := a_annotations(a_for_annotation).next( l_line_no ); end loop; end if; @@ -396,7 +385,7 @@ create or replace package body ut_suite_builder is if l_annotation_name member of a_invalid_annotations then l_line_no := a_proc_annotations(l_annotation_name).first; while l_line_no is not null loop - add_annotation_warning( + add_annotation_ignored_warning( a_suite, l_annotation_name, 'Annotation %%% cannot be used with "--%'|| a_for_annotation || '".', l_line_no, a_procedure_name ); @@ -432,7 +421,7 @@ create or replace package body ut_suite_builder is l_annotation_texts := a_annotations(gc_rollback); l_test.rollback_type := get_rollback_type(l_annotation_texts(l_annotation_texts.first)); if l_test.rollback_type is null then - add_annotation_warning( + add_annotation_ignored_warning( a_suite, gc_rollback, 'Annotation %%% must be provided with one of values: "auto" or "manual".', l_annotation_texts.first, a_procedure_name ); @@ -569,13 +558,13 @@ create or replace package body ut_suite_builder is if regexp_like(l_annotation_text,'^((\w|[$#])+\.)*(\w|[$#])+$') then a_suite.path := l_annotation_text||'.'||l_object_name; else - add_annotation_warning( + add_annotation_ignored_warning( a_suite, gc_suitepath||'('||l_annotation_text||')', 'Invalid path value in annotation %%%.', a_package_ann_index(gc_suitepath).first ); end if; else - add_annotation_warning( + add_annotation_ignored_warning( a_suite, gc_suitepath, '%%% annotation requires a non-empty parameter value.', a_package_ann_index(gc_suitepath).first ); @@ -589,7 +578,7 @@ create or replace package body ut_suite_builder is if l_annotation_text is not null then a_suite.description := l_annotation_text; else - add_annotation_warning( + add_annotation_ignored_warning( a_suite, gc_displayname, '%%% annotation requires a non-empty parameter value.', a_package_ann_index(gc_displayname).first ); @@ -600,7 +589,7 @@ create or replace package body ut_suite_builder is if a_package_ann_index.exists(gc_rollback) then l_rollback_type := get_rollback_type(a_annotations(a_package_ann_index(gc_rollback).first).text); if l_rollback_type is null then - add_annotation_warning( + add_annotation_ignored_warning( a_suite, gc_rollback, '%%% annotation requires one of values as parameter: "auto" or "manual".', a_package_ann_index(gc_rollback).first ); @@ -712,7 +701,7 @@ create or replace package body ut_suite_builder is if a_package_ann_index.exists(gc_context) then l_annotation_pos := a_package_ann_index(gc_context).first; while l_annotation_pos is not null loop - add_annotation_warning( + add_annotation_ignored_warning( a_suite, gc_context, 'Invalid annotation %%%. Cannot find following "--%endcontext".', l_annotation_pos ); @@ -722,7 +711,7 @@ create or replace package body ut_suite_builder is if a_package_ann_index.exists(gc_endcontext) then l_annotation_pos := a_package_ann_index(gc_endcontext).first; while l_annotation_pos is not null loop - add_annotation_warning( + add_annotation_ignored_warning( a_suite, gc_endcontext, 'Invalid annotation %%%. Cannot find preceding "--%context".', l_annotation_pos ); diff --git a/source/core/ut_utils.pkb b/source/core/ut_utils.pkb index 4964848e7..4654f9b34 100644 --- a/source/core/ut_utils.pkb +++ b/source/core/ut_utils.pkb @@ -525,7 +525,7 @@ procedure append_to_clob(a_src_clob in out nocopy clob, a_clob_table t_clob_tab, return l_trimmed_list; end; - function filter_list(a_list IN ut_varchar2_list, a_regexp_filter in varchar2) return ut_varchar2_list is + function filter_list(a_list in ut_varchar2_list, a_regexp_filter in varchar2) return ut_varchar2_list is l_filtered_list ut_varchar2_list; l_index integer; begin From 9e55e99fafa9e754e6bf065502947551258ad223 Mon Sep 17 00:00:00 2001 From: Jacek Gebal Date: Mon, 4 Jun 2018 11:26:27 +0100 Subject: [PATCH 078/184] Documentation improvements --- docs/userguide/annotations.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/userguide/annotations.md b/docs/userguide/annotations.md index c51ac2f5e..be0846f75 100644 --- a/docs/userguide/annotations.md +++ b/docs/userguide/annotations.md @@ -1179,9 +1179,13 @@ Keep in mind that when your test runs as autonomous transaction it will not see ### Throws -The `--%throws` annotation allows you to specify a list of exception either by numbers or by exception type that can be expected from a test. +The `--%throws` annotation allows you to specify a list of exceptions as one of: +- number literals +- variables of type exception defined in a package specification +- variables of type number defined in a package specification +- [predefined oracle exceptions](https://docs.oracle.com/cd/E11882_01/timesten.112/e21639/exceptions.htm#CIHFIGFE) -If `--%throws(-20001,-20002)` is specified and no exception is raised or the exception raised is not on the list of provided exception numbers, the test is marked as failed. +If `--%throws(-20001,-20002)` is specified and no exception is raised or the exception raised is not on the list of provided exceptions, the test is marked as failed. The framework ignores bad arguments. `--%throws(7894562, operaqk, -=1, -20496, pow74d, posdfk3)` will be interpreted as `--%throws(-20496)`. The annotation is ignored, when no valid arguments are provided `--%throws()`,`--%throws`, `--%throws(abe, 723pf)`. From 984736474a6a69dbd4e4a4a8f4583ea5cec584c5 Mon Sep 17 00:00:00 2001 From: Jacek Gebal Date: Mon, 4 Jun 2018 12:53:05 +0100 Subject: [PATCH 079/184] Added support for warnings on `--%throws` annotation --- docs/userguide/annotations.md | 65 ++++++++++++++++-------- source/core/ut_suite_builder.pkb | 87 +++++++++++++++++++++++--------- test/core/test_suite_builder.pkb | 36 +++++++++++++ test/core/test_suite_builder.pks | 6 +++ 4 files changed, 148 insertions(+), 46 deletions(-) diff --git a/docs/userguide/annotations.md b/docs/userguide/annotations.md index be0846f75..636c09264 100644 --- a/docs/userguide/annotations.md +++ b/docs/userguide/annotations.md @@ -1180,20 +1180,23 @@ Keep in mind that when your test runs as autonomous transaction it will not see ### Throws The `--%throws` annotation allows you to specify a list of exceptions as one of: -- number literals -- variables of type exception defined in a package specification -- variables of type number defined in a package specification -- [predefined oracle exceptions](https://docs.oracle.com/cd/E11882_01/timesten.112/e21639/exceptions.htm#CIHFIGFE) +- number literals - example `--%throws(-20134)` +- variables of type exception defined in a package specification - example `--%throws(exc_pkg.c_exception_No_variable)` +- variables of type number defined in a package specification - example `--%throws(exc_pkg.c_some_exception)` +- [predefined oracle exceptions](https://docs.oracle.com/cd/E11882_01/timesten.112/e21639/exceptions.htm#CIHFIGFE) - example `--%throws(no_data_found)` -If `--%throws(-20001,-20002)` is specified and no exception is raised or the exception raised is not on the list of provided exceptions, the test is marked as failed. +The annotation is ignored, when no valid arguments are provided. Examples of invalid annotations `--%throws()`,`--%throws`, `--%throws(abe, 723pf)`. -The framework ignores bad arguments. `--%throws(7894562, operaqk, -=1, -20496, pow74d, posdfk3)` will be interpreted as `--%throws(-20496)`. -The annotation is ignored, when no valid arguments are provided `--%throws()`,`--%throws`, `--%throws(abe, 723pf)`. +If `--%throws` annotation is specified with arguments and no exception is raised, the test is marked as failed. -The framework allows to pass exception defined in variables for example constants in other packages or as exceptions `--%throws(exc_pkg.c_exc_variable)` +If `--%throws` annotation is specified with arguments and exception raised is not on the list of provided exceptions, the test is marked as failed. -Please note that NO_DATA_FOUND is a special case and it will be translated into -1403. +The framework will raise a warning, when `--%throws` annotation has invalid arguments or when no arguments were provided. +Annotation `--%throws(7894562, operaqk, -=1, -20496, pow74d, posdfk3)` will be interpreted as `--%throws(-20496)`. + +Please note that `NO_DATA_FOUND` exception is a special case in Oracle. To capture it use `NO_DATA_FOUND` named exception or `-1403` exception No. + Example: ```sql create or replace package exc_pkg is @@ -1212,7 +1215,7 @@ create or replace package example_pgk as --%suite(Example Throws Annotation) --%test(Throws one of the listed exceptions) - --%throws(-20145,-20146, -20189 ,-20563) + --%throws(-20145,bad,-20146, -20189 ,-20563) procedure raised_one_listed_exception; --%test(Throws different exception than expected) @@ -1247,6 +1250,10 @@ create or replace package example_pgk as --%throws(DUP_VAL_ON_INDEX) procedure raise_named_exc; + --%test(Invalid throws annotation) + --%throws + procedure bad_throws_annotation; + end; / create or replace package body example_pgk is @@ -1295,24 +1302,29 @@ create or replace package body example_pgk is raise DUP_VAL_ON_INDEX; end; + procedure bad_throws_annotation is + begin + null; + end; end; / -exec ut.run('example_pgk'); +exec ut3.ut.run('example_pgk'); ``` Running the test will give report: ``` Example Throws Annotation - Throws one of the listed exceptions [.003 sec] - Throws different exception than expected [.003 sec] (FAILED - 1) - Throws different exception than listed [.004 sec] (FAILED - 2) - Gives failure when an exception is expected and nothing is thrown [.004 sec] (FAILED - 3) + Throws one of the listed exceptions [.002 sec] + Throws different exception than expected [.002 sec] (FAILED - 1) + Throws different exception than listed [.003 sec] (FAILED - 2) + Gives failure when an exception is expected and nothing is thrown [.002 sec] (FAILED - 3) Throws package exception option1 [.003 sec] - Throws package exception option2 [.003 sec] - Throws package exception option3 [.003 sec] - Throws package exception option4 [.003 sec] - Raise name exception [.003 sec] + Throws package exception option2 [.002 sec] + Throws package exception option3 [.002 sec] + Throws package exception option4 [.002 sec] + Raise name exception [.002 sec] + Invalid throws annotation [.002 sec] Failures: @@ -1333,9 +1345,18 @@ Failures: 3) nothing_thrown Expected one of exceptions (-20459, -20136, -20145) but nothing was raised. -Finished in .033843 seconds -9 tests, 3 failed, 0 errored, 0 disabled, 0 warning(s) - + +Warnings: + + 1) example_pgk + Invalid parameter value "bad" for "--%throws" annotation. Parameter ignored. + at "UT3.EXAMPLE_PGK.RAISED_ONE_LISTED_EXCEPTION", line 6 + 2) example_pgk + "--%throws" annotation requires a parameter. Annotation ignored. + at "UT3.EXAMPLE_PGK.BAD_THROWS_ANNOTATION", line 42 + +Finished in .025784 seconds +10 tests, 3 failed, 0 errored, 0 disabled, 2 warning(s) ``` ## Order of execution diff --git a/source/core/ut_suite_builder.pkb b/source/core/ut_suite_builder.pkb index 192ed8142..1f55d4291 100644 --- a/source/core/ut_suite_builder.pkb +++ b/source/core/ut_suite_builder.pkb @@ -159,6 +159,20 @@ create or replace package body ut_suite_builder is -- Processing annotations ----------------------------------------------- + function get_qualified_object_name( + a_suite ut_suite_item, a_procedure_name t_object_name + ) return varchar2 is + l_result varchar2(1000); + begin + if a_suite is not null then + l_result := upper( a_suite.object_owner || '.' || a_suite.object_name ); + if a_procedure_name is not null then + l_result := l_result || upper( '.' || a_procedure_name ); + end if; + end if; + return l_result; + end; + procedure add_annotation_ignored_warning( a_suite in out nocopy ut_suite_item, a_annotation t_annotation_name, @@ -168,13 +182,9 @@ create or replace package body ut_suite_builder is ) is l_object_name varchar2(1000); begin - l_object_name := upper( a_suite.object_owner || '.' || a_suite.object_name ); - if a_procedure_name is not null then - l_object_name := l_object_name || upper( '.' || a_procedure_name ); - end if; a_suite.put_warning( replace(a_message,'%%%','"--%'||a_annotation||'"') || ' Annotation ignored.' - || chr( 10 ) || 'at "' || l_object_name || '", line ' || a_line_no + || chr( 10 ) || 'at "' || get_qualified_object_name(a_suite, a_procedure_name) || '", line ' || a_line_no ); end; @@ -256,10 +266,16 @@ create or replace package body ut_suite_builder is return false; end; - function build_exception_numbers_list(a_annotation_text in varchar2) return ut_integer_list is + function build_exception_numbers_list( + a_suite in out nocopy ut_suite, + a_procedure_name t_object_name, + a_line_no integer, + a_annotation_text in varchar2 + ) return ut_integer_list is l_throws_list ut_varchar2_list; + l_exception_number integer; l_exception_number_list ut_integer_list := ut_integer_list(); - l_regexp_for_exception_no varchar2(30) := '^-?[[:digit:]]{1,5}$'; + c_regexp_for_exception_no constant varchar2(30) := '^-?[[:digit:]]{1,5}$'; begin /*the a_expected_error_codes is converted to a ut_varchar2_list after that is trimmed and filtered to left only valid exception numbers*/ l_throws_list := ut_utils.trim_list_elements(ut_utils.string_to_table(a_annotation_text, ',', 'Y')); @@ -269,22 +285,31 @@ create or replace package body ut_suite_builder is /** * Check if its a valid qualified name and if so try to resolve name to an exception number */ - if is_valid_qualified_name(l_throws_list(i)) then - l_throws_list(i) := get_exception_number(l_throws_list(i)); + if is_valid_qualified_name(l_throws_list(i)) then + l_exception_number := get_exception_number(l_throws_list(i)); + elsif regexp_like(l_throws_list(i), c_regexp_for_exception_no) then + l_exception_number := l_throws_list(i); end if; - end loop; - - l_throws_list := ut_utils.filter_list( ut_utils.trim_list_elements(l_throws_list), l_regexp_for_exception_no); - l_exception_number_list.extend(l_throws_list.count); - for i in 1 .. l_throws_list.count loop - l_exception_number_list(i) := l_throws_list(i); + if l_exception_number is null then + a_suite.put_warning( + 'Invalid parameter value "'||l_throws_list(i)||'" for "--%throws" annotation. Parameter ignored.' + || chr( 10 ) || 'at "' || get_qualified_object_name(a_suite, a_procedure_name) || '", line ' || a_line_no + ); + else + l_exception_number_list.extend; + l_exception_number_list(l_exception_number_list.last) := l_exception_number; + end if; + l_exception_number := null; end loop; + return l_exception_number_list; end; procedure add_to_throws_numbers_list( - a_list in out nocopy ut_integer_list, + a_suite in out nocopy ut_suite, + a_list in out nocopy ut_integer_list, + a_procedure_name t_object_name, a_throws_ann_text tt_annotation_texts ) is l_annotation_pos binary_integer; @@ -292,16 +317,30 @@ create or replace package body ut_suite_builder is a_list := ut_integer_list(); l_annotation_pos := a_throws_ann_text.first; while l_annotation_pos is not null loop - a_list := a_list multiset union build_exception_numbers_list( a_throws_ann_text(l_annotation_pos)); + if a_throws_ann_text(l_annotation_pos) is null then + a_suite.put_warning( + '"--%throws" annotation requires a parameter. Annotation ignored.' + || chr( 10 ) || 'at "' || get_qualified_object_name(a_suite, a_procedure_name) || '", line ' || l_annotation_pos + ); + else + a_list := + a_list multiset union + build_exception_numbers_list( + a_suite, + a_procedure_name, + l_annotation_pos, + a_throws_ann_text(l_annotation_pos) + ); + end if; l_annotation_pos := a_throws_ann_text.next(l_annotation_pos); end loop; end; procedure add_to_list( a_executables in out nocopy ut_executables, - a_owner varchar2, - a_package_name varchar2, - a_procedure_name varchar2, + a_owner t_object_name, + a_package_name t_object_name, + a_procedure_name t_object_name, a_executable_type ut_utils.t_executable_type ) is begin @@ -314,8 +353,8 @@ create or replace package body ut_suite_builder is procedure add_all_to_list( a_executables in out nocopy ut_executables, - a_owner varchar2, - a_package_name varchar2, + a_owner t_object_name, + a_package_name t_object_name, a_annotation_texts tt_annotation_texts, a_event_name ut_utils.t_event_name ) is @@ -398,7 +437,7 @@ create or replace package body ut_suite_builder is procedure add_test( a_suite in out nocopy ut_suite, - a_procedure_name varchar2, + a_procedure_name t_object_name, a_annotations tt_procedure_annotations ) is l_test ut_test; @@ -435,7 +474,7 @@ create or replace package body ut_suite_builder is add_all_to_list( l_test.after_test_list, l_test.object_owner, l_test.object_name, a_annotations(gc_aftertest), ut_utils.gc_after_test ); end if; if a_annotations.exists(gc_throws) then - add_to_throws_numbers_list(l_test.expected_error_codes, a_annotations(gc_throws)); + add_to_throws_numbers_list(a_suite, l_test.expected_error_codes, a_procedure_name, a_annotations(gc_throws)); end if; l_test.disabled_flag := ut_utils.boolean_to_int(a_annotations.exists(gc_disabled)); diff --git a/test/core/test_suite_builder.pkb b/test/core/test_suite_builder.pkb index 654143349..4bdd8095d 100644 --- a/test/core/test_suite_builder.pkb +++ b/test/core/test_suite_builder.pkb @@ -705,5 +705,41 @@ create or replace package body test_suite_builder is ); end; + procedure throws_value_empty is + l_actual clob; + l_annotations ut3.ut_annotations; + begin + --Arrange + l_annotations := ut3.ut_annotations( + ut3.ut_annotation(1, 'suite','Cool', null), + ut3.ut_annotation(3, 'test','A test with empty throws annotation', 'A_TEST_PROCEDURE'), + ut3.ut_annotation(3, 'throws',null, 'A_TEST_PROCEDURE') + ); + --Act + l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); + --Assert + ut.expect(l_actual).to_be_like( + '%%"--%throws" annotation requires a parameter. Annotation ignored.%%' + ); + end; + + procedure throws_value_invalid is + l_actual clob; + l_annotations ut3.ut_annotations; + begin + --Arrange + l_annotations := ut3.ut_annotations( + ut3.ut_annotation(1, 'suite','Cool', null), + ut3.ut_annotation(3, 'test','A test with invalid throws annotation', 'A_TEST_PROCEDURE'), + ut3.ut_annotation(3, 'throws',' -20145 , bad_variable_name ', 'A_TEST_PROCEDURE') + ); + --Act + l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); + --Assert + ut.expect(l_actual).to_be_like( + '%%Invalid parameter value "bad_variable_name" for "--%throws" annotation. Parameter ignored.%%' + ); + end; + end; / diff --git a/test/core/test_suite_builder.pks b/test/core/test_suite_builder.pks index d8bf40164..6eef1ee2c 100644 --- a/test/core/test_suite_builder.pks +++ b/test/core/test_suite_builder.pks @@ -83,5 +83,11 @@ create or replace package test_suite_builder is --%test(Gives warning if --%endcontext is missing a preceding --%context) procedure endcontext_without_context; + --%test(Gives warning if --%throws annotation has no value) + procedure throws_value_empty; + + --%test(Gives warning if --%throws annotation has invalid value) + procedure throws_value_invalid; + end; / From 1373583b35ea859be449937817ad62624d9a4255 Mon Sep 17 00:00:00 2001 From: Travis CI Date: Mon, 4 Jun 2018 21:21:26 +0000 Subject: [PATCH 080/184] Updated project version after build [skip ci] --- source/core/ut_utils.pks | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/core/ut_utils.pks b/source/core/ut_utils.pks index 9176b1e07..76c8a4491 100644 --- a/source/core/ut_utils.pks +++ b/source/core/ut_utils.pks @@ -21,7 +21,7 @@ create or replace package ut_utils authid definer is * */ - gc_version constant varchar2(50) := 'v3.1.2.1964-develop'; + gc_version constant varchar2(50) := 'v3.1.2.1973-develop'; /* Constants: Event names */ subtype t_event_name is varchar2(30); From f06bd0a292a33cc9d2c691f376ae98071171062d Mon Sep 17 00:00:00 2001 From: Jacek Gebal Date: Tue, 5 Jun 2018 01:27:40 +0100 Subject: [PATCH 081/184] Split uninstall script into smaller, independent pieces. Added `uninstall_all` to remove all objects created by install. Added calls to `uninstall_all` into deployment to validate the uninstall process completeness. --- .travis/install.sh | 31 +++ source/uninstall.sql | 359 +-------------------------- source/uninstall_all.sql | 45 ++++ source/uninstall_coverage_tables.sql | 33 +++ source/uninstall_objects.sql | 299 ++++++++++++++++++++++ source/uninstall_synonyms.sql | 64 +++++ 6 files changed, 474 insertions(+), 357 deletions(-) create mode 100644 source/uninstall_all.sql create mode 100644 source/uninstall_coverage_tables.sql create mode 100644 source/uninstall_objects.sql create mode 100644 source/uninstall_synonyms.sql diff --git a/.travis/install.sh b/.travis/install.sh index 0cc3400dc..1c3e3ef7e 100644 --- a/.travis/install.sh +++ b/.travis/install.sh @@ -11,6 +11,37 @@ alter session set plsql_warnings = 'ENABLE:ALL', 'DISABLE:(5004,5018,6000,6001,6 @install_headless.sql $UT3_OWNER $UT3_OWNER_PASSWORD SQL +#uninstall core of utplsql +"$SQLCLI" sys/$ORACLE_PWD@//$CONNECTION_STR AS SYSDBA <<-SQL +set feedback off +set verify off + +@uninstall_all.sql $UT3_OWNER +declare + v_leftover_objects_count integer; +begin + select sum(cnt) + into v_leftover_objects_count + from (select count(1) cnt from dba_objects where owner = '$UT3_OWNER' + union all + select count(1) cnt from dba_synonyms where table_owner = '$UT3_OWNER' + ); + if v_leftover_objects_count > 0 then + raise_application_error(-20000, 'Not all objects were successfully uninstalled - leftover objects count='||v_leftover_objects_count); + end if; +end; +/ +SQL + +#reinstall core of utplsql +"$SQLCLI" sys/$ORACLE_PWD@//$CONNECTION_STR AS SYSDBA <<-SQL +set feedback off +set verify off + +alter session set plsql_warnings = 'ENABLE:ALL', 'DISABLE:(5004,5018,6000,6001,6003,6009,6010,7206)'; +@install.sql $UT3_OWNER +SQL + #additional privileges to run scripted tests "$SQLCLI" sys/$ORACLE_PWD@//$CONNECTION_STR AS SYSDBA <<-SQL set feedback on diff --git a/source/uninstall.sql b/source/uninstall.sql index 0a8540592..0991d9245 100644 --- a/source/uninstall.sql +++ b/source/uninstall.sql @@ -25,365 +25,10 @@ prompt Uninstalling UTPLSQL v3 framework prompt &&line_separator alter session set current_schema = &&ut3_owner; -set echo on -drop synonym be_between; -drop synonym have_count; +@@uninstall_objects.sql -drop synonym match; - -drop synonym be_false; - -drop synonym be_empty; - -drop synonym be_greater_or_equal; - -drop synonym be_greater_than; - -drop synonym be_less_or_equal; - -drop synonym be_less_than; - -drop synonym be_like; - -drop synonym be_not_null; - -drop synonym be_null; - -drop synonym be_true; - -drop synonym equal; - -drop type ut_coveralls_reporter force; - -drop type ut_coverage_sonar_reporter force; - -drop type ut_coverage_cobertura_reporter force; - -drop package ut_coverage_report_html_helper; - -drop type ut_coverage_html_reporter force; - -drop type ut_sonar_test_reporter force; - -drop package ut_coverage; - -drop package ut_coverage_helper; - -drop view ut_coverage_sources_tmp; - -drop table ut_coverage_sources_tmp$; - -drop package ut_teamcity_reporter_helper; - -drop package ut_runner; - -drop package ut_suite_manager; - -drop package ut_suite_builder; - -drop package ut; - -drop table ut_dbms_output_cache; - -drop type ut_expectation_compound force; - -drop type ut_expectation force; - -drop package ut_expectation_processor; - -drop type ut_match force; - -drop type ut_be_between force; - -drop type ut_equal force; - -drop type ut_be_true force; - -drop type ut_be_null force; - -drop type ut_be_not_null force; - -drop type ut_be_like force; - -drop type ut_be_greater_or_equal force; - -drop type ut_be_empty force; - -drop type ut_be_greater_than force; - -drop type ut_be_less_or_equal force; - -drop type ut_be_less_than force; - -drop type ut_be_false force; - -drop type ut_comparison_matcher force; - -drop type ut_matcher force; - -drop type ut_data_value_yminterval force; - -drop type ut_data_value_varchar2 force; - -drop type ut_data_value_timestamp_tz force; - -drop type ut_data_value_timestamp_ltz force; - -drop type ut_data_value_timestamp force; - -drop type ut_data_value_number force; - -drop type ut_data_value_refcursor force; - -drop type ut_data_value_dsinterval force; - -drop type ut_data_value_date force; - -drop type ut_data_value_clob force; - -drop type ut_data_value_boolean force; - -drop type ut_data_value_blob force; - -drop type ut_data_value_object force; - -drop type ut_data_value_collection force; - -drop type ut_data_value_anydata force; - -drop type ut_data_value_xmltype force; - -drop type ut_data_value force; - -drop table ut_compound_data_tmp; - -drop table ut_compound_data_diff_tmp; - -drop package ut_annotation_manager; - -drop package ut_annotation_parser; - -drop package ut_annotation_cache_manager; - -drop table ut_annotation_cache cascade constraints; - -drop table ut_annotation_cache_info cascade constraints; - -drop sequence ut_annotation_cache_seq; - -drop type ut_annotation_objs_cache_info force; - -drop type ut_annotation_obj_cache_info force; - -drop type ut_annotated_objects force; - -drop type ut_annotated_object force; - -drop type ut_annotations force; - -drop type ut_annotation force; - -drop package ut_file_mapper; - -drop package ut_metadata; - -drop package ut_ansiconsole_helper; - -drop package ut_utils; - -drop type ut_documentation_reporter force; - -drop type ut_teamcity_reporter force; - -drop type ut_xunit_reporter force; - -drop type ut_junit_reporter force; - -drop type ut_tfs_junit_reporter force; - -drop type ut_event_listener force; - -drop type ut_output_reporter_base force; - -drop type ut_coverage_reporter_base force; - -drop type ut_reporters force; - -drop type ut_reporter_base force; - -drop type ut_run force; - -drop type ut_coverage_options force; - -drop type ut_file_mappings force; - -drop type ut_file_mapping force; - -drop type ut_suite force; - -drop type ut_logical_suite force; - -drop type ut_test force; - -drop type ut_console_reporter_base force; - -drop type ut_executable_test force; - -drop type ut_executables force; - -drop type ut_executable force; - -drop type ut_suite_items force; - -drop type ut_suite_item force; - -drop type ut_output_table_buffer force; - -drop type ut_output_buffer_base force; - -drop view ut_output_buffer_tmp; - -drop table ut_output_buffer_tmp$ purge; - -drop view ut_output_buffer_info_tmp; - -drop table ut_output_buffer_info_tmp$; - -drop sequence ut_message_id_seq; - -drop type ut_results_counter force; - -drop type ut_expectation_results force; - -drop type ut_expectation_result force; - -drop package ut_event_manager; - -drop type ut_event_item force; - -drop type ut_key_anyval_pair force; - -drop type ut_key_anyval_pairs force; - -drop type ut_key_value_pairs force; - -drop type ut_key_value_pair force; - -drop type ut_object_names force; - -drop type ut_object_name force; - -drop type ut_integer_list force; - -drop type ut_varchar2_list force; - -drop type ut_varchar2_rows force; - -drop package ut_coverage_profiler; - -drop package ut_compound_data_helper; - -drop package ut_coverage_helper_profiler; - -drop type ut_have_count; - -drop type ut_compound_data_value; - -set echo off -set feedback off -declare - i integer := 0; -begin - dbms_output.put_line('Dropping synonyms pointing to non-existing objects in schema '||upper('&&ut3_owner')); - for syn in ( - select - case when owner = 'PUBLIC' - then 'public synonym ' - else 'synonym ' || owner || '.' end || synonym_name as syn_name, - table_owner||'.'||table_name as for_object - from all_synonyms s - where table_owner = upper('&&ut3_owner') and table_owner != owner - and not exists (select 1 from all_objects o where o.owner = s.table_owner and o.object_name = s.table_name) - ) - loop - i := i + 1; - begin - execute immediate 'drop '||syn.syn_name; - dbms_output.put_line('Dropped '||syn.syn_name||' for object '||syn.for_object); - exception - when others then - dbms_output.put_line('FAILED to drop '||syn.syn_name||' for object '||syn.for_object); - end; - end loop; - dbms_output.put_line('&&line_separator'); - dbms_output.put_line(i||' synonyms dropped'); -end; -/ - -declare - i integer := 0; -begin - dbms_output.put_line('Dropping synonyms pointing to PL/SQL code coverage objects on 12.2 ' || upper('&&ut3_owner')); - for syn in ( - select - case when owner = 'PUBLIC' then 'public synonym ' - else 'synonym ' || owner || '.' - end || synonym_name as syn_name, - table_owner || '.' || table_name as for_object - from all_synonyms s - where 1 = 1 - and table_owner = upper('&&ut3_owner') - and synonym_name in ('DBMSPCC_BLOCKS','DBMSPCC_RUNS','DBMSPCC_UNITS') - ) - loop - - begin - - execute immediate 'drop '||syn.syn_name; - sys.dbms_output.put_line('Dropped '||syn.syn_name||' for object '||syn.for_object); - - i := i + 1; - exception - when others then - sys.dbms_output.put_line('FAILED to drop '||syn.syn_name||' for object '||syn.for_object); - end; - end loop; - sys.dbms_output.put_line('&&line_separator'); - sys.dbms_output.put_line(i||' synonyms dropped'); -end; -/ - -declare - i integer := 0; -begin - sys.dbms_output.put_line('Dropping packages created for 12.2+ ' || upper('&&ut3_owner')); - - for pkg in (select object_name, owner - from all_objects - where 1 = 1 - and owner = upper('&&ut3_owner') - and object_type = 'PACKAGE' - and object_name in ('UT_COVERAGE_HELPER_BLOCK','UT_COVERAGE_BLOCK')) - loop - - begin - execute immediate 'drop package ' || pkg.owner || '.' || pkg.object_name; - - sys.dbms_output.put_line('Dropped '|| pkg.object_name); - i := i + 1; - - exception - when others then - dbms_output.put_line('FAILED to drop ' || pkg.object_name); - end; - - end loop; - - sys.dbms_output.put_line('&&line_separator'); - sys.dbms_output.put_line(i || ' packages dropped'); -end; -/ +@@uninstall_synonyms.sql begin dbms_output.put_line('&&line_separator'); diff --git a/source/uninstall_all.sql b/source/uninstall_all.sql new file mode 100644 index 000000000..21b567d0e --- /dev/null +++ b/source/uninstall_all.sql @@ -0,0 +1,45 @@ +/* + utPLSQL - Version 3 + Copyright 2016 - 2017 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. +*/ +@@define_ut3_owner_param.sql + +set feedback on + +spool uninstall.log + +prompt &&line_separator +prompt Uninstalling UTPLSQL v3 framework +prompt &&line_separator + +alter session set current_schema = &&ut3_owner; + +@@uninstall_objects.sql + +@@uninstall_coverage_tables.sql + +@@uninstall_synonyms.sql + +begin + dbms_output.put_line('&&line_separator'); + dbms_output.put_line('Uninstall complete'); + dbms_output.put_line('&&line_separator'); +end; +/ + +spool off + +exit; + diff --git a/source/uninstall_coverage_tables.sql b/source/uninstall_coverage_tables.sql new file mode 100644 index 000000000..8de75b51e --- /dev/null +++ b/source/uninstall_coverage_tables.sql @@ -0,0 +1,33 @@ +set echo off +set feedback off +begin + for to_be_dopped in ( + select table_name + from all_tables + where table_name in ( + 'PLSQL_PROFILER_RUNS','PLSQL_PROFILER_UNITS','PLSQL_PROFILER_DATA', + 'DBMSPCC_BLOCKS','DBMSPCC_RUNS','DBMSPCC_UNITS' + ) + and owner = sys_context( 'USERENV', 'CURRENT_SCHEMA' ) + ) + loop + execute immediate 'drop table '||to_be_dopped.table_name||' cascade constraints'; + dbms_output.put_line('Table '||to_be_dopped.table_name||' dropped'); + end loop; +end; +/ + +declare + l_seq_exist number; +begin + select count(*) into l_seq_exist + from all_sequences + where sequence_name = 'PLSQL_PROFILER_RUNNUMBER' + and sequence_owner = sys_context('USERENV','CURRENT_SCHEMA'); + if l_seq_exist = 1 then + execute immediate 'drop sequence plsql_profiler_runnumber'; + dbms_output.put_line('Sequence PLSQL_PROFILER_RUNNUMBER dropped'); + end if; +end; +/ + diff --git a/source/uninstall_objects.sql b/source/uninstall_objects.sql new file mode 100644 index 000000000..48bf7cc76 --- /dev/null +++ b/source/uninstall_objects.sql @@ -0,0 +1,299 @@ +set echo on +drop synonym be_between; + +drop synonym have_count; + +drop synonym match; + +drop synonym be_false; + +drop synonym be_empty; + +drop synonym be_greater_or_equal; + +drop synonym be_greater_than; + +drop synonym be_less_or_equal; + +drop synonym be_less_than; + +drop synonym be_like; + +drop synonym be_not_null; + +drop synonym be_null; + +drop synonym be_true; + +drop synonym equal; + +drop type ut_coveralls_reporter force; + +drop type ut_coverage_sonar_reporter force; + +drop type ut_coverage_cobertura_reporter force; + +drop package ut_coverage_report_html_helper; + +drop type ut_coverage_html_reporter force; + +drop type ut_sonar_test_reporter force; + +drop package ut_coverage; + +drop package ut_coverage_helper; + +drop view ut_coverage_sources_tmp; + +drop table ut_coverage_sources_tmp$; + +drop package ut_teamcity_reporter_helper; + +drop package ut_runner; + +drop package ut_suite_manager; + +drop package ut_suite_builder; + +drop package ut; + +drop table ut_dbms_output_cache; + +drop type ut_expectation_compound force; + +drop type ut_expectation force; + +drop package ut_expectation_processor; + +drop type ut_match force; + +drop type ut_be_between force; + +drop type ut_equal force; + +drop type ut_be_true force; + +drop type ut_be_null force; + +drop type ut_be_not_null force; + +drop type ut_be_like force; + +drop type ut_be_greater_or_equal force; + +drop type ut_be_empty force; + +drop type ut_be_greater_than force; + +drop type ut_be_less_or_equal force; + +drop type ut_be_less_than force; + +drop type ut_be_false force; + +drop type ut_comparison_matcher force; + +drop type ut_matcher force; + +drop type ut_data_value_yminterval force; + +drop type ut_data_value_varchar2 force; + +drop type ut_data_value_timestamp_tz force; + +drop type ut_data_value_timestamp_ltz force; + +drop type ut_data_value_timestamp force; + +drop type ut_data_value_number force; + +drop type ut_data_value_refcursor force; + +drop type ut_data_value_dsinterval force; + +drop type ut_data_value_date force; + +drop type ut_data_value_clob force; + +drop type ut_data_value_boolean force; + +drop type ut_data_value_blob force; + +drop type ut_data_value_object force; + +drop type ut_data_value_collection force; + +drop type ut_data_value_anydata force; + +drop type ut_data_value_xmltype force; + +drop type ut_data_value force; + +drop table ut_compound_data_tmp; + +drop table ut_compound_data_diff_tmp; + +drop package ut_annotation_manager; + +drop package ut_annotation_parser; + +drop package ut_annotation_cache_manager; + +drop table ut_annotation_cache cascade constraints; + +drop table ut_annotation_cache_info cascade constraints; + +drop sequence ut_annotation_cache_seq; + +drop type ut_annotation_objs_cache_info force; + +drop type ut_annotation_obj_cache_info force; + +drop type ut_annotated_objects force; + +drop type ut_annotated_object force; + +drop type ut_annotations force; + +drop type ut_annotation force; + +drop package ut_file_mapper; + +drop package ut_metadata; + +drop package ut_ansiconsole_helper; + +drop package ut_utils; + +drop type ut_documentation_reporter force; + +drop type ut_teamcity_reporter force; + +drop type ut_xunit_reporter force; + +drop type ut_junit_reporter force; + +drop type ut_tfs_junit_reporter force; + +drop type ut_event_listener force; + +drop type ut_output_reporter_base force; + +drop type ut_coverage_reporter_base force; + +drop type ut_reporters force; + +drop type ut_reporter_base force; + +drop type ut_run force; + +drop type ut_coverage_options force; + +drop type ut_file_mappings force; + +drop type ut_file_mapping force; + +drop type ut_suite force; + +drop type ut_logical_suite force; + +drop type ut_test force; + +drop type ut_console_reporter_base force; + +drop type ut_executable_test force; + +drop type ut_executables force; + +drop type ut_executable force; + +drop type ut_suite_items force; + +drop type ut_suite_item force; + +drop type ut_output_table_buffer force; + +drop type ut_output_buffer_base force; + +drop view ut_output_buffer_tmp; + +drop table ut_output_buffer_tmp$ purge; + +drop view ut_output_buffer_info_tmp; + +drop table ut_output_buffer_info_tmp$; + +drop sequence ut_message_id_seq; + +drop type ut_results_counter force; + +drop type ut_expectation_results force; + +drop type ut_expectation_result force; + +drop package ut_event_manager; + +drop type ut_event_item force; + +drop type ut_key_anyval_pair force; + +drop type ut_key_anyval_pairs force; + +drop type ut_key_value_pairs force; + +drop type ut_key_value_pair force; + +drop type ut_object_names force; + +drop type ut_object_name force; + +drop type ut_integer_list force; + +drop type ut_varchar2_list force; + +drop type ut_varchar2_rows force; + +drop package ut_coverage_profiler; + +drop package ut_compound_data_helper; + +drop package ut_curr_usr_compound_helper; + +drop package ut_coverage_helper_profiler; + +drop type ut_have_count; + +drop type ut_compound_data_value; + +set echo off +set feedback off +declare + i integer := 0; +begin + dbms_output.put_line('Dropping packages created for 12.2+ ' || upper('&&ut3_owner')); + for pkg in ( + select object_name, owner + from all_objects + where 1 = 1 + and owner = upper('&&ut3_owner') + and object_type = 'PACKAGE' + and object_name in ('UT_COVERAGE_HELPER_BLOCK','UT_COVERAGE_BLOCK')) + loop + + begin + + execute immediate 'drop package ' || pkg.owner || '.' || pkg.object_name; + dbms_output.put_line('Dropped '|| pkg.object_name); + i := i + 1; + + exception + when others then + dbms_output.put_line('FAILED to drop ' || pkg.object_name); + end; + + end loop; + + dbms_output.put_line('&&line_separator'); + dbms_output.put_line(i || ' packages dropped'); +end; +/ diff --git a/source/uninstall_synonyms.sql b/source/uninstall_synonyms.sql new file mode 100644 index 000000000..569e5057d --- /dev/null +++ b/source/uninstall_synonyms.sql @@ -0,0 +1,64 @@ +set echo off +set feedback off +declare + i integer := 0; +begin + dbms_output.put_line('Dropping synonyms pointing to non-existing objects in schema '||upper('&&ut3_owner')); + for syn in ( + select + case when owner = 'PUBLIC' + then 'public synonym ' + else 'synonym ' || owner || '.' end || synonym_name as syn_name, + table_owner||'.'||table_name as for_object + from all_synonyms s + where table_owner = upper('&&ut3_owner') and table_owner != owner + and not exists (select 1 from all_objects o where o.owner = s.table_owner and o.object_name = s.table_name) + ) + loop + i := i + 1; + begin + execute immediate 'drop '||syn.syn_name; + dbms_output.put_line('Dropped '||syn.syn_name||' for object '||syn.for_object); + exception + when others then + dbms_output.put_line('FAILED to drop '||syn.syn_name||' for object '||syn.for_object); + end; + end loop; + dbms_output.put_line('&&line_separator'); + dbms_output.put_line(i||' synonyms dropped'); +end; +/ + +declare + i integer := 0; +begin + dbms_output.put_line('Dropping synonyms pointing to PL/SQL code coverage objects on 12.2 ' || upper('&&ut3_owner')); + for syn in ( + select + case when owner = 'PUBLIC' then 'public synonym ' + else 'synonym ' || owner || '.' + end || synonym_name as syn_name, + table_owner || '.' || table_name as for_object + from all_synonyms s + where 1 = 1 + and table_owner = upper('&&ut3_owner') + and synonym_name in ('DBMSPCC_BLOCKS','DBMSPCC_RUNS','DBMSPCC_UNITS') + ) + loop + + begin + + execute immediate 'drop '||syn.syn_name; + dbms_output.put_line('Dropped '||syn.syn_name||' for object '||syn.for_object); + i := i + 1; + + exception + when others then + dbms_output.put_line('FAILED to drop '||syn.syn_name||' for object '||syn.for_object); + end; + + end loop; + dbms_output.put_line('&&line_separator'); + dbms_output.put_line(i||' synonyms dropped'); +end; +/ From c85f8237bc723d9cc55994af54108703f289917b Mon Sep 17 00:00:00 2001 From: Travis CI Date: Tue, 5 Jun 2018 23:12:13 +0000 Subject: [PATCH 082/184] Updated project version after build [skip ci] --- source/core/ut_utils.pks | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/core/ut_utils.pks b/source/core/ut_utils.pks index 76c8a4491..ffb8f8747 100644 --- a/source/core/ut_utils.pks +++ b/source/core/ut_utils.pks @@ -21,7 +21,7 @@ create or replace package ut_utils authid definer is * */ - gc_version constant varchar2(50) := 'v3.1.2.1973-develop'; + gc_version constant varchar2(50) := 'v3.1.2.1976-develop'; /* Constants: Event names */ subtype t_event_name is varchar2(30); From 81c5908e1bddd1a35cb42773cad7ce9f62a0436e Mon Sep 17 00:00:00 2001 From: Jacek Gebal Date: Wed, 6 Jun 2018 00:46:15 +0100 Subject: [PATCH 083/184] Fixed typo in coverage documentation. --- docs/userguide/coverage.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/userguide/coverage.md b/docs/userguide/coverage.md index b8ec894be..f123a0d22 100644 --- a/docs/userguide/coverage.md +++ b/docs/userguide/coverage.md @@ -237,7 +237,7 @@ By default, utPLSQL will convert file paths into database objects using the foll **Note** -> utPLSQL will replace any '\' with '/' for the purpose of mapping files to objects. The paths shown in the results will remain (contain '\' where it was present). +> utPLSQL will replace any '\\' with '/' for the purpose of mapping files to objects. The paths shown in the results will remain (contain '\' where it was present). > This is done to simplify the syntax of regular expressions. Regular expression will always use '/' as a directory separator on a file path regardless of whether you're on a Windows or Unix system. **Note** From 16a76324aa59ee9593c221a8372ebcb6197fde16 Mon Sep 17 00:00:00 2001 From: Travis CI Date: Wed, 6 Jun 2018 00:08:15 +0000 Subject: [PATCH 084/184] Updated project version after build [skip ci] --- source/core/ut_utils.pks | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/core/ut_utils.pks b/source/core/ut_utils.pks index ffb8f8747..d7698dacf 100644 --- a/source/core/ut_utils.pks +++ b/source/core/ut_utils.pks @@ -21,7 +21,7 @@ create or replace package ut_utils authid definer is * */ - gc_version constant varchar2(50) := 'v3.1.2.1976-develop'; + gc_version constant varchar2(50) := 'v3.1.2.1979-develop'; /* Constants: Event names */ subtype t_event_name is varchar2(30); From 36a3f2233a133846cc0fd56e1ebf1532ab842e78 Mon Sep 17 00:00:00 2001 From: lwasylow Date: Wed, 6 Jun 2018 23:36:52 +0100 Subject: [PATCH 085/184] Added XML Validation --- .travis/lib/xml_validator.jar | Bin 0 -> 10131 bytes .travis/validate_report_files.sh | 65 ++++++++-- .travis/xsd/junit4.xsd | 92 ++++++++++++++ .travis/xsd/junit_windy.xsd | 206 +++++++++++++++++++++++++++++++ test/install_and_run_tests.sh | 3 +- 5 files changed, 356 insertions(+), 10 deletions(-) create mode 100644 .travis/lib/xml_validator.jar create mode 100644 .travis/xsd/junit4.xsd create mode 100644 .travis/xsd/junit_windy.xsd diff --git a/.travis/lib/xml_validator.jar b/.travis/lib/xml_validator.jar new file mode 100644 index 0000000000000000000000000000000000000000..ccac6370bdc1a669ae1a82bc08b242634bac1c49 GIT binary patch literal 10131 zcmaJ{1ymeO*2R6W4DRmkZoz^xxVu|$cXxuj4Z(vu1b24`?oMz>Lc*Wyr~mG^TXWjZ z+H`PO_LPv=9LXAm6o z{q?CC?O!s16#R& z2KHxz`FUpQX#eMZ_)i4d?+6!TdnY$LJ7Z_#{{epWpI}ov>puwy|LUKuv7wC@3j*Q? z69fd&KNG~9EnS#R?TlSqO0+<@7?b-EIgRf&XO4Lk$BKD!?x?>< z#B3IA+1xdEeo>;~JN8g~Gb5nroj%oZ{CJlq_#<8Fg(*0|Y4&C2W$YjU|GR9dh=4Wj zcgf;zn>!wwwi7_^59Y^!k%N~U&fra!0<;WQi?TyOnxh5)(ke4f#86hU8*?Ijsh%El z)=0P>+^Bi&9RMS#&>4?9Aq*dF*$al+sAY5YsRtapGBN)5v z89Zf>OB1dC`AksuXcX3!PHEP&Vrt$skNFU5v_wno$(4C_wZ=ts56{H4d-Nb)GNycAO<}6(%q=pX|%zCrDaDlK~ zI@V(0wg|>d(gJzatuCfTzm{X57)`M%O9=nam1eD#b~k55Ti(bc)i(=QM|#VQ;SekC zbAsdri>FJQl+nj&aVE+>>x9Ct*PDVPMp1+Hh9(30w69RB-qoIb6JHVR&Vo#H_9|&f zO)$uKvl<6jCutJ*mfE9v8&i*ACT>9Y1h8yBu!dReqo1bJv465c z;0ga!R32AomHi1?i*FuW#fCL&)k+7{*E1whq;6nq9293tY>FsKLeDw13VRsga*~wb z#kY=v;G)(Hkt9Je#$TRZQf(F8E6|8>U9vg6>&Wuws}OvL5P@IOSANLrDMCGbGwG4R znz&~!Sw*CV9>POgZ_cvX#1Q1>R{628jKzecZg~AG$y;UYr}l02YNrvorF#^j!yYR8 zBr6Fm?gZqR)kN%korU4pUA=EZ+Bgo;MjPZnqD{xewbhS#uWm0cs4s4I ztV0tJbYxdI^~TjwC}8dyB$oo91e_~?YvEe97u0z3^$Ci@dNE77^Y}agCUM`hY9Q@j zois^8J9Hr1m*woV2@}hic(!0Nc-x(im!q+{O_Lg~FH^`12)FI7$B%JkA_FG^iAUM) zBgD!`m>(`qrr>%QMKFVLXe_#_;+Gp2d9oo(rGLP*$4s^gxEOi5?6#ctE0b#ujg-ho zbXNr`Z{;_9-H0F=R;c%kd5Z0EtFFEuZzcYrhXkz})$H9Mg};v3&TnUN7Fl8R9_Iiz8DnIO zIzFuyIQpGR!7BpsM*P}Uo3mE2wTyZ*tqiRuGLj5dRdPDwHWy=#1CPDINDceH*=dvMTUmc>H~a6B#p1vJO9=S9eAg>av@ zE4kwF*ZVvpT^Q*5H`TIB?~s z3GSxvC_>^#fYJxf-FgP4E^u2t`COhXdWflLMbF*JqYY`LLK6`qYL;LCm~NoQV0xb z!UJ9P*{atWs4ICA>>;vvo~oyli)z_j;T-elw6nV~MhzE}!uwuqe8L5A>C@H!r0Tai zMR*?Y=Jw1~Kc#wTdi&J&oAEjo_M>MQU*$eahI9`Yaz8Qn_H5VO=);kKQ^a0gi?ANU zey!_`z@3j<$8@}HZlnSkgigj5qkR1cam$!%P9B1GyS$x5k70}26wy^!l{&avCz@;R z_wa;sLN&v(hpn=uZ{72Nh$BP4GM8Bwm!uWaBK%6DGby9R;DHzz2XR@L!V^XdUDdT= z{PsK=o!cvf2kVhOivruCO2SF~J%MX}Reel1s*sSv#o_FRZ^F

yyF9>4N-OTR4)P zV*D)@q2YE3sp;d$uGCCIjTY0UTb=o!1`&!A z9sO+|r@yA)>LC@~eFkuqN@S|h6i)?mD z_4gXVLCJG)s8<_e30mreKrC|s&a*X9<1GWb%R}XQeqV(*ei#+09F^Xba9nnAgIYY}5M#lJ-p+Jc;PV$T#Qk6UZ*J z*qIB`RN=NYv;^RYA6TB*)}s63SPH-1Wt8t&p&0B_wH#a4410Jg*bAsHWma zd)3dX2bT9gHMd)ViDRK2nuMY^evJ7f5=IGp0~j6N49||{Gab}wCtYw;_XjiY~?{4-|S`H`=G{4BTk38V6 z-dZJpwss~YPydXUKpjef4&n&>>>YKUB)g&SAK!;PBS!2Q&T3 z(RMuACaP-^2!@0L2Q+h8m(T37pKk3id69_W-onjL_Dzsq3YXS|ttjMNEc=BGAH|Ey z31OZri>10ScFsM+ijMIdyc1#7x5sHRzPBGfN`WlxHfNPUl&*M_17=fl^Sz3F;nnC& zdzd@2Mn7N(s4B&1^_D4R;tpC?{_R7GqA z&MWMfngR%5OX>Uo_sXfI?lhRHn9x=|s&6QbE zTInGt2EJJJQl}!Hw~nx3*gfyHyV9sr){1QM)XV_=i+1#Qc#dA2J-g&Ze0hDgQ+{{{ z^y5jZEjk@NB=4XY5yDe2EU{0I=`GNcka)7#Lq!%|0qu0vhuVmor?_@uV5&GD9Fvb} zI9&{AM64QrxW{)kHbg0O+aD5cN7&3oDaULNwg@S_t=*Jt3`3a*fYuoAY={@#6-c)=nH19{rK8ZB(LOc|XPJ?c! z27jBybhwng^-JhO%?x)pF(eE*P~@A`_4k9Fg9EqMu4nGfzVbiV)^>7o+h!y}?D1&` zX%6&UA!ZdiN5~*vf_fh@SnaaC6ilKD37<>EIRM(;E_7{Vd_|cG&y^59 z$?Baf&5%UEntwctgp;AaM9}TUphx@IL(zDQ%Lmdlh8iOL^%XhJn3D~GB= z=OEW%rLBw;%LF?<*)eP(RKps9ihPINxsKUb*|EnsdB#1qApEI#H4mJsdm|K&zi;FO zVH2u=YVDpKeS9{{UrwHU{74SO;0{EFEJrUK56OFrAPB;6dPdM}*y(f*Ek=R?yE(nU zg%;a8xd`bIOWw%z&iZVh`pFQqK$Zz4;-Zq;ugBdvp`7fH^*kZG>!%a_#tF4liJ)Dx zb5R5Fs0(ra2%&U5hoDtddq4(z0QsE7Bw9>Lvxq5PYlBF3qjpA|ngw=Ko0ZggWN4R> zD?98t-2_J@`BKRcm%h@tXdv1%+m|We|4VpUa zC|kiG&~y7t&W=IRC5F>wtLz)6NpDLOek#5bYS7xfO~i$1bIC+!!q}HI6L`H#-!N5o znxst;HTL2b;AABq!FG--{{e=#U63ceGafYVH~a&BWKpklmKol)vK~3C z(5jdUlP_UlaWPA{3REC)!-0hm$=8hcTxt*5U?19CpLs10;H@+76Op;z;aQ^6KHV}B zl>!f@?#p6{BdC;&ge-l$SU=?dj-_ z219)NG?5%Nq`lqInCGQ|pSge#BGP(Ku!_tt!DYAnIlic~`{@vuhGNx*L8>ost($=% z0npWsa~*fhhA6nmLnU(WqQ54aVOyB6tz=Au{C;4&|g}h)lOHnrt z=CB!xB=Z!dw)!!{R#{^zw}C_YfX_X5sIdV!ZnIt)4+a`W_$3pRi|ldpq;54xIf`GP z9O~cs1DJ{|bEoCagi}ZKwr8+&*0G`~q#h3qSTGc{S}6`)cB5QKkVFx>|;TNgKa1Z96$) z)+64$OOCBxSNHv!`!yXPPRK!9GZ)EB2jox%;y2W#T-l1 zUESy2^E+MVL*{U1Uu6|0Q^bmURJQ6+82jmj{ks~)4AUL-w)A4`G#~wTlUv!aY3{jI zMPhC%Mgc29TeT^ErhTXiQyQ+?7>7f#v7|GxgKN@Dv?QC0vgG&Vej=rc(IB-rs#%+W zPbJ^xVK!@Ia!YkKK5RKsX_h`8j1`^0jYKXW%rwR$A})Z-bH7n45x>DlgZ4uzPn4!T zlgct>inm!Qdo16lBiQ+ZR)=x=%?^e*PF66(45iJ>PK2Nr<#3f?2lh3&OS_0@jFU-r zPUKwY6?AntYQ-_4>67U@F(hY#b2n&|h()h!KFf*I9_L?PF48w+huY%u%-kp#JOu8*Dso9FcxLK^`7!H1f}3EvyP z%)*trd|8^8oa8#?n06F$kEOfn-I!cW(S~x3{I2B(L76Z1sx2k@$pq<2-qQqoa&Hy5 z&!-lo-x)M6`mt?c;`YP_RW){;ZZKxfpkg4Lzg##*Z9DOry*@UVy6DbRk_b1(iPa0s zOR~?<=ab9Dm|T^PG?twIo15~Opj6P0XLH!8h(bB34>x2Eyv_Ul7?FfY^bD~n+s5$N z$2C(HQjOnmm){j4tYDx!r;J3DlGS=b>DzxXiDiA4P71>k!opmN*qPJW8LV;hrb&u~ z@ydj#g_HsDL*-nhmU*=ag7_#)qL|NzUAKMJ)&~8^ONri&}dr2h$aRL;e@uz^7fIm{c zzolG-f8;sKLP9_=K|w%}{nwPMo4vV%>u+h-utYf}C^lf2k{19?McJ1W*-e5}h312P zQbANyO<=o`rUf$?%n_1{R}?TACelM<-f0?)F1}mT)>3Myr1W|DahN6$nUj%Ft4x;{ zI5Gu}mn~Sb*;3q>|D^NPw1WiiAb|z8f@lkk9Iw3R^PJ2OKW3ol=8SC>N*mOPhEJk} zu7(Rpg5sWm0%sjMZ7Vpnl$>2Y7YX=H%#N^KBa0(Nz=F_cU;0QE zGsv6ef#P5`25C`wo*Zc{kFg{*0N$O)$)9NC;A;3RlUP#TX;|i#WS?zj%*%4-RA@_N zV_hGSGpDCP;zYr;x+JN&I8_LZSy}r@2!&?9*0u2=YS1xD5DDx_WjbLF!#+Yizpu|9 zIw(#Y*2XHD6gJ0R*DLOIKXzDA+r+5$)J5MyXJ;B=o7#cDtS`kLDs=t=@yBz3fEfC> z?-0LI?~cxvegZ_a@;{*X{|@!Ew{thPvo!$kfW*-dNq$+U~cvB2LW~G%pGi(tR_ZW>rXfgt*#2fH#G;4NFO2p6 zU>g*Uixu4pDTj~fyg!-?PiTC{Q?CXd@BAP2=RuqWs(E%5)%gsY<(?Qk=y+WRq;)Z0 zS>^Q-n7A;!KG-f3#u3Kp^?AqJv`IIE)T2#!Sa#@grwr|)#Hn-!r=5#X@E&PR2X7UZ zfF%YsmS+sw{vP9P>+kBjL05>Fd81l`E_k-brWvSL@eUP$N=AgV%GNy4d}mfMgWPIP zXlJZjr%^`76uGfmYEJZM%gCgij3=EbOwIAb<(xRmM$z$mo7B{<5L5kITsYq3QWrY= zw=OTc{&?QmnvGo^bo_2U`K+$m-hOM&LW{d$h5&wb%J(2#jW)lQ=C4dr;**E?4*dm+ zlxF3NxS(#(A{i%Q1%44%k=rw-7#}aX`Re`=3ykw9tX59I6@SWEW!r6_mL5=|( zE*Yc=-dx{ctz_3rx+I1@7d9y$bVor33ccXOWOC`y+W8c7TU%Yl;Ud$ZE@w zW{1|op7&Fgbdt2gOo$UJhh|Ss9`xm64W%@5s0N$miqM^rKh$+UM>E{y?`UeRMZgEO1C! zFy3ppRhvBLo4Yzv#+7%j`|oO~y~qQT#bS-rddo=tWB?%Ir-sHw@7*)c1tL^An3#)e(VjkVC;RrTjki$ga^G3|T{ ze0&cy0MY`=srwwevuaY$^X9#7KP+%Z#?VBU;jMP28e)3wQ*2{T=jFxqq~Fem+?~1H zty+&0i+FMPFFcIfMDC+}YbXMiHpT9(qM8Km2@U`=d&HyAK@lT0`LtDVW?0=_o* zctV9o$BD@$C+)paP`2ani#$91 zRY|e+Eo(CrOA4X*#)p~Q>Q%Ae9GYs6gL&xoCPNC`%qlxo4j<0(MAxJfw{U=s0nxNh z`LXO?O7diuyDOzV_M}<0m0?yw^Z@bX2&=*-rw3FVVU|7wrbMbR`ONkynEud*GHYeM z#gDSQ<4Z9d+iSXFZ6jkbiA}bNV+Uyu(?OpE3pO7&th;&R@P#Ejm2Tl(t@_u8N+3)g zJ8fC6{;aN$>rvfyT@O{G0ZA8@z*%txW$)REmDs~K*VfGQ>wE+=QXlh^of`MAg>Wd0d%=2~^cG zt~XAlRHah|DOMnvmR!`-co|!F}-aifzPI*vWzM?gJ*`kbTz;Mv*S!z)6i+eh!pr-pC ze#e3*y~DN}mhQpg?#;07O*mf}=&+@=d>3Htoek78$YIh&j>A&~>NwFl4)sN7e6Vju zYk1$Ri%p?^tbdBMcA2fEwK=>35(0&3?D%QPvB@<{IOkS=C@J`$mb;*-k{Eq7#V8vT zL9D!f{%sX7G(}J4{J2>T!z!Fw+CVtuFpVfk9F>0LCQ(Ah+Ck>$r7JfIRZ}1~6?+mz z)I=mS$yS_z>pD%a$^Mxn+Ev3>&5rl?7*Y%bJ5QJSrx>ga#-#9@G@!dxiMecwH~f@ zH76z2_T`6MsvbyF`uiC2>Qu`QeMzf>NvHm@PjBxm^i19dk#pKGew9VAB}a4ZW>iD* z2J~Ju)bnjPOTlWWzfl49vhK#@O zx$72^BYgR>tMxPOr9jL#W{*c@fCz$~h&=t6zSCoqepu^-1lF$JcV-vj2Pbu8sN+6^ z%f*$51m)-ip@1SiF49W_Y4sO%&)p0A9RNq5lBuje0DJ2aho_vAFj+0i1NbOK2RU=K^`B;5ecW-(_)R+`3zXN_W|pf zKq33E6i^-BI)FFdGSYWYaO`LIn0$K0mJj1R{idg>exPX=`OBp(6|4E6$oLzhvFL6i z^LwsP7?U4~FZlQ{Lsynw-ZIU!+EDm~kCk0V3xvsSzo!yFIcJ zDoulm?#)wSC__adgI&$VMtJ%oKle&Oy^PBgtdE4fgc1xFJZ1EZU)2*U?V%vw32qJv zl;JS#mdQAa&};&`X|~R=7n!&bYLOrtjhJ;t9VHMhtjxSx8ZejlFdl|=u%C;oUTDg= z!X?0}c2V2{6rM|{X#E0R)lwr5tJPp#~_ksc~X@R1~osdL7Xu#VkW@H5632^CHJ zpvP>PD2R2&6GtvAc%S-5^-7UZ?FlOWn3ZIZKRgDk1OpX~>Y2l5vK!(G;1FRW9qWW0 z9%z0S(|$BydMTWy?ioo#Px{r*Odufxb!~mEqR}E&Bap?0g5ygQm4D^9Bi%Jl>XSXk z0SWW7jiu-4Qze<1p3jLo=>|at4 zIKPGdw?KZ4<)_r&EbU)%|LL@Td9mNxuSXb(`-e08BbNVU{PJdhF)Ds%{LQKTcj_;% z_7`>W->LuR-2Tw{XYclh5;zEe_uHWV9K!$8`FAJx*Uk9n1@T|H=!E}E_n()?%5t!9 SzZ6h@{+OX5Ae1P7UHu&1) -ERROR_COUNT=`echo "$VALIDATION_RESULTS" | grep -c "$ERROR_REGEX"` -WARNING_COUNT=`echo "$VALIDATION_RESULTS" | grep -c "$WARNING_REGEX"` +if [ $? -ne 0 ]; then + GL_VALID=0 + echo "" + echo "******************************" + echo "TFS Test Result XML is invalid" + echo "Please see results:" + echo "$TFS_RESULT" +fi + +#Validate XML JUNIT_FILENAME +JUNIT_RESULT=$(java -jar $XML_VALIDATOR -s $JUNIT_XSD $JUNIT_FILENAME 2>&1) -echo "There are $ERROR_COUNT errors, $WARNING_COUNT warning in $HTML_FILENAME" +if [ $? -ne 0 ]; then + GL_VALID=0 + echo "" + echo "******************************" + echo "JUNIT Test Result XML is invalid" + echo "Please see results:" + echo "$JUNIT_RESULT" +fi -if [ $ERROR_COUNT -gt 0 ]; then - echo "$VALIDATION_RESULTS" | grep "$ERROR_REGEX" - exit 1 +if [ $GL_VALID -ne 1 ]; then + echo "" + echo "******************************" + echo "Validation failed please see results above." + exit 1 else - exit 0 + exit 0 fi diff --git a/.travis/xsd/junit4.xsd b/.travis/xsd/junit4.xsd new file mode 100644 index 000000000..1142fb28d --- /dev/null +++ b/.travis/xsd/junit4.xsd @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.travis/xsd/junit_windy.xsd b/.travis/xsd/junit_windy.xsd new file mode 100644 index 000000000..fe134662a --- /dev/null +++ b/.travis/xsd/junit_windy.xsd @@ -0,0 +1,206 @@ + + + + + JUnit test result schema for the Apache Ant JUnit and JUnitReport tasks +Copyright © 2011, Windy Road Technology Pty. Limited +The Apache Ant JUnit XML Schema is distributed under the terms of the Apache License Version 2.0 http://www.apache.org/licenses/ +Permission to waive conditions of this license may be requested from Windy Road Support (http://windyroad.org/support). + + + + + + + + + + Contains an aggregation of testsuite results + + + + + + + + + + Derived from testsuite/@name in the non-aggregated documents + + + + + Starts at '0' for the first testsuite and is incremented by 1 for each following testsuite + + + + + + + + + + + + Contains the results of exexuting a testsuite + + + + + Properties (e.g., environment settings) set during test execution + + + + + + + + + + + + + + + + + + + + + + + + Indicates that the test errored. An errored test is one that had an unanticipated problem. e.g., an unchecked throwable; or a problem with the implementation of the test. Contains as a text node relevant data for the error, e.g., a stack trace + + + + + + + The error message. e.g., if a java exception is thrown, the return value of getMessage() + + + + + The type of error that occured. e.g., if a java execption is thrown the full class name of the exception. + + + + + + + + + Indicates that the test failed. A failure is a test which the code has explicitly failed by using the mechanisms for that purpose. e.g., via an assertEquals. Contains as a text node relevant data for the failure, e.g., a stack trace + + + + + + + The message specified in the assert + + + + + The type of the assert. + + + + + + + + + + Name of the test method + + + + + Full class name for the class the test method is in. + + + + + Time taken (in seconds) to execute the test + + + + + + + Data that was written to standard out while the test was executed + + + + + + + + + + Data that was written to standard error while the test was executed + + + + + + + + + + + Full class name of the test for non-aggregated testsuite documents. Class name without the package for aggregated testsuites documents + + + + + + + + + + when the test was executed. Timezone may not be specified. + + + + + Host on which the tests were executed. 'localhost' should be used if the hostname cannot be determined. + + + + + + + + + + The total number of tests in the suite + + + + + The total number of tests in the suite that failed. A failure is a test which the code has explicitly failed by using the mechanisms for that purpose. e.g., via an assertEquals + + + + + The total number of tests in the suite that errored. An errored test is one that had an unanticipated problem. e.g., an unchecked throwable; or a problem with the implementation of the test. + + + + + Time taken (in seconds) to execute the tests in the suite + + + + + + + + + diff --git a/test/install_and_run_tests.sh b/test/install_and_run_tests.sh index 444346bb2..2c6f78ae1 100644 --- a/test/install_and_run_tests.sh +++ b/test/install_and_run_tests.sh @@ -20,7 +20,8 @@ utPLSQL-cli/bin/utplsql run ${UT3_TESTER}/${UT3_TESTER_PASSWORD}@${CONNECTION_ST -f=ut_coverage_html_reporter -o=coverage.html \ -f=ut_coveralls_reporter -o=coverage.json \ -f=ut_sonar_test_reporter -o=test_results.xml \ --f=ut_xunit_reporter -o=xunit_test_results.xml \ +-f=ut_junit_reporter -o=junit_test_results.xml \ +-f=ut_tfs_junit_reporter -o=tfs_test_results.xml \ -scc status_line_regex="^[0-9]+ tests, ([0-9]+) failed, ([0-9]+) errored.*" From 0dfa7a27e20f854cda4575c5e598c44ebab5a8b0 Mon Sep 17 00:00:00 2001 From: lwasylow Date: Wed, 6 Jun 2018 23:53:02 +0100 Subject: [PATCH 086/184] Update folder structure --- .travis/{xsd => }/junit4.xsd | 0 .travis/{xsd => }/junit_windy.xsd | 0 .travis/validate_report_files.sh | 6 +++--- .travis/{lib => }/xml_validator.jar | Bin 4 files changed, 3 insertions(+), 3 deletions(-) rename .travis/{xsd => }/junit4.xsd (100%) rename .travis/{xsd => }/junit_windy.xsd (100%) rename .travis/{lib => }/xml_validator.jar (100%) diff --git a/.travis/xsd/junit4.xsd b/.travis/junit4.xsd similarity index 100% rename from .travis/xsd/junit4.xsd rename to .travis/junit4.xsd diff --git a/.travis/xsd/junit_windy.xsd b/.travis/junit_windy.xsd similarity index 100% rename from .travis/xsd/junit_windy.xsd rename to .travis/junit_windy.xsd diff --git a/.travis/validate_report_files.sh b/.travis/validate_report_files.sh index 3ae93dec1..6c96f57a7 100644 --- a/.travis/validate_report_files.sh +++ b/.travis/validate_report_files.sh @@ -4,9 +4,9 @@ GL_VALID=1 HTML_FILENAME="coverage.html" JUNIT_FILENAME="junit_test_results.xml" -JUNIT_XSD="xsd\\junit4.xsd" +JUNIT_XSD="junit4.xsd" TFS_FILENAME="tfs_test_results.xml" -TFS_XSD="xsd\\junit_windy.xsd" +TFS_XSD="junit_windy.xsd" #Exclude existing issue with OL nested in PRE @@ -19,7 +19,7 @@ WARNING_REGEX="info warning:" ERROR_REGEX="error:" #XML Validator -XML_VALIDATOR="lib\\xml_validator.jar" +XML_VALIDATOR="xml_validator.jar" #Validate HTML HTML_VALIDATION_RESULTS=$(curl -H "Content-Type: text/html; charset=utf-8" --data-binary @$HTML_FILENAME "$HTML_VALIDATOR_URL?out=$VALIDATOR_OUT&filterpattern=$EXCLUSION_REGEX") diff --git a/.travis/lib/xml_validator.jar b/.travis/xml_validator.jar similarity index 100% rename from .travis/lib/xml_validator.jar rename to .travis/xml_validator.jar From 4f8caa4917239cefb3964f155f32d55168a801bd Mon Sep 17 00:00:00 2001 From: Jacek Gebal Date: Thu, 7 Jun 2018 01:47:40 +0100 Subject: [PATCH 087/184] Fixed running single test procedure in context by path Changed context naming (context name can be now explicit) Context description is now only set from `--%displayname` annotation Resolves #679 Resolves #674 Fixed most of compiler-warnings --- docs/userguide/annotations.md | 6 +- source/core/events/ut_event_manager.pkb | 3 +- source/core/types/ut_suite.tpb | 4 +- source/core/types/ut_suite.tps | 4 +- source/core/types/ut_suite_context.tpb | 32 +++++++ source/core/types/ut_suite_context.tps | 22 +++++ source/core/types/ut_suite_item.tpb | 2 +- source/core/types/ut_suite_item.tps | 2 +- source/core/ut_suite_builder.pkb | 26 +++--- source/core/ut_suite_manager.pkb | 83 ++++++++++++++----- source/core/ut_suite_manager.pks | 2 +- source/core/ut_utils.pkb | 4 - .../data_values/ut_compound_data_value.tpb | 14 ++-- .../ut_curr_usr_compound_helper.pkb | 31 ++++--- .../ut_curr_usr_compound_helper.pks | 10 ++- source/install.sql | 6 +- source/install_component.sql | 1 + source/uninstall_objects.sql | 2 + test/core/test_suite_builder.pkb | 26 +++--- test/core/test_suite_manager.pkb | 81 ++++++++++++++++++ test/core/test_suite_manager.pks | 6 ++ 21 files changed, 286 insertions(+), 81 deletions(-) create mode 100644 source/core/types/ut_suite_context.tpb create mode 100644 source/core/types/ut_suite_context.tps diff --git a/docs/userguide/annotations.md b/docs/userguide/annotations.md index 636c09264..011626b80 100644 --- a/docs/userguide/annotations.md +++ b/docs/userguide/annotations.md @@ -30,7 +30,7 @@ We strongly recommend putting package level annotations at the very top of packa | `--%aftertest()` | Procedure | Denotes that mentioned procedure should be executed after the annotated `%test` procedure. | | `--%rollback()` | Package/procedure | Defines transaction control. Supported values: `auto`(default) - a savepoint is created before invocation of each "before block" is and a rollback to specific savepoint is issued after each "after" block; `manual` - rollback is never issued automatically. Property can be overridden for child element (test in suite) | | `--%disabled` | Package/procedure | Used to disable a suite or a test. Disabled suites/tests do not get executed, they are however marked and reported as disabled in a test run. | -| `--%context()` | Package | Denotes start of a nested context (sub-suite) in a suite package | +| `--%context()` | Package | Denotes start of a named context (sub-suite) in a suite package | | `--%endcontext` | Package | Denotes end of a nested context (sub-suite) in a suite package | ### Suite @@ -863,7 +863,7 @@ In essence, context behaves like a suite within a suite. Context have following characteristics: - start with the `--%context` annotation and ends with `--%endcontext` -- can have a name provided a parameter for example `--%context(Remove rooms by name)` +- can have a name provided as parameter for example `--%context(remove_rooms_by_name)` - when no name is provided for context, the context is names `context_N` where `N` is the number of the context in suite - can have their own `--%beforeall`, `--%beforeeach`, `--%afterall` and `--%aftereach` procedures - `--%beforeall`, `--%beforeeach`, `--%afterall` and `--%aftereach` procedures defined at suite level, propagate to context @@ -945,6 +945,7 @@ create or replace package test_rooms_management is --%context(remove_rooms_by_name) + --%description(Remove rooms by name) --%test(Removes a room without content in it) procedure remove_empty_room; @@ -957,6 +958,7 @@ create or replace package test_rooms_management is --%context(add_rooms_content) + --%description(Add content to a room) --%test(Fails when room name is not valid) --%throws(-1403) diff --git a/source/core/events/ut_event_manager.pkb b/source/core/events/ut_event_manager.pkb index 312ddc9c3..cb556050a 100644 --- a/source/core/events/ut_event_manager.pkb +++ b/source/core/events/ut_event_manager.pkb @@ -33,7 +33,8 @@ create or replace package body ut_event_manager as procedure trigger_event( a_event_name t_event_name, a_event_object ut_event_item ) is begin if a_event_name is not null and g_event_listeners_index.exists(a_event_name) - and g_event_listeners_index(a_event_name) is not null + -- disabled due to compiler warning: PLW-06023: invocation of IS NOT NULL computes trivial value +-- and g_event_listeners_index(a_event_name) is not null then for listener_number in 1 .. g_event_listeners_index(a_event_name).count loop g_listeners(listener_number).on_event(a_event_name, a_event_object); diff --git a/source/core/types/ut_suite.tpb b/source/core/types/ut_suite.tpb index 7b5525664..1c5663dd9 100644 --- a/source/core/types/ut_suite.tpb +++ b/source/core/types/ut_suite.tpb @@ -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, a_suite_name varchar2 := null + self in out nocopy ut_suite, a_object_owner varchar2, a_object_name varchar2 ) return self as result is begin self.self_type := $$plsql_unit; - self.init(a_object_owner, a_object_name, nvl(a_suite_name, a_object_name)); + self.init(a_object_owner, a_object_name, a_object_name); self.items := ut_suite_items(); before_all_list := ut_executables(); after_all_list := ut_executables(); diff --git a/source/core/types/ut_suite.tps b/source/core/types/ut_suite.tps index c80316172..866eefc80 100644 --- a/source/core/types/ut_suite.tps +++ b/source/core/types/ut_suite.tps @@ -27,10 +27,10 @@ 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, a_suite_name varchar2 := null + self in out nocopy ut_suite, a_object_owner varchar2, a_object_name varchar2 ) 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, overriding member function get_serveroutputs return clob -) +) not final / diff --git a/source/core/types/ut_suite_context.tpb b/source/core/types/ut_suite_context.tpb new file mode 100644 index 000000000..d09fb824f --- /dev/null +++ b/source/core/types/ut_suite_context.tpb @@ -0,0 +1,32 @@ +create or replace type body ut_suite_context as + /* + utPLSQL - Version 3 + Copyright 2016 - 2017 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. + */ + + 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 + ) return self as result is + begin + self.self_type := $$plsql_unit; + self.init(a_object_owner, a_object_name, a_context_name); + self.items := ut_suite_items(); + before_all_list := ut_executables(); + after_all_list := ut_executables(); + return; + end; + +end; +/ diff --git a/source/core/types/ut_suite_context.tps b/source/core/types/ut_suite_context.tps new file mode 100644 index 000000000..ea7d6d31c --- /dev/null +++ b/source/core/types/ut_suite_context.tps @@ -0,0 +1,22 @@ +create or replace type ut_suite_context under ut_suite ( + /* + utPLSQL - Version 3 + Copyright 2016 - 2017 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. + */ + 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 + ) return self as result +) +/ diff --git a/source/core/types/ut_suite_item.tpb b/source/core/types/ut_suite_item.tpb index 5325be9de..b63ed9931 100644 --- a/source/core/types/ut_suite_item.tpb +++ b/source/core/types/ut_suite_item.tpb @@ -98,7 +98,7 @@ final member procedure do_execute(self in out nocopy ut_suite_item) is return transaction_invalidators; end; - member procedure add_transaction_invalidator(a_object_name varchar2) is + member procedure add_transaction_invalidator(self in out nocopy ut_suite_item, a_object_name varchar2) is begin if a_object_name not member of transaction_invalidators then transaction_invalidators.extend(); diff --git a/source/core/types/ut_suite_item.tps b/source/core/types/ut_suite_item.tps index 6a36d88ee..5973f9bd9 100644 --- a/source/core/types/ut_suite_item.tps +++ b/source/core/types/ut_suite_item.tps @@ -61,7 +61,7 @@ create or replace type ut_suite_item force under ut_event_item ( member function create_savepoint_if_needed return varchar2, member procedure rollback_to_savepoint(self in out nocopy ut_suite_item, a_savepoint varchar2), member function get_transaction_invalidators return ut_varchar2_list, - member procedure add_transaction_invalidator(a_object_name varchar2), + member procedure add_transaction_invalidator(self in out nocopy ut_suite_item, a_object_name varchar2), /* Returns execution time in seconds (with miliseconds) */ diff --git a/source/core/ut_suite_builder.pkb b/source/core/ut_suite_builder.pkb index 1f55d4291..71ed7ed2c 100644 --- a/source/core/ut_suite_builder.pkb +++ b/source/core/ut_suite_builder.pkb @@ -552,8 +552,8 @@ create or replace package body ut_suite_builder is procedure add_annotated_procedures( a_annotations tt_package_annotations, a_suite in out nocopy ut_suite, - a_before_each_list out ut_executables, - a_after_each_list out ut_executables + a_before_each_list out nocopy ut_executables, + a_after_each_list out nocopy ut_executables ) is l_position t_annotation_position; begin @@ -653,9 +653,10 @@ create or replace package body ut_suite_builder is ) is l_context_pos t_annotation_position; l_end_context_pos t_annotation_position; - l_package_ann_index tt_annotations_index; + l_context_ann_index tt_annotations_index; + l_context_name t_object_name; l_annotations tt_package_annotations; - l_suite ut_suite; + l_context ut_suite_context; l_context_no binary_integer := 1; function get_endcontext_position( @@ -705,17 +706,20 @@ create or replace package body ut_suite_builder is --create a sub-set of annotations to process as sub-suite (context) l_annotations := get_annotations_in_context(a_annotations, l_context_pos, l_end_context_pos); - l_package_ann_index := build_annotation_index(l_annotations); + l_context_ann_index := build_annotation_index(l_annotations); - l_suite := ut_suite(a_suite.object_owner, a_suite.object_name, gc_context||'_'||l_context_no); + l_context_name := coalesce( + l_annotations( l_context_pos ).text + , gc_context||'_'||l_context_no + ); + l_context := ut_suite_context(a_suite.object_owner, a_suite.object_name, l_context_name ); - l_suite.description := l_annotations(l_package_ann_index(gc_context).first).text; - l_suite.description := l_annotations(l_context_pos).text; - warning_on_duplicate_annot( l_suite, l_package_ann_index, gc_suite ); + l_context.description := l_annotations(l_context_pos).text; + warning_on_duplicate_annot( l_context, l_context_ann_index, gc_suite ); - populate_suite_contents( l_suite, l_annotations, l_package_ann_index, gc_context||'_'||l_context_no ); + populate_suite_contents( l_context, l_annotations, l_context_ann_index, l_context_name ); - a_suite.add_item(l_suite); + a_suite.add_item(l_context); -- remove annotations within context after processing them a_annotations.delete(l_context_pos, l_end_context_pos); diff --git a/source/core/ut_suite_manager.pkb b/source/core/ut_suite_manager.pkb index 4a8927496..dccd745d2 100644 --- a/source/core/ut_suite_manager.pkb +++ b/source/core/ut_suite_manager.pkb @@ -213,26 +213,64 @@ create or replace package body ut_suite_manager is end; procedure filter_suite_by_path(a_suite in out nocopy ut_suite_item, a_path varchar2) is - c_root constant varchar2(32767) := lower(regexp_substr(a_path, '[A-Za-z0-9$#_]+')); - c_rest_path constant varchar2(32767) := regexp_substr(a_path, '\.(.+)', subexpression => 1); - l_suite ut_logical_suite; - l_item ut_suite_item; - l_items ut_suite_items := ut_suite_items(); - begin - if a_path is not null and a_suite is not null and a_suite is of (ut_logical_suite) then - l_suite := treat(a_suite as ut_logical_suite); + c_item_name constant varchar2(32767) := lower(regexp_substr(a_path, '[A-Za-z0-9$#_]+')); + c_child_filter_path constant varchar2(32767) := regexp_substr(a_path, '\.(.+)', subexpression => 1); + l_suite ut_logical_suite; + l_item ut_suite_item; + l_items ut_suite_items := ut_suite_items(); - for i in 1 .. l_suite.items.count loop - l_item := l_suite.items(i); - if lower(l_item.name) = c_root then - filter_suite_by_path(l_item, c_rest_path); - l_items.extend; - l_items(l_items.count) := l_item; + function find_item_in_suite(a_suite ut_logical_suite, a_item_name varchar2) return ut_suite_item is + l_item_index binary_integer; + begin + l_item_index := a_suite.items.first; + while l_item_index is not null loop + if lower(a_suite.items(l_item_index).name) = a_item_name then + return a_suite.items(l_item_index); end if; + l_item_index := a_suite.items.next(l_item_index); end loop; + return null; + end; - if l_items.count = 0 then - raise_application_error(-20203, 'Suite not found'); + function find_item_in_suite_contexts(a_suite ut_logical_suite, a_item_name varchar2) return ut_suite_item is + l_item_index binary_integer; + l_context ut_suite_context; + l_item ut_suite_item; + begin + l_item_index := a_suite.items.first; + while l_item_index is not null loop + if a_suite.items(l_item_index) is of (ut_suite_context) then + l_item := find_item_in_suite( + treat(a_suite.items(l_item_index) as ut_suite_context) + , a_item_name + ); + end if; + + if l_item is not null then + l_context := treat(a_suite.items(l_item_index) as ut_suite_context); + l_context.items := ut_suite_items(l_item); + exit; + end if; + l_item_index := a_suite.items.next(l_item_index); + end loop; + return l_context; + end; + begin + if a_suite is of (ut_logical_suite) then + l_suite := treat(a_suite as ut_logical_suite); + + l_item := coalesce( + find_item_in_suite(l_suite, c_item_name) + , find_item_in_suite_contexts(l_suite, c_item_name) + ); + if l_item is not null then + if c_child_filter_path is not null then + filter_suite_by_path(l_item, c_child_filter_path); + end if; + l_items.extend; + l_items(l_items.count) := l_item; + else + raise_application_error(-20203, 'Suite item '||c_item_name||' not found'); end if; l_suite.items := l_items; @@ -241,12 +279,15 @@ create or replace package body ut_suite_manager is end filter_suite_by_path; function get_suite_filtered_by_path(a_path varchar2, a_schema_suites tt_schema_suites) return ut_logical_suite is - l_suite ut_logical_suite; - c_suite_path constant varchar2(4000) := regexp_substr(a_path, ':(.+)', subexpression => 1); - c_root_suite_name constant varchar2(4000) := regexp_substr(c_suite_path, '^[A-Za-z0-9$#_]+'); + l_suite ut_logical_suite; + c_suite_path constant varchar2(32767) := regexp_substr(a_path, ':(.+)', subexpression => 1); + c_root_suite_name constant varchar2(32767) := regexp_substr(c_suite_path, '^[A-Za-z0-9$#_]+'); + c_child_filter_path constant varchar2(32767) := regexp_substr(c_suite_path, '\.(.+)', subexpression => 1); begin l_suite := a_schema_suites(c_root_suite_name); - filter_suite_by_path(l_suite, regexp_substr(c_suite_path, '\.(.+)', subexpression => 1)); + if c_child_filter_path is not null then + filter_suite_by_path(l_suite, c_child_filter_path); + end if; return l_suite; exception when no_data_found then @@ -293,7 +334,7 @@ create or replace package body ut_suite_manager is l_index varchar2(4000 char); l_suite ut_logical_suite; l_objects_to_run ut_suite_items; - l_schema_paths t_schema_paths; + l_schema_paths t_schema_paths; begin --resolve schema names from paths and group paths by schema name resolve_schema_names(l_paths); diff --git a/source/core/ut_suite_manager.pks b/source/core/ut_suite_manager.pks index 8b1b34335..f35ddb4b3 100644 --- a/source/core/ut_suite_manager.pks +++ b/source/core/ut_suite_manager.pks @@ -17,7 +17,7 @@ create or replace package ut_suite_manager authid current_user is */ /** - * Reads database source code, parses it and returns annotations + * Resposible for building hierarhy of sutes from individual suites created by suite_builder */ /** diff --git a/source/core/ut_utils.pkb b/source/core/ut_utils.pkb index 4654f9b34..c6ffe2060 100644 --- a/source/core/ut_utils.pkb +++ b/source/core/ut_utils.pkb @@ -571,10 +571,6 @@ procedure append_to_clob(a_src_clob in out nocopy clob, a_clob_table t_clob_tab, l_newlines_count binary_integer; l_offset binary_integer := 1; l_length binary_integer := coalesce(dbms_lob.getlength(a_source), 0); - function is_before(a_x binary_integer, a_y binary_integer) return boolean is - begin - return a_x < a_y or a_y = 0; - end; begin l_ml_comment_start := instr(a_source,'/*'); l_comment_start := instr(a_source,'--'); diff --git a/source/expectations/data_values/ut_compound_data_value.tpb b/source/expectations/data_values/ut_compound_data_value.tpb index 45841e5a9..0222c4fd0 100644 --- a/source/expectations/data_values/ut_compound_data_value.tpb +++ b/source/expectations/data_values/ut_compound_data_value.tpb @@ -96,13 +96,13 @@ create or replace type body ut_compound_data_value as function get_diff_message (a_row_diff ut_compound_data_helper.t_row_diffs,a_compare_type varchar2) return varchar2 is begin - if a_compare_type = ut_compound_data_helper.gc_compare_join_by and a_row_diff.pk_value is not null then - return ' PK '||a_row_diff.pk_value||' - '||rpad(a_row_diff.diff_type,10)||a_row_diff.diffed_row; - elsif a_compare_type = ut_compound_data_helper.gc_compare_join_by or a_compare_type = ut_compound_data_helper.gc_compare_normal then - return ' Row No. '||a_row_diff.rn||' - '||rpad(a_row_diff.diff_type,10)||a_row_diff.diffed_row; - elsif a_compare_type = ut_compound_data_helper.gc_compare_unordered then - return rpad(a_row_diff.diff_type,10)||a_row_diff.diffed_row; - end if; + if a_compare_type = ut_compound_data_helper.gc_compare_join_by and a_row_diff.pk_value is not null then + return ' PK '||a_row_diff.pk_value||' - '||rpad(a_row_diff.diff_type,10)||a_row_diff.diffed_row; + elsif a_compare_type = ut_compound_data_helper.gc_compare_join_by or a_compare_type = ut_compound_data_helper.gc_compare_normal then + return ' Row No. '||a_row_diff.rn||' - '||rpad(a_row_diff.diff_type,10)||a_row_diff.diffed_row; + elsif a_compare_type = ut_compound_data_helper.gc_compare_unordered then + return rpad(a_row_diff.diff_type,10)||a_row_diff.diffed_row; + end if; end; begin diff --git a/source/expectations/data_values/ut_curr_usr_compound_helper.pkb b/source/expectations/data_values/ut_curr_usr_compound_helper.pkb index c07b2801b..c910aca65 100644 --- a/source/expectations/data_values/ut_curr_usr_compound_helper.pkb +++ b/source/expectations/data_values/ut_curr_usr_compound_helper.pkb @@ -15,7 +15,7 @@ create or replace package body ut_curr_usr_compound_helper is end if; end; - function get_column_type(a_desc_rec dbms_sql.desc_rec3,a_desc_user_types boolean := false) return ut_key_anyval_pair is + function get_column_type(a_desc_rec dbms_sql.desc_rec3, a_desc_user_types boolean := false) return ut_key_anyval_pair is l_data ut_data_value; l_result ut_key_anyval_pair; l_data_type varchar2(500) := 'unknown datatype'; @@ -47,7 +47,9 @@ create or replace package body ut_curr_usr_compound_helper is return ut_key_anyval_pair(a_desc_rec.col_name,l_data); end; - function get_columns_info(a_columns_tab dbms_sql.desc_tab3, a_columns_count integer,a_desc_user_types boolean := false) return ut_key_anyval_pairs is + function get_columns_info( + a_columns_tab dbms_sql.desc_tab3, a_columns_count integer, a_desc_user_types boolean := false + ) return ut_key_anyval_pairs is l_result ut_key_anyval_pairs := ut_key_anyval_pairs(); begin for i in 1 .. a_columns_count loop @@ -57,7 +59,7 @@ create or replace package body ut_curr_usr_compound_helper is return l_result; end; - function get_descr_cursor(a_cursor in out nocopy sys_refcursor,a_desc_user_types boolean := false) return ut_key_anyval_pairs is + function get_descr_cursor(a_cursor in out nocopy sys_refcursor, a_desc_user_types boolean := false) return ut_key_anyval_pairs is l_cursor_number integer; l_columns_count pls_integer; l_columns_desc dbms_sql.desc_tab3; @@ -69,12 +71,15 @@ create or replace package body ut_curr_usr_compound_helper is l_cursor_number := dbms_sql.to_cursor_number( a_cursor ); dbms_sql.describe_columns3( l_cursor_number, l_columns_count, l_columns_desc ); a_cursor := dbms_sql.to_refcursor( l_cursor_number ); - l_columns_tab := get_columns_info( l_columns_desc, l_columns_count,a_desc_user_types); + l_columns_tab := get_columns_info( l_columns_desc, l_columns_count, a_desc_user_types); return l_columns_tab; end; - procedure get_descr_cursor(a_cursor in out nocopy sys_refcursor,a_columns_tab in out ut_key_anyval_pairs, - a_join_by_tab in out ut_key_anyval_pairs) is + procedure get_descr_cursor( + a_cursor in out nocopy sys_refcursor, + a_columns_tab in out nocopy ut_key_anyval_pairs, + a_join_by_tab in out nocopy ut_key_anyval_pairs + ) is l_cursor_number integer; l_columns_count pls_integer; l_columns_desc dbms_sql.desc_tab3; @@ -86,12 +91,16 @@ create or replace package body ut_curr_usr_compound_helper is l_cursor_number := dbms_sql.to_cursor_number( a_cursor ); dbms_sql.describe_columns3( l_cursor_number, l_columns_count, l_columns_desc ); a_cursor := dbms_sql.to_refcursor( l_cursor_number ); - a_columns_tab := get_columns_info( l_columns_desc, l_columns_count,false); - a_join_by_tab := get_columns_info( l_columns_desc, l_columns_count,true); + a_columns_tab := get_columns_info( l_columns_desc, l_columns_count, false); + a_join_by_tab := get_columns_info( l_columns_desc, l_columns_count, true); end; - procedure get_columns_info(a_cursor in out nocopy sys_refcursor,a_columns_info out xmltype, - a_join_by_info out xmltype, a_contains_collection out number) is + procedure get_columns_info( + a_cursor in out nocopy sys_refcursor, + a_columns_info out nocopy xmltype, + a_join_by_info out nocopy xmltype, + a_contains_collection out nocopy number + ) is l_columns_info xmltype; l_join_by_info xmltype; l_result_tmp xmltype; @@ -119,7 +128,7 @@ create or replace package body ut_curr_usr_compound_helper is a_contains_collection := ut_utils.boolean_to_int(g_is_collection); end; - function get_columns_info(a_cursor in out nocopy sys_refcursor,a_desc_user_types boolean := false) return xmltype is + function get_columns_info(a_cursor in out nocopy sys_refcursor, a_desc_user_types boolean := false) return xmltype is l_result xmltype; l_result_tmp xmltype; l_columns_tab ut_key_anyval_pairs; diff --git a/source/expectations/data_values/ut_curr_usr_compound_helper.pks b/source/expectations/data_values/ut_curr_usr_compound_helper.pks index 7c622f0c2..4bf32cf31 100644 --- a/source/expectations/data_values/ut_curr_usr_compound_helper.pks +++ b/source/expectations/data_values/ut_curr_usr_compound_helper.pks @@ -1,12 +1,16 @@ create or replace package ut_curr_usr_compound_helper authid current_user is - procedure get_columns_info(a_cursor in out nocopy sys_refcursor,a_columns_info out xmltype, - a_join_by_info out xmltype, a_contains_collection out number); + procedure get_columns_info( + a_cursor in out nocopy sys_refcursor, + a_columns_info out nocopy xmltype, + a_join_by_info out nocopy xmltype, + a_contains_collection out nocopy number + ); function get_columns_info(a_cursor in out nocopy sys_refcursor, a_desc_user_types boolean := false) return xmltype; - function get_user_defined_type(a_owner varchar2,a_type_name varchar2) return xmltype; + function get_user_defined_type(a_owner varchar2, a_type_name varchar2) return xmltype; end; / diff --git a/source/install.sql b/source/install.sql index 0bd30222c..7a8d89614 100644 --- a/source/install.sql +++ b/source/install.sql @@ -68,6 +68,7 @@ alter session set current_schema = &&ut3_owner; @@install_component.sql 'core/types/ut_test.tps' @@install_component.sql 'core/types/ut_logical_suite.tps' @@install_component.sql 'core/types/ut_suite.tps' +@@install_component.sql 'core/types/ut_suite_context.tps' @@install_component.sql 'core/types/ut_file_mapping.tps' @@install_component.sql 'core/types/ut_file_mappings.tps' @@install_component.sql 'core/types/ut_coverage_options.tps' @@ -151,6 +152,7 @@ prompt Installing DBMSPLSQL Tables objects into &&ut3_owner schema @@install_component.sql 'core/types/ut_test.tpb' @@install_component.sql 'core/types/ut_logical_suite.tpb' @@install_component.sql 'core/types/ut_suite.tpb' +@@install_component.sql 'core/types/ut_suite_context.tpb' @@install_component.sql 'core/types/ut_run.tpb' @@install_component.sql 'core/types/ut_expectation_result.tpb' @@install_component.sql 'core/types/ut_reporter_base.tpb' @@ -162,8 +164,6 @@ prompt Installing DBMSPLSQL Tables objects into &&ut3_owner schema @@install_component.sql 'core/types/ut_console_reporter_base.tpb' --expectations and matchers -@@install_component.sql 'expectations/data_values/ut_key_anyval_pair.tps' -@@install_component.sql 'expectations/data_values/ut_key_anyval_pairs.tps' @@install_component.sql 'expectations/data_values/ut_compound_data_tmp.sql' @@install_component.sql 'expectations/data_values/ut_compound_data_diff_tmp.sql' @@install_component.sql 'expectations/data_values/ut_data_value.tps' @@ -184,6 +184,8 @@ prompt Installing DBMSPLSQL Tables objects into &&ut3_owner schema @@install_component.sql 'expectations/data_values/ut_data_value_varchar2.tps' @@install_component.sql 'expectations/data_values/ut_data_value_yminterval.tps' @@install_component.sql 'expectations/data_values/ut_data_value_xmltype.tps' +@@install_component.sql 'expectations/data_values/ut_key_anyval_pair.tps' +@@install_component.sql 'expectations/data_values/ut_key_anyval_pairs.tps' @@install_component.sql 'expectations/data_values/ut_compound_data_helper.pks' @@install_component.sql 'expectations/data_values/ut_curr_usr_compound_helper.pks' @@install_component.sql 'expectations/matchers/ut_matcher.tps' diff --git a/source/install_component.sql b/source/install_component.sql index 1248c872f..5a9fc7e56 100644 --- a/source/install_component.sql +++ b/source/install_component.sql @@ -18,5 +18,6 @@ set heading off set feedback off exec dbms_output.put_line('Installing component '||upper(regexp_substr('&&1','\/(\w*)\.',1,1,'i',1))); @@&&1 +show errors exec dbms_output.put_line('&&line_separator'); diff --git a/source/uninstall_objects.sql b/source/uninstall_objects.sql index 48bf7cc76..cf8b3905f 100644 --- a/source/uninstall_objects.sql +++ b/source/uninstall_objects.sql @@ -193,6 +193,8 @@ drop type ut_file_mappings force; drop type ut_file_mapping force; +drop type ut_suite_context force; + drop type ut_suite force; drop type ut_logical_suite force; diff --git a/test/core/test_suite_builder.pkb b/test/core/test_suite_builder.pkb index 4bdd8095d..c159be4f0 100644 --- a/test/core/test_suite_builder.pkb +++ b/test/core/test_suite_builder.pkb @@ -485,8 +485,9 @@ create or replace package body test_suite_builder is ut3.ut_annotation(1, 'suite','Cool', null), ut3.ut_annotation(2, 'beforeall',null, 'suite_level_beforeall'), ut3.ut_annotation(3, 'test','In suite', 'suite_level_test'), - ut3.ut_annotation(4, 'context','A context', null), - ut3.ut_annotation(5, 'beforeall',null, 'context_setup'), + ut3.ut_annotation(4, 'context','a_context', null), + ut3.ut_annotation(5, 'displayname','A context', null), + ut3.ut_annotation(6, 'beforeall',null, 'context_setup'), ut3.ut_annotation(7, 'test', 'In context', 'test_in_a_context'), ut3.ut_annotation(8, 'endcontext',null, null) ); @@ -498,10 +499,10 @@ create or replace package body test_suite_builder is '%' || '%' || '' || - '%context_1A contextsome_package.context_1' || + '%a_contextA contextsome_package.a_context' || '%' || '' || - '%test_in_a_contextIn contextsome_package.context_1.test_in_a_context' || + '%test_in_a_contextIn contextsome_package.a_context.test_in_a_context' || '%' || '' || '' || @@ -529,7 +530,7 @@ create or replace package body test_suite_builder is l_annotations := ut3.ut_annotations( ut3.ut_annotation(1, 'suite','Cool', null), ut3.ut_annotation(2, 'test','In suite', 'suite_level_test'), - ut3.ut_annotation(3, 'context','A context', null), + ut3.ut_annotation(3, 'context','a_context', null), ut3.ut_annotation(4, 'beforeall',null, 'context_beforeall'), ut3.ut_annotation(5, 'beforeeach',null, 'context_beforeeach'), ut3.ut_annotation(6, 'test', 'In context', 'test_in_a_context'), @@ -544,7 +545,7 @@ create or replace package body test_suite_builder is '' || '%' || '%' || - '%context_1' || + '%a_context' || '%' || '%' || '%test_in_a_context' || @@ -579,7 +580,7 @@ create or replace package body test_suite_builder is ut3.ut_annotation(2, 'beforeall',null, 'suite_level_beforeall'), ut3.ut_annotation(3, 'beforeeach',null, 'suite_level_beforeeach'), ut3.ut_annotation(4, 'test','In suite', 'suite_level_test'), - ut3.ut_annotation(5, 'context','A context', null), + ut3.ut_annotation(5, 'context','a_context', null), ut3.ut_annotation(6, 'test', 'In context', 'test_in_a_context'), ut3.ut_annotation(7, 'endcontext',null, null), ut3.ut_annotation(8, 'aftereach',null, 'suite_level_aftereach'), @@ -592,7 +593,7 @@ create or replace package body test_suite_builder is '' || '%' || '%' || - '%context_1' || + '%a_context' || '%' || '%' || '%test_in_a_context' || @@ -665,8 +666,9 @@ create or replace package body test_suite_builder is ut3.ut_annotation(1, 'suite','Cool', null), ut3.ut_annotation(2, 'beforeall',null, 'suite_level_beforeall'), ut3.ut_annotation(3, 'test','In suite', 'suite_level_test'), - ut3.ut_annotation(4, 'context','A context', null), - ut3.ut_annotation(5, 'beforeall',null, 'context_setup'), + ut3.ut_annotation(4, 'context','a_context', null), + ut3.ut_annotation(5, 'displayname','A context', null), + ut3.ut_annotation(6, 'beforeall',null, 'context_setup'), ut3.ut_annotation(7, 'test', 'In context', 'test_in_a_context'), ut3.ut_annotation(8, 'endcontext',null, null), ut3.ut_annotation(9, 'endcontext',null, null) @@ -682,10 +684,10 @@ create or replace package body test_suite_builder is '' || '%' || '' || - '%context_1A contextsome_package.context_1' || + '%a_contextA contextsome_package.a_context' || '%' || '' || - '%test_in_a_contextIn contextsome_package.context_1.test_in_a_context' || + '%test_in_a_contextIn contextsome_package.a_context.test_in_a_context' || '%' || '' || '' || diff --git a/test/core/test_suite_manager.pkb b/test/core/test_suite_manager.pkb index 25f42ab11..59f1f42ea 100644 --- a/test/core/test_suite_manager.pkb +++ b/test/core/test_suite_manager.pkb @@ -242,6 +242,32 @@ end test_package_3;]'; end; end test_package_3;]'; + + execute immediate q'[create or replace package test_package_with_ctx is + + --%suite(test_package_with_ctx) + + gv_glob_val number; + + --%context(some_context) + --%displayname(Some context description) + + --%test + --%displayname(Test1 from test package 1) + procedure test1; + + --%endcontext + +end test_package_with_ctx;]'; + + execute immediate q'[create or replace package body test_package_with_ctx is + + procedure test1 is + begin + null; + end; + +end test_package_with_ctx;]'; end; @@ -251,6 +277,7 @@ end test_package_3;]'; execute immediate 'drop package test_package_1'; execute immediate 'drop package test_package_2'; execute immediate 'drop package test_package_3'; + execute immediate 'drop package test_package_with_ctx'; end; procedure test_schema_run is @@ -1352,5 +1379,59 @@ end;]'; clean_disabled_pck; end; + procedure pck_proc_in_ctx_by_name is + c_path varchar2(100) := USER||'.test_package_with_ctx.test1'; + l_objects_to_run ut3.ut_suite_items; + + l_test_suite ut3.ut_logical_suite; + l_ctx_suite ut3.ut_logical_suite; + l_test_proc ut3.ut_test; + begin + --Act + l_objects_to_run := ut3.ut_suite_manager.configure_execution_by_path(ut3.ut_varchar2_list(c_path)); + + --Assert + ut.expect(l_objects_to_run.count).to_equal(1); + + l_test_suite := treat(l_objects_to_run(1) as ut3.ut_logical_suite); + ut.expect(l_test_suite.name).to_equal('test_package_with_ctx'); + ut.expect(l_test_suite.items.count).to_equal(1); + + l_ctx_suite := treat(l_test_suite.items(1) as ut3.ut_logical_suite); + ut.expect(l_ctx_suite.name).to_equal('some_context'); + ut.expect(l_ctx_suite.description).to_equal('Some context description'); + ut.expect(l_ctx_suite.items.count).to_equal(1); + + l_test_proc := treat(l_ctx_suite.items(1) as ut3.ut_test); + ut.expect(l_test_proc.name).to_equal('test1'); + end; + + procedure pck_proc_in_ctx_by_path is + c_path varchar2(100) := USER||':test_package_with_ctx.some_context.test1'; + l_objects_to_run ut3.ut_suite_items; + + l_test_suite ut3.ut_logical_suite; + l_ctx_suite ut3.ut_logical_suite; + l_test_proc ut3.ut_test; + begin + --Act + l_objects_to_run := ut3.ut_suite_manager.configure_execution_by_path(ut3.ut_varchar2_list(c_path)); + + --Assert + ut.expect(l_objects_to_run.count).to_equal(1); + + l_test_suite := treat(l_objects_to_run(1) as ut3.ut_logical_suite); + ut.expect(l_test_suite.name).to_equal('test_package_with_ctx'); + ut.expect(l_test_suite.items.count).to_equal(1); + + l_ctx_suite := treat(l_test_suite.items(1) as ut3.ut_logical_suite); + ut.expect(l_ctx_suite.name).to_equal('some_context'); + ut.expect(l_ctx_suite.description).to_equal('Some context description'); + ut.expect(l_ctx_suite.items.count).to_equal(1); + + l_test_proc := treat(l_ctx_suite.items(1) as ut3.ut_test); + ut.expect(l_test_proc.name).to_equal('test1'); + end; + end test_suite_manager; / diff --git a/test/core/test_suite_manager.pks b/test/core/test_suite_manager.pks index 495f317a6..45466b9d2 100644 --- a/test/core/test_suite_manager.pks +++ b/test/core/test_suite_manager.pks @@ -145,5 +145,11 @@ create or replace package test_suite_manager is --%test(Whole suite gets disabled with floating annotation) procedure disable_suite_floating_annot; + --%test(Prepare runner for a package procedure inside context) + procedure pck_proc_in_ctx_by_name; + + --%test(Prepare runner for a package procedure inside context by path) + procedure pck_proc_in_ctx_by_path; + end test_suite_manager; / From 79330f7910fe856cdb03f5ee35f91f4ee7df29aa Mon Sep 17 00:00:00 2001 From: lwasylow Date: Thu, 7 Jun 2018 07:52:57 +0100 Subject: [PATCH 088/184] Update --- .travis/{ => lib}/xml_validator.jar | Bin .travis/pom.xml | 13 +++++++++++++ .travis/validate_report_files.sh | 10 ++++++---- .travis/{ => xsd}/junit4.xsd | 0 .travis/{ => xsd}/junit_windy.xsd | 0 5 files changed, 19 insertions(+), 4 deletions(-) rename .travis/{ => lib}/xml_validator.jar (100%) rename .travis/{ => xsd}/junit4.xsd (100%) rename .travis/{ => xsd}/junit_windy.xsd (100%) diff --git a/.travis/xml_validator.jar b/.travis/lib/xml_validator.jar similarity index 100% rename from .travis/xml_validator.jar rename to .travis/lib/xml_validator.jar diff --git a/.travis/pom.xml b/.travis/pom.xml index 706bd79bb..24f340c36 100644 --- a/.travis/pom.xml +++ b/.travis/pom.xml @@ -27,6 +27,19 @@ 12.2.0.1 compile + + xml_validator + xml_validator + 1.0 + system + ${project.basedir}/lib/xml_validator.jar + + + com.oracle.jdbc + orai18n + 12.2.0.1 + compile + diff --git a/.travis/validate_report_files.sh b/.travis/validate_report_files.sh index 6c96f57a7..23a98acf8 100644 --- a/.travis/validate_report_files.sh +++ b/.travis/validate_report_files.sh @@ -3,10 +3,12 @@ GL_VALID=1 HTML_FILENAME="coverage.html" +XSD_DIR="xsd" +XML_JAR_DIR="lib" JUNIT_FILENAME="junit_test_results.xml" -JUNIT_XSD="junit4.xsd" +JUNIT_XSD="xsd\junit4.xsd" TFS_FILENAME="tfs_test_results.xml" -TFS_XSD="junit_windy.xsd" +TFS_XSD="xsd\junit_windy.xsd" #Exclude existing issue with OL nested in PRE @@ -19,7 +21,7 @@ WARNING_REGEX="info warning:" ERROR_REGEX="error:" #XML Validator -XML_VALIDATOR="xml_validator.jar" +XML_VALIDATOR="lib\xml_validator.jar" #Validate HTML HTML_VALIDATION_RESULTS=$(curl -H "Content-Type: text/html; charset=utf-8" --data-binary @$HTML_FILENAME "$HTML_VALIDATOR_URL?out=$VALIDATOR_OUT&filterpattern=$EXCLUSION_REGEX") @@ -39,7 +41,7 @@ fi #Validate XML TFS_FILENAME -TFS_RESULT=$(java -jar $XML_VALIDATOR -s $TFS_XSD $TFS_FILENAME 2>&1) +TFS_RESULT=$(java -jar $$XML_VALIDATOR -s $TFS_XSD $TFS_FILENAME 2>&1) if [ $? -ne 0 ]; then GL_VALID=0 diff --git a/.travis/junit4.xsd b/.travis/xsd/junit4.xsd similarity index 100% rename from .travis/junit4.xsd rename to .travis/xsd/junit4.xsd diff --git a/.travis/junit_windy.xsd b/.travis/xsd/junit_windy.xsd similarity index 100% rename from .travis/junit_windy.xsd rename to .travis/xsd/junit_windy.xsd From 21a74fcc2bc29f2fee8015cd4f78dabc45f86258 Mon Sep 17 00:00:00 2001 From: lwasylow Date: Thu, 7 Jun 2018 08:38:07 +0100 Subject: [PATCH 089/184] Fixing wrong path --- .travis/pom.xml | 13 ------------- .travis/validate_report_files.sh | 10 +++++----- 2 files changed, 5 insertions(+), 18 deletions(-) diff --git a/.travis/pom.xml b/.travis/pom.xml index 24f340c36..706bd79bb 100644 --- a/.travis/pom.xml +++ b/.travis/pom.xml @@ -27,19 +27,6 @@ 12.2.0.1 compile - - xml_validator - xml_validator - 1.0 - system - ${project.basedir}/lib/xml_validator.jar - - - com.oracle.jdbc - orai18n - 12.2.0.1 - compile - diff --git a/.travis/validate_report_files.sh b/.travis/validate_report_files.sh index 23a98acf8..218e30e45 100644 --- a/.travis/validate_report_files.sh +++ b/.travis/validate_report_files.sh @@ -3,12 +3,12 @@ GL_VALID=1 HTML_FILENAME="coverage.html" -XSD_DIR="xsd" -XML_JAR_DIR="lib" JUNIT_FILENAME="junit_test_results.xml" -JUNIT_XSD="xsd\junit4.xsd" TFS_FILENAME="tfs_test_results.xml" -TFS_XSD="xsd\junit_windy.xsd" +XSD_DIR="xsd" +XML_JAR_DIR="lib" +JUNIT_XSD="$$XSD_DIR/junit4.xsd" +TFS_XSD="$XSD_DIR/junit_windy.xsd" #Exclude existing issue with OL nested in PRE @@ -21,7 +21,7 @@ WARNING_REGEX="info warning:" ERROR_REGEX="error:" #XML Validator -XML_VALIDATOR="lib\xml_validator.jar" +XML_VALIDATOR="$XML_JAR_DIR/xml_validator.jar" #Validate HTML HTML_VALIDATION_RESULTS=$(curl -H "Content-Type: text/html; charset=utf-8" --data-binary @$HTML_FILENAME "$HTML_VALIDATOR_URL?out=$VALIDATOR_OUT&filterpattern=$EXCLUSION_REGEX") From 7f2d63c3fe2d2c150c0ef3bc9dc66dc0c27ccdad Mon Sep 17 00:00:00 2001 From: Lukasz Date: Thu, 7 Jun 2018 09:12:48 +0100 Subject: [PATCH 090/184] Commit update path and see debug path --- .travis/validate_report_files.sh | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/.travis/validate_report_files.sh b/.travis/validate_report_files.sh index 218e30e45..39bca1c9d 100644 --- a/.travis/validate_report_files.sh +++ b/.travis/validate_report_files.sh @@ -7,7 +7,7 @@ JUNIT_FILENAME="junit_test_results.xml" TFS_FILENAME="tfs_test_results.xml" XSD_DIR="xsd" XML_JAR_DIR="lib" -JUNIT_XSD="$$XSD_DIR/junit4.xsd" +JUNIT_XSD="$XSD_DIR/junit4.xsd" TFS_XSD="$XSD_DIR/junit_windy.xsd" @@ -40,8 +40,22 @@ if [ "$ERROR_COUNT" -gt 0 ]; then fi + +#Debug +echo "PWD" +pwd + +echo "" +echo "LS" +ls + +echo "" +echo "LS LIB" +ls lib + + #Validate XML TFS_FILENAME -TFS_RESULT=$(java -jar $$XML_VALIDATOR -s $TFS_XSD $TFS_FILENAME 2>&1) +TFS_RESULT=$(java -jar $XML_VALIDATOR -s $TFS_XSD $TFS_FILENAME 2>&1) if [ $? -ne 0 ]; then GL_VALID=0 From d0ea705eb0867f7722fc656c38d1bcf43c19a212 Mon Sep 17 00:00:00 2001 From: Lukasz Date: Thu, 7 Jun 2018 10:08:08 +0100 Subject: [PATCH 091/184] upate paths --- .travis/validate_report_files.sh | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/.travis/validate_report_files.sh b/.travis/validate_report_files.sh index 39bca1c9d..3a9a40934 100644 --- a/.travis/validate_report_files.sh +++ b/.travis/validate_report_files.sh @@ -5,8 +5,8 @@ GL_VALID=1 HTML_FILENAME="coverage.html" JUNIT_FILENAME="junit_test_results.xml" TFS_FILENAME="tfs_test_results.xml" -XSD_DIR="xsd" -XML_JAR_DIR="lib" +XSD_DIR="$HOME/.travis/xsd" +XML_JAR_DIR="$HOME/.travis/lib" JUNIT_XSD="$XSD_DIR/junit4.xsd" TFS_XSD="$XSD_DIR/junit_windy.xsd" @@ -46,12 +46,9 @@ echo "PWD" pwd echo "" -echo "LS" -ls +echo "LS $HOME"] +ls $HOME -echo "" -echo "LS LIB" -ls lib #Validate XML TFS_FILENAME From 1acf150d1aa19ac3ba64b356623882ae7a01fa6d Mon Sep 17 00:00:00 2001 From: Lukasz Date: Thu, 7 Jun 2018 10:34:48 +0100 Subject: [PATCH 092/184] Debug test --- .travis/validate_report_files.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis/validate_report_files.sh b/.travis/validate_report_files.sh index 3a9a40934..c9f788247 100644 --- a/.travis/validate_report_files.sh +++ b/.travis/validate_report_files.sh @@ -5,8 +5,8 @@ GL_VALID=1 HTML_FILENAME="coverage.html" JUNIT_FILENAME="junit_test_results.xml" TFS_FILENAME="tfs_test_results.xml" -XSD_DIR="$HOME/.travis/xsd" -XML_JAR_DIR="$HOME/.travis/lib" +XSD_DIR="$TRAVIS_BUILD_DIR/.travis/xsd" +XML_JAR_DIR="$TRAVIS_BUILD_DIR/.travis/lib" JUNIT_XSD="$XSD_DIR/junit4.xsd" TFS_XSD="$XSD_DIR/junit_windy.xsd" @@ -46,8 +46,8 @@ echo "PWD" pwd echo "" -echo "LS $HOME"] -ls $HOME +echo "LS $TRAVIS_BUILD_DIR"] +ls $TRAVIS_BUILD_DIR From ad26c1a58c666ef550fd7249c889a3cad03b2767 Mon Sep 17 00:00:00 2001 From: Lukasz Date: Thu, 7 Jun 2018 10:49:25 +0100 Subject: [PATCH 093/184] Update --- .travis/validate_report_files.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis/validate_report_files.sh b/.travis/validate_report_files.sh index c9f788247..fa49e47ff 100644 --- a/.travis/validate_report_files.sh +++ b/.travis/validate_report_files.sh @@ -81,5 +81,7 @@ if [ $GL_VALID -ne 1 ]; then echo "Validation failed please see results above." exit 1 else - exit 0 + echo "" + echo "******************************" + echo "Validation passed. Good Job!" fi From 934e991c1164a2558d89c8dec940de92e3bc7c2f Mon Sep 17 00:00:00 2001 From: lwasylow Date: Thu, 7 Jun 2018 12:51:47 +0100 Subject: [PATCH 094/184] Update xml validation file --- .travis/validate_report_files.sh | 119 +++++++++++++------------------ 1 file changed, 49 insertions(+), 70 deletions(-) diff --git a/.travis/validate_report_files.sh b/.travis/validate_report_files.sh index fa49e47ff..9aa1df12e 100644 --- a/.travis/validate_report_files.sh +++ b/.travis/validate_report_files.sh @@ -1,79 +1,60 @@ #!/usr/bin/env bash GL_VALID=1 - -HTML_FILENAME="coverage.html" -JUNIT_FILENAME="junit_test_results.xml" -TFS_FILENAME="tfs_test_results.xml" XSD_DIR="$TRAVIS_BUILD_DIR/.travis/xsd" XML_JAR_DIR="$TRAVIS_BUILD_DIR/.travis/lib" -JUNIT_XSD="$XSD_DIR/junit4.xsd" -TFS_XSD="$XSD_DIR/junit_windy.xsd" - - -#Exclude existing issue with OL nested in PRE -EXCLUSION_REGEX=".*Element\s.?ol.?\snot\sallowed\sas\schild\sof\selement\s.?pre.*" - -#HTML Validation API -HTML_VALIDATOR_URL="https://validator.w3.org/nu/" -VALIDATOR_OUT="gnu" -WARNING_REGEX="info warning:" -ERROR_REGEX="error:" - #XML Validator XML_VALIDATOR="$XML_JAR_DIR/xml_validator.jar" +HTML_VALIDATOR_URL="https://validator.w3.org/nu/" -#Validate HTML -HTML_VALIDATION_RESULTS=$(curl -H "Content-Type: text/html; charset=utf-8" --data-binary @$HTML_FILENAME "$HTML_VALIDATOR_URL?out=$VALIDATOR_OUT&filterpattern=$EXCLUSION_REGEX") - -ERROR_COUNT=$(echo "$HTML_VALIDATION_RESULTS" | grep -c "$ERROR_REGEX") -WARNING_COUNT=$(echo "$HTML_VALIDATION_RESULTS" | grep -c "$WARNING_REGEX") - -if [ "$ERROR_COUNT" -gt 0 ]; then - GL_VALID=0 - echo "" - echo "******************************" - echo "HTML File is invalid" - echo "There are $ERROR_COUNT errors, $WARNING_COUNT warning in $HTML_FILENAME" - echo "Please see results:" - echo "$HTML_VALIDATION_RESULTS" | grep "$ERROR_REGEX" -fi - - - -#Debug -echo "PWD" -pwd - -echo "" -echo "LS $TRAVIS_BUILD_DIR"] -ls $TRAVIS_BUILD_DIR - - - -#Validate XML TFS_FILENAME -TFS_RESULT=$(java -jar $XML_VALIDATOR -s $TFS_XSD $TFS_FILENAME 2>&1) - -if [ $? -ne 0 ]; then - GL_VALID=0 - echo "" - echo "******************************" - echo "TFS Test Result XML is invalid" - echo "Please see results:" - echo "$TFS_RESULT" -fi - -#Validate XML JUNIT_FILENAME -JUNIT_RESULT=$(java -jar $XML_VALIDATOR -s $JUNIT_XSD $JUNIT_FILENAME 2>&1) - -if [ $? -ne 0 ]; then +HTML_FILENAME="coverage.html" +declare -A XML_FILES +XML_FILES["junit_test_results.xml"]="junit4.xsd" +XML_FILES["tfs_test_results.xml"]="junit_windy.xsd" + +function ValidateHtml { + EXCLUSION_REGEX=".*Element\s.?ol.?\snot\sallowed\sas\schild\sof\selement\s.?pre.*" + #HTML Validation API + VALIDATOR_OUT="gnu" + WARNING_REGEX="info warning:" + ERROR_REGEX="error:" + #Validate HTML + HTML_VALIDATION_RESULTS=$(curl -H "Content-Type: text/html; charset=utf-8" --data-binary @$1 "$HTML_VALIDATOR_URL?out=$VALIDATOR_OUT&filterpattern=$EXCLUSION_REGEX") + + ERROR_COUNT=$(echo "$HTML_VALIDATION_RESULTS" | grep -c "$ERROR_REGEX") + WARNING_COUNT=$(echo "$HTML_VALIDATION_RESULTS" | grep -c "$WARNING_REGEX") + + if [ "$ERROR_COUNT" -gt 0 ]; then GL_VALID=0 - echo "" - echo "******************************" - echo "JUNIT Test Result XML is invalid" - echo "Please see results:" - echo "$JUNIT_RESULT" -fi + echo "" + echo "******************************" + echo "HTML File is invalid" + echo "There are $ERROR_COUNT errors, $WARNING_COUNT warning in $HTML_FILENAME" + echo "Please see results:" + echo "$HTML_VALIDATION_RESULTS" | grep "$ERROR_REGEX" + fi +} + +function ValidateXML() { + echo "Validate File $1 against schema $2" + VALIDATION_RESULT=$(java -jar $XML_VALIDATOR -s $1 $2 2>&1) + + if [ $? -ne 0 ]; then + GL_VALID=0 + echo "" + echo "******************************" + echo "XML is invalid" + echo "Please see results:" + echo "$VALIDATION_RESULT" + fi +} + +ValidateHtml "$HTML_FILENAME" + +for XMLFILE in "${!XML_FILES[@]}"; do + #echo "$XMLFILE" "${XML_FILES[$XMLFILE]}"; + ValidateXML "$XMLFILE" "XSD_DIR/${XML_FILES[$XMLFILE]}" +done if [ $GL_VALID -ne 1 ]; then echo "" @@ -81,7 +62,5 @@ if [ $GL_VALID -ne 1 ]; then echo "Validation failed please see results above." exit 1 else - echo "" - echo "******************************" - echo "Validation passed. Good Job!" + exit 0 fi From c44e0e69244a5159ae7abea2c72c66f7a94ee3b2 Mon Sep 17 00:00:00 2001 From: lwasylow Date: Thu, 7 Jun 2018 13:41:22 +0100 Subject: [PATCH 095/184] Incorrect call to schema --- .travis/validate_report_files.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis/validate_report_files.sh b/.travis/validate_report_files.sh index 9aa1df12e..b227b9181 100644 --- a/.travis/validate_report_files.sh +++ b/.travis/validate_report_files.sh @@ -36,7 +36,7 @@ function ValidateHtml { } function ValidateXML() { - echo "Validate File $1 against schema $2" + echo "Validate File $2 against schema $1" VALIDATION_RESULT=$(java -jar $XML_VALIDATOR -s $1 $2 2>&1) if [ $? -ne 0 ]; then @@ -53,7 +53,7 @@ ValidateHtml "$HTML_FILENAME" for XMLFILE in "${!XML_FILES[@]}"; do #echo "$XMLFILE" "${XML_FILES[$XMLFILE]}"; - ValidateXML "$XMLFILE" "XSD_DIR/${XML_FILES[$XMLFILE]}" + ValidateXML "XSD_DIR/${XML_FILES[$XMLFILE]}" "$XMLFILE" done if [ $GL_VALID -ne 1 ]; then From 1b3e0bd794c6b647c0845d6da60477e3fff4e24d Mon Sep 17 00:00:00 2001 From: Lukasz Date: Thu, 7 Jun 2018 14:02:55 +0100 Subject: [PATCH 096/184] Update Path --- .travis/validate_report_files.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis/validate_report_files.sh b/.travis/validate_report_files.sh index b227b9181..621297a0b 100644 --- a/.travis/validate_report_files.sh +++ b/.travis/validate_report_files.sh @@ -53,7 +53,7 @@ ValidateHtml "$HTML_FILENAME" for XMLFILE in "${!XML_FILES[@]}"; do #echo "$XMLFILE" "${XML_FILES[$XMLFILE]}"; - ValidateXML "XSD_DIR/${XML_FILES[$XMLFILE]}" "$XMLFILE" + ValidateXML "$XSD_DIR/${XML_FILES[$XMLFILE]}" "$XMLFILE" done if [ $GL_VALID -ne 1 ]; then From 19c6730865c34422bc42dadb299838181d4301fd Mon Sep 17 00:00:00 2001 From: Travis CI Date: Thu, 7 Jun 2018 14:46:13 +0000 Subject: [PATCH 097/184] Updated project version after build [skip ci] --- source/core/ut_utils.pks | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/core/ut_utils.pks b/source/core/ut_utils.pks index d7698dacf..f8a8779b7 100644 --- a/source/core/ut_utils.pks +++ b/source/core/ut_utils.pks @@ -21,7 +21,7 @@ create or replace package ut_utils authid definer is * */ - gc_version constant varchar2(50) := 'v3.1.2.1979-develop'; + gc_version constant varchar2(50) := 'v3.1.2.1993-develop'; /* Constants: Event names */ subtype t_event_name is varchar2(30); From 3e709fbe44b72c942abbdb577475861c01fcd9fa Mon Sep 17 00:00:00 2001 From: Travis CI Date: Thu, 7 Jun 2018 16:54:15 +0000 Subject: [PATCH 098/184] Updated project version after build [skip ci] --- source/core/ut_utils.pks | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/core/ut_utils.pks b/source/core/ut_utils.pks index f8a8779b7..c2e37b794 100644 --- a/source/core/ut_utils.pks +++ b/source/core/ut_utils.pks @@ -21,7 +21,7 @@ create or replace package ut_utils authid definer is * */ - gc_version constant varchar2(50) := 'v3.1.2.1993-develop'; + gc_version constant varchar2(50) := 'v3.1.2.1994-develop'; /* Constants: Event names */ subtype t_event_name is varchar2(30); From 641c9f9e3e82841f2ce0e8ebe89cd0572c6eb2c4 Mon Sep 17 00:00:00 2001 From: Jacek Gebal Date: Sun, 10 Jun 2018 16:03:33 +0100 Subject: [PATCH 099/184] Removed leftover XUNIT test package body. --- test/core/reporters/test_xunit_reporter.pkb | 133 -------------------- 1 file changed, 133 deletions(-) delete mode 100644 test/core/reporters/test_xunit_reporter.pkb diff --git a/test/core/reporters/test_xunit_reporter.pkb b/test/core/reporters/test_xunit_reporter.pkb deleted file mode 100644 index f75c53ce4..000000000 --- a/test/core/reporters/test_xunit_reporter.pkb +++ /dev/null @@ -1,133 +0,0 @@ -create or replace package body test_xunit_reporter as - - procedure crate_a_test_package is - pragma autonomous_transaction; - begin - execute immediate q'[create or replace package check_xunit_reporting is - --%suite(A suite with ) - - --%test(A test with ) - procedure test_do_stuff; - - end;]'; - execute immediate q'[create or replace package body check_xunit_reporting is - procedure test_do_stuff is - begin - ut3.ut.expect(1).to_equal(1); - ut3.ut.expect(1).to_equal(2); - end; - - end;]'; - - execute immediate q'[create or replace package check_xunit_rep_suitepath is - --%suitepath(core) - --%suite(check_xunit_rep_suitepath) - --%displayname(Check XUNIT Get path for suitepath) - - --%test(check_xunit_rep_suitepath) - --%displayname(Check XUNIT Get path for suitepath) - procedure check_xunit_rep_suitepath; - end;]'; - execute immediate q'[create or replace package body check_xunit_rep_suitepath is - procedure check_xunit_rep_suitepath is - begin - ut3.ut.expect(1).to_equal(1); - end; - end;]'; - end; - - procedure escapes_special_chars is - l_results ut3.ut_varchar2_list; - l_actual clob; - begin - --Act - select * - bulk collect into l_results - from table(ut3.ut.run('check_xunit_reporting',ut3.ut_xunit_reporter())); - l_actual := ut3.ut_utils.table_to_clob(l_results); - --Assert - ut.expect(l_actual).not_to_be_like('%%'); - ut.expect(l_actual).to_be_like('%<tag>%'); - end; - - procedure reports_only_failed_or_errored is - l_results ut3.ut_varchar2_list; - l_actual clob; - begin - --Act - select * - bulk collect into l_results - from table(ut3.ut.run('check_xunit_reporting',ut3.ut_xunit_reporter())); - l_actual := ut3.ut_utils.table_to_clob(l_results); - --Assert - ut.expect(l_actual).not_to_be_like('%Actual: 1 (number) was expected to equal: 1 (number)%'); - ut.expect(l_actual).to_be_like('%Actual: 1 (number) was expected to equal: 2 (number)%'); - end; - - procedure reports_failed_line is - l_results ut3.ut_varchar2_list; - l_actual clob; - begin - --Act - select * - bulk collect into l_results - from table(ut3.ut.run('check_xunit_reporting',ut3.ut_xunit_reporter())); - l_actual := ut3.ut_utils.table_to_clob(l_results); - --Assert - ut.expect(l_actual).to_be_like('%at "%.CHECK_XUNIT_REPORTING%", line %'); - end; - - procedure check_classname_suite is - l_results ut3.ut_varchar2_list; - l_actual clob; - begin - --Act - select * - bulk collect into l_results - from table(ut3.ut.run('check_xunit_reporting',ut3.ut_xunit_reporter())); - l_actual := ut3.ut_utils.table_to_clob(l_results); - --Assert - ut.expect(l_actual).to_be_like('%testcase classname="check_xunit_reporting"%'); - end; - - procedure check_nls_number_formatting is - l_results ut3.ut_varchar2_list; - l_actual clob; - l_nls_numeric_characters varchar2(30); - begin - --Arrange - select nsp.value into l_nls_numeric_characters - from nls_session_parameters nsp - where parameter = 'NLS_NUMERIC_CHARACTERS'; - execute immediate q'[alter session set NLS_NUMERIC_CHARACTERS=', ']'; - --Act - select * - bulk collect into l_results - from table(ut3.ut.run('check_xunit_reporting', ut3.ut_xunit_reporter())); - l_actual := ut3.ut_utils.table_to_clob(l_results); - --Assert - ut.expect(l_actual).to_match('time="[0-9]*\.[0-9]{3,6}"'); - --Cleanup - execute immediate 'alter session set NLS_NUMERIC_CHARACTERS='''||l_nls_numeric_characters||''''; - end; - - procedure check_classname_suitepath is - l_results ut3.ut_varchar2_list; - l_actual clob; - begin - --Act - select * - bulk collect into l_results - from table(ut3.ut.run('check_xunit_rep_suitepath',ut3.ut_xunit_reporter())); - l_actual := ut3.ut_utils.table_to_clob(l_results); - --Assert - ut.expect(l_actual).to_be_like('%testcase classname="core.check_xunit_rep_suitepath"%'); - end; - procedure remove_test_package is - pragma autonomous_transaction; - begin - execute immediate 'drop package check_xunit_reporting'; - execute immediate 'drop package check_xunit_rep_suitepath'; - end; -end; -/ From fe90466ea6cc4dba9fa7fe225105b01cdd35c351 Mon Sep 17 00:00:00 2001 From: Jacek Gebal Date: Sun, 10 Jun 2018 18:45:54 +0100 Subject: [PATCH 100/184] Added support for `a_client_character_set` --- source/api/ut.pkb | 328 ++++++++++++++---- source/api/ut.pks | 140 ++++++-- source/api/ut_runner.pkb | 16 +- source/api/ut_runner.pks | 14 +- source/core/types/ut_run.tpb | 4 +- source/core/types/ut_run.tps | 4 +- source/core/ut_utils.pkb | 11 + source/core/ut_utils.pks | 7 + .../ut_coverage_cobertura_reporter.tpb | 24 +- .../reporters/ut_coverage_sonar_reporter.tpb | 6 +- source/reporters/ut_junit_reporter.tpb | 1 + source/reporters/ut_sonar_test_reporter.tpb | 1 + source/reporters/ut_tfs_junit_reporter.tpb | 1 + test/core/reporters.pkb | 17 + test/core/reporters.pks | 6 + test/core/reporters/test_coverage.pkb | 3 +- .../test_coverage_sonar_reporter.pkb | 8 +- .../test_coverage_sonar_reporter.pks | 3 + test/core/reporters/test_junit_reporter.pkb | 19 +- test/core/reporters/test_junit_reporter.pks | 3 + .../reporters/test_tfs_junit_reporter.pkb | 9 +- .../reporters/test_tfs_junit_reporter.pks | 3 + 22 files changed, 487 insertions(+), 141 deletions(-) diff --git a/source/api/ut.pkb b/source/api/ut.pkb index 4225629b8..94ff1e2b5 100644 --- a/source/api/ut.pkb +++ b/source/api/ut.pkb @@ -105,50 +105,89 @@ create or replace package body ut is end; procedure run_autonomous( - a_paths ut_varchar2_list, a_reporter ut_reporter_base, a_color_console integer, - a_coverage_schemes ut_varchar2_list := null, a_source_file_mappings ut_file_mappings, a_test_file_mappings ut_file_mappings, - a_include_objects ut_varchar2_list, a_exclude_objects ut_varchar2_list + a_paths ut_varchar2_list, + a_reporter ut_reporter_base, + a_color_console integer, + a_coverage_schemes ut_varchar2_list := null, + a_source_file_mappings ut_file_mappings, + a_test_file_mappings ut_file_mappings, + a_include_objects ut_varchar2_list, + a_exclude_objects ut_varchar2_list, + a_client_character_set varchar2 := null ) is pragma autonomous_transaction; + c_fail_on_errors constant boolean := false; begin ut_runner.run( - a_paths, ut_reporters(coalesce(a_reporter,ut_documentation_reporter())), - ut_utils.int_to_boolean(a_color_console), a_coverage_schemes, a_source_file_mappings, - a_test_file_mappings, a_include_objects, a_exclude_objects, false + a_paths, + ut_reporters(coalesce(a_reporter,ut_documentation_reporter())), + ut_utils.int_to_boolean(a_color_console), + a_coverage_schemes, + a_source_file_mappings, + a_test_file_mappings, + a_include_objects, + a_exclude_objects, + c_fail_on_errors, + a_client_character_set ); rollback; end; procedure run_autonomous( - a_paths ut_varchar2_list, a_reporter ut_reporter_base, a_color_console integer, - a_coverage_schemes ut_varchar2_list := null, a_source_files ut_varchar2_list, a_test_files ut_varchar2_list, - a_include_objects ut_varchar2_list, a_exclude_objects ut_varchar2_list + a_paths ut_varchar2_list, + a_reporter ut_reporter_base, + a_color_console integer, + a_coverage_schemes ut_varchar2_list := null, + a_source_files ut_varchar2_list, + a_test_files ut_varchar2_list, + a_include_objects ut_varchar2_list, + a_exclude_objects ut_varchar2_list, + a_client_character_set varchar2 := null ) is pragma autonomous_transaction; + c_fail_on_errors constant boolean := false; begin ut_runner.run( - a_paths, ut_reporters(coalesce(a_reporter,ut_documentation_reporter())), - ut_utils.int_to_boolean(a_color_console), a_coverage_schemes, + a_paths, + ut_reporters(coalesce(a_reporter,ut_documentation_reporter())), + ut_utils.int_to_boolean(a_color_console), + a_coverage_schemes, ut_file_mapper.build_file_mappings(a_source_files), ut_file_mapper.build_file_mappings(a_test_files), - a_include_objects, a_exclude_objects, false + a_include_objects, + a_exclude_objects, + c_fail_on_errors, + a_client_character_set ); rollback; end; function run( - a_reporter ut_reporter_base := null, a_color_console integer := 0, - a_coverage_schemes ut_varchar2_list := null, a_source_file_mappings ut_file_mappings := null, a_test_file_mappings ut_file_mappings := null, - a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null + a_reporter ut_reporter_base := null, + a_color_console integer := 0, + a_coverage_schemes ut_varchar2_list := null, + a_source_file_mappings ut_file_mappings := null, + a_test_file_mappings ut_file_mappings := null, + a_include_objects ut_varchar2_list := null, + a_exclude_objects ut_varchar2_list := null, + a_client_character_set varchar2 := null ) return ut_varchar2_rows pipelined is - l_reporter ut_reporter_base := coalesce(a_reporter, ut_documentation_reporter()); + l_reporter ut_reporter_base := coalesce(a_reporter, + ut_documentation_reporter()); l_paths ut_varchar2_list := ut_varchar2_list(sys_context('userenv', 'current_schema')); l_lines sys_refcursor; l_line varchar2(4000); begin run_autonomous( - l_paths, l_reporter, a_color_console, - a_coverage_schemes, a_source_file_mappings, a_test_file_mappings, a_include_objects, a_exclude_objects + l_paths, + l_reporter, + a_color_console, + a_coverage_schemes, + a_source_file_mappings, + a_test_file_mappings, + a_include_objects, + a_exclude_objects, + a_client_character_set ); if l_reporter is of (ut_output_reporter_base) then l_lines := treat(l_reporter as ut_output_reporter_base).get_lines_cursor(); @@ -164,9 +203,14 @@ create or replace package body ut is end; function run( - a_reporter ut_reporter_base := null, a_color_console integer := 0, - a_coverage_schemes ut_varchar2_list := null, a_source_files ut_varchar2_list, a_test_files ut_varchar2_list, - a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null + a_reporter ut_reporter_base := null, + a_color_console integer := 0, + a_coverage_schemes ut_varchar2_list := null, + a_source_files ut_varchar2_list, + a_test_files ut_varchar2_list, + a_include_objects ut_varchar2_list := null, + a_exclude_objects ut_varchar2_list := null, + a_client_character_set varchar2 := null ) return ut_varchar2_rows pipelined is l_reporter ut_reporter_base := coalesce(a_reporter, ut_documentation_reporter()); l_paths ut_varchar2_list := ut_varchar2_list(sys_context('userenv', 'current_schema')); @@ -174,8 +218,15 @@ create or replace package body ut is l_line varchar2(4000); begin run_autonomous( - l_paths, l_reporter, a_color_console, a_coverage_schemes, a_source_files, a_test_files, - a_include_objects, a_exclude_objects + l_paths, + l_reporter, + a_color_console, + a_coverage_schemes, + a_source_files, + a_test_files, + a_include_objects, + a_exclude_objects, + a_client_character_set ); if l_reporter is of (ut_output_reporter_base) then l_lines := treat(l_reporter as ut_output_reporter_base).get_lines_cursor(); @@ -191,17 +242,30 @@ create or replace package body ut is end; function run( - a_paths ut_varchar2_list, a_reporter ut_reporter_base := null, a_color_console integer := 0, - a_coverage_schemes ut_varchar2_list := null, a_source_file_mappings ut_file_mappings := null, a_test_file_mappings ut_file_mappings := null, - a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null + a_paths ut_varchar2_list, + a_reporter ut_reporter_base := null, + a_color_console integer := 0, + a_coverage_schemes ut_varchar2_list := null, + a_source_file_mappings ut_file_mappings := null, + a_test_file_mappings ut_file_mappings := null, + a_include_objects ut_varchar2_list := null, + a_exclude_objects ut_varchar2_list := null, + a_client_character_set varchar2 := null ) return ut_varchar2_rows pipelined is l_reporter ut_reporter_base := coalesce(a_reporter, ut_documentation_reporter()); l_lines sys_refcursor; l_line varchar2(4000); begin run_autonomous( - a_paths, l_reporter, a_color_console, a_coverage_schemes, a_source_file_mappings, a_test_file_mappings, - a_include_objects, a_exclude_objects + a_paths, + l_reporter, + a_color_console, + a_coverage_schemes, + a_source_file_mappings, + a_test_file_mappings, + a_include_objects, + a_exclude_objects, + a_client_character_set ); if l_reporter is of (ut_output_reporter_base) then l_lines := treat(l_reporter as ut_output_reporter_base).get_lines_cursor(); @@ -217,17 +281,30 @@ create or replace package body ut is end; function run( - a_paths ut_varchar2_list, a_reporter ut_reporter_base := null, a_color_console integer := 0, - a_coverage_schemes ut_varchar2_list := null, a_source_files ut_varchar2_list, a_test_files ut_varchar2_list, - a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null + a_paths ut_varchar2_list, + a_reporter ut_reporter_base := null, + a_color_console integer := 0, + a_coverage_schemes ut_varchar2_list := null, + a_source_files ut_varchar2_list, + a_test_files ut_varchar2_list, + a_include_objects ut_varchar2_list := null, + a_exclude_objects ut_varchar2_list := null, + a_client_character_set varchar2 := null ) return ut_varchar2_rows pipelined is l_reporter ut_reporter_base := coalesce(a_reporter, ut_documentation_reporter()); l_lines sys_refcursor; l_line varchar2(4000); begin run_autonomous( - a_paths, l_reporter, a_color_console, a_coverage_schemes, a_source_files, a_test_files, - a_include_objects, a_exclude_objects + a_paths, + l_reporter, + a_color_console, + a_coverage_schemes, + a_source_files, + a_test_files, + a_include_objects, + a_exclude_objects, + a_client_character_set ); if l_reporter is of (ut_output_reporter_base) then l_lines := treat(l_reporter as ut_output_reporter_base).get_lines_cursor(); @@ -243,18 +320,32 @@ create or replace package body ut is end; function run( - a_path varchar2, a_reporter ut_reporter_base := null, a_color_console integer := 0, - a_coverage_schemes ut_varchar2_list := null, a_source_file_mappings ut_file_mappings := null, a_test_file_mappings ut_file_mappings := null, - a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null + a_path varchar2, + a_reporter ut_reporter_base := null, + a_color_console integer := 0, + a_coverage_schemes ut_varchar2_list := null, + a_source_file_mappings ut_file_mappings := null, + a_test_file_mappings ut_file_mappings := null, + a_include_objects ut_varchar2_list := null, + a_exclude_objects ut_varchar2_list := null, + a_client_character_set varchar2 := null ) return ut_varchar2_rows pipelined is - l_reporter ut_reporter_base := coalesce(a_reporter, ut_documentation_reporter()); + l_reporter ut_reporter_base := coalesce(a_reporter, + ut_documentation_reporter()); l_paths ut_varchar2_list := ut_varchar2_list(coalesce(a_path, sys_context('userenv', 'current_schema'))); l_lines sys_refcursor; l_line varchar2(4000); begin run_autonomous( - l_paths, l_reporter, a_color_console, a_coverage_schemes, a_source_file_mappings, a_test_file_mappings, - a_include_objects, a_exclude_objects + l_paths, + l_reporter, + a_color_console, + a_coverage_schemes, + a_source_file_mappings, + a_test_file_mappings, + a_include_objects, + a_exclude_objects, + a_client_character_set ); if l_reporter is of (ut_output_reporter_base) then l_lines := treat(l_reporter as ut_output_reporter_base).get_lines_cursor(); @@ -270,9 +361,15 @@ create or replace package body ut is end; function run( - a_path varchar2, a_reporter ut_reporter_base := null, a_color_console integer := 0, - a_coverage_schemes ut_varchar2_list := null, a_source_files ut_varchar2_list, a_test_files ut_varchar2_list, - a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null + a_path varchar2, + a_reporter ut_reporter_base := null, + a_color_console integer := 0, + a_coverage_schemes ut_varchar2_list := null, + a_source_files ut_varchar2_list, + a_test_files ut_varchar2_list, + a_include_objects ut_varchar2_list := null, + a_exclude_objects ut_varchar2_list := null, + a_client_character_set varchar2 := null ) return ut_varchar2_rows pipelined is l_reporter ut_reporter_base := coalesce(a_reporter, ut_documentation_reporter()); l_paths ut_varchar2_list := ut_varchar2_list(coalesce(a_path, sys_context('userenv', 'current_schema'))); @@ -280,8 +377,15 @@ create or replace package body ut is l_line varchar2(4000); begin run_autonomous( - l_paths, l_reporter, a_color_console, a_coverage_schemes, a_source_files, a_test_files, - a_include_objects, a_exclude_objects + l_paths, + l_reporter, + a_color_console, + a_coverage_schemes, + a_source_files, + a_test_files, + a_include_objects, + a_exclude_objects, + a_client_character_set ); if l_reporter is of (ut_output_reporter_base) then l_lines := treat(l_reporter as ut_output_reporter_base).get_lines_cursor(); @@ -297,15 +401,28 @@ create or replace package body ut is end; procedure run( - a_paths ut_varchar2_list, a_reporter ut_reporter_base := null, a_color_console boolean := false, - a_coverage_schemes ut_varchar2_list := null, a_source_file_mappings ut_file_mappings := null, a_test_file_mappings ut_file_mappings := null, - a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null + a_paths ut_varchar2_list, + a_reporter ut_reporter_base := null, + a_color_console boolean := false, + a_coverage_schemes ut_varchar2_list := null, + a_source_file_mappings ut_file_mappings := null, + a_test_file_mappings ut_file_mappings := null, + a_include_objects ut_varchar2_list := null, + a_exclude_objects ut_varchar2_list := null, + a_client_character_set varchar2 := null ) is l_reporter ut_reporter_base := coalesce(a_reporter, ut_documentation_reporter()); begin run_autonomous( - a_paths, l_reporter, ut_utils.boolean_to_int(a_color_console), a_coverage_schemes, a_source_file_mappings, a_test_file_mappings, - a_include_objects, a_exclude_objects + a_paths, + l_reporter, + ut_utils.boolean_to_int(a_color_console), + a_coverage_schemes, + a_source_file_mappings, + a_test_file_mappings, + a_include_objects, + a_exclude_objects, + a_client_character_set ); if l_reporter is of (ut_output_reporter_base) then treat(l_reporter as ut_output_reporter_base).lines_to_dbms_output(); @@ -314,15 +431,28 @@ create or replace package body ut is end; procedure run( - a_paths ut_varchar2_list, a_reporter ut_reporter_base := null, a_color_console boolean := false, - a_coverage_schemes ut_varchar2_list := null, a_source_files ut_varchar2_list, a_test_files ut_varchar2_list, - a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null + a_paths ut_varchar2_list, + a_reporter ut_reporter_base := null, + a_color_console boolean := false, + a_coverage_schemes ut_varchar2_list := null, + a_source_files ut_varchar2_list, + a_test_files ut_varchar2_list, + a_include_objects ut_varchar2_list := null, + a_exclude_objects ut_varchar2_list := null, + a_client_character_set varchar2 := null ) is l_reporter ut_reporter_base := coalesce(a_reporter, ut_documentation_reporter()); begin run_autonomous( - a_paths, l_reporter, ut_utils.boolean_to_int(a_color_console), a_coverage_schemes, a_source_files, a_test_files, - a_include_objects, a_exclude_objects + a_paths, + l_reporter, + ut_utils.boolean_to_int(a_color_console), + a_coverage_schemes, + a_source_files, + a_test_files, + a_include_objects, + a_exclude_objects, + a_client_character_set ); if l_reporter is of (ut_output_reporter_base) then treat(l_reporter as ut_output_reporter_base).lines_to_dbms_output(); @@ -331,52 +461,102 @@ create or replace package body ut is end; procedure run( - a_reporter ut_reporter_base := null, a_color_console boolean := false, - a_coverage_schemes ut_varchar2_list := null, a_source_file_mappings ut_file_mappings := null, a_test_file_mappings ut_file_mappings := null, - a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null + a_reporter ut_reporter_base := null, + a_color_console boolean := false, + a_coverage_schemes ut_varchar2_list := null, + a_source_file_mappings ut_file_mappings := null, + a_test_file_mappings ut_file_mappings := null, + a_include_objects ut_varchar2_list := null, + a_exclude_objects ut_varchar2_list := null, + a_client_character_set varchar2 := null ) is begin ut.run( - ut_varchar2_list(sys_context('userenv', 'current_schema')), a_reporter, a_color_console, - a_coverage_schemes, a_source_file_mappings, a_test_file_mappings, a_include_objects, a_exclude_objects + ut_varchar2_list(sys_context('userenv', 'current_schema')), + a_reporter, + a_color_console, + a_coverage_schemes, + a_source_file_mappings, + a_test_file_mappings, + a_include_objects, + a_exclude_objects, + a_client_character_set ); end; procedure run( - a_reporter ut_reporter_base := null, a_color_console boolean := false, - a_coverage_schemes ut_varchar2_list := null, a_source_files ut_varchar2_list, a_test_files ut_varchar2_list, - a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null + a_reporter ut_reporter_base := null, + a_color_console boolean := false, + a_coverage_schemes ut_varchar2_list := null, + a_source_files ut_varchar2_list, + a_test_files ut_varchar2_list, + a_include_objects ut_varchar2_list := null, + a_exclude_objects ut_varchar2_list := null, + a_client_character_set varchar2 := null ) is begin ut.run( - ut_varchar2_list(sys_context('userenv', 'current_schema')), a_reporter, a_color_console, - a_coverage_schemes, a_source_files, a_test_files, a_include_objects, a_exclude_objects + ut_varchar2_list(sys_context('userenv', 'current_schema')), + a_reporter, + a_color_console, + a_coverage_schemes, + a_source_files, + a_test_files, + a_include_objects, + a_exclude_objects, + a_client_character_set ); end; procedure run( - a_path varchar2, a_reporter ut_reporter_base := null, a_color_console boolean := false, - a_coverage_schemes ut_varchar2_list := null, a_source_file_mappings ut_file_mappings := null, a_test_file_mappings ut_file_mappings := null, - a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null + a_path varchar2, + a_reporter ut_reporter_base := null, + a_color_console boolean := false, + a_coverage_schemes ut_varchar2_list := null, + a_source_file_mappings ut_file_mappings := null, + a_test_file_mappings ut_file_mappings := null, + a_include_objects ut_varchar2_list := null, + a_exclude_objects ut_varchar2_list := null, + a_client_character_set varchar2 := null ) is l_paths ut_varchar2_list := ut_varchar2_list(coalesce(a_path, sys_context('userenv', 'current_schema'))); begin ut.run( - l_paths, a_reporter, a_color_console, a_coverage_schemes, a_source_file_mappings, a_test_file_mappings, - a_include_objects, a_exclude_objects + l_paths, + a_reporter, + a_color_console, + a_coverage_schemes, + a_source_file_mappings, + a_test_file_mappings, + a_include_objects, + a_exclude_objects, + a_client_character_set ); end; procedure run( - a_path varchar2, a_reporter ut_reporter_base := null, a_color_console boolean := false, - a_coverage_schemes ut_varchar2_list := null, a_source_files ut_varchar2_list, a_test_files ut_varchar2_list, - a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null + a_path varchar2, + a_reporter ut_reporter_base := null, + a_color_console boolean := false, + a_coverage_schemes ut_varchar2_list := null, + a_source_files ut_varchar2_list, + a_test_files ut_varchar2_list, + a_include_objects ut_varchar2_list := null, + a_exclude_objects ut_varchar2_list := null, + a_client_character_set varchar2 := null ) is l_paths ut_varchar2_list := ut_varchar2_list(coalesce(a_path, sys_context('userenv', 'current_schema'))); begin ut.run( - l_paths, a_reporter, a_color_console, a_coverage_schemes, a_source_files, a_test_files, - a_include_objects, a_exclude_objects + l_paths, + a_reporter, + a_color_console, + a_coverage_schemes, + a_source_files, + a_test_files, + a_include_objects, + a_exclude_objects, + a_client_character_set ); end; diff --git a/source/api/ut.pks b/source/api/ut.pks index ad6ea9757..a90957fd2 100644 --- a/source/api/ut.pks +++ b/source/api/ut.pks @@ -48,75 +48,143 @@ create or replace package ut authid current_user as procedure fail(a_message in varchar2); function run( - a_reporter ut_reporter_base := null, a_color_console integer := 0, - a_coverage_schemes ut_varchar2_list := null, a_source_file_mappings ut_file_mappings := null, a_test_file_mappings ut_file_mappings := null, - a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null + a_reporter ut_reporter_base := null, + a_color_console integer := 0, + a_coverage_schemes ut_varchar2_list := null, + a_source_file_mappings ut_file_mappings := null, + a_test_file_mappings ut_file_mappings := null, + a_include_objects ut_varchar2_list := null, + a_exclude_objects ut_varchar2_list := null, + a_client_character_set varchar2 := null ) return ut_varchar2_rows pipelined; function run( - a_reporter ut_reporter_base := null, a_color_console integer := 0, - a_coverage_schemes ut_varchar2_list := null, a_source_files ut_varchar2_list, a_test_files ut_varchar2_list, - a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null + a_reporter ut_reporter_base := null, + a_color_console integer := 0, + a_coverage_schemes ut_varchar2_list := null, + a_source_files ut_varchar2_list, + a_test_files ut_varchar2_list, + a_include_objects ut_varchar2_list := null, + a_exclude_objects ut_varchar2_list := null, + a_client_character_set varchar2 := null ) return ut_varchar2_rows pipelined; function run( - a_paths ut_varchar2_list, a_reporter ut_reporter_base := null, a_color_console integer := 0, - a_coverage_schemes ut_varchar2_list := null, a_source_file_mappings ut_file_mappings := null, a_test_file_mappings ut_file_mappings := null, - a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null + a_paths ut_varchar2_list, + a_reporter ut_reporter_base := null, + a_color_console integer := 0, + a_coverage_schemes ut_varchar2_list := null, + a_source_file_mappings ut_file_mappings := null, + a_test_file_mappings ut_file_mappings := null, + a_include_objects ut_varchar2_list := null, + a_exclude_objects ut_varchar2_list := null, + a_client_character_set varchar2 := null ) return ut_varchar2_rows pipelined; function run( - a_paths ut_varchar2_list, a_reporter ut_reporter_base := null, a_color_console integer := 0, - a_coverage_schemes ut_varchar2_list := null, a_source_files ut_varchar2_list, a_test_files ut_varchar2_list, - a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null + a_paths ut_varchar2_list, + a_reporter ut_reporter_base := null, + a_color_console integer := 0, + a_coverage_schemes ut_varchar2_list := null, + a_source_files ut_varchar2_list, + a_test_files ut_varchar2_list, + a_include_objects ut_varchar2_list := null, + a_exclude_objects ut_varchar2_list := null, + a_client_character_set varchar2 := null ) return ut_varchar2_rows pipelined; function run( - a_path varchar2, a_reporter ut_reporter_base := null, a_color_console integer := 0, - a_coverage_schemes ut_varchar2_list := null, a_source_file_mappings ut_file_mappings := null, a_test_file_mappings ut_file_mappings := null, - a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null + a_path varchar2, + a_reporter ut_reporter_base := null, + a_color_console integer := 0, + a_coverage_schemes ut_varchar2_list := null, + a_source_file_mappings ut_file_mappings := null, + a_test_file_mappings ut_file_mappings := null, + a_include_objects ut_varchar2_list := null, + a_exclude_objects ut_varchar2_list := null, + a_client_character_set varchar2 := null ) return ut_varchar2_rows pipelined; function run( - a_path varchar2, a_reporter ut_reporter_base := null, a_color_console integer := 0, - a_coverage_schemes ut_varchar2_list := null, a_source_files ut_varchar2_list, a_test_files ut_varchar2_list, - a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null + a_path varchar2, + a_reporter ut_reporter_base := null, + a_color_console integer := 0, + a_coverage_schemes ut_varchar2_list := null, + a_source_files ut_varchar2_list, + a_test_files ut_varchar2_list, + a_include_objects ut_varchar2_list := null, + a_exclude_objects ut_varchar2_list := null, + a_client_character_set varchar2 := null ) return ut_varchar2_rows pipelined; procedure run( - a_reporter ut_reporter_base := null, a_color_console boolean := false, - a_coverage_schemes ut_varchar2_list := null, a_source_file_mappings ut_file_mappings := null, a_test_file_mappings ut_file_mappings := null, - a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null + a_reporter ut_reporter_base := null, + a_color_console boolean := false, + a_coverage_schemes ut_varchar2_list := null, + a_source_file_mappings ut_file_mappings := null, + a_test_file_mappings ut_file_mappings := null, + a_include_objects ut_varchar2_list := null, + a_exclude_objects ut_varchar2_list := null, + a_client_character_set varchar2 := null ); procedure run( - a_reporter ut_reporter_base := null, a_color_console boolean := false, - a_coverage_schemes ut_varchar2_list := null, a_source_files ut_varchar2_list, a_test_files ut_varchar2_list, - a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null + a_reporter ut_reporter_base := null, + a_color_console boolean := false, + a_coverage_schemes ut_varchar2_list := null, + a_source_files ut_varchar2_list, + a_test_files ut_varchar2_list, + a_include_objects ut_varchar2_list := null, + a_exclude_objects ut_varchar2_list := null, + a_client_character_set varchar2 := null ); procedure run( - a_paths ut_varchar2_list, a_reporter ut_reporter_base := null, a_color_console boolean := false, - a_coverage_schemes ut_varchar2_list := null, a_source_file_mappings ut_file_mappings := null, a_test_file_mappings ut_file_mappings := null, - a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null + a_paths ut_varchar2_list, + a_reporter ut_reporter_base := null, + a_color_console boolean := false, + a_coverage_schemes ut_varchar2_list := null, + a_source_file_mappings ut_file_mappings := null, + a_test_file_mappings ut_file_mappings := null, + a_include_objects ut_varchar2_list := null, + a_exclude_objects ut_varchar2_list := null, + a_client_character_set varchar2 := null ); procedure run( - a_paths ut_varchar2_list, a_reporter ut_reporter_base := null, a_color_console boolean := false, - a_coverage_schemes ut_varchar2_list := null, a_source_files ut_varchar2_list, a_test_files ut_varchar2_list, - a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null + a_paths ut_varchar2_list, + a_reporter ut_reporter_base := null, + a_color_console boolean := false, + a_coverage_schemes ut_varchar2_list := null, + a_source_files ut_varchar2_list, + a_test_files ut_varchar2_list, + a_include_objects ut_varchar2_list := null, + a_exclude_objects ut_varchar2_list := null, + a_client_character_set varchar2 := null ); procedure run( - a_path varchar2, a_reporter ut_reporter_base := null, a_color_console boolean := false, - a_coverage_schemes ut_varchar2_list := null, a_source_file_mappings ut_file_mappings := null, a_test_file_mappings ut_file_mappings := null, - a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null + a_path varchar2, + a_reporter ut_reporter_base := null, + a_color_console boolean := false, + a_coverage_schemes ut_varchar2_list := null, + a_source_file_mappings ut_file_mappings := null, + a_test_file_mappings ut_file_mappings := null, + a_include_objects ut_varchar2_list := null, + a_exclude_objects ut_varchar2_list := null, + a_client_character_set varchar2 := null ); procedure run( - a_path varchar2, a_reporter ut_reporter_base := null, a_color_console boolean := false, - a_coverage_schemes ut_varchar2_list := null, a_source_files ut_varchar2_list, a_test_files ut_varchar2_list, - a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null + a_path varchar2, + a_reporter ut_reporter_base := null, + a_color_console boolean := false, + a_coverage_schemes ut_varchar2_list := null, + a_source_files ut_varchar2_list, + a_test_files ut_varchar2_list, + a_include_objects ut_varchar2_list := null, + a_exclude_objects ut_varchar2_list := null, + a_client_character_set varchar2 := null ); /** diff --git a/source/api/ut_runner.pkb b/source/api/ut_runner.pkb index 78db64c77..eb3bc8e68 100644 --- a/source/api/ut_runner.pkb +++ b/source/api/ut_runner.pkb @@ -74,9 +74,16 @@ create or replace package body ut_runner is end; procedure run( - a_paths ut_varchar2_list, a_reporters ut_reporters, a_color_console boolean := false, - a_coverage_schemes ut_varchar2_list := null, a_source_file_mappings ut_file_mappings := null, a_test_file_mappings ut_file_mappings := null, - a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null, a_fail_on_errors boolean default false + a_paths ut_varchar2_list, + a_reporters ut_reporters, + a_color_console boolean := false, + a_coverage_schemes ut_varchar2_list := null, + a_source_file_mappings ut_file_mappings := null, + a_test_file_mappings ut_file_mappings := null, + 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 ) is l_run ut_run; l_coverage_schema_names ut_varchar2_rows; @@ -118,7 +125,8 @@ create or replace package body ut_runner is l_exclude_object_names, l_include_object_names, set(a_source_file_mappings), - set(a_test_file_mappings) + set(a_test_file_mappings), + a_client_character_set ); l_run.do_execute(); diff --git a/source/api/ut_runner.pks b/source/api/ut_runner.pks index ae83b2e60..b796aab9b 100644 --- a/source/api/ut_runner.pks +++ b/source/api/ut_runner.pks @@ -56,10 +56,16 @@ create or replace package ut_runner authid current_user is * schema.suite1.test2 - executes test2 procedure of suite1 suite with execution of all parent setup/teardown procedures */ procedure run( - a_paths ut_varchar2_list, a_reporters ut_reporters, a_color_console boolean := false, - a_coverage_schemes ut_varchar2_list := null, a_source_file_mappings ut_file_mappings := null, a_test_file_mappings ut_file_mappings := null, - a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null, - a_fail_on_errors boolean default false + a_paths ut_varchar2_list, + a_reporters ut_reporters, + a_color_console boolean := false, + a_coverage_schemes ut_varchar2_list := null, + a_source_file_mappings ut_file_mappings := null, + a_test_file_mappings ut_file_mappings := null, + 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 ); /** diff --git a/source/core/types/ut_run.tpb b/source/core/types/ut_run.tpb index ccbd847fc..a282bcfdb 100644 --- a/source/core/types/ut_run.tpb +++ b/source/core/types/ut_run.tpb @@ -24,7 +24,8 @@ create or replace type body ut_run as a_exclude_objects ut_object_names := null, a_include_objects ut_object_names := null, a_project_file_mappings ut_file_mappings := null, - a_test_file_mappings ut_file_mappings := null + a_test_file_mappings ut_file_mappings := null, + a_client_character_set varchar2 := null ) return self as result is l_coverage_schema_names ut_varchar2_rows; l_coverage_options ut_coverage_options; @@ -33,6 +34,7 @@ create or replace type body ut_run as self.run_paths := a_run_paths; self.self_type := $$plsql_unit; self.items := a_items; + self.client_character_set := lower(a_client_character_set); self.results_count := ut_results_counter(); self.test_file_mappings := coalesce(a_test_file_mappings, ut_file_mappings()); self.coverage_options := ut_coverage_options( diff --git a/source/core/types/ut_run.tps b/source/core/types/ut_run.tps index 59bde318f..0f1c71ca7 100644 --- a/source/core/types/ut_run.tps +++ b/source/core/types/ut_run.tps @@ -23,6 +23,7 @@ create or replace type ut_run under ut_suite_item ( run_paths ut_varchar2_list, coverage_options ut_coverage_options, test_file_mappings ut_file_mappings, + client_character_set varchar2(100), constructor function ut_run( self in out nocopy ut_run, a_items ut_suite_items, @@ -31,7 +32,8 @@ create or replace type ut_run under ut_suite_item ( a_exclude_objects ut_object_names := null, a_include_objects ut_object_names := null, a_project_file_mappings ut_file_mappings := null, - a_test_file_mappings ut_file_mappings := null + a_test_file_mappings ut_file_mappings := null, + a_client_character_set varchar2 := null ) return self as result, overriding member procedure mark_as_skipped(self in out nocopy ut_run), overriding member function do_execute(self in out nocopy ut_run) return boolean, diff --git a/source/core/ut_utils.pkb b/source/core/ut_utils.pkb index 4654f9b34..81d15ea8c 100644 --- a/source/core/ut_utils.pkb +++ b/source/core/ut_utils.pkb @@ -507,6 +507,17 @@ procedure append_to_clob(a_src_clob in out nocopy clob, a_clob_table t_clob_tab, return to_char(a_value, gc_number_format, 'NLS_NUMERIC_CHARACTERS=''. '''); end; + function get_xml_header(a_encoding varchar2) return varchar2 is + begin + return + ''; + end; + function trim_list_elements(a_list IN ut_varchar2_list, a_regexp_to_trim in varchar2 default '[:space:]') return ut_varchar2_list is l_trimmed_list ut_varchar2_list; l_index integer; diff --git a/source/core/ut_utils.pks b/source/core/ut_utils.pks index c2e37b794..19118aae8 100644 --- a/source/core/ut_utils.pks +++ b/source/core/ut_utils.pks @@ -320,6 +320,13 @@ create or replace package ut_utils authid definer is */ function to_xml_number_format(a_value number) return varchar2; + + /** + * Returns xml header. If a_encoding is not null, header will include encoding attribute with provided value + */ + function get_xml_header(a_encoding varchar2) return varchar2; + + /*It takes a collection of type ut_varchar2_list and it trims the characters passed as arguments for every element*/ function trim_list_elements(a_list IN ut_varchar2_list, a_regexp_to_trim in varchar2 default '[:space:]') return ut_varchar2_list; diff --git a/source/reporters/ut_coverage_cobertura_reporter.tpb b/source/reporters/ut_coverage_cobertura_reporter.tpb index 82d085604..cce2224df 100644 --- a/source/reporters/ut_coverage_cobertura_reporter.tpb +++ b/source/reporters/ut_coverage_cobertura_reporter.tpb @@ -66,25 +66,27 @@ create or replace type body ut_coverage_cobertura_reporter is end; function get_coverage_xml( - a_coverage_data ut_coverage.t_coverage + a_coverage_data ut_coverage.t_coverage, + a_run ut_run ) return clob is - l_file_part varchar2(32767); - l_result clob; - l_unit ut_coverage.t_full_name; - l_obj_name ut_coverage.t_object_name; - c_coverage_def constant varchar2(200) := ''||CHR(10)||''||chr(10); + l_file_part varchar2(32767); + l_result clob; + l_unit ut_coverage.t_full_name; + l_obj_name ut_coverage.t_object_name; + c_coverage_def constant varchar2(200) := ''||chr(10); c_file_footer constant varchar2(30) := ''||chr(10); c_coverage_footer constant varchar2(30) := ''; c_sources_footer constant varchar2(30) := ''||chr(10); - c_packages_footer constant varchar2(30) := ''||chr(10); + c_packages_footer constant varchar2(30) := ''||chr(10); c_package_footer constant varchar2(30) := ''||chr(10); - c_class_footer constant varchar2(30) := ''||chr(10); - c_lines_footer constant varchar2(30) := ''||chr(10); - l_epoch varchar2(50) := (sysdate - to_date('01-01-1970 00:00:00', 'dd-mm-yyyy hh24:mi:ss')) * 24 * 60 * 60; + c_class_footer constant varchar2(30) := ''||chr(10); + c_lines_footer constant varchar2(30) := ''||chr(10); + l_epoch varchar2(50) := (sysdate - to_date('01-01-1970 00:00:00', 'dd-mm-yyyy hh24:mi:ss')) * 24 * 60 * 60; begin dbms_lob.createtemporary(l_result,true); + ut_utils.append_to_clob(l_result, ut_utils.get_xml_header(a_run.client_character_set)||chr(10)); ut_utils.append_to_clob(l_result, c_coverage_def); --write header @@ -138,7 +140,7 @@ create or replace type body ut_coverage_cobertura_reporter is l_coverage_data := ut_coverage.get_coverage_data(a_run.coverage_options); - self.print_clob( get_coverage_xml( l_coverage_data ) ); + self.print_clob( get_coverage_xml( l_coverage_data, a_run ) ); (self as ut_reporter_base).after_calling_run(a_run); end; diff --git a/source/reporters/ut_coverage_sonar_reporter.tpb b/source/reporters/ut_coverage_sonar_reporter.tpb index a82097061..29d3d351d 100644 --- a/source/reporters/ut_coverage_sonar_reporter.tpb +++ b/source/reporters/ut_coverage_sonar_reporter.tpb @@ -59,7 +59,8 @@ create or replace type body ut_coverage_sonar_reporter is return l_result; end; function get_coverage_xml( - a_coverage_data ut_coverage.t_coverage + a_coverage_data ut_coverage.t_coverage, + a_run ut_run ) return clob is l_file_part varchar2(32767); l_result clob; @@ -70,6 +71,7 @@ create or replace type body ut_coverage_sonar_reporter is begin dbms_lob.createtemporary(l_result,true); + ut_utils.append_to_clob(l_result, ut_utils.get_xml_header(a_run.client_character_set)||chr(10)); ut_utils.append_to_clob(l_result, c_coverage_header); l_unit := a_coverage_data.objects.first; while l_unit is not null loop @@ -90,7 +92,7 @@ create or replace type body ut_coverage_sonar_reporter is l_coverage_data := ut_coverage.get_coverage_data(a_run.coverage_options); - self.print_clob( get_coverage_xml( l_coverage_data ) ); + self.print_clob( get_coverage_xml( l_coverage_data, a_run ) ); end; overriding member function get_description return varchar2 as diff --git a/source/reporters/ut_junit_reporter.tpb b/source/reporters/ut_junit_reporter.tpb index 5833b53c6..204a39fb4 100644 --- a/source/reporters/ut_junit_reporter.tpb +++ b/source/reporters/ut_junit_reporter.tpb @@ -135,6 +135,7 @@ create or replace type body ut_junit_reporter is end; begin l_suite_id := 0; + self.print_text(ut_utils.get_xml_header(a_run.client_character_set)); self.print_text(''); for i in 1 .. a_run.items.count loop print_suite_elements(treat(a_run.items(i) as ut_logical_suite), l_suite_id); diff --git a/source/reporters/ut_sonar_test_reporter.tpb b/source/reporters/ut_sonar_test_reporter.tpb index 1152c87d3..a410480ae 100644 --- a/source/reporters/ut_sonar_test_reporter.tpb +++ b/source/reporters/ut_sonar_test_reporter.tpb @@ -87,6 +87,7 @@ create or replace type body ut_sonar_test_reporter is end; begin + self.print_text(ut_utils.get_xml_header(a_run.client_character_set)); self.print_text(''); for i in 1 .. a_run.items.count loop print_suite_results(treat(a_run.items(i) as ut_logical_suite), a_run.test_file_mappings); diff --git a/source/reporters/ut_tfs_junit_reporter.tpb b/source/reporters/ut_tfs_junit_reporter.tpb index b2a777c9f..dbcd558a6 100644 --- a/source/reporters/ut_tfs_junit_reporter.tpb +++ b/source/reporters/ut_tfs_junit_reporter.tpb @@ -141,6 +141,7 @@ create or replace type body ut_tfs_junit_reporter is begin l_suite_id := 0; + self.print_text(ut_utils.get_xml_header(a_run.client_character_set)); self.print_text(''); for i in 1 .. a_run.items.count loop print_suite_results(treat(a_run.items(i) as ut_logical_suite), l_suite_id); diff --git a/test/core/reporters.pkb b/test/core/reporters.pkb index 29299ca08..3e76be717 100644 --- a/test/core/reporters.pkb +++ b/test/core/reporters.pkb @@ -123,5 +123,22 @@ end;]'; drop_test_helper_package; end; + procedure check_xml_encoding_included( + a_suite varchar2, + a_reporter ut3.ut_output_reporter_base, + a_client_character_set varchar2 + ) is + l_results ut3.ut_varchar2_list; + l_actual clob; + begin + --Act + select * + bulk collect into l_results + from table(ut3.ut.run(a_suite, a_reporter, a_client_character_set => a_client_character_set)); + l_actual := ut3.ut_utils.table_to_clob(l_results); + --Assert + ut.expect(l_actual).to_be_like('%'); + end; + end reporters; / diff --git a/test/core/reporters.pks b/test/core/reporters.pks index 998427203..646c26820 100644 --- a/test/core/reporters.pks +++ b/test/core/reporters.pks @@ -4,5 +4,11 @@ create or replace package reporters is procedure reporters_cleanup; + procedure check_xml_encoding_included( + a_suite varchar2, + a_reporter ut3.ut_output_reporter_base, + a_client_character_set varchar2 + ); + end reporters; / diff --git a/test/core/reporters/test_coverage.pkb b/test/core/reporters/test_coverage.pkb index 347f4f463..c6188a956 100644 --- a/test/core/reporters/test_coverage.pkb +++ b/test/core/reporters/test_coverage.pkb @@ -244,7 +244,8 @@ create or replace package body test_coverage is --Assert l_actual := ut3.ut_utils.table_to_clob(l_results); - ut.expect(l_actual).to_equal(to_clob(' + ut.expect(l_actual).to_equal(to_clob(' + ')); drop_dummy_coverage_test_1; end; diff --git a/test/core/reporters/test_coverage/test_coverage_sonar_reporter.pkb b/test/core/reporters/test_coverage/test_coverage_sonar_reporter.pkb index 7aa2b3cd4..f4860bd21 100644 --- a/test/core/reporters/test_coverage/test_coverage_sonar_reporter.pkb +++ b/test/core/reporters/test_coverage/test_coverage_sonar_reporter.pkb @@ -6,7 +6,8 @@ create or replace package body test_coverage_sonar_reporter is l_actual clob; begin --Arrange - l_expected := ' + l_expected := ' + @@ -29,5 +30,10 @@ create or replace package body test_coverage_sonar_reporter is ut.expect(l_actual).to_equal(l_expected); end; + procedure check_encoding_included is + begin + reporters.check_xml_encoding_included('ut3.test_dummy_coverage', ut3.ut_coverage_sonar_reporter(), 'UTF-8'); + end; + end; / diff --git a/test/core/reporters/test_coverage/test_coverage_sonar_reporter.pks b/test/core/reporters/test_coverage/test_coverage_sonar_reporter.pks index 26aad7cb5..31cb358dd 100644 --- a/test/core/reporters/test_coverage/test_coverage_sonar_reporter.pks +++ b/test/core/reporters/test_coverage/test_coverage_sonar_reporter.pks @@ -6,5 +6,8 @@ create or replace package test_coverage_sonar_reporter is --%test(reports on a project file mapped to database object) procedure report_on_file; + --%test(Includes XML header with encoding when encoding provided) + procedure check_encoding_included; + end; / diff --git a/test/core/reporters/test_junit_reporter.pkb b/test/core/reporters/test_junit_reporter.pkb index 3e60b31c6..d111cb823 100644 --- a/test/core/reporters/test_junit_reporter.pkb +++ b/test/core/reporters/test_junit_reporter.pkb @@ -199,7 +199,8 @@ create or replace package body test_junit_reporter as procedure report_test_without_desc is l_results ut3.ut_varchar2_list; l_actual clob; - l_expected varchar2(32767):= q'[ + l_expected varchar2(32767):= q'[ + @@ -224,7 +225,8 @@ create or replace package body test_junit_reporter as procedure report_suite_without_desc is l_results ut3.ut_varchar2_list; l_actual clob; - l_expected varchar2(32767):= q'[ + l_expected varchar2(32767):= q'[ + @@ -245,7 +247,8 @@ create or replace package body test_junit_reporter as procedure reporort_produces_expected_out is l_results ut3.ut_varchar2_list; l_actual clob; - l_expected varchar2(32767):=q'[ + l_expected varchar2(32767):=q'[ + @@ -311,7 +314,8 @@ create or replace package body test_junit_reporter as procedure check_classname_is_populated is l_results ut3.ut_varchar2_list; l_actual clob; - l_expected varchar2(32767):= q'[ + l_expected varchar2(32767):= q'[ + @@ -328,7 +332,12 @@ create or replace package body test_junit_reporter as l_actual := ut3.ut_utils.table_to_clob(l_results); ut.expect(l_actual).to_be_like(l_expected); end; - + + procedure check_encoding_included is + begin + reporters.check_xml_encoding_included('check_fail_escape', ut3.ut_junit_reporter(), 'UTF-8'); + end; + procedure remove_test_package is pragma autonomous_transaction; begin diff --git a/test/core/reporters/test_junit_reporter.pks b/test/core/reporters/test_junit_reporter.pks index 397fa09d8..b39c5ff03 100644 --- a/test/core/reporters/test_junit_reporter.pks +++ b/test/core/reporters/test_junit_reporter.pks @@ -42,6 +42,9 @@ create or replace package test_junit_reporter as --%test( Validate that fail with special char are escaped ) procedure check_failure_escaped; + --%test(Includes XML header with encoding when encoding provided) + procedure check_encoding_included; + --%afterall procedure remove_test_package; end; diff --git a/test/core/reporters/test_tfs_junit_reporter.pkb b/test/core/reporters/test_tfs_junit_reporter.pkb index ff77cff5e..3f2945112 100644 --- a/test/core/reporters/test_tfs_junit_reporter.pkb +++ b/test/core/reporters/test_tfs_junit_reporter.pkb @@ -134,7 +134,8 @@ create or replace package body test_tfs_junit_reporter as from table(ut3.ut.run('check_junit_flat_suitepath',ut3.ut_tfs_junit_reporter())); l_actual := ut3.ut_utils.table_to_clob(l_results); --Assert - ut.expect(l_actual).to_be_like(' + ut.expect(l_actual).to_be_like(' + @@ -196,5 +197,11 @@ create or replace package body test_tfs_junit_reporter as execute immediate 'drop package check_junit_flat_suitepath'; execute immediate 'drop package check_fail_escape'; end; + + procedure check_encoding_included is + begin + reporters.check_xml_encoding_included('check_fail_escape', ut3.ut_tfs_junit_reporter(), 'UTF-8'); + end; + end; / diff --git a/test/core/reporters/test_tfs_junit_reporter.pks b/test/core/reporters/test_tfs_junit_reporter.pks index 8716fdf14..cc589be1b 100644 --- a/test/core/reporters/test_tfs_junit_reporter.pks +++ b/test/core/reporters/test_tfs_junit_reporter.pks @@ -30,6 +30,9 @@ create or replace package test_tfs_junit_reporter as --%test( Validate that failures with special char are escaped ) procedure check_failure_escaped; + --%test(Includes XML header with encoding when encoding provided) + procedure check_encoding_included; + --%afterall procedure remove_test_package; end; From 5b33d2f4edbe7f2b449cbd375b776bdb9020f161 Mon Sep 17 00:00:00 2001 From: Jacek Gebal Date: Sun, 10 Jun 2018 18:54:15 +0100 Subject: [PATCH 101/184] Fixed coveralls reporting issue with long packages. --- source/reporters/ut_coveralls_reporter.tpb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/reporters/ut_coveralls_reporter.tpb b/source/reporters/ut_coveralls_reporter.tpb index f19d1f3ce..8470d7f76 100644 --- a/source/reporters/ut_coveralls_reporter.tpb +++ b/source/reporters/ut_coveralls_reporter.tpb @@ -42,7 +42,7 @@ create or replace type body ut_coveralls_reporter is if l_last_line_no is null then l_last_line_no := a_unit_coverage.total_lines - 1; for i in 1 .. l_last_line_no loop - ut_utils.append_to_clob(l_result, '0,'); + ut_utils.append_to_clob(l_result, '0,'||chr(10)); end loop; ut_utils.append_to_clob(l_result, '0'); else @@ -55,7 +55,7 @@ create or replace type body ut_coveralls_reporter is if line_no < l_last_line_no then l_file_part := l_file_part ||','; end if; - ut_utils.append_to_clob(l_result, l_file_part); + ut_utils.append_to_clob(l_result, l_file_part||chr(10)); end loop; end if; ut_utils.append_to_clob(l_result, ']'); From ecae542fe46ddf0ea3c234f9f29000d8c405e3b1 Mon Sep 17 00:00:00 2001 From: Jacek Gebal Date: Mon, 11 Jun 2018 00:10:31 +0100 Subject: [PATCH 102/184] Fixed failing tests and added additional test for missing coverage. --- source/reporters/ut_coveralls_reporter.tpb | 11 ++-- test/core/reporters/test_coverage.pkb | 17 ++++-- test/core/reporters/test_coverage.pks | 8 +++ .../test_coverage/test_coveralls_reporter.pkb | 54 +++++++++++++++++-- .../test_coverage/test_coveralls_reporter.pks | 3 ++ 5 files changed, 80 insertions(+), 13 deletions(-) diff --git a/source/reporters/ut_coveralls_reporter.tpb b/source/reporters/ut_coveralls_reporter.tpb index 8470d7f76..96df05483 100644 --- a/source/reporters/ut_coveralls_reporter.tpb +++ b/source/reporters/ut_coveralls_reporter.tpb @@ -40,16 +40,15 @@ create or replace type body ut_coveralls_reporter is l_last_line_no := a_unit_coverage.lines.last; if l_last_line_no is null then - l_last_line_no := a_unit_coverage.total_lines - 1; - for i in 1 .. l_last_line_no loop - ut_utils.append_to_clob(l_result, '0,'||chr(10)); - end loop; - ut_utils.append_to_clob(l_result, '0'); + ut_utils.append_to_clob( + l_result + , rpad( to_clob( '0' ), ( a_unit_coverage.total_lines * 3 ) - 2, ','||chr(10)||'0' ) + ); else for line_no in 1 .. l_last_line_no loop if a_unit_coverage.lines.exists(line_no) then l_file_part := to_char(a_unit_coverage.lines(line_no).executions); - else + else l_file_part := c_null; end if; if line_no < l_last_line_no then diff --git a/test/core/reporters/test_coverage.pkb b/test/core/reporters/test_coverage.pkb index 347f4f463..060c8f124 100644 --- a/test/core/reporters/test_coverage.pkb +++ b/test/core/reporters/test_coverage.pkb @@ -1,7 +1,5 @@ create or replace package body test_coverage is - g_run_id integer; - function get_mock_run_id return integer is v_result integer; begin @@ -100,22 +98,32 @@ create or replace package body test_coverage is select a_run_id, c_unit_id, 7, 1, 1 from dual; end; - procedure setup_dummy_coverage is + procedure create_dummy_coverage_pkg is pragma autonomous_transaction; begin create_dummy_coverage_package(); create_dummy_coverage_test(); + end; + + procedure setup_dummy_coverage is + pragma autonomous_transaction; + begin g_run_id := get_mock_run_id(); ut3.ut_coverage.mock_coverage_id(g_run_id, ut3.ut_coverage.gc_proftab_coverage); mock_coverage_data(g_run_id); commit; end; - procedure cleanup_dummy_coverage is + procedure drop_dummy_coverage_pkg is pragma autonomous_transaction; begin begin execute immediate q'[drop package ut3.test_dummy_coverage]'; exception when others then null; end; begin execute immediate q'[drop package ut3.dummy_coverage]'; exception when others then null; end; + end; + + procedure cleanup_dummy_coverage is + pragma autonomous_transaction; + begin delete from ut3.plsql_profiler_data where runid = g_run_id; delete from ut3.plsql_profiler_units where runid = g_run_id; delete from ut3.plsql_profiler_runs where runid = g_run_id; @@ -229,6 +237,7 @@ create or replace package body test_coverage is ) ); cleanup_dummy_coverage(); + drop_dummy_coverage_pkg(); create_dummy_coverage_test_1; --Act diff --git a/test/core/reporters/test_coverage.pks b/test/core/reporters/test_coverage.pks index d507fa0ee..65e99666b 100644 --- a/test/core/reporters/test_coverage.pks +++ b/test/core/reporters/test_coverage.pks @@ -3,9 +3,16 @@ create or replace package test_coverage is --%suite --%suitepath(utplsql.core.reporters) + g_run_id integer; + + --%beforeall + procedure create_dummy_coverage_pkg; --%beforeall procedure setup_dummy_coverage; + + --%afterall + procedure drop_dummy_coverage_pkg; --%afterall procedure cleanup_dummy_coverage; @@ -23,6 +30,7 @@ create or replace package test_coverage is procedure coverage_for_file; --%test(Coverage data is not cached between runs - issue #562 ) + --%aftertest(create_dummy_coverage_pkg) --%aftertest(setup_dummy_coverage) procedure coverage_tmp_data_refresh; diff --git a/test/core/reporters/test_coverage/test_coveralls_reporter.pkb b/test/core/reporters/test_coverage/test_coveralls_reporter.pkb index 2efa8f0ca..3b6b88346 100644 --- a/test/core/reporters/test_coverage/test_coveralls_reporter.pkb +++ b/test/core/reporters/test_coverage/test_coveralls_reporter.pkb @@ -6,10 +6,17 @@ create or replace package body test_coveralls_reporter is l_actual clob; begin --Arrange - l_expected := '{"source_files":[ + l_expected := q'[{"source_files":[ { "name": "test/ut3.dummy_coverage.pkb", -"coverage": [null,null,null,1,0,null,1]}]} - '; +"coverage": [null, +null, +null, +1, +0, +null, +1 +]}]} + ]'; --Act select * bulk collect into l_results @@ -26,5 +33,46 @@ create or replace package body test_coveralls_reporter is ut.expect(l_actual).to_equal(l_expected); end; + procedure report_zero_coverage is + l_results ut3.ut_varchar2_list; + l_expected clob; + l_actual clob; + pragma autonomous_transaction; + begin + --Arrange + l_expected := q'[{"source_files":[ +{ "name": "ut3.dummy_coverage", +"coverage": [0, +0, +0, +0, +0, +0, +0, +0, +0, +0]}]} + ]'; + + test_coverage.cleanup_dummy_coverage; + + --Act + select * + bulk collect into l_results + from table( + ut3.ut.run( + 'ut3.test_dummy_coverage', + ut3.ut_coveralls_reporter(), + a_include_objects => ut3.ut_varchar2_list('UT3.DUMMY_COVERAGE') + ) + ); + l_actual := ut3.ut_utils.table_to_clob(l_results); + --Assert + ut.expect(l_actual).to_equal(l_expected); + + test_coverage.setup_dummy_coverage; + + end; + end; / diff --git a/test/core/reporters/test_coverage/test_coveralls_reporter.pks b/test/core/reporters/test_coverage/test_coveralls_reporter.pks index a479e69a2..bf2b861f7 100644 --- a/test/core/reporters/test_coverage/test_coveralls_reporter.pks +++ b/test/core/reporters/test_coverage/test_coveralls_reporter.pks @@ -6,5 +6,8 @@ create or replace package test_coveralls_reporter is --%test(reports on a project file mapped to database object) procedure report_on_file; + --%test(reports zero coverage on each line of non-executed database object) + procedure report_zero_coverage; + end; / From 7943b57ca4dd9cadbfeea30475d6ca3a69c2d651 Mon Sep 17 00:00:00 2001 From: Jacek Gebal Date: Mon, 11 Jun 2018 00:45:25 +0100 Subject: [PATCH 103/184] Removed obsolete old tests. Updated tests. Added test for `sonar_test_reporter` --- old_tests/RunAll.sql | 10 ++--- ...rage_sonar_reporter.AcceptsFileMapping.sql | 27 ------------- ...nar_reporter.BuildsSonarCoverageReport.sql | 20 ---------- ...sonar_test_reporter.AcceptsFileMapping.sql | 38 ------------------- ..._test_reporter.ProducesExpectedOutputs.sql | 32 ---------------- test/core/reporters.pkb | 5 ++- test/core/reporters.pks | 6 ++- .../test_coverage_sonar_reporter.pkb | 2 +- test/core/reporters/test_junit_reporter.pkb | 6 +-- .../reporters/test_sonar_test_reporter.pkb | 36 ++++++++++++++++++ .../reporters/test_sonar_test_reporter.pks | 13 +++++++ .../reporters/test_tfs_junit_reporter.pkb | 2 +- test/install_tests.sql | 2 + 13 files changed, 66 insertions(+), 133 deletions(-) delete mode 100644 old_tests/ut_reporters/ut_coverage_sonar_reporter.AcceptsFileMapping.sql delete mode 100644 old_tests/ut_reporters/ut_coverage_sonar_reporter.BuildsSonarCoverageReport.sql delete mode 100644 old_tests/ut_reporters/ut_sonar_test_reporter.AcceptsFileMapping.sql delete mode 100644 old_tests/ut_reporters/ut_sonar_test_reporter.ProducesExpectedOutputs.sql create mode 100644 test/core/reporters/test_sonar_test_reporter.pkb create mode 100644 test/core/reporters/test_sonar_test_reporter.pks diff --git a/old_tests/RunAll.sql b/old_tests/RunAll.sql index 434d8574f..206c01a1b 100644 --- a/old_tests/RunAll.sql +++ b/old_tests/RunAll.sql @@ -78,16 +78,12 @@ exec ut_coverage.set_develop_mode(true); @@lib/RunTest.sql ut_output_buffer/send_line.DoesNotSendLineIfNullTextGiven.sql @@lib/RunTest.sql ut_output_buffer/send_line.SendsALineIntoBufferTable.sql -@@lib/RunTest.sql ut_reporters/ut_coverage_sonar_reporter.AcceptsFileMapping.sql -@@lib/RunTest.sql ut_reporters/ut_coverage_sonar_reporter.BuildsSonarCoverageReport.sql @@lib/RunTest.sql ut_reporters/ut_documentation_reporter.providesCorrectLineFromStacktrace.sql -@@lib/RunTest.sql ut_reporters/ut_sonar_test_reporter.AcceptsFileMapping.sql -@@lib/RunTest.sql ut_reporters/ut_sonar_test_reporter.ProducesExpectedOutputs.sql -@@lib/RunTest.sql ut_reporters/ut_teamcity_reporter.ProducesExpectedOutputs.sql -@@lib/RunTest.sql ut_reporters/ut_html_reporter.UserOverrideSchemaCoverage.sql -@@lib/RunTest.sql ut_reporters/ut_html_reporter.DefaultSchemaCoverage.sql @@lib/RunTest.sql ut_reporters/ut_documentation_reporter.reportMultipleWarnings.sql @@lib/RunTest.sql ut_reporters/ut_documentation_reporter.reportTestTiming.sql +@@lib/RunTest.sql ut_reporters/ut_html_reporter.DefaultSchemaCoverage.sql +@@lib/RunTest.sql ut_reporters/ut_html_reporter.UserOverrideSchemaCoverage.sql +@@lib/RunTest.sql ut_reporters/ut_teamcity_reporter.ProducesExpectedOutputs.sql @@lib/RunTest.sql ut/ut.run.AcceptsCoverageFileList.sql @@lib/RunTest.sql ut/ut.run.AcceptsCoverageFileListWithSutePaths.sql diff --git a/old_tests/ut_reporters/ut_coverage_sonar_reporter.AcceptsFileMapping.sql b/old_tests/ut_reporters/ut_coverage_sonar_reporter.AcceptsFileMapping.sql deleted file mode 100644 index a27cb4ef4..000000000 --- a/old_tests/ut_reporters/ut_coverage_sonar_reporter.AcceptsFileMapping.sql +++ /dev/null @@ -1,27 +0,0 @@ -declare - l_results ut_varchar2_list; - l_clob clob; - l_expected varchar2(32767); -begin - l_expected := '%'; - select * - bulk collect into l_results - from table( - ut.run( - 'test_reporters', - ut_coverage_sonar_reporter(), - a_source_file_mappings => ut_file_mapper.build_file_mappings( user, ut_varchar2_list( - 'tests/helpers/test_reporters.pkb' ) - ) - ) - ); - l_clob := ut_utils.table_to_clob(l_results); - - if l_clob like l_expected then - :test_result := ut_utils.gc_success; - else - dbms_output.put_line(l_clob); - end if; - -end; -/ diff --git a/old_tests/ut_reporters/ut_coverage_sonar_reporter.BuildsSonarCoverageReport.sql b/old_tests/ut_reporters/ut_coverage_sonar_reporter.BuildsSonarCoverageReport.sql deleted file mode 100644 index e76385cfa..000000000 --- a/old_tests/ut_reporters/ut_coverage_sonar_reporter.BuildsSonarCoverageReport.sql +++ /dev/null @@ -1,20 +0,0 @@ -declare - l_results ut_varchar2_list; - l_clob clob; - l_expected varchar2(32767); -begin - l_expected := '%'; - select * - bulk collect into l_results - from table(ut.run('test_reporters',ut_coverage_sonar_reporter(), a_include_objects => ut_varchar2_list('test_reporters'))); - l_clob := ut_utils.table_to_clob(l_results); - - if l_clob like l_expected then - :test_result := ut_utils.gc_success; - else - dbms_output.put_line(l_clob); - end if; - -end; -/ - diff --git a/old_tests/ut_reporters/ut_sonar_test_reporter.AcceptsFileMapping.sql b/old_tests/ut_reporters/ut_sonar_test_reporter.AcceptsFileMapping.sql deleted file mode 100644 index 4e4bea8dc..000000000 --- a/old_tests/ut_reporters/ut_sonar_test_reporter.AcceptsFileMapping.sql +++ /dev/null @@ -1,38 +0,0 @@ -declare - l_output_data ut_varchar2_list; - l_output varchar2(32767); - l_expected varchar2(32767); -begin - l_expected := q'[ - -% - - -% -%%% -%%% -%% - -]'; - - --act - select * - bulk collect into l_output_data - from table( - ut.run( - 'test_reporters', - ut_sonar_test_reporter(), - a_test_file_mappings => ut_file_mapper.build_file_mappings( user, ut_varchar2_list('tests/helpers/test_reporters.pkb', 'tests/helpers/test_reporters_1.pkb')) - ) - ); - - l_output := ut_utils.table_to_clob(l_output_data); - - --assert - if l_output like l_expected then - :test_result := ut_utils.gc_success; - else - dbms_output.put_line('Actual:"'||l_output||'"'); - end if; -end; -/ diff --git a/old_tests/ut_reporters/ut_sonar_test_reporter.ProducesExpectedOutputs.sql b/old_tests/ut_reporters/ut_sonar_test_reporter.ProducesExpectedOutputs.sql deleted file mode 100644 index 51fd3c7c7..000000000 --- a/old_tests/ut_reporters/ut_sonar_test_reporter.ProducesExpectedOutputs.sql +++ /dev/null @@ -1,32 +0,0 @@ -declare - l_output_data ut_varchar2_list; - l_output varchar2(32767); - l_expected varchar2(32767); -begin - l_expected := q'[ - -% - - -% -%%% -%%% -%% - -]'; - - --act - select * - bulk collect into l_output_data - from table(ut.run('test_reporters',ut_sonar_test_reporter(),a_source_files=> null, a_test_files=>ut_varchar2_list('tests/helpers/test_reporters.pkb', 'tests/helpers/test_reporters_1.pkb'))); - - l_output := ut_utils.table_to_clob(l_output_data); - - --assert - if l_output like l_expected then - :test_result := ut_utils.gc_success; - else - dbms_output.put_line('Actual:"'||l_output||'"'); - end if; -end; -/ diff --git a/test/core/reporters.pkb b/test/core/reporters.pkb index 3e76be717..c5bf04d49 100644 --- a/test/core/reporters.pkb +++ b/test/core/reporters.pkb @@ -1,6 +1,7 @@ create or replace package body reporters is procedure create_test_helper_package is + pragma autonomous_transaction; begin execute immediate q'[create or replace package test_reporters as @@ -119,12 +120,12 @@ end;]'; end; procedure reporters_cleanup is + pragma autonomous_transaction; begin drop_test_helper_package; end; procedure check_xml_encoding_included( - a_suite varchar2, a_reporter ut3.ut_output_reporter_base, a_client_character_set varchar2 ) is @@ -134,7 +135,7 @@ end;]'; --Act select * bulk collect into l_results - from table(ut3.ut.run(a_suite, a_reporter, a_client_character_set => a_client_character_set)); + from table(ut3.ut.run('test_reporters', a_reporter, a_client_character_set => a_client_character_set)); l_actual := ut3.ut_utils.table_to_clob(l_results); --Assert ut.expect(l_actual).to_be_like('%'); diff --git a/test/core/reporters.pks b/test/core/reporters.pks index 646c26820..229e4e9b1 100644 --- a/test/core/reporters.pks +++ b/test/core/reporters.pks @@ -1,11 +1,15 @@ create or replace package reporters is + --%suite + --%suitepath(utplsql.core) + + --%beforeall procedure reporters_setup; + --%afterall procedure reporters_cleanup; procedure check_xml_encoding_included( - a_suite varchar2, a_reporter ut3.ut_output_reporter_base, a_client_character_set varchar2 ); diff --git a/test/core/reporters/test_coverage/test_coverage_sonar_reporter.pkb b/test/core/reporters/test_coverage/test_coverage_sonar_reporter.pkb index f4860bd21..81b2c12f8 100644 --- a/test/core/reporters/test_coverage/test_coverage_sonar_reporter.pkb +++ b/test/core/reporters/test_coverage/test_coverage_sonar_reporter.pkb @@ -32,7 +32,7 @@ create or replace package body test_coverage_sonar_reporter is procedure check_encoding_included is begin - reporters.check_xml_encoding_included('ut3.test_dummy_coverage', ut3.ut_coverage_sonar_reporter(), 'UTF-8'); + reporters.check_xml_encoding_included(ut3.ut_coverage_sonar_reporter(), 'UTF-8'); end; end; diff --git a/test/core/reporters/test_junit_reporter.pkb b/test/core/reporters/test_junit_reporter.pkb index d111cb823..29beaaa55 100644 --- a/test/core/reporters/test_junit_reporter.pkb +++ b/test/core/reporters/test_junit_reporter.pkb @@ -90,8 +90,6 @@ create or replace package body test_junit_reporter as end; end;]'; - reporters.reporters_setup; - end; procedure escapes_special_chars is @@ -335,7 +333,7 @@ create or replace package body test_junit_reporter as procedure check_encoding_included is begin - reporters.check_xml_encoding_included('check_fail_escape', ut3.ut_junit_reporter(), 'UTF-8'); + reporters.check_xml_encoding_included(ut3.ut_junit_reporter(), 'UTF-8'); end; procedure remove_test_package is @@ -347,7 +345,7 @@ create or replace package body test_junit_reporter as execute immediate 'drop package tst_package_junit_nosuite'; execute immediate 'drop package check_fail_escape'; execute immediate 'drop package Tst_Fix_Case_Sensitive'; - reporters.reporters_cleanup; end; + end; / diff --git a/test/core/reporters/test_sonar_test_reporter.pkb b/test/core/reporters/test_sonar_test_reporter.pkb new file mode 100644 index 000000000..9cf38ea91 --- /dev/null +++ b/test/core/reporters/test_sonar_test_reporter.pkb @@ -0,0 +1,36 @@ +create or replace package body test_sonar_test_reporter as + + procedure report_produces_expected_out is + l_results ut3.ut_varchar2_list; + l_actual clob; + l_expected varchar2(32767):=q'[ + + +% +%%% +%%% +%% + +]'; + + begin + select * + bulk collect into l_results + from table( + ut3.ut.run( + 'test_reporters', + ut3.ut_sonar_test_reporter(), + a_test_file_mappings => ut3.ut_file_mapper.build_file_mappings( user, ut3.ut_varchar2_list('tests/helpers/test_reporters.pkb')) + ) + ); + l_actual := ut3.ut_utils.table_to_clob(l_results); + ut.expect(l_actual).to_be_like(l_expected); + end; + + procedure check_encoding_included is + begin + reporters.check_xml_encoding_included(ut3.ut_sonar_test_reporter(), 'UTF-8'); + end; + +end; +/ diff --git a/test/core/reporters/test_sonar_test_reporter.pks b/test/core/reporters/test_sonar_test_reporter.pks new file mode 100644 index 000000000..ab4776c38 --- /dev/null +++ b/test/core/reporters/test_sonar_test_reporter.pks @@ -0,0 +1,13 @@ +create or replace package test_sonar_test_reporter as + + --%suite(ut_sonar_test_reporter) + --%suitepath(utplsql.core.reporters) + + --%test(Report produces expected output) + procedure report_produces_expected_out; + + --%test(Includes XML header with encoding when encoding provided) + procedure check_encoding_included; + +end; +/ diff --git a/test/core/reporters/test_tfs_junit_reporter.pkb b/test/core/reporters/test_tfs_junit_reporter.pkb index 3f2945112..bd09b8682 100644 --- a/test/core/reporters/test_tfs_junit_reporter.pkb +++ b/test/core/reporters/test_tfs_junit_reporter.pkb @@ -200,7 +200,7 @@ create or replace package body test_tfs_junit_reporter as procedure check_encoding_included is begin - reporters.check_xml_encoding_included('check_fail_escape', ut3.ut_tfs_junit_reporter(), 'UTF-8'); + reporters.check_xml_encoding_included(ut3.ut_tfs_junit_reporter(), 'UTF-8'); end; end; diff --git a/test/install_tests.sql b/test/install_tests.sql index 282e8b440..0b04be320 100644 --- a/test/install_tests.sql +++ b/test/install_tests.sql @@ -41,6 +41,7 @@ set define on @@install_below_12_2.sql 'core/reporters/test_coverage/test_html_proftab_reporter.pks' set define off @@core/reporters/test_tfs_junit_reporter.pks +@@core/reporters/test_sonar_test_reporter.pks @@core/expectations.pks @@core/expectations/scalar_data/binary/test_be_greater_or_equal.pks @@core/expectations/scalar_data/binary/test_be_greater_than.pks @@ -84,6 +85,7 @@ set define on @@install_below_12_2.sql 'core/reporters/test_coverage/test_html_proftab_reporter.pkb' set define off @@core/reporters/test_tfs_junit_reporter.pkb +@@core/reporters/test_sonar_test_reporter.pkb @@core/expectations.pkb @@core/expectations/scalar_data/binary/test_be_greater_or_equal.pkb @@core/expectations/scalar_data/binary/test_be_greater_than.pkb From 435ddf9188bfe2ae3586192574696ca46ae3401e Mon Sep 17 00:00:00 2001 From: Jacek Gebal Date: Tue, 12 Jun 2018 21:16:47 +0100 Subject: [PATCH 104/184] Reworked unit tests. Refactored parameter name for `ut_executable` Refactored event name constants to be aligned with annotation names. --- source/core/types/ut_executable.tpb | 12 +- source/core/types/ut_executable.tps | 4 +- source/core/types/ut_executable_test.tpb | 4 +- source/core/types/ut_executable_test.tps | 2 +- source/core/ut_utils.pks | 42 +- .../test_before_after_test_annotation.pkb | 407 ++++++++++++------ .../test_before_after_test_annotation.pks | 34 +- 7 files changed, 324 insertions(+), 181 deletions(-) diff --git a/source/core/types/ut_executable.tpb b/source/core/types/ut_executable.tpb index 9947e6b05..610b7ab96 100644 --- a/source/core/types/ut_executable.tpb +++ b/source/core/types/ut_executable.tpb @@ -18,11 +18,11 @@ create or replace type body ut_executable is constructor function ut_executable( self in out nocopy ut_executable, a_owner varchar2, a_package varchar2, - a_procedure_name varchar2, a_associated_event_name varchar2 + a_procedure_name varchar2, a_executable_type varchar2 ) return self as result is begin self.self_type := $$plsql_unit; - self.associated_event_name := a_associated_event_name; + self.executable_type := a_executable_type; self.owner_name := a_owner; self.object_name := a_package; self.procedure_name := a_procedure_name; @@ -31,7 +31,7 @@ create or replace type body ut_executable is member function is_defined(self in out nocopy ut_executable) return boolean is l_result boolean := false; - l_message_part varchar2(4000) := 'Call params for ' || self.associated_event_name || ' are not valid: '; + l_message_part varchar2(4000) := 'Call params for ' || self.executable_type || ' are not valid: '; begin if self.object_name is null then @@ -50,7 +50,7 @@ create or replace type body ut_executable is **/ member function is_invalid(self in out nocopy ut_executable) return boolean is l_result boolean := true; - l_message_part varchar2(4000) := 'Call params for ' || self.associated_event_name || ' are not valid: '; + l_message_part varchar2(4000) := 'Call params for ' || self.executable_type || ' are not valid: '; begin if not ut_metadata.package_valid(self.owner_name, self.object_name) then @@ -109,7 +109,7 @@ create or replace type body ut_executable is ut_utils.set_client_info(self.procedure_name); --listener - before call to executable - ut_event_manager.trigger_event('before_'||self.associated_event_name, self); + ut_event_manager.trigger_event('before_'||self.executable_type, self); l_completed_without_errors := self.is_defined(); if l_completed_without_errors then @@ -168,7 +168,7 @@ create or replace type body ut_executable is end if; --listener - after call to executable - ut_event_manager.trigger_event('after_'||self.associated_event_name, self); + ut_event_manager.trigger_event('after_'||self.executable_type, self); l_end_transaction_id := dbms_transaction.local_transaction_id(); if l_start_transaction_id != l_end_transaction_id or l_end_transaction_id is null then diff --git a/source/core/types/ut_executable.tps b/source/core/types/ut_executable.tps index 8cbebf6bd..5dbda5eff 100644 --- a/source/core/types/ut_executable.tps +++ b/source/core/types/ut_executable.tps @@ -18,14 +18,14 @@ create or replace type ut_executable under ut_event_item( /** * The name of the event to be executed before and after the executable is invoked */ - associated_event_name varchar2(250 char), + executable_type varchar2(250 char), owner_name varchar2(250 char), object_name varchar2(250 char), procedure_name varchar2(250 char), error_backtrace varchar2(4000), error_stack varchar2(4000), serveroutput clob, - constructor function ut_executable( self in out nocopy ut_executable, a_owner varchar2, a_package varchar2, a_procedure_name varchar2, a_associated_event_name varchar2) return self as result, + 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 is_invalid(self in out nocopy ut_executable) return boolean, member function is_defined(self in out nocopy ut_executable) return boolean, member function form_name return varchar2, diff --git a/source/core/types/ut_executable_test.tpb b/source/core/types/ut_executable_test.tpb index 9aeaa29c6..09ffab55d 100644 --- a/source/core/types/ut_executable_test.tpb +++ b/source/core/types/ut_executable_test.tpb @@ -1,11 +1,11 @@ create or replace type body ut_executable_test as constructor function ut_executable_test( self in out nocopy ut_executable_test, a_owner varchar2, a_package varchar2, - a_procedure_name varchar2, a_associated_event_name varchar2 + a_procedure_name varchar2, a_executable_type varchar2 ) return self as result is begin self.self_type := $$plsql_unit; - self.associated_event_name := a_associated_event_name; + self.executable_type := a_executable_type; self.owner_name := a_owner; self.object_name := a_package; self.procedure_name := a_procedure_name; diff --git a/source/core/types/ut_executable_test.tps b/source/core/types/ut_executable_test.tps index af3cb1923..a4963a2b9 100644 --- a/source/core/types/ut_executable_test.tps +++ b/source/core/types/ut_executable_test.tps @@ -17,7 +17,7 @@ create or replace type ut_executable_test authid current_user under ut_executabl */ constructor function ut_executable_test( self in out nocopy ut_executable_test, a_owner varchar2, a_package varchar2, - a_procedure_name varchar2, a_associated_event_name varchar2 + a_procedure_name varchar2, a_executable_type varchar2 ) return self as result, member procedure do_execute( diff --git a/source/core/ut_utils.pks b/source/core/ut_utils.pks index c2e37b794..ca671edae 100644 --- a/source/core/ut_utils.pks +++ b/source/core/ut_utils.pks @@ -27,32 +27,32 @@ create or replace package ut_utils authid definer is subtype t_event_name is varchar2(30); gc_before_run constant t_event_name := 'before_run'; gc_before_suite constant t_event_name := 'before_suite'; - gc_before_before_all constant t_event_name := 'before_before_all'; - gc_before_before_each constant t_event_name := 'before_before_each'; - gc_before_before_test constant t_event_name := 'before_before_test'; - gc_before_test_execute constant t_event_name := 'before_test_execute'; - gc_before_after_test constant t_event_name := 'before_after_test'; - gc_before_after_each constant t_event_name := 'before_after_each'; - gc_before_after_all constant t_event_name := 'before_after_all'; + gc_before_before_all constant t_event_name := 'before_beforeall'; + gc_before_before_each constant t_event_name := 'before_beforeeach'; + gc_before_before_test constant t_event_name := 'before_beforetest'; + gc_before_test_execute constant t_event_name := 'before_test'; + gc_before_after_test constant t_event_name := 'before_aftertest'; + gc_before_after_each constant t_event_name := 'before_aftereach'; + gc_before_after_all constant t_event_name := 'before_afterall'; gc_after_run constant t_event_name := 'after_run'; gc_after_suite constant t_event_name := 'after_suite'; - gc_after_before_all constant t_event_name := 'after_before_all'; - gc_after_before_each constant t_event_name := 'after_before_each'; - gc_after_before_test constant t_event_name := 'after_before_test'; - gc_after_test_execute constant t_event_name := 'after_test_execute'; - gc_after_after_test constant t_event_name := 'after_after_test'; - gc_after_after_each constant t_event_name := 'after_after_each'; - gc_after_after_all constant t_event_name := 'after_after_all'; + gc_after_before_all constant t_event_name := 'after_beforeall'; + gc_after_before_each constant t_event_name := 'after_beforeeach'; + gc_after_before_test constant t_event_name := 'after_beforetest'; + gc_after_test_execute constant t_event_name := 'after_test'; + gc_after_after_test constant t_event_name := 'after_aftertest'; + gc_after_after_each constant t_event_name := 'after_aftereach'; + gc_after_after_all constant t_event_name := 'after_afterall'; gc_finalize constant t_event_name := 'finalize'; subtype t_executable_type is varchar2(30); - gc_before_all constant t_executable_type := 'before_all'; - gc_before_each constant t_executable_type := 'before_each'; - gc_before_test constant t_executable_type := 'before_test'; - gc_test_execute constant t_executable_type := 'test_execute'; - gc_after_test constant t_executable_type := 'after_test'; - gc_after_each constant t_executable_type := 'after_each'; - gc_after_all constant t_executable_type := 'after_all'; + gc_before_all constant t_executable_type := 'beforeall'; + gc_before_each constant t_executable_type := 'beforeeach'; + gc_before_test constant t_executable_type := 'beforetest'; + gc_test_execute constant t_executable_type := 'test'; + gc_after_test constant t_executable_type := 'aftertest'; + gc_after_each constant t_executable_type := 'aftereach'; + gc_after_all constant t_executable_type := 'afterall'; /* Constants: Test Results */ subtype t_test_result is binary_integer range 0 .. 3; diff --git a/test/core/annotations/test_before_after_test_annotation.pkb b/test/core/annotations/test_before_after_test_annotation.pkb index 27d787b79..06871a335 100644 --- a/test/core/annotations/test_before_after_test_annotation.pkb +++ b/test/core/annotations/test_before_after_test_annotation.pkb @@ -1,184 +1,311 @@ create or replace package body test_before_after_annotations is + + type t_executed_procedures is table of t_procedures index by t_procedure_name; g_tests_results clob; + g_executed_procedures t_executed_procedures; + + + procedure set_procs_called(a_for_procedure t_procedure_name, a_procedures t_procedures) is + begin + g_executed_procedures(a_for_procedure) := a_procedures; + end; + + function get_procs_called(a_for_procedure varchar2) return t_procedures pipelined is + begin + if g_executed_procedures.exists(a_for_procedure) then + for i in 1 .. g_executed_procedures(a_for_procedure).count loop + pipe row (g_executed_procedures(a_for_procedure)(i)); + end loop; + end if; + return; + end; procedure create_tests_results is pragma autonomous_transaction; - l_test_package_spec varchar2(32737); - l_test_package_body varchar2(32737); + l_dummy_utility_pkg_spec varchar2(32737); l_dummy_utility_pkg_body varchar2(32737); + l_test_package_spec varchar2(32737); + l_test_package_body varchar2(32737); l_test_results ut3.ut_varchar2_list; - procedure drop_package(a_package_name varchar2) - is - begin - execute immediate 'drop package '||a_package_name; - end; begin - l_dummy_utility_pkg_spec := ' - create or replace package dummy_utility_pkg_1 is - g_executed_procedures ut_varchar2_list; - g_test4_executed boolean := false; - g_test5_executed boolean := false; - g_beforetest_one_err_procedure boolean := false; - - procedure insert_executed_procedure(a_procedure_name varchar2); - - procedure test1; - - procedure test3; - - procedure test4; - - procedure test5; + l_dummy_utility_pkg_spec := q'[ + create or replace package shared_test_package is + + procedure before_test; + + procedure set_proc_called(a_procedure_name varchar2); + + function get_procs_called return test_before_after_annotations.t_procedures; + + procedure reset_proc_called; + end; - '; - - l_dummy_utility_pkg_body := ' - create or replace package body dummy_utility_pkg_1 is - procedure insert_executed_procedure(a_procedure_name varchar2) - is + ]'; + + l_dummy_utility_pkg_body := q'[ + create or replace package body shared_test_package is + + g_called_procedures test_before_after_annotations.t_procedures := test_before_after_annotations.t_procedures(); + + procedure set_proc_called(a_procedure_name varchar2) is + begin + g_called_procedures.extend; + g_called_procedures(g_called_procedures.last) := a_procedure_name; + end; + + function get_procs_called return test_before_after_annotations.t_procedures is + begin + return g_called_procedures; + end; + + procedure reset_proc_called is + begin + g_called_procedures.delete; + end; + + procedure before_test is + begin + set_proc_called('shared_test_package.before_test'); + end; + + end; + ]'; + + l_test_package_spec := q'[ + create or replace package dummy_before_after_test is + --%suite(Package to test annotations beforetest and aftertest) + + --%aftereach + procedure clean_global_variables; + + --%test(Executes Beforetest call to procedure inside package) + --%beforetest(before_test) + procedure beforetest_local_procedure; + + --%test(Executes beforetest procedure defined in the package when specified with package name) + --%beforetest(dummy_before_after_test.before_test) + procedure beforetest_local_proc_with_pkg; + + --%test(Executes Beforetest procedure twice when defined twice) + --%beforetest(before_test, before_test) + procedure beforetest_twice; + + --%test(Executes Beforetest procedure from external package) + --%beforetest(shared_test_package.before_test) + procedure beforetest_one_ext_procedure; + + --%test(Executed external and internal Beforetest procedures) + --%beforetest(shared_test_package.before_test, before_test) + procedure beforetest_multi_ext_procedure; + + --%test(Stops execution at first non-existing Beforetest procedure and marks test as errored) + --%beforetest(shared_test_package.before_test, non_existent_procedure, before_test) + procedure beforetest_missing_procedure; + + --%test(Stops execution at first erroring Beforetest procedure and marks test as errored) + --%beforetest(shared_test_package.before_test, before_test_erroring, before_test) + procedure beforetest_one_err_procedure; + + procedure before_test; + + procedure before_test_erroring; + + end; + ]'; + + l_test_package_body := q'[ + create or replace package body dummy_before_after_test is + + procedure clean_global_variables is begin - if g_executed_procedures is null then - g_executed_procedures := ut_varchar2_list(a_procedure_name); - else - g_executed_procedures.extend; - g_executed_procedures(g_executed_procedures.count) := a_procedure_name; - end if; + shared_test_package.reset_proc_called; end; - - procedure test1 is + + procedure beforetest_local_procedure is begin - insert_executed_procedure(''test1''); + test_before_after_annotations.set_procs_called( + 'beforetest_local_procedure', + shared_test_package.get_procs_called() + ); end; - - procedure test3 is + + procedure beforetest_local_proc_with_pkg is begin - insert_executed_procedure(''test3''); + test_before_after_annotations.set_procs_called( + 'beforetest_local_proc_with_pkg', + shared_test_package.get_procs_called() + ); end; - - procedure test4 is + + procedure beforetest_twice is begin - g_test4_executed := true; + test_before_after_annotations.set_procs_called( + 'beforetest_twice', + shared_test_package.get_procs_called() + ); end; - - procedure test5 is + + procedure beforetest_one_ext_procedure is begin - g_test4_executed := true; + test_before_after_annotations.set_procs_called( + 'beforetest_one_ext_procedure', + shared_test_package.get_procs_called() + ); end; - end; - '; - - l_test_package_spec := ' - create or replace package dummy_before_after_test is - --%suite(Package to test annotations beforetest and aftertest) - - --%aftereach - procedure clean_global_variables; - - --%test(Beforetest with call to procedure external to the test package) - --%beforetest(dummy_utility_pkg_1.test1) - procedure beforetest_one_ext_procedure; - - - --%test(Beforetest with call to multi procedures external and interal to the test package) - --%beforetest(dummy_utility_pkg_1.test1, test2, ut3_tester.dummy_utility_pkg_1.test3) - procedure beforetest_multi_ext_procedure; - - --%test(Beforetest with call to multi procedures where one does not exist) - --%beforetest(dummy_utility_pkg_1.test4, non_existent_procedure, ut3_tester.dummy_utility_pkg_1.test5) - procedure beforetest_one_err_procedure; - - --%test(Test which beforetest procedures were executed) - procedure test_executed_beforetests; - - procedure test2; + + procedure beforetest_multi_ext_procedure is + begin + test_before_after_annotations.set_procs_called( + 'beforetest_multi_ext_procedure', + shared_test_package.get_procs_called() + ); end; - '; - - l_test_package_body := ' - create or replace package body dummy_before_after_test is - procedure clean_global_variables is - begin - dummy_utility_pkg_1.g_executed_procedures := null; - end; - - procedure beforetest_one_ext_procedure is - begin - ut3.ut.expect(dummy_utility_pkg_1.g_executed_procedures(1)).to_equal(''test1''); - end; - - procedure beforetest_multi_ext_procedure - is - begin - ut3.ut.expect(dummy_utility_pkg_1.g_executed_procedures(1)).to_equal(''test1''); - ut3.ut.expect(dummy_utility_pkg_1.g_executed_procedures(2)).to_equal(''test2''); - ut3.ut.expect(dummy_utility_pkg_1.g_executed_procedures(3)).to_equal(''test3''); - end; - - procedure beforetest_one_err_procedure - is - begin - dummy_utility_pkg_1.g_beforetest_one_err_procedure := true; - end; - - procedure test_executed_beforetests - is - begin - ut3.ut.expect(dummy_utility_pkg_1.g_test4_executed).to_be_true; - ut3.ut.expect(dummy_utility_pkg_1.g_test5_executed).to_be_false; - ut3.ut.expect(dummy_utility_pkg_1.g_beforetest_one_err_procedure).to_be_false; - end; - - procedure test2 is - begin - dummy_utility_pkg_1.insert_executed_procedure(''test2''); - end; + + procedure beforetest_missing_procedure is + begin + test_before_after_annotations.set_procs_called( + 'beforetest_missing_procedure', + shared_test_package.get_procs_called() + ); end; - '; + + procedure beforetest_one_err_procedure is + begin + test_before_after_annotations.set_procs_called( + 'beforetest_one_err_procedure', + shared_test_package.get_procs_called() + ); + end; + + procedure before_test is + begin + shared_test_package.set_proc_called('dummy_before_after_test.before_test'); + end; + + procedure before_test_erroring is + begin + shared_test_package.set_proc_called('dummy_before_after_test.before_test_erroring'); + raise program_error; + end; + + end; + ]'; execute immediate l_dummy_utility_pkg_spec; execute immediate l_dummy_utility_pkg_body; execute immediate l_test_package_spec; execute immediate l_test_package_body; - --Execute the tests and recolect the results + --Execute the tests and collect the results select * bulk collect into l_test_results from table(ut3.ut.run(('dummy_before_after_test'))); - - drop_package('dummy_utility_pkg_1'); - drop_package('dummy_before_after_test'); + + execute immediate 'drop package dummy_before_after_test'; + execute immediate 'drop package shared_test_package'; g_tests_results := ut3.ut_utils.table_to_clob(l_test_results); end; - - procedure beforetest_one_ext_procedure - is + + procedure beforetest_local_procedure is + l_expected sys_refcursor; + l_actual sys_refcursor; + begin + open l_expected for + select 'dummy_before_after_test.before_test' as column_value from dual; + open l_actual for + select * from table(test_before_after_annotations.get_procs_called('beforetest_local_procedure')); + ut.expect(l_actual).to_equal(l_expected); + end; + + procedure beforetest_local_proc_with_pkg is + l_expected sys_refcursor; + l_actual sys_refcursor; begin - ut.expect(g_tests_results).to_match('^\s*Beforetest with call to procedure external to the test package \[[\.0-9]+ sec\]\s*$','m'); - ut.expect(g_tests_results).not_to_match('beforetest_one_ext_procedure'); + open l_expected for + select 'dummy_before_after_test.before_test' as column_value from dual; + open l_actual for + select * from table(test_before_after_annotations.get_procs_called('beforetest_local_procedure')); + ut.expect(l_actual).to_equal(l_expected); end; - - procedure beforetest_multi_ext_procedure - is + + procedure beforetest_twice is + l_expected sys_refcursor; + l_actual sys_refcursor; begin - --Also test the execution order of the beforetest procedures - ut.expect(g_tests_results).to_match('^\s*Beforetest with call to multi procedures external and interal to the test package \[[\.0-9]+ sec\]\s*$','m'); - ut.expect(g_tests_results).not_to_match('beforetest_multi_ext_procedure'); + open l_expected for + select 'dummy_before_after_test.before_test' as column_value from dual union all + select 'dummy_before_after_test.before_test' as column_value from dual; + + open l_actual for + select * from table(test_before_after_annotations.get_procs_called('beforetest_twice')); + ut.expect(l_actual).to_equal(l_expected); end; - - procedure beforetest_one_err_procedure - is + + procedure beforetest_one_ext_procedure is + l_expected sys_refcursor; + l_actual sys_refcursor; begin - ut.expect(g_tests_results).to_match('^\s*Call params for before_test are not valid: procedure does not exist\s*[^.]+\.DUMMY_BEFORE_AFTER_TEST\.NON_EXISTENT_PROCEDURE\s*$', 'm'); - ut.expect(g_tests_results).not_to_match('^\s*Beforetest with call to multi procedures where one does not exist \[[\.0-9]+ sec\]\s*$','m'); + open l_expected for + select 'shared_test_package.before_test' as column_value from dual; + + open l_actual for + select * from table(test_before_after_annotations.get_procs_called('beforetest_one_ext_procedure')); + ut.expect(l_actual).to_equal(l_expected); end; - - procedure test_executed_beforetests - is + + procedure beforetest_multi_ext_procedure is + l_expected sys_refcursor; + l_actual sys_refcursor; begin - ut.expect(g_tests_results).to_match('^\s*Test which beforetest procedures were executed \[[\.0-9]+ sec\]\s*$','m'); - ut.expect(g_tests_results).not_to_match('test_executed_beforetests'); + open l_expected for + select 'shared_test_package.before_test' as column_value from dual union all + select 'dummy_before_after_test.before_test' as column_value from dual; + + open l_actual for + select * from table(test_before_after_annotations.get_procs_called('beforetest_multi_ext_procedure')); + ut.expect(l_actual).to_equal(l_expected); end; + + procedure beforetest_missing_procedure is + l_actual sys_refcursor; + begin + open l_actual for + select * from table(test_before_after_annotations.get_procs_called('beforetest_missing_procedure')); + + ut.expect(l_actual).to_be_empty; + + ut.expect(g_tests_results).to_match( + '^\s*Stops execution at first non-existing Beforetest procedure and marks test as errored \[[\.0-9]+ sec\] \(FAILED - 1\)\s*$' + ,'m' + ); + ut.expect(g_tests_results).to_match( + '1\) beforetest_missing_procedure\s+' || + 'Call params for beforetest are not valid: procedure does not exist ' || + 'UT3_TESTER.DUMMY_BEFORE_AFTER_TEST.NON_EXISTENT_PROCEDURE' + ,'m' + ); + end; + + procedure beforetest_one_err_procedure is + l_actual sys_refcursor; + begin + open l_actual for + select * from table(test_before_after_annotations.get_procs_called('beforetest_one_err_procedure')); + + ut.expect(l_actual).to_be_empty; + + ut.expect(g_tests_results).to_match( + '^\s*Stops execution at first non-existing Beforetest procedure and marks test as errored \[[\.0-9]+ sec\] \(FAILED - 1\)\s*$' + ,'m' + ); + ut.expect(g_tests_results).to_match( + '2\) beforetest_one_err_procedure\s+' || + 'ORA-06501: PL/SQL: program error' + ,'m' + ); + end; + end; / \ No newline at end of file diff --git a/test/core/annotations/test_before_after_test_annotation.pks b/test/core/annotations/test_before_after_test_annotation.pks index bb1216f2c..a4ce52727 100644 --- a/test/core/annotations/test_before_after_test_annotation.pks +++ b/test/core/annotations/test_before_after_test_annotation.pks @@ -3,20 +3,36 @@ create or replace package test_before_after_annotations is --%suite(annotations - beforetest and aftertest) --%suitepath(utplsql.core.annotations) + subtype t_procedure_name is varchar2(250) not null; + type t_procedures is table of t_procedure_name; + + procedure set_procs_called(a_for_procedure t_procedure_name, a_procedures t_procedures); + + function get_procs_called(a_for_procedure varchar2) return t_procedures pipelined; + --%beforeall procedure create_tests_results; + --%test(Executes Beforetest call to procedure inside package) + procedure beforetest_local_procedure; + + --%test(Executes beforetest procedure defined in the package when specified with package name) + procedure beforetest_local_proc_with_pkg; + + --%test(Executes Beforetest procedure twice when defined twice) + procedure beforetest_twice; - --%test(Beforetest with call to procedure external to the test package) + --%test(Executes Beforetest procedure from external package) procedure beforetest_one_ext_procedure; - - --%test(Beforetest with call to multi procedures external and interal to the test package) - procedure beforetest_multi_ext_procedure; - - --%test(Beforetest with call to multi procedure where one does not exist) + + --%test(Executed external and internal Beforetest procedures) + procedure beforetest_multi_ext_procedure; + + --%test(Stops execution at first non-existing Beforetest procedure and marks test as errored) + procedure beforetest_missing_procedure; + + --%test(Stops execution at first erroring Beforetest procedure and marks test as errored) procedure beforetest_one_err_procedure; - - --%test(Test which beforetest procedures were executed) - procedure test_executed_beforetests; + end; / \ No newline at end of file From 49b5fba4784f40d2694188889de1d4265b91ddf6 Mon Sep 17 00:00:00 2001 From: Jacek Gebal Date: Tue, 12 Jun 2018 21:45:22 +0100 Subject: [PATCH 105/184] Added support for charset in HTML reports. --- source/core/ut_utils.pkb | 2 +- source/reporters/ut_coverage_html_reporter.tpb | 9 ++++++++- .../reporters/ut_coverage_report_html_helper.pkb | 15 +++++++++++---- .../reporters/ut_coverage_report_html_helper.pks | 8 +++++++- test/core/reporters.pkb | 2 +- .../test_coverage/test_html_extended_reporter.pkb | 6 ++++-- .../test_coverage/test_html_proftab_reporter.pkb | 8 ++++---- 7 files changed, 36 insertions(+), 14 deletions(-) diff --git a/source/core/ut_utils.pkb b/source/core/ut_utils.pkb index 81d15ea8c..a8817fcdf 100644 --- a/source/core/ut_utils.pkb +++ b/source/core/ut_utils.pkb @@ -513,7 +513,7 @@ procedure append_to_clob(a_src_clob in out nocopy clob, a_clob_table t_clob_tab, ''; end; diff --git a/source/reporters/ut_coverage_html_reporter.tpb b/source/reporters/ut_coverage_html_reporter.tpb index d1a9dd473..08069ff65 100644 --- a/source/reporters/ut_coverage_html_reporter.tpb +++ b/source/reporters/ut_coverage_html_reporter.tpb @@ -35,7 +35,14 @@ create or replace type body ut_coverage_html_reporter is ut_coverage.coverage_stop(); l_coverage_data := ut_coverage.get_coverage_data(a_run.coverage_options); - self.print_clob( ut_coverage_report_html_helper.get_index( a_coverage_data => l_coverage_data,a_assets_path => self.assets_path, a_project_name=> self.project_name )); + self.print_clob( + ut_coverage_report_html_helper.get_index( + a_coverage_data => l_coverage_data, + a_assets_path => self.assets_path, + a_project_name => self.project_name, + a_charset => a_run.client_character_set + ) + ); end; diff --git a/source/reporters/ut_coverage_report_html_helper.pkb b/source/reporters/ut_coverage_report_html_helper.pkb index 34e241d17..ea03e461b 100644 --- a/source/reporters/ut_coverage_report_html_helper.pkb +++ b/source/reporters/ut_coverage_report_html_helper.pkb @@ -277,8 +277,13 @@ function get_details_file_content(a_object_id varchar2, a_unit ut_object_name, a /* * public definitions */ - function get_index(a_coverage_data ut_coverage.t_coverage, a_assets_path varchar2, a_project_name varchar2 := null, a_command_line varchar2 := null) - return clob is + function get_index( + a_coverage_data ut_coverage.t_coverage, + a_assets_path varchar2, + a_project_name varchar2 := null, + a_command_line varchar2 := null, + a_charset varchar2 := null + ) return clob is l_file_part varchar2(32767); l_result clob; @@ -287,8 +292,10 @@ function get_details_file_content(a_object_id varchar2, a_unit ut_object_name, a l_time_str varchar2(50); l_using varchar2(1000); l_unit ut_coverage.t_full_name; + l_charset varchar2(1000); begin - l_coverage_pct := coverage_pct(a_coverage_data.covered_lines, a_coverage_data.uncovered_lines); + l_charset := coalesce(upper(a_charset),'UTF-8'); + l_coverage_pct := coverage_pct(a_coverage_data.covered_lines, a_coverage_data.uncovered_lines); l_time_str := ut_utils.to_string(sysdate); l_using := case @@ -305,7 +312,7 @@ function get_details_file_content(a_object_id varchar2, a_unit ut_object_name, a end; --TODO - build main file containing total run data and per schema data l_file_part := '' || '' || l_title || - '' || '' || + '' || '' || '' || '' || diff --git a/source/reporters/ut_coverage_report_html_helper.pks b/source/reporters/ut_coverage_report_html_helper.pks index e718f9fed..8970a235e 100644 --- a/source/reporters/ut_coverage_report_html_helper.pks +++ b/source/reporters/ut_coverage_report_html_helper.pks @@ -31,7 +31,13 @@ create or replace package ut_coverage_report_html_helper authid current_user is function line_hits_css_class(a_line_hist number) return varchar2; - function get_index(a_coverage_data ut_coverage.t_coverage, a_assets_path varchar2, a_project_name varchar2 := null, a_command_line varchar2 := null) return clob; + function get_index( + a_coverage_data ut_coverage.t_coverage, + a_assets_path varchar2, + a_project_name varchar2 := null, + a_command_line varchar2 := null, + a_charset varchar2 := null + ) return clob; end; / diff --git a/test/core/reporters.pkb b/test/core/reporters.pkb index c5bf04d49..8eb2a4992 100644 --- a/test/core/reporters.pkb +++ b/test/core/reporters.pkb @@ -138,7 +138,7 @@ end;]'; from table(ut3.ut.run('test_reporters', a_reporter, a_client_character_set => a_client_character_set)); l_actual := ut3.ut_utils.table_to_clob(l_results); --Assert - ut.expect(l_actual).to_be_like('%'); + ut.expect(l_actual).to_be_like('%'); end; end reporters; diff --git a/test/core/reporters/test_coverage/test_html_extended_reporter.pkb b/test/core/reporters/test_coverage/test_html_extended_reporter.pkb index cd71a6c8c..b1f6fa4bd 100644 --- a/test/core/reporters/test_coverage/test_html_extended_reporter.pkb +++ b/test/core/reporters/test_coverage/test_html_extended_reporter.pkb @@ -4,9 +4,10 @@ create or replace package body test_html_extended_reporter is l_results ut3.ut_varchar2_list; l_expected varchar2(32767); l_actual clob; + l_charset varchar2(100) := 'ISO-8859-1'; begin --Arrange - l_expected := '%

UT3.DUMMY_COVERAGE

%4 relevant lines. 3 lines covered (including 1 lines partially covered ) and 1 lines missed%'; + l_expected := '%%

UT3.DUMMY_COVERAGE

%4 relevant lines. 3 lines covered (including 1 lines partially covered ) and 1 lines missed%'; select * bulk collect into l_results @@ -15,7 +16,8 @@ create or replace package body test_html_extended_reporter is a_path => 'ut3.test_dummy_coverage', a_reporter=> ut3.ut_coverage_html_reporter(), a_source_files => ut3.ut_varchar2_list( 'test/ut3.dummy_coverage.pkb' ), - a_test_files => ut3.ut_varchar2_list( ) + a_test_files => ut3.ut_varchar2_list( ), + a_client_character_set => l_charset ) ); l_actual := ut3.ut_utils.table_to_clob(l_results); diff --git a/test/core/reporters/test_coverage/test_html_proftab_reporter.pkb b/test/core/reporters/test_coverage/test_html_proftab_reporter.pkb index 7167dc6f6..c10af2869 100644 --- a/test/core/reporters/test_coverage/test_html_proftab_reporter.pkb +++ b/test/core/reporters/test_coverage/test_html_proftab_reporter.pkb @@ -4,11 +4,10 @@ create or replace package body test_html_proftab_reporter is l_results ut3.ut_varchar2_list; l_expected varchar2(32767); l_actual clob; + l_charset varchar2(100) := 'ISO-8859-1'; begin --Arrange - l_expected := '%

UT3.DUMMY_COVERAGE

%3 relevant lines. 2 lines covered and 1 lines missed%'; - - --l_expected := '%

UT3.DUMMY_COVERAGE

66% lines covered

3 relevant lines. 2 lines covered ) and 1 lines missed
%'; + l_expected := '%%

UT3.DUMMY_COVERAGE

%3 relevant lines. 2 lines covered and 1 lines missed%'; --Act select * bulk collect into l_results @@ -17,7 +16,8 @@ create or replace package body test_html_proftab_reporter is a_path => 'ut3.test_dummy_coverage', a_reporter=> ut3.ut_coverage_html_reporter(), a_source_files => ut3.ut_varchar2_list( 'test/ut3.dummy_coverage.pkb' ), - a_test_files => ut3.ut_varchar2_list( ) + a_test_files => ut3.ut_varchar2_list( ), + a_client_character_set => l_charset ) ); l_actual := ut3.ut_utils.table_to_clob(l_results); From 7d26df3dc492777243cf7dc541d297150bf62f31 Mon Sep 17 00:00:00 2001 From: Travis CI Date: Tue, 12 Jun 2018 21:37:04 +0000 Subject: [PATCH 106/184] Updated project version after build [skip ci] --- source/core/ut_utils.pks | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/core/ut_utils.pks b/source/core/ut_utils.pks index c2e37b794..f8156b613 100644 --- a/source/core/ut_utils.pks +++ b/source/core/ut_utils.pks @@ -21,7 +21,7 @@ create or replace package ut_utils authid definer is * */ - gc_version constant varchar2(50) := 'v3.1.2.1994-develop'; + gc_version constant varchar2(50) := 'v3.1.2.2007-develop'; /* Constants: Event names */ subtype t_event_name is varchar2(30); From 2d80c8013a019a8a9c0a015f6a3d4fb473460342 Mon Sep 17 00:00:00 2001 From: Travis CI Date: Tue, 12 Jun 2018 23:42:44 +0000 Subject: [PATCH 107/184] Updated project version after build [skip ci] --- source/core/ut_utils.pks | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/core/ut_utils.pks b/source/core/ut_utils.pks index 25bf152fb..ddcfa1c52 100644 --- a/source/core/ut_utils.pks +++ b/source/core/ut_utils.pks @@ -21,7 +21,7 @@ create or replace package ut_utils authid definer is * */ - gc_version constant varchar2(50) := 'v3.1.2.2007-develop'; + gc_version constant varchar2(50) := 'v3.1.2.2010-develop'; /* Constants: Event names */ subtype t_event_name is varchar2(30); From 74f11e2cf5833bd41470f5df1babd43e5459aac0 Mon Sep 17 00:00:00 2001 From: Travis CI Date: Wed, 13 Jun 2018 22:42:19 +0000 Subject: [PATCH 108/184] Updated project version after build [skip ci] --- source/core/ut_utils.pks | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/core/ut_utils.pks b/source/core/ut_utils.pks index fe137960c..cf75a3f63 100644 --- a/source/core/ut_utils.pks +++ b/source/core/ut_utils.pks @@ -21,7 +21,7 @@ create or replace package ut_utils authid definer is * */ - gc_version constant varchar2(50) := 'v3.1.2.2010-develop'; + gc_version constant varchar2(50) := 'v3.1.2.2013-develop'; /* Constants: Event names */ subtype t_event_name is varchar2(30); From a5fe6f9243760dcd5d1b73e5a40b09a5c0b58487 Mon Sep 17 00:00:00 2001 From: Jacek Gebal Date: Thu, 14 Jun 2018 00:44:23 +0100 Subject: [PATCH 109/184] Updated documentation for beforetest/aftertest --- docs/userguide/annotations.md | 64 +++++++++++++++++++++++++++-------- 1 file changed, 50 insertions(+), 14 deletions(-) diff --git a/docs/userguide/annotations.md b/docs/userguide/annotations.md index 011626b80..9c9df44ea 100644 --- a/docs/userguide/annotations.md +++ b/docs/userguide/annotations.md @@ -26,8 +26,8 @@ We strongly recommend putting package level annotations at the very top of packa | `--%afterall` | Procedure | Denotes that the annotated procedure should be executed once after all elements of the suite. | | `--%beforeeach` | Procedure | Denotes that the annotated procedure should be executed before each `%test` procedure in the suite. | | `--%aftereach` | Procedure | Denotes that the annotated procedure should be executed after each `%test` procedure in the suite. | -| `--%beforetest()` | Procedure | Denotes that mentioned procedure should be executed before the annotated `%test` procedure. | -| `--%aftertest()` | Procedure | Denotes that mentioned procedure should be executed after the annotated `%test` procedure. | +| `--%beforetest(<[owner.[package.]]procedure_name>[,...])` | Procedure | Denotes that mentioned procedure(s) should be executed before the annotated `%test` procedure. | +| `--%aftertest(<[owner.[package.]]procedure_name>[,...]>)` | Procedure | Denotes that mentioned procedure(s) should be executed after the annotated `%test` procedure. | | `--%rollback()` | Package/procedure | Defines transaction control. Supported values: `auto`(default) - a savepoint is created before invocation of each "before block" is and a rollback to specific savepoint is issued after each "after" block; `manual` - rollback is never issued automatically. Property can be overridden for child element (test in suite) | | `--%disabled` | Package/procedure | Used to disable a suite or a test. Disabled suites/tests do not get executed, they are however marked and reported as disabled in a test run. | | `--%context()` | Package | Denotes start of a named context (sub-suite) in a suite package | @@ -685,12 +685,15 @@ Finished in .018115 seconds ### Beforetest -Indicates a specific setup to be executed for a test. -Used alongside `--%test` annotation. Indicates procedure name to be executed before specific test. +Indicates specific setup procedure(s) to be executed for a test. The procedure(s) can be located either: +- within current package (package name is optional) +- within another package + +The annotation need to be placed alongside `--%test` annotation. The `--%beforetest` procedures are executed after invoking all `--%beforeeach` for a test. -If a test is marked as disabled the `--%beforetest` procedure is not invoked for that test. +If a test is marked as disabled the `--%beforetest` procedures are not invoked for that test. If `--%beforetest` raises an unhandled exception the following will happen: - the following `--%beforetest` for that test **will not be executed** @@ -701,16 +704,31 @@ If `--%beforetest` raises an unhandled exception the following will happen: When multiple `--%beforetest` procedures are defined for a test, all of them will be executed before invoking the test. -For multiple `--%beforetest` procedures order of execution is defined by annotation position in the package specification. +The order of execution for `--%beforetest` procedures is defined by: +- position of procedure on the list within single annotation +- annotation position As a rule, the `--%beforetest` execution gets aborted if preceding `--%beforeeach` or `--%beforetest` failed. ```sql +create or replace package shared_package as + procedure do_some_stuff; +end; +/ + +create or replace package body shared_package as + procedure do_some_stuff is + begin + dbms_output.put_line('---DO_SOME_STUFF invoked ---'); + end; +end; +/ + create or replace package test_package as --%suite(Tests for a package) --%test(Description of tested behavior) - --%beforetest(setup_for_a_test) + --%beforetest(setup_for_a_test, shared_package.do_some_stuff) --%beforetest(another_setup_for_a_test) procedure some_test; @@ -754,6 +772,7 @@ exec ut.run('test_package'); Tests for a package Description of tested behavior [.011 sec] ---SETUP_FOR_A_TEST invoked --- + ---DO_SOME_STUFF invoked --- ---ANOTHER_SETUP_FOR_A_TEST invoked --- ---SOME_TEST invoked --- Description of another behavior [.005 sec] @@ -767,12 +786,13 @@ Finished in .018446 seconds ### Aftertest -Indicates a specific cleanup to be executed for a test. -Used alongside `--%test` annotation. Indicates procedure name to be executed after specific test. - -The `--%aftertest` procedures are executed before invoking any `--%aftereach` for a test. +Indicates specific cleanup procedure(s) to be executed for a test. The procedure(s) can be located either: +- within current package (package name is optional) +- within another package + +The annotation need to be placed alongside `--%test` annotation. -If a test is marked as disabled the `--%aftertest` procedure is not invoked for that test. +If a test is marked as disabled the `--%aftertest` procedures are not invoked for that test. If `--%aftertest` raises an unhandled exception the following will happen: - the test will be marked as errored and exception stack trace will be captured and reported @@ -782,16 +802,31 @@ If `--%aftertest` raises an unhandled exception the following will happen: When multiple `--%aftertest` procedures are defined for a test, all of them will be executed before invoking the test. -For multiple `--%aftertest` procedures order of execution is defined by annotation position in the package specification. +The order of execution for `--%aftertest` procedures is defined by: +- position of procedure on the list within single annotation +- annotation position As a rule, the `--%aftertest` gets executed even if the associated `--%beforeeach`, `--%beforetest`, `--%test` or other `--%aftertest` procedures have raised unhandled exceptions. ```sql +create or replace package shared_package as + procedure do_some_stuff; +end; +/ + +create or replace package body shared_package as + procedure do_some_stuff is + begin + dbms_output.put_line('---DO_SOME_STUFF invoked ---'); + end; +end; +/ + create or replace package test_package as --%suite(Tests for a package) --%test(Description of tested behavior) - --%aftertest(cleanup_for_a_test) + --%aftertest(cleanup_for_a_test, shared_package.do_some_stuff) --%aftertest(another_cleanup_for_a_test) procedure some_test; @@ -836,6 +871,7 @@ Tests for a package Description of tested behavior [.01 sec] ---SOME_TEST invoked --- ---CLEANUP_FOR_A_TEST invoked --- + ---DO_SOME_STUFF invoked --- ---ANOTHER_CLEANUP_FOR_A_TEST invoked --- Description of another behavior [.006 sec] ---OTHER_TEST invoked --- From 7afc6ef59fbb14e83427f6e9239a9f451d2ca0b1 Mon Sep 17 00:00:00 2001 From: Travis CI Date: Thu, 14 Jun 2018 06:49:32 +0000 Subject: [PATCH 110/184] Updated project version after build [skip ci] --- source/core/ut_utils.pks | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/core/ut_utils.pks b/source/core/ut_utils.pks index cf75a3f63..96236d3ff 100644 --- a/source/core/ut_utils.pks +++ b/source/core/ut_utils.pks @@ -21,7 +21,7 @@ create or replace package ut_utils authid definer is * */ - gc_version constant varchar2(50) := 'v3.1.2.2013-develop'; + gc_version constant varchar2(50) := 'v3.1.2.2016-develop'; /* Constants: Event names */ subtype t_event_name is varchar2(30); From c54c14b03bf4b463f50c8005aacb547e3bdec370 Mon Sep 17 00:00:00 2001 From: lwasylow Date: Sun, 8 Jul 2018 09:32:27 +0100 Subject: [PATCH 111/184] Trigger subbuild on develop --- .travis.yml | 3 ++ .travis/trigger_travis.sh | 71 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 .travis/trigger_travis.sh diff --git a/.travis.yml b/.travis.yml index cf4abb857..3eb275811 100644 --- a/.travis.yml +++ b/.travis.yml @@ -104,6 +104,9 @@ script: - if [[ ! $TRAVIS_TAG ]]; then bash .travis/push_release_version.sh; fi - bash .travis/push_docs_to_gh_pages.sh +after_success: + - if [[ ($TRAVIS_BRANCH == develop) && ($TRAVIS_PULL_REQUEST == false) ]]; then bash trigger-travis.sh $TRAVIS_ACCESS_TOKEN fi + before_deploy: - bash .travis/build_release_archive.sh diff --git a/.travis/trigger_travis.sh b/.travis/trigger_travis.sh new file mode 100644 index 000000000..ccf90c397 --- /dev/null +++ b/.travis/trigger_travis.sh @@ -0,0 +1,71 @@ +#!/bin/bash + +# Trigger a new Travis-CI job. +# Ordinarily, a new Travis job is triggered when a commit is pushed to a +# GitHub repository. The trigger-travis.sh script provides a programmatic +# way to trigger a new Travis job. + +# To use this script to trigger a dependent build in Travis, do two things: +# +# 1. Set an environment variable TRAVIS_ACCESS_TOKEN by navigating to +# https://travis-ci.org/MYGITHUBID/MYGITHUBPROJECT/settings +# The TRAVIS_ACCESS_TOKEN environment variable will be set when Travis runs +# the job, but won't be visible to anyone browsing https://travis-ci.org/. +# + + +TRAVIS_URL=travis-ci.org +BRANCH=develop +USER="utPLSQL" +RESULT=1 +declare -a REPO_MATRIX=("utPLSQL-java-api" "utPLSQL-v2-v3-migration" "utPLSQL-cli") + +TOKEN=$1 + +if [ -n "$TRAVIS_REPO_SLUG" ] ; then + MESSAGE=",\"message\": \"Triggered by upstream build of $TRAVIS_REPO_SLUG commit "`git rev-parse --short HEAD`"\"" +else + MESSAGE=",\"message\": \"Triggered manually from shell\"" +fi + +## For debugging: +# echo "TOKEN=$TOKEN" +# echo "MESSAGE=$MESSAGE" + +body="{ +\"request\": { + \"branch\":\"$BRANCH\" + $MESSAGE +}}" + +for DOWNSTREAM_BUILD in "${REPO_MATRIX[@]}"; do + + curl -s -X POST \ + -H "Content-Type: application/json" \ + -H "Accept: application/json" \ + -H "Travis-API-Version: 3" \ + -H "Authorization: token ${TOKEN}" \ + -d "$body" \ + https://api.${TRAVIS_URL}/repo/${USER}%2F${DOWNSTREAM_BUILD}/requests \ + | tee ${DOWNSTREAM_BUILD}-output.txt + + if grep -q '"@type": "error"' ${DOWNSTREAM_BUILD}-output.txt; then + #exit 1 + RESULT=0 + echo "" + echo "Failed to start ${DOWNSTREAM_BUILD}" + echo "" + fi + if grep -q 'access denied' ${DOWNSTREAM_BUILD}-output.txt; then + #exit 1 + RESULT=0 + echo "" + echo "Failed to start ${DOWNSTREAM_BUILD}" + echo "" + fi + +done + +if [[ RESULT -eq 0 ]]; then + exit 1 +fi From 77299541f2fb37d360918162abd3d6a102466e4f Mon Sep 17 00:00:00 2001 From: lwasylow Date: Sun, 8 Jul 2018 09:34:04 +0100 Subject: [PATCH 112/184] update --- .travis/trigger_travis.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis/trigger_travis.sh b/.travis/trigger_travis.sh index ccf90c397..8844ffd05 100644 --- a/.travis/trigger_travis.sh +++ b/.travis/trigger_travis.sh @@ -50,14 +50,12 @@ for DOWNSTREAM_BUILD in "${REPO_MATRIX[@]}"; do | tee ${DOWNSTREAM_BUILD}-output.txt if grep -q '"@type": "error"' ${DOWNSTREAM_BUILD}-output.txt; then - #exit 1 RESULT=0 echo "" echo "Failed to start ${DOWNSTREAM_BUILD}" echo "" fi if grep -q 'access denied' ${DOWNSTREAM_BUILD}-output.txt; then - #exit 1 RESULT=0 echo "" echo "Failed to start ${DOWNSTREAM_BUILD}" From 27a361c4db2fef154bda96e8e7d26c874dda96f6 Mon Sep 17 00:00:00 2001 From: lwasylow Date: Sun, 8 Jul 2018 09:58:52 +0100 Subject: [PATCH 113/184] Update if --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 3eb275811..266edd96d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -105,7 +105,7 @@ script: - bash .travis/push_docs_to_gh_pages.sh after_success: - - if [[ ($TRAVIS_BRANCH == develop) && ($TRAVIS_PULL_REQUEST == false) ]]; then bash trigger-travis.sh $TRAVIS_ACCESS_TOKEN fi + - if [[ ($TRAVIS_BRANCH == develop) && ($TRAVIS_PULL_REQUEST == false) ]]; then bash trigger-travis.sh $TRAVIS_ACCESS_TOKEN; fi before_deploy: - bash .travis/build_release_archive.sh From 4c6476b9593902b2a7720232893853afdbb140b6 Mon Sep 17 00:00:00 2001 From: Jacek Gebal Date: Sun, 8 Jul 2018 15:24:05 +0100 Subject: [PATCH 114/184] Changed printing of messages to be directed to STDERR rather than STDOUT when errors encountered while triggering child builds. --- .travis/trigger_travis.sh | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.travis/trigger_travis.sh b/.travis/trigger_travis.sh index 8844ffd05..c7b9a7071 100644 --- a/.travis/trigger_travis.sh +++ b/.travis/trigger_travis.sh @@ -13,6 +13,7 @@ # the job, but won't be visible to anyone browsing https://travis-ci.org/. # +echoerr() { echo "$@" 1>&2; } TRAVIS_URL=travis-ci.org BRANCH=develop @@ -51,15 +52,15 @@ for DOWNSTREAM_BUILD in "${REPO_MATRIX[@]}"; do if grep -q '"@type": "error"' ${DOWNSTREAM_BUILD}-output.txt; then RESULT=0 - echo "" - echo "Failed to start ${DOWNSTREAM_BUILD}" - echo "" + echoerr "" + echoerr "Failed to start ${DOWNSTREAM_BUILD}" + echoerr "" fi if grep -q 'access denied' ${DOWNSTREAM_BUILD}-output.txt; then RESULT=0 - echo "" - echo "Failed to start ${DOWNSTREAM_BUILD}" - echo "" + echoerr "" + echoerr "Failed to start ${DOWNSTREAM_BUILD}" + echoerr "" fi done From e4823b096095f892bbb7c5b7fbd0cc01278c087d Mon Sep 17 00:00:00 2001 From: Jacek Gebal Date: Sun, 8 Jul 2018 15:49:30 +0100 Subject: [PATCH 115/184] Testing deploy stages --- .travis.yml | 57 +++++++++++++++++++++++++++++------------------------ 1 file changed, 31 insertions(+), 26 deletions(-) diff --git a/.travis.yml b/.travis.yml index 266edd96d..4adf04428 100644 --- a/.travis.yml +++ b/.travis.yml @@ -52,8 +52,8 @@ env: - MAVEN_HOME=/usr/local/maven - MAVEN_CFG=$HOME/.m2 matrix: - - ORACLE_VERSION="${DOCKER_TAG_11G:-11g-r2-xe}" CONNECTION_STR='127.0.0.1:1521/XE' DOCKER_OPTIONS='--shm-size=1g' - - ORACLE_VERSION="${DOCKER_TAG_12C:-12c-r1-se2}" CONNECTION_STR='127.0.0.1:1521/ORCLPDB1' DOCKER_OPTIONS="-v /dev/pdbs:/opt/oracle/oradata/pdbs" + - ORACLE_VERSION="${DOCKER_TAG_11G:-11g-r2-xe}" CONNECTION_STR='127.0.0.1:1521/XE' DOCKER_OPTIONS='--shm-size=1g' + - ORACLE_VERSION="${DOCKER_TAG_12C:-12c-r1-se2}" CONNECTION_STR='127.0.0.1:1521/ORCLPDB1' DOCKER_OPTIONS="-v /dev/pdbs:/opt/oracle/oradata/pdbs" - ORACLE_VERSION="${DOCKER_TAG_12C2:-12c-r2-se2}" CONNECTION_STR='127.0.0.1:1521/ORCLPDB1' DOCKER_OPTIONS="-v /dev/pdbs:/opt/oracle/oradata/pdbs" cache: @@ -100,30 +100,6 @@ script: - if [[ ! $TRAVIS_TAG ]]; then bash .travis/validate_report_files.sh; fi - if [[ ! $TRAVIS_TAG ]] && [ "${TRAVIS_REPO_SLUG}" = "${UTPLSQL_REPO}" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then sonar-scanner; fi - if [[ ! $TRAVIS_TAG ]]; then bash .travis/coveralls_uploader.sh; fi - - bash .travis/build_docs.sh - - if [[ ! $TRAVIS_TAG ]]; then bash .travis/push_release_version.sh; fi - - bash .travis/push_docs_to_gh_pages.sh - -after_success: - - if [[ ($TRAVIS_BRANCH == develop) && ($TRAVIS_PULL_REQUEST == false) ]]; then bash trigger-travis.sh $TRAVIS_ACCESS_TOKEN; fi - -before_deploy: - - bash .travis/build_release_archive.sh - -deploy: - provider: releases - api_key: $github_api_token - file: - - utPLSQL.zip - - utPLSQL.tar.gz - - utPLSQL.zip.md5 - - utPLSQL.tar.gz.md5 - skip_cleanup: true - on: - repo: ${UTPLSQL_REPO} - tags: true - # when building from a release tag, use only first job "#xxx.1" to publish artifacts - condition: "${TRAVIS_JOB_NUMBER} =~ \\.1$" notifications: slack: @@ -131,3 +107,32 @@ notifications: - secure: "nemt9n2y5sVCAKqa/s7JDQ8AcM59Xu/XbH/RkMOXvPgc+KtR8lBtVD1LkvJ5BaQhqgjuDT7DNt/uisQJ7k6a2OsrVFbnkypZ1hCvntOBpJyoSpD/YL1X8a9GbGojuJcph0BX76KN21LaOVdyOfY0TSlw53XiYWS8iL5HtjpWCbIwHL1SJ8JT8mhdT4hDoUWZjcZ4s4bLH6BQm4un/bMQOmB4sDoCeg4CllJwxgkswVF7OHpOFjgPetvUp7ps8b/Rj8en6zCj9drb0SVbXFgumo2Wd1bC3HHZB8MAZU0kuEV5VgUdum6EelUL5yfB72hssNQA0+CaT3HjBFkTlqWYJmjC4/xyGN3sseiW82T9FDY0g0GAGayNRW+QSiTQ1hbJEcAnNe0GrBUdRsgXdI6COd76YP5VxzRSF6H7niLfgCZdKbIivKUd1o+wBhuyJmqCFIkRWmT38tMGJqJAzbY1jq5gQXbb6E7gt+KdTjlSjcnJYf7XI7zqm+BRr+fbA0ixfXHvfqOBgZN6g08y9nPlDnIjtSF2NSdrj2zqYQAtKuWSOD1bnTyfDJyrtK7OLffZcMYD5Bcss4c8op8tP7MGTjt1S046SJocboh6H4c/nTokpoMRsWs6MKRdebl8C2RObGf5FebSOJg+oh2ZYS5Z/G9GshiY2BD/81+Hc4Miacc=" on_success: change on_failure: always + +jobs: + include: + - stage: deploy + env: CONNECTION_STR='127.0.0.1:1521/XE' + before_install: skip + install: skip + before_script: skip + script: + - if [[ ($TRAVIS_BRANCH == develop) && ($TRAVIS_PULL_REQUEST == false) ]]; then bash trigger-travis.sh $TRAVIS_ACCESS_TOKEN; fi + - if [[ ! $TRAVIS_TAG ]]; then bash .travis/push_release_version.sh; fi + - bash .travis/build_docs.sh + - bash .travis/push_docs_to_gh_pages.sh + before_deploy: + - bash .travis/build_release_archive.sh + deploy: + provider: releases + api_key: $github_api_token + file: + - utPLSQL.zip + - utPLSQL.tar.gz + - utPLSQL.zip.md5 + - utPLSQL.tar.gz.md5 + skip_cleanup: true + on: + repo: ${UTPLSQL_REPO} + tags: true + # when building from a release tag, use only first job "#xxx.1" to publish artifacts + condition: "${TRAVIS_JOB_NUMBER} =~ \\.1$" From 4b2062d561e1500a8b1aca8c2895b88da6184b15 Mon Sep 17 00:00:00 2001 From: Jacek Gebal Date: Sun, 8 Jul 2018 16:15:49 +0100 Subject: [PATCH 116/184] Moved mkdocs to `deploy` stage. --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4adf04428..4a6e03fa8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -81,7 +81,6 @@ install: - unzip utPLSQL-cli.zip && chmod -R u+x utPLSQL-cli # Get ojdbc via maven - bash .travis/maven_cfg.sh - - pip install mkdocs - bash .travis/install_sqlcl.sh - sudo mkdir -p /dev/pdbs - sudo chmod -R 777 /dev/pdbs @@ -111,9 +110,10 @@ notifications: jobs: include: - stage: deploy - env: CONNECTION_STR='127.0.0.1:1521/XE' + env: ORACLE_VERSION="none" before_install: skip - install: skip + install: + - pip install mkdocs before_script: skip script: - if [[ ($TRAVIS_BRANCH == develop) && ($TRAVIS_PULL_REQUEST == false) ]]; then bash trigger-travis.sh $TRAVIS_ACCESS_TOKEN; fi From b3f445692f569db99021a9c50f6487ed4295be6a Mon Sep 17 00:00:00 2001 From: Jacek Gebal Date: Sun, 8 Jul 2018 17:47:45 +0100 Subject: [PATCH 117/184] Fixed issue with references to `TRAVIS_JOB_NUMBER` in scripts. Testing execution of `.travis/trigger-travis.sh` --- .travis.yml | 5 +- .travis/push_docs_to_gh_pages.sh | 150 +++++++++++++++---------------- .travis/push_release_version.sh | 20 ++--- .travis/trigger_travis.sh | 5 +- 4 files changed, 85 insertions(+), 95 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4a6e03fa8..6e6357ef3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -116,7 +116,8 @@ jobs: - pip install mkdocs before_script: skip script: - - if [[ ($TRAVIS_BRANCH == develop) && ($TRAVIS_PULL_REQUEST == false) ]]; then bash trigger-travis.sh $TRAVIS_ACCESS_TOKEN; fi +# - if [[ ($TRAVIS_BRANCH == develop) && ($TRAVIS_PULL_REQUEST == false) ]]; then bash trigger-travis.sh $TRAVIS_ACCESS_TOKEN; fi + - bash .travis/trigger-travis.sh $TRAVIS_ACCESS_TOKEN #testing triggering - if [[ ! $TRAVIS_TAG ]]; then bash .travis/push_release_version.sh; fi - bash .travis/build_docs.sh - bash .travis/push_docs_to_gh_pages.sh @@ -134,5 +135,3 @@ jobs: on: repo: ${UTPLSQL_REPO} tags: true - # when building from a release tag, use only first job "#xxx.1" to publish artifacts - condition: "${TRAVIS_JOB_NUMBER} =~ \\.1$" diff --git a/.travis/push_docs_to_gh_pages.sh b/.travis/push_docs_to_gh_pages.sh index 86ee00310..d2c5a685c 100644 --- a/.travis/push_docs_to_gh_pages.sh +++ b/.travis/push_docs_to_gh_pages.sh @@ -17,87 +17,85 @@ PAGES_TARGET_BRANCH="gh-pages" LATEST_DOCS_BRANCH="develop" # TRAVIS_* variables are set by travis directly and only need to be if testing externally -# Since we are running job matrix, only thie first job slave will need to do the work -if [[ "${TRAVIS_JOB_NUMBER}" =~ \.1$ ]]; then - # We don't want a pull request automatically updating the repository - if [ "$TRAVIS_PULL_REQUEST" == "false" ] && { [ "${CURRENT_BRANCH}" == "${LATEST_DOCS_BRANCH}" ] || [ -n "${TRAVIS_TAG}" ]; }; then +# We don't want a pull request automatically updating the repository +if [ "$TRAVIS_PULL_REQUEST" == "false" ] && { [ "${CURRENT_BRANCH}" == "${LATEST_DOCS_BRANCH}" ] || [ -n "${TRAVIS_TAG}" ]; }; then - # ENV Variable checks are to help with configuration troubleshooting, they silently exit with unique message. - # Anyone one of them not set can be used to turn off this functionality. + # ENV Variable checks are to help with configuration troubleshooting, they silently exit with unique message. + # Anyone one of them not set can be used to turn off this functionality. - # If a version of the project is not defined - [[ -n "${UTPLSQL_VERSION}" ]] || { echo "variable UTPLSQL_VERSION is not defines or missing value"; exit 0; } - # Fail if the markdown documentation is not present. - [[ -f ./docs/index.md ]] || { echo "file docs/index.md not found"; exit 1; } + # If a version of the project is not defined + [[ -n "${UTPLSQL_VERSION}" ]] || { echo "variable UTPLSQL_VERSION is not defines or missing value"; exit 0; } + # Fail if the markdown documentation is not present. + [[ -f ./docs/index.md ]] || { echo "file docs/index.md not found"; exit 1; } - # Save some useful information - SHA=`git rev-parse --verify HEAD` + # Save some useful information + SHA=`git rev-parse --verify HEAD` - # clone the repository and switch to PAGES_TARGET_BRANCH branch - mkdir pages - cd pages - git clone https://${github_api_token}@github.com/${UTPLSQL_REPO} . + # clone the repository and switch to PAGES_TARGET_BRANCH branch + mkdir pages + cd pages + git clone https://${github_api_token}@github.com/${UTPLSQL_REPO} . - PAGES_BRANCH_EXISTS=$(git ls-remote --heads origin ${PAGES_TARGET_BRANCH}) + PAGES_BRANCH_EXISTS=$(git ls-remote --heads origin ${PAGES_TARGET_BRANCH}) - if [ -n "$PAGES_BRANCH_EXISTS" ] ; then - echo "Pages Branch Found" - git checkout ${PAGES_TARGET_BRANCH} - else - echo "Creating Pages Branch" - git checkout --orphan ${PAGES_TARGET_BRANCH} - git rm -rf . - fi - #clear out develop documentation directory and copy docs contents to it. - echo "updating 'develop' directory" - mkdir -p develop - rm -rf develop/**./* || exit 0 - cp -a ../docs/. ./develop - # If a Tagged Build then copy to it's own directory as well and to the 'latest' release directory - if [ -n "$TRAVIS_TAG" ]; then - echo "Creating ${UTPLSQL_VERSION}" - mkdir -p ${UTPLSQL_VERSION} - rm -rf ${UTPLSQL_VERSION}/**./* || exit 0 - cp -a ../docs/. ${UTPLSQL_VERSION} - echo "Populating 'latest' directory" - mkdir -p latest - rm -rf latest/**./* || exit 0 - cp -a ../docs/. latest - fi - # Stage changes for commit - git add . - #Check if there are doc changes, if none exit the script - if [[ -z `git diff HEAD --exit-code` ]] && [ -n "${PAGES_BRANCH_EXISTS}" ] ; then - echo "No changes to docs detected." - exit 0 - fi - #Changes where detected, so we need to update the version log. - now=$(date +"%d %b %Y - %r") - if [ ! -f index.md ]; then - echo "---" >>index.md - echo "layout: default" >>index.md - echo "---" >>index.md - echo "" >>index.md - echo "# Documentation versions" >>index.md - echo "" >>index.md - echo "" >>index.md #- 7th line - placeholder for latest release doc - echo "" >>index.md #- 8th line - placeholder for develop branch doc - echo "" >>index.md - echo "## Released Version Doc History" >>index.md - echo "" >>index.md - fi - #If build running on a TAG - it's a new release - need to add it to documentation - if [ -n "${TRAVIS_TAG}" ]; then - sed -i '7s@.*@'" - [Latest ${TRAVIS_TAG} documentation](latest/) - Created $now"'@' index.md - #add entry to the top of version history (line end of file - ## Released Version Doc History - sed -i '12i'" - [${TRAVIS_TAG} documentation](${UTPLSQL_VERSION}/) - Created $now" index.md - fi - #replace 4th line in log - sed -i '8s@.*@'" - [Latest development version](develop/) - Created $now"'@' index.md - #Add and Commit the changes back to pages repo. - git add . - git commit -m "Deploy to gh-pages branch: base commit ${SHA}" - # Now that we're all set up, we can push. - git push --quiet origin HEAD:${PAGES_TARGET_BRANCH} + if [ -n "$PAGES_BRANCH_EXISTS" ] ; then + echo "Pages Branch Found" + git checkout ${PAGES_TARGET_BRANCH} + else + echo "Creating Pages Branch" + git checkout --orphan ${PAGES_TARGET_BRANCH} + git rm -rf . fi + #clear out develop documentation directory and copy docs contents to it. + echo "updating 'develop' directory" + mkdir -p develop + rm -rf develop/**./* || exit 0 + cp -a ../docs/. ./develop + # If a Tagged Build then copy to it's own directory as well and to the 'latest' release directory + if [ -n "$TRAVIS_TAG" ]; then + echo "Creating ${UTPLSQL_VERSION}" + mkdir -p ${UTPLSQL_VERSION} + rm -rf ${UTPLSQL_VERSION}/**./* || exit 0 + cp -a ../docs/. ${UTPLSQL_VERSION} + echo "Populating 'latest' directory" + mkdir -p latest + rm -rf latest/**./* || exit 0 + cp -a ../docs/. latest + fi + # Stage changes for commit + git add . + #Check if there are doc changes, if none exit the script + if [[ -z `git diff HEAD --exit-code` ]] && [ -n "${PAGES_BRANCH_EXISTS}" ] ; then + echo "No changes to docs detected." + exit 0 + fi + #Changes where detected, so we need to update the version log. + now=$(date +"%d %b %Y - %r") + if [ ! -f index.md ]; then + echo "---" >>index.md + echo "layout: default" >>index.md + echo "---" >>index.md + echo "" >>index.md + echo "# Documentation versions" >>index.md + echo "" >>index.md + echo "" >>index.md #- 7th line - placeholder for latest release doc + echo "" >>index.md #- 8th line - placeholder for develop branch doc + echo "" >>index.md + echo "## Released Version Doc History" >>index.md + echo "" >>index.md + fi + #If build running on a TAG - it's a new release - need to add it to documentation + if [ -n "${TRAVIS_TAG}" ]; then + sed -i '7s@.*@'" - [Latest ${TRAVIS_TAG} documentation](latest/) - Created $now"'@' index.md + #add entry to the top of version history (line end of file - ## Released Version Doc History + sed -i '12i'" - [${TRAVIS_TAG} documentation](${UTPLSQL_VERSION}/) - Created $now" index.md + fi + #replace 4th line in log + sed -i '8s@.*@'" - [Latest development version](develop/) - Created $now"'@' index.md + #Add and Commit the changes back to pages repo. + git add . + git commit -m "Deploy to gh-pages branch: base commit ${SHA}" + # Now that we're all set up, we can push. + git push --quiet origin HEAD:${PAGES_TARGET_BRANCH} fi + diff --git a/.travis/push_release_version.sh b/.travis/push_release_version.sh index d0288f418..43ca773d8 100644 --- a/.travis/push_release_version.sh +++ b/.travis/push_release_version.sh @@ -5,19 +5,13 @@ # - branch name is = develop or branch name is like release/vX.X.X... if [ "${TRAVIS_REPO_SLUG}" = "${UTPLSQL_REPO}" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ] && [[ "${CURRENT_BRANCH}" =~ ^(release/v[0-9]+\.[0-9]+\.[0-9]+.*|develop)$ ]]; then echo Current branch is "${CURRENT_BRANCH}" - echo Current job number is "${TRAVIS_JOB_NUMBER}" - #The publishing is done only once (for first job on a build matrix) - if [[ "${TRAVIS_JOB_NUMBER}" =~ \.1$ ]]; then - echo "Committing version & buildNo into branch (${CURRENT_BRANCH})" - git add sonar-project.properties - git add VERSION - git add source/* - git commit -m 'Updated project version after build [skip ci]' - echo "Pushing to origin" - git push --quiet origin HEAD:${CURRENT_BRANCH} - else - echo "Publishing of version skipped for job No.: ${TRAVIS_JOB_NUMBER}" - fi + echo "Committing version & buildNo into branch (${CURRENT_BRANCH})" + git add sonar-project.properties + git add VERSION + git add source/* + git commit -m 'Updated project version after build [skip ci]' + echo "Pushing to origin" + git push --quiet origin HEAD:${CURRENT_BRANCH} else echo "Publishing of version skipped for branch ${CURRENT_BRANCH}, pull request ${TRAVIS_PULL_REQUEST}" fi diff --git a/.travis/trigger_travis.sh b/.travis/trigger_travis.sh index c7b9a7071..6625d90a7 100644 --- a/.travis/trigger_travis.sh +++ b/.travis/trigger_travis.sh @@ -29,9 +29,8 @@ else MESSAGE=",\"message\": \"Triggered manually from shell\"" fi -## For debugging: -# echo "TOKEN=$TOKEN" -# echo "MESSAGE=$MESSAGE" +# For debugging: +echo "MESSAGE=$MESSAGE" body="{ \"request\": { From 90b9db90874515ba7c4e5f7088e2528ac9b9216d Mon Sep 17 00:00:00 2001 From: Jacek Gebal Date: Sun, 8 Jul 2018 18:50:35 +0100 Subject: [PATCH 118/184] Fixing `travis.yml` config --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6e6357ef3..5aa44a443 100644 --- a/.travis.yml +++ b/.travis.yml @@ -116,8 +116,8 @@ jobs: - pip install mkdocs before_script: skip script: -# - if [[ ($TRAVIS_BRANCH == develop) && ($TRAVIS_PULL_REQUEST == false) ]]; then bash trigger-travis.sh $TRAVIS_ACCESS_TOKEN; fi - - bash .travis/trigger-travis.sh $TRAVIS_ACCESS_TOKEN #testing triggering +# - if [[ ($TRAVIS_BRANCH == develop) && ($TRAVIS_PULL_REQUEST == false) ]]; then bash .travis/trigger_travis.sh $TRAVIS_ACCESS_TOKEN; fi + - bash .travis/trigger_travis.sh $TRAVIS_ACCESS_TOKEN #testing triggering - if [[ ! $TRAVIS_TAG ]]; then bash .travis/push_release_version.sh; fi - bash .travis/build_docs.sh - bash .travis/push_docs_to_gh_pages.sh From a3db2a5223ee6ecb0940c2cd20731400bffd1fc9 Mon Sep 17 00:00:00 2001 From: Jacek Gebal Date: Sun, 8 Jul 2018 20:19:23 +0100 Subject: [PATCH 119/184] Update `travis.yml` config. Added `utPLSQL-maven-plugin` and `utPLSQL-demo-project` to be triggered automatically after the build is finished. --- .travis.yml | 3 +-- .travis/trigger_travis.sh | 8 ++++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5aa44a443..e9d632e70 100644 --- a/.travis.yml +++ b/.travis.yml @@ -116,8 +116,7 @@ jobs: - pip install mkdocs before_script: skip script: -# - if [[ ($TRAVIS_BRANCH == develop) && ($TRAVIS_PULL_REQUEST == false) ]]; then bash .travis/trigger_travis.sh $TRAVIS_ACCESS_TOKEN; fi - - bash .travis/trigger_travis.sh $TRAVIS_ACCESS_TOKEN #testing triggering + - if [[ ($TRAVIS_BRANCH == develop) && ($TRAVIS_PULL_REQUEST == false) ]]; then bash .travis/trigger_travis.sh $TRAVIS_ACCESS_TOKEN; fi - if [[ ! $TRAVIS_TAG ]]; then bash .travis/push_release_version.sh; fi - bash .travis/build_docs.sh - bash .travis/push_docs_to_gh_pages.sh diff --git a/.travis/trigger_travis.sh b/.travis/trigger_travis.sh index 6625d90a7..039b00bbb 100644 --- a/.travis/trigger_travis.sh +++ b/.travis/trigger_travis.sh @@ -19,7 +19,7 @@ TRAVIS_URL=travis-ci.org BRANCH=develop USER="utPLSQL" RESULT=1 -declare -a REPO_MATRIX=("utPLSQL-java-api" "utPLSQL-v2-v3-migration" "utPLSQL-cli") +declare -a REPO_MATRIX=("utPLSQL-java-api" "utPLSQL-v2-v3-migration" "utPLSQL-cli" "utPLSQL-maven-plugin" "utPLSQL-demo-project") TOKEN=$1 @@ -30,7 +30,7 @@ else fi # For debugging: -echo "MESSAGE=$MESSAGE" +#echo "MESSAGE=$MESSAGE" body="{ \"request\": { @@ -52,13 +52,13 @@ for DOWNSTREAM_BUILD in "${REPO_MATRIX[@]}"; do if grep -q '"@type": "error"' ${DOWNSTREAM_BUILD}-output.txt; then RESULT=0 echoerr "" - echoerr "Failed to start ${DOWNSTREAM_BUILD}" + echoerr "ERROR: Failed to start ${DOWNSTREAM_BUILD}" echoerr "" fi if grep -q 'access denied' ${DOWNSTREAM_BUILD}-output.txt; then RESULT=0 echoerr "" - echoerr "Failed to start ${DOWNSTREAM_BUILD}" + echoerr "ERROR: Failed to start ${DOWNSTREAM_BUILD} - access denied" echoerr "" fi From 50bacde2df5ee50386980f7b72dd285120a4b6bc Mon Sep 17 00:00:00 2001 From: Jacek Gebal Date: Sun, 8 Jul 2018 15:14:33 +0100 Subject: [PATCH 120/184] Resolves #649 New ability to use standalone/floating `--%beforeall`,`--%beforeeach`,`--%afterall`,`--%aftereach`. Now you can use multiple before/after and use mixed approach of procedure level or standalone annotation, depending on your needs and pattern chosen. Reworked package-level private data-types in suite_builder to make the code more readable. --- source/core/ut_suite_builder.pkb | 915 +++++++++++++++---------------- test/api/test_ut_run.pkb | 34 +- test/core/test_suite_builder.pkb | 271 ++++++++- test/core/test_suite_builder.pks | 119 +++- 4 files changed, 803 insertions(+), 536 deletions(-) diff --git a/source/core/ut_suite_builder.pkb b/source/core/ut_suite_builder.pkb index d8be844ee..bc2d20b36 100644 --- a/source/core/ut_suite_builder.pkb +++ b/source/core/ut_suite_builder.pkb @@ -23,15 +23,15 @@ create or replace package body ut_suite_builder is gc_suite constant t_annotation_name := 'suite'; gc_suitepath constant t_annotation_name := 'suitepath'; - gc_test constant t_annotation_name := 'test'; + gc_test constant t_annotation_name := ut_utils.gc_test_execute; gc_disabled constant t_annotation_name := 'disabled'; gc_displayname constant t_annotation_name := 'displayname'; - gc_beforeall constant t_annotation_name := 'beforeall'; - gc_beforeeach constant t_annotation_name := 'beforeeach'; - gc_beforetest constant t_annotation_name := 'beforetest'; - gc_afterall constant t_annotation_name := 'afterall'; - gc_aftereach constant t_annotation_name := 'aftereach'; - gc_aftertest constant t_annotation_name := 'aftertest'; + gc_beforeall constant t_annotation_name := ut_utils.gc_before_all; + gc_beforeeach constant t_annotation_name := ut_utils.gc_before_each; + gc_beforetest constant t_annotation_name := ut_utils.gc_before_test; + gc_afterall constant t_annotation_name := ut_utils.gc_after_all; + gc_aftereach constant t_annotation_name := ut_utils.gc_after_each; + gc_aftertest constant t_annotation_name := ut_utils.gc_after_test; gc_throws constant t_annotation_name := 'throws'; gc_rollback constant t_annotation_name := 'rollback'; gc_context constant t_annotation_name := 'context'; @@ -42,6 +42,19 @@ create or replace package body ut_suite_builder is gc_integer_exception constant varchar2(1) := 'I'; gc_named_exception constant varchar2(1) := 'N'; + 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, + procedure_name t_object_name + ); + + type tt_annotations_by_line is table of t_annotation index by t_annotation_position; + --list of annotation texts for a given annotation indexed by annotation position: --This would hold: ('some', 'other') for a single annotation name recurring in a single procedure example -- --%beforetest(some) @@ -50,109 +63,40 @@ create or replace package body ut_suite_builder is -- procedure some_test ... -- when you'd like to have two beforetest procedures executed in a single test type tt_annotation_texts is table of t_annotation_text index by t_annotation_position; + + type tt_annotations_by_name is table of tt_annotation_texts index by t_annotation_name; - type tt_procedure_annotations is table of tt_annotation_texts index by t_annotation_name; - - --holds information about - -- package level annotation - -- or - -- procedure and annotations associated with the procedure - type t_package_annotation is record( - text t_annotation_text, - name t_annotation_name, - procedure_name t_object_name, - procedure_annotations tt_procedure_annotations - ); - - --holds a list of package and procedure level annotations indexed (order) by position. - --procedure level annotations are grouped under procedure name - type tt_package_annotations is table of t_package_annotation index by t_annotation_position; + type tt_annotations_by_proc is table of tt_annotations_by_name index by t_object_name; - --holds all annotations for object - type t_package_annotations_info is record( - owner t_object_name, - name t_object_name, - annotations tt_package_annotations + type t_annotations_info is record ( + owner t_object_name, + name t_object_name, + by_line tt_annotations_by_line, + by_proc tt_annotations_by_proc, + by_name tt_annotations_by_name ); - --list of all package level annotation positions for a given annotaion name - type tt_package_annot_positions is table of boolean index by t_annotation_position; - --index used to lookup package level annotations by package-level annotation name - type tt_annotations_index is table of tt_package_annot_positions index by t_annotation_name; - - - ----------------------------------------------- - --- Conversion of annotations for processing - ----------------------------------------------- - function get_procedure_annotations(a_annotations ut_annotations, a_index in out nocopy binary_integer) return tt_procedure_annotations is - l_result tt_procedure_annotations; - l_index binary_integer := a_index; - l_annotation_pos binary_integer; - function is_last_annotation_for_proc(a_annotations ut_annotations, a_index binary_integer) return boolean is - begin - return a_index = a_annotations.count or a_annotations(a_index).subobject_name != nvl(a_annotations(a_index+1).subobject_name, ' '); - end; - begin - loop - l_annotation_pos := a_annotations(a_index).position; - l_result(a_annotations(a_index).name)(l_annotation_pos) := a_annotations(a_index).text; - exit when is_last_annotation_for_proc(a_annotations, a_index); - a_index := a_annotations.next(a_index); - end loop; - return l_result; - end; - - function convert_package_annotations(a_object ut_annotated_object) return t_package_annotations_info is - l_result t_package_annotations_info; - l_annotation_no binary_integer; - l_annotation_pos binary_integer; - begin - l_result.owner := a_object.object_owner; - l_result.name := lower(trim(a_object.object_name)); - l_annotation_no := a_object.annotations.first; - while l_annotation_no is not null loop - l_annotation_pos := a_object.annotations(l_annotation_no).position; - if a_object.annotations(l_annotation_no).subobject_name is null then - l_result.annotations(l_annotation_pos).name := a_object.annotations(l_annotation_no).name; - l_result.annotations(l_annotation_pos).text := a_object.annotations(l_annotation_no).text; - else - l_result.annotations(l_annotation_pos).procedure_name := lower(trim(a_object.annotations(l_annotation_no).subobject_name)); - l_result.annotations(l_annotation_pos).procedure_annotations := get_procedure_annotations(a_object.annotations, l_annotation_no); - end if; - l_annotation_no := a_object.annotations.next(l_annotation_no); - end loop; - return l_result; - end; - - function build_annotation_index(a_annotations tt_package_annotations ) return tt_annotations_index is - l_result tt_annotations_index; - l_annotation_pos binary_integer; - begin - l_annotation_pos := a_annotations.first; - while l_annotation_pos is not null loop - if a_annotations( l_annotation_pos ).name is not null then - l_result(a_annotations( l_annotation_pos ).name)( l_annotation_pos ) := true; - end if; - l_annotation_pos := a_annotations.next( l_annotation_pos ); - end loop; - return l_result; - end; - - procedure delete_from_annotation_index( - a_index in out nocopy tt_annotations_index, - a_start_pos t_annotation_position, - a_end_pos t_annotation_position + procedure delete_annotations_range( + a_annotations in out nocopy t_annotations_info, + a_start_pos t_annotation_position, + a_end_pos t_annotation_position ) is - l_idx t_annotation_name; + l_pos t_annotation_position := a_start_pos; + l_annotation t_annotation; begin - l_idx := a_index.first; - while l_idx is not null loop - a_index( l_idx ).delete( a_start_pos, a_end_pos); - if a_index( l_idx ).count = 0 then - a_index.delete( l_idx ); + while l_pos is not null and l_pos <= a_end_pos loop + l_annotation := a_annotations.by_line(l_pos); + if l_annotation.procedure_name is not null and a_annotations.by_proc.exists(l_annotation.procedure_name) then + a_annotations.by_proc.delete(l_annotation.procedure_name); + elsif a_annotations.by_name.exists(l_annotation.name) then + a_annotations.by_name(l_annotation.name).delete(l_pos); + if a_annotations.by_name(l_annotation.name).count = 0 then + a_annotations.by_name.delete(l_annotation.name); + end if; end if; - l_idx := a_index.next( l_idx ); + l_pos := a_annotations.by_line.next( l_pos ); end loop; + a_annotations.by_line.delete(a_start_pos, a_end_pos); end; ----------------------------------------------- @@ -180,7 +124,6 @@ create or replace package body ut_suite_builder is a_line_no binary_integer, a_procedure_name t_object_name := null ) is - l_object_name varchar2(1000); begin a_suite.put_warning( replace(a_message,'%%%','"--%'||a_annotation||'"') || ' Annotation ignored.' @@ -199,120 +142,121 @@ create or replace package body ut_suite_builder is return l_rollback_type; end; - function check_exception_type(a_exception_name in varchar2) return varchar2 is + procedure add_to_throws_numbers_list( + a_suite in out nocopy ut_suite, + a_list in out nocopy ut_integer_list, + a_procedure_name t_object_name, + a_throws_ann_text tt_annotation_texts + ) is + l_annotation_pos binary_integer; + + function is_valid_qualified_name (a_name varchar2) return boolean is + l_name varchar2(500); + begin + l_name := dbms_assert.qualified_sql_name(a_name); + return true; + exception when others then + return false; + end; + + function check_exception_type(a_exception_name in varchar2) return varchar2 is l_exception_type varchar2(50); begin --check if it is a predefined exception begin execute immediate 'begin null; exception when '||a_exception_name||' then null; end;'; l_exception_type := gc_named_exception; - exception + exception when others then - if dbms_utility.format_error_stack() like '%PLS-00485%' then - begin - execute immediate 'declare x positiven := -('||a_exception_name||'); begin null; end;'; - l_exception_type := gc_integer_exception; + if dbms_utility.format_error_stack() like '%PLS-00485%' then + begin + execute immediate 'declare x positiven := -('||a_exception_name||'); begin null; end;'; + l_exception_type := gc_integer_exception; exception - when others then - --invalid exception number (positive) - --TODO add warning for this value - null; - end; - end if; + when others then + --invalid exception number (positive) + --TODO add warning for this value + null; + end; + end if; end; return l_exception_type; - end; + end; - function get_exception_number (a_exception_var in varchar2) return integer is - l_exc_no integer; - l_exc_type varchar2(50); - l_sql varchar2(32767); - function remap_no_data_found (a_number integer) return integer is + function get_exception_number (a_exception_var in varchar2) return integer is + l_exc_no integer; + l_exc_type varchar2(50); + l_sql varchar2(32767); + function remap_no_data_found (a_number integer) return integer is + begin + return case a_number when 100 then -1403 else a_number end; + end; begin - return case a_number when 100 then -1403 else a_number end; - end; - begin - l_exc_type := check_exception_type(a_exception_var); - - if l_exc_type is not null then - - execute immediate - case l_exc_type - when gc_integer_exception then - 'declare - l_exception number; - begin - :l_exception := '||a_exception_var||'; ' - when gc_named_exception then - 'begin - raise '||a_exception_var||'; - exception - when others then - :l_exception := sqlcode; ' - end || - 'end;' - using out l_exc_no; + l_exc_type := check_exception_type(a_exception_var); - end if; - return remap_no_data_found(l_exc_no); - end; + if l_exc_type is not null then - function is_valid_qualified_name (a_name varchar2) return boolean is - l_name varchar2(500); - begin - l_name:=dbms_assert.qualified_sql_name(a_name); - return true; - exception when others then - return false; - end; - - function build_exception_numbers_list( - a_suite in out nocopy ut_suite, - a_procedure_name t_object_name, - a_line_no integer, - a_annotation_text in varchar2 - ) return ut_integer_list is - l_throws_list ut_varchar2_list; - l_exception_number integer; - l_exception_number_list ut_integer_list := ut_integer_list(); - c_regexp_for_exception_no constant varchar2(30) := '^-?[[:digit:]]{1,5}$'; - begin - /*the a_expected_error_codes is converted to a ut_varchar2_list after that is trimmed and filtered to left only valid exception numbers*/ - l_throws_list := ut_utils.trim_list_elements(ut_utils.string_to_table(a_annotation_text, ',', 'Y')); - - for i in 1 .. l_throws_list.count - loop - /** - * Check if its a valid qualified name and if so try to resolve name to an exception number - */ - if is_valid_qualified_name(l_throws_list(i)) then - l_exception_number := get_exception_number(l_throws_list(i)); - elsif regexp_like(l_throws_list(i), c_regexp_for_exception_no) then - l_exception_number := l_throws_list(i); - end if; + execute immediate + case l_exc_type + when gc_integer_exception then + 'declare + l_exception number; + begin + :l_exception := '||a_exception_var||'; ' + when gc_named_exception then + 'begin + raise '||a_exception_var||'; + exception + when others then + :l_exception := sqlcode; ' + end || + 'end;' + using out l_exc_no; - if l_exception_number is null then - a_suite.put_warning( - 'Invalid parameter value "'||l_throws_list(i)||'" for "--%throws" annotation. Parameter ignored.' - || chr( 10 ) || 'at "' || get_qualified_object_name(a_suite, a_procedure_name) || '", line ' || a_line_no - ); - else - l_exception_number_list.extend; - l_exception_number_list(l_exception_number_list.last) := l_exception_number; end if; - l_exception_number := null; - end loop; - - return l_exception_number_list; - end; + return remap_no_data_found(l_exc_no); + end; + + function build_exception_numbers_list( + a_suite in out nocopy ut_suite, + a_procedure_name t_object_name, + a_line_no integer, + a_annotation_text in varchar2 + ) return ut_integer_list is + l_throws_list ut_varchar2_list; + l_exception_number integer; + l_exception_number_list ut_integer_list := ut_integer_list(); + c_regexp_for_exception_no constant varchar2(30) := '^-?[[:digit:]]{1,5}$'; + begin + /*the a_expected_error_codes is converted to a ut_varchar2_list after that is trimmed and filtered to left only valid exception numbers*/ + l_throws_list := ut_utils.trim_list_elements(ut_utils.string_to_table(a_annotation_text, ',', 'Y')); + + for i in 1 .. l_throws_list.count + loop + /** + * Check if its a valid qualified name and if so try to resolve name to an exception number + */ + if is_valid_qualified_name(l_throws_list(i)) then + l_exception_number := get_exception_number(l_throws_list(i)); + elsif regexp_like(l_throws_list(i), c_regexp_for_exception_no) then + l_exception_number := l_throws_list(i); + end if; + + if l_exception_number is null then + a_suite.put_warning( + 'Invalid parameter value "'||l_throws_list(i)||'" for "--%throws" annotation. Parameter ignored.' + || chr( 10 ) || 'at "' || get_qualified_object_name(a_suite, a_procedure_name) || '", line ' || a_line_no + ); + else + l_exception_number_list.extend; + l_exception_number_list(l_exception_number_list.last) := l_exception_number; + end if; + l_exception_number := null; + end loop; + + return l_exception_number_list; + end; - procedure add_to_throws_numbers_list( - a_suite in out nocopy ut_suite, - a_list in out nocopy ut_integer_list, - a_procedure_name t_object_name, - a_throws_ann_text tt_annotation_texts - ) is - l_annotation_pos binary_integer; begin a_list := ut_integer_list(); l_annotation_pos := a_throws_ann_text.first; @@ -336,7 +280,34 @@ create or replace package body ut_suite_builder is end loop; end; - procedure add_to_list( + function convert_list( + 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 + l_result := l_result multiset union all a_list(l_pos); + l_pos := a_list.next(l_pos); + end loop; + return l_result; + end; + + function convert_list( + a_list tt_tests + ) return ut_suite_items is + l_result ut_suite_items := ut_suite_items(); + l_pos t_annotation_position := a_list.first; + begin + while l_pos is not null loop + l_result.extend; + l_result(l_result.last) := a_list(l_pos); + l_pos := a_list.next(l_pos); + end loop; + return l_result; + end; + + procedure add_executable( a_executables in out nocopy ut_executables, a_owner t_object_name, a_package_name t_object_name, @@ -351,51 +322,59 @@ create or replace package body ut_suite_builder is a_executables(a_executables.last) := ut_executable(a_owner, a_package_name, a_procedure_name, a_executable_type); end; - procedure add_all_to_list( - a_executables in out nocopy ut_executables, + function add_executables( a_owner t_object_name, a_package_name t_object_name, a_annotation_texts tt_annotation_texts, a_event_name ut_utils.t_event_name - ) is - l_string_buffer varchar2(32767); - l_annotation_pos binary_integer; + ) return tt_executables is + l_executables ut_executables; + l_result tt_executables; + l_annotation_pos binary_integer; l_procedures_list ut_varchar2_list; - l_procedures_pos binary_integer; + l_procedures_pos binary_integer; l_components_list ut_varchar2_list; begin l_annotation_pos := a_annotation_texts.first; while l_annotation_pos is not null loop - l_string_buffer := l_string_buffer||','||a_annotation_texts(l_annotation_pos); + l_procedures_list := + ut_utils.filter_list( + ut_utils.trim_list_elements( + ut_utils.string_to_table(a_annotation_texts(l_annotation_pos), ',') + ) + , '[[:alpha:]]+' + ); + + l_procedures_pos := l_procedures_list.first; + l_executables := ut_executables(); + while l_procedures_pos is not null loop + l_components_list := ut_utils.string_to_table(l_procedures_list(l_procedures_pos), '.'); + + l_executables.extend; + l_executables(l_executables.last) := + case(l_components_list.count()) + when 1 then + ut_executable(a_owner, a_package_name, l_components_list(1), a_event_name) + when 2 then + ut_executable(a_owner,l_components_list(1), l_components_list(2), a_event_name) + when 3 then + ut_executable(l_components_list(1), l_components_list(2), l_components_list(3), a_event_name) + else + null + end; + l_procedures_pos := l_procedures_list.next(l_procedures_pos); + end loop; + l_result(l_annotation_pos) := l_executables; l_annotation_pos := a_annotation_texts.next(l_annotation_pos); end loop; - - l_procedures_list := ut_utils.trim_list_elements(ut_utils.string_to_table(l_string_buffer, ',')); - l_procedures_list := ut_utils.filter_list(l_procedures_list, '[[:alpha:]]+'); - - l_procedures_pos := l_procedures_list.first; - while l_procedures_pos is not null loop - l_components_list := ut_utils.string_to_table(l_procedures_list(l_procedures_pos), '.'); - - case(l_components_list.count()) - when 1 then - add_to_list(a_executables, a_owner, a_package_name, l_components_list(1), a_event_name ); - when 2 then - add_to_list(a_executables, a_owner, l_components_list(1), l_components_list(2), a_event_name ); - when 3 then - add_to_list(a_executables, l_components_list(1), l_components_list(2), l_components_list(3), a_event_name ); - else - null; - end case; - - l_procedures_pos := l_procedures_list.next(l_procedures_pos); - end loop; + return l_result; end; procedure warning_on_duplicate_annot( a_suite in out nocopy ut_suite_item, - a_annotations tt_annotations_index, - a_for_annotation varchar2 + a_annotations tt_annotations_by_name, + a_for_annotation varchar2, + a_procedure_name t_object_name := null ) is l_annotation_name t_annotation_name; l_line_no binary_integer; @@ -405,38 +384,17 @@ create or replace package body ut_suite_builder is --start from second occurrence of annotation l_line_no := a_annotations(a_for_annotation).next( a_annotations(a_for_annotation).first ); while l_line_no is not null loop - add_annotation_ignored_warning( a_suite, a_for_annotation, 'Duplicate annotation %%%.', l_line_no ); + add_annotation_ignored_warning( a_suite, a_for_annotation, 'Duplicate annotation %%%.', l_line_no, a_procedure_name ); l_line_no := a_annotations(a_for_annotation).next( l_line_no ); end loop; end if; end if; end; - procedure warning_on_duplicate_annot( - a_suite in out nocopy ut_suite_item, - a_procedure_name t_object_name, - a_annotations tt_procedure_annotations, - a_for_annotation varchar2 - ) is - l_annotation_name t_annotation_name; - l_line_no binary_integer; - begin - if a_annotations.exists(a_for_annotation) then - if a_annotations(a_for_annotation).count > 1 then - --start from second occurrence of annotation - l_line_no := a_annotations(a_for_annotation).next( a_annotations(a_for_annotation).first ); - while l_line_no is not null loop - add_annotation_ignored_warning( a_suite, a_for_annotation, 'Duplicate annotation %%%.', l_line_no, a_procedure_name ); - l_line_no := a_annotations(a_for_annotation).next( l_line_no ); - end loop; - end if; - end if; - end; - procedure warning_bad_annot_combination( a_suite in out nocopy ut_suite_item, a_procedure_name t_object_name, - a_proc_annotations tt_procedure_annotations, + a_proc_annotations tt_annotations_by_name, a_for_annotation varchar2, a_invalid_annotations ut_varchar2_list ) is @@ -444,45 +402,59 @@ create or replace package body ut_suite_builder is l_warning varchar2(32767); l_line_no binary_integer; begin - l_annotation_name := a_proc_annotations.first; - while l_annotation_name is not null loop - if l_annotation_name member of a_invalid_annotations then - l_line_no := a_proc_annotations(l_annotation_name).first; - while l_line_no is not null loop - add_annotation_ignored_warning( - a_suite, l_annotation_name, 'Annotation %%% cannot be used with "--%'|| a_for_annotation || '".', - l_line_no, a_procedure_name - ); - l_line_no := a_proc_annotations(l_annotation_name).next(l_line_no); - end loop; - end if; - l_annotation_name := a_proc_annotations.next(l_annotation_name); - end loop; + if a_proc_annotations.exists(a_for_annotation) then + l_annotation_name := a_proc_annotations.first; + while l_annotation_name is not null loop + if l_annotation_name member of a_invalid_annotations then + l_line_no := a_proc_annotations(l_annotation_name).first; + while l_line_no is not null loop + add_annotation_ignored_warning( + a_suite, l_annotation_name, 'Annotation %%% cannot be used with "--%'|| a_for_annotation || '".', + l_line_no, a_procedure_name + ); + l_line_no := a_proc_annotations(l_annotation_name).next(l_line_no); + end loop; + end if; + l_annotation_name := a_proc_annotations.next(l_annotation_name); + end loop; + end if; end; procedure add_test( - a_suite in out nocopy ut_suite, - a_procedure_name t_object_name, - a_annotations tt_procedure_annotations + a_suite in out nocopy ut_suite, + a_tests in out nocopy tt_tests, + a_procedure_name t_object_name, + a_proc_annotations tt_annotations_by_name ) is l_test ut_test; l_annotation_texts tt_annotation_texts; l_annotation_pos binary_integer; begin + if not a_proc_annotations.exists(gc_test) then + return; + end if; + warning_on_duplicate_annot(a_suite, a_proc_annotations, gc_test, a_procedure_name); + warning_on_duplicate_annot(a_suite, a_proc_annotations, gc_displayname, a_procedure_name); + warning_on_duplicate_annot(a_suite, a_proc_annotations, gc_rollback, a_procedure_name); + warning_bad_annot_combination( + a_suite, a_procedure_name, a_proc_annotations, gc_test, + ut_varchar2_list(gc_beforeeach, gc_aftereach, gc_beforeall, gc_afterall) + ); + l_test := ut_test(a_suite.object_owner, a_suite.object_name, a_procedure_name); - if a_annotations.exists(gc_displayname) then - l_annotation_texts := a_annotations(gc_displayname); + if a_proc_annotations.exists(gc_displayname) then + l_annotation_texts := a_proc_annotations(gc_displayname); --take the last definition if more than one was provided l_test.description := l_annotation_texts(l_annotation_texts.first); --TODO if more than one - warning else - l_test.description := a_annotations(gc_test)(a_annotations(gc_test).first); + l_test.description := a_proc_annotations(gc_test)(a_proc_annotations(gc_test).first); end if; l_test.path := a_suite.path ||'.'||a_procedure_name; - if a_annotations.exists(gc_rollback) then - l_annotation_texts := a_annotations(gc_rollback); + if a_proc_annotations.exists(gc_rollback) then + l_annotation_texts := a_proc_annotations(gc_rollback); l_test.rollback_type := get_rollback_type(l_annotation_texts(l_annotation_texts.first)); if l_test.rollback_type is null then add_annotation_ignored_warning( @@ -492,24 +464,28 @@ create or replace package body ut_suite_builder is end if; end if; - if a_annotations.exists(gc_beforetest) then - add_all_to_list( l_test.before_test_list, l_test.object_owner, l_test.object_name, a_annotations(gc_beforetest), ut_utils.gc_before_test ); + if a_proc_annotations.exists(gc_beforetest) then + l_test.before_test_list := convert_list( + add_executables( l_test.object_owner, l_test.object_name, a_proc_annotations( gc_beforetest ), gc_beforetest ) + ); end if; - if a_annotations.exists(gc_aftertest) then - add_all_to_list( l_test.after_test_list, l_test.object_owner, l_test.object_name, a_annotations(gc_aftertest), ut_utils.gc_after_test ); + if a_proc_annotations.exists(gc_aftertest) then + l_test.after_test_list := convert_list( + add_executables( l_test.object_owner, l_test.object_name, a_proc_annotations( gc_aftertest ), gc_aftertest ) + ); end if; - if a_annotations.exists(gc_throws) then - add_to_throws_numbers_list(a_suite, l_test.expected_error_codes, a_procedure_name, a_annotations(gc_throws)); + if a_proc_annotations.exists(gc_throws) then + add_to_throws_numbers_list(a_suite, l_test.expected_error_codes, a_procedure_name, a_proc_annotations(gc_throws)); end if; - l_test.disabled_flag := ut_utils.boolean_to_int(a_annotations.exists(gc_disabled)); + l_test.disabled_flag := ut_utils.boolean_to_int(a_proc_annotations.exists(gc_disabled)); - a_suite.add_item(l_test); + a_tests(a_proc_annotations(gc_test).first) := l_test; end; - procedure update_before_after_list( + procedure update_before_after_each( a_suite in out nocopy ut_logical_suite, - a_before_each_list ut_executables, - a_after_each_list ut_executables + a_before_each_list tt_executables, + a_after_each_list tt_executables ) is l_test ut_test; l_context ut_logical_suite; @@ -518,307 +494,298 @@ 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(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(a_after_each_list,ut_executables()); + 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()); 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); - update_before_after_list(l_context, a_before_each_list, a_after_each_list); + update_before_after_each(l_context, a_before_each_list, a_after_each_list); a_suite.items(i) := l_context; end if; end loop; end if; end; - procedure add_annotated_procedure( + procedure process_before_after_annot( + a_list in out nocopy tt_executables, + a_annotation_name t_annotation_name, a_procedure_name t_object_name, - a_proc_annotations tt_procedure_annotations, - a_suite in out nocopy ut_suite, - a_before_each_list in out nocopy ut_executables, - a_after_each_list in out nocopy ut_executables - ) is + a_proc_annotations tt_annotations_by_name, + a_suite in out nocopy ut_suite + ) is begin - warning_on_duplicate_annot(a_suite, a_procedure_name, a_proc_annotations, gc_test); - warning_on_duplicate_annot(a_suite, a_procedure_name, a_proc_annotations, gc_displayname); - warning_on_duplicate_annot(a_suite, a_procedure_name, a_proc_annotations, gc_rollback); - warning_on_duplicate_annot(a_suite, a_procedure_name, a_proc_annotations, gc_beforeall); - warning_on_duplicate_annot(a_suite, a_procedure_name, a_proc_annotations, gc_beforeeach); - warning_on_duplicate_annot(a_suite, a_procedure_name, a_proc_annotations, gc_afterall); - warning_on_duplicate_annot(a_suite, a_procedure_name, a_proc_annotations, gc_aftereach); - - if a_proc_annotations.exists(gc_test) then - add_test( a_suite, a_procedure_name, a_proc_annotations); - - warning_bad_annot_combination( - a_suite, a_procedure_name, a_proc_annotations, gc_test, - ut_varchar2_list(gc_beforeeach, gc_aftereach, gc_beforeall, gc_afterall) - ); - - else - if a_proc_annotations.exists(gc_beforeeach) then - add_to_list( a_before_each_list, a_suite.object_owner, a_suite.object_name, a_procedure_name, ut_utils.gc_before_each ); - --TODO add warning if annotation has text - text ignored - end if; - if a_proc_annotations.exists(gc_aftereach) then - add_to_list( a_after_each_list, a_suite.object_owner, a_suite.object_name, a_procedure_name, ut_utils.gc_after_each ); - --TODO add warning if annotation has text - text ignored - end if; - if a_proc_annotations.exists(gc_beforeall) then - add_to_list( a_suite.before_all_list, a_suite.object_owner, a_suite.object_name, a_procedure_name, ut_utils.gc_before_all ); - --TODO add warning if annotation has text - text ignored - end if; - if a_proc_annotations.exists(gc_afterall) then - add_to_list( a_suite.after_all_list, a_suite.object_owner, a_suite.object_name, a_procedure_name, ut_utils.gc_after_all ); - --TODO add warning if annotation has text - text ignored - end if; + if a_proc_annotations.exists(a_annotation_name) and not a_proc_annotations.exists(gc_test) then + a_list( a_proc_annotations(a_annotation_name).first ) := ut_executables(ut_executable(a_suite.object_owner, a_suite.object_name, a_procedure_name, a_annotation_name)); + warning_on_duplicate_annot(a_suite, a_proc_annotations, a_annotation_name, a_procedure_name); + --TODO add warning if annotation has text - text ignored end if; end; procedure add_annotated_procedures( - a_annotations tt_package_annotations, - a_suite in out nocopy ut_suite, - a_before_each_list out nocopy ut_executables, - a_after_each_list out nocopy ut_executables + a_proc_annotations tt_annotations_by_proc, + a_suite in out nocopy ut_suite, + a_before_each_list in out nocopy tt_executables, + a_after_each_list in out nocopy tt_executables, + a_before_all_list in out nocopy tt_executables, + a_after_all_list in out nocopy tt_executables ) is - l_position t_annotation_position; + l_procedure_name t_object_name; + l_tests tt_tests; begin - a_before_each_list := ut_executables(); - a_after_each_list := ut_executables(); - l_position := a_annotations.first; - while l_position is not null loop - if a_annotations(l_position).procedure_name is not null then - add_annotated_procedure( - a_annotations(l_position).procedure_name, - a_annotations(l_position).procedure_annotations, - a_suite, - a_before_each_list, - a_after_each_list - ); - end if; - l_position := a_annotations.next( l_position); + l_procedure_name := a_proc_annotations.first; + while l_procedure_name is not null loop + add_test( a_suite, l_tests, l_procedure_name, a_proc_annotations(l_procedure_name) ); + process_before_after_annot(a_before_each_list, gc_beforeeach, l_procedure_name, a_proc_annotations(l_procedure_name), a_suite); + process_before_after_annot(a_after_each_list, gc_aftereach, l_procedure_name, a_proc_annotations(l_procedure_name), a_suite); + process_before_after_annot(a_before_all_list, gc_beforeall, l_procedure_name, a_proc_annotations(l_procedure_name), a_suite); + process_before_after_annot(a_after_all_list, gc_afterall, l_procedure_name, a_proc_annotations(l_procedure_name), a_suite); + l_procedure_name := a_proc_annotations.next( l_procedure_name ); end loop; + a_suite.items := a_suite.items multiset union all convert_list(l_tests); end; - procedure populate_suite_contents( + procedure build_suitepath( a_suite in out nocopy ut_suite, - a_annotations tt_package_annotations, - a_package_ann_index tt_annotations_index, - a_context_name t_object_name := null + a_annotations t_annotations_info ) is - l_before_each_list ut_executables; - l_after_each_list ut_executables; - l_rollback_type ut_utils.t_rollback_type; - l_annotation_text varchar2(32767); - l_object_name t_object_name; + l_annotation_text t_annotation_text; begin - if a_context_name is not null then - l_object_name := a_suite.object_name||'.'||a_context_name; - else - l_object_name := a_suite.object_name; - end if; - if a_package_ann_index.exists(gc_suitepath) then - l_annotation_text := trim(a_annotations(a_package_ann_index(gc_suitepath).first).text); + if a_annotations.by_name.exists(gc_suitepath) then + l_annotation_text := trim(a_annotations.by_name(gc_suitepath)(a_annotations.by_name(gc_suitepath).first)); if l_annotation_text is not null then if regexp_like(l_annotation_text,'^((\w|[$#])+\.)*(\w|[$#])+$') then - a_suite.path := l_annotation_text||'.'||l_object_name; + a_suite.path := l_annotation_text||'.'||a_suite.object_name; else add_annotation_ignored_warning( - a_suite, gc_suitepath||'('||l_annotation_text||')', - 'Invalid path value in annotation %%%.', a_package_ann_index(gc_suitepath).first + a_suite, gc_suitepath||'('||l_annotation_text||')', + 'Invalid path value in annotation %%%.', a_annotations.by_name(gc_suitepath).first ); end if; else add_annotation_ignored_warning( - a_suite, gc_suitepath, '%%% annotation requires a non-empty parameter value.', - a_package_ann_index(gc_suitepath).first + a_suite, gc_suitepath, '%%% annotation requires a non-empty parameter value.', + a_annotations.by_name(gc_suitepath).first ); end if; - warning_on_duplicate_annot(a_suite, a_package_ann_index, gc_suitepath); + warning_on_duplicate_annot(a_suite, a_annotations.by_name, gc_suitepath); end if; - a_suite.path := lower(coalesce(a_suite.path, l_object_name)); + a_suite.path := lower(coalesce(a_suite.path, a_suite.object_name)); + end; - if a_package_ann_index.exists(gc_displayname) then - l_annotation_text := trim(a_annotations(a_package_ann_index(gc_displayname).first).text); + procedure populate_suite_contents( + a_suite in out nocopy ut_suite, + a_annotations t_annotations_info + ) is + l_before_each_list tt_executables; + l_after_each_list tt_executables; + l_before_all_list tt_executables; + l_after_all_list tt_executables; + l_executables ut_executables; + l_rollback_type ut_utils.t_rollback_type; + l_annotation_text t_annotation_text; + begin + if a_annotations.by_name.exists(gc_displayname) then + l_annotation_text := trim(a_annotations.by_name(gc_displayname)(a_annotations.by_name(gc_displayname).first)); if l_annotation_text is not null then a_suite.description := l_annotation_text; else add_annotation_ignored_warning( a_suite, gc_displayname, '%%% annotation requires a non-empty parameter value.', - a_package_ann_index(gc_displayname).first + a_annotations.by_name(gc_displayname).first ); end if; - warning_on_duplicate_annot(a_suite, a_package_ann_index, gc_displayname); + warning_on_duplicate_annot(a_suite, a_annotations.by_name, gc_displayname); end if; - if a_package_ann_index.exists(gc_rollback) then - l_rollback_type := get_rollback_type(a_annotations(a_package_ann_index(gc_rollback).first).text); + if a_annotations.by_name.exists(gc_rollback) then + l_rollback_type := get_rollback_type(a_annotations.by_name(gc_rollback)(a_annotations.by_name(gc_rollback).first)); if l_rollback_type is null then add_annotation_ignored_warning( a_suite, gc_rollback, '%%% annotation requires one of values as parameter: "auto" or "manual".', - a_package_ann_index(gc_rollback).first + a_annotations.by_name(gc_rollback).first ); end if; - warning_on_duplicate_annot(a_suite, a_package_ann_index, gc_rollback); + warning_on_duplicate_annot(a_suite, a_annotations.by_name, gc_rollback); + end if; + if a_annotations.by_name.exists(gc_beforeall) then + l_before_all_list := add_executables( a_suite.object_owner, a_suite.object_name, a_annotations.by_name(gc_beforeall), gc_beforeall ); + end if; + if a_annotations.by_name.exists(gc_afterall) then + l_after_all_list := add_executables( a_suite.object_owner, a_suite.object_name, a_annotations.by_name(gc_afterall), gc_afterall ); end if; - a_suite.disabled_flag := ut_utils.boolean_to_int(a_package_ann_index.exists(gc_disabled)); + if a_annotations.by_name.exists(gc_beforeeach) then + l_before_each_list := add_executables( a_suite.object_owner, a_suite.object_name, a_annotations.by_name(gc_beforeeach), gc_beforeeach ); + end if; + if a_annotations.by_name.exists(gc_aftereach) then + l_after_each_list := add_executables( a_suite.object_owner, a_suite.object_name, a_annotations.by_name(gc_aftereach), gc_aftereach ); + end if; + + a_suite.disabled_flag := ut_utils.boolean_to_int(a_annotations.by_name.exists(gc_disabled)); --process procedure annotations for suite - add_annotated_procedures(a_annotations, a_suite, l_before_each_list, l_after_each_list); + add_annotated_procedures(a_annotations.by_proc, a_suite, l_before_each_list, l_after_each_list, l_before_all_list, l_after_all_list); a_suite.set_rollback_type(l_rollback_type); - update_before_after_list(a_suite, l_before_each_list, l_after_each_list); + update_before_after_each(a_suite, l_before_each_list, l_after_each_list); + a_suite.before_all_list := convert_list(l_before_all_list); + a_suite.after_all_list := convert_list(l_after_all_list); end; procedure add_suite_contexts( a_suite in out nocopy ut_suite, - a_annotations in out nocopy tt_package_annotations, - a_package_ann_index in out nocopy tt_annotations_index + a_annotations in out nocopy t_annotations_info ) is l_context_pos t_annotation_position; l_end_context_pos t_annotation_position; - l_context_ann_index tt_annotations_index; l_context_name t_object_name; - l_annotations tt_package_annotations; + l_ctx_annotations t_annotations_info; l_context ut_suite_context; l_context_no binary_integer := 1; function get_endcontext_position( - a_context_ann_pos t_annotation_position, - a_package_ann_index in out nocopy tt_annotations_index + a_context_ann_pos t_annotation_position, + a_package_annotations in out nocopy tt_annotations_by_name ) return t_annotation_position is l_result t_annotation_position; begin - if a_package_ann_index.exists(gc_endcontext) then - l_result := a_package_ann_index(gc_endcontext).first; + if a_package_annotations.exists(gc_endcontext) then + l_result := a_package_annotations(gc_endcontext).first; while l_result <= a_context_ann_pos loop - --remove invalid endcontext - delete_from_annotation_index(a_package_ann_index, l_result, l_result); - --remove the bad endcontext from index - l_result := a_package_ann_index(gc_endcontext).next(l_result); + l_result := a_package_annotations(gc_endcontext).next(l_result); end loop; end if; return l_result; end; function get_annotations_in_context( - a_annotations tt_package_annotations, + a_annotations t_annotations_info, a_context_pos t_annotation_position, a_end_context_pos t_annotation_position - ) return tt_package_annotations is - l_annotations tt_package_annotations; - l_position t_annotation_position; + ) return t_annotations_info is + l_result t_annotations_info; + l_position t_annotation_position; + l_procedure_name t_object_name; + l_annotation_name t_annotation_name; + l_annotation_text t_annotation_text; begin l_position := a_context_pos; + l_result.owner := a_annotations.owner; + l_result.name := a_annotations.name; while l_position is not null and l_position <= a_end_context_pos loop - l_annotations(l_position) := a_annotations(l_position); - l_position := a_annotations.next(l_position); + l_result.by_line(l_position) := a_annotations.by_line(l_position); + l_procedure_name := l_result.by_line(l_position).procedure_name; + l_annotation_name := l_result.by_line(l_position).name; + l_annotation_text := l_result.by_line(l_position).text; + if l_procedure_name is not null then + l_result.by_proc(l_procedure_name)(l_annotation_name)(l_position) := l_annotation_text; + else + l_result.by_name(l_annotation_name)(l_position) := l_annotation_text; + end if; + l_position := a_annotations.by_line.next(l_position); end loop; - return l_annotations; + return l_result; end; begin - if not a_package_ann_index.exists(gc_context) then + if not a_annotations.by_name.exists(gc_context) then return; end if; - l_context_pos := a_package_ann_index(gc_context).first; + + l_context_pos := a_annotations.by_name( gc_context).first; + while l_context_pos is not null loop - l_end_context_pos := get_endcontext_position(l_context_pos, a_package_ann_index); + l_end_context_pos := get_endcontext_position(l_context_pos, a_annotations.by_name ); if l_end_context_pos is null then exit; end if; --create a sub-set of annotations to process as sub-suite (context) - l_annotations := get_annotations_in_context(a_annotations, l_context_pos, l_end_context_pos); - l_context_ann_index := build_annotation_index(l_annotations); + l_ctx_annotations := get_annotations_in_context( a_annotations, l_context_pos, l_end_context_pos); l_context_name := coalesce( - l_annotations( l_context_pos ).text - , gc_context||'_'||l_context_no + l_ctx_annotations.by_line( l_context_pos ).text + , gc_context||'_'||l_context_no ); + l_context := ut_suite_context(a_suite.object_owner, a_suite.object_name, l_context_name ); - l_context.description := l_annotations(l_context_pos).text; - warning_on_duplicate_annot( l_context, l_context_ann_index, gc_suite ); + l_context.path := a_suite.path||'.'||l_context_name; + l_context.description := l_ctx_annotations.by_line( l_context_pos ).text; - populate_suite_contents( l_context, l_annotations, l_context_ann_index, l_context_name ); + warning_on_duplicate_annot( l_context, l_ctx_annotations.by_name, gc_context ); + + populate_suite_contents( l_context, l_ctx_annotations ); a_suite.add_item(l_context); -- remove annotations within context after processing them - a_annotations.delete(l_context_pos, l_end_context_pos); - delete_from_annotation_index(a_package_ann_index, l_context_pos, l_end_context_pos); + delete_annotations_range(a_annotations, l_context_pos, l_end_context_pos); - if a_package_ann_index.exists(gc_context) then - l_context_pos := a_package_ann_index(gc_context).next(l_context_pos); - else - l_context_pos := null; - end if; + exit when not a_annotations.by_name.exists( gc_context); + + l_context_pos := a_annotations.by_name( gc_context).next( l_context_pos); l_context_no := l_context_no + 1; end loop; end; procedure warning_on_incomplete_context( a_suite in out nocopy ut_suite, - a_annotations tt_package_annotations, - a_package_ann_index tt_annotations_index + a_package_ann_index tt_annotations_by_name ) is l_annotation_pos t_annotation_position; - begin - if a_package_ann_index.exists(gc_context) then - l_annotation_pos := a_package_ann_index(gc_context).first; - while l_annotation_pos is not null loop - add_annotation_ignored_warning( - a_suite, gc_context, 'Invalid annotation %%%. Cannot find following "--%endcontext".', - l_annotation_pos - ); - l_annotation_pos := a_package_ann_index(gc_context).next(l_annotation_pos); - end loop; - end if; - if a_package_ann_index.exists(gc_endcontext) then - l_annotation_pos := a_package_ann_index(gc_endcontext).first; - while l_annotation_pos is not null loop - add_annotation_ignored_warning( - a_suite, gc_endcontext, 'Invalid annotation %%%. Cannot find preceding "--%context".', - l_annotation_pos - ); - l_annotation_pos := a_package_ann_index(gc_endcontext).next(l_annotation_pos); - end loop; - end if; - end; - + begin + if a_package_ann_index.exists(gc_context) then + l_annotation_pos := a_package_ann_index(gc_context).first; + while l_annotation_pos is not null loop + add_annotation_ignored_warning( + a_suite, gc_context, 'Invalid annotation %%%. Cannot find following "--%endcontext".', + l_annotation_pos + ); + l_annotation_pos := a_package_ann_index(gc_context).next(l_annotation_pos); + end loop; + end if; + if a_package_ann_index.exists(gc_endcontext) then + l_annotation_pos := a_package_ann_index(gc_endcontext).first; + while l_annotation_pos is not null loop + add_annotation_ignored_warning( + a_suite, gc_endcontext, 'Invalid annotation %%%. Cannot find preceding "--%context".', + l_annotation_pos + ); + l_annotation_pos := a_package_ann_index(gc_endcontext).next(l_annotation_pos); + end loop; + end if; + end; + function create_suite( - a_package_annotations t_package_annotations_info + a_annotations t_annotations_info ) return ut_logical_suite is - l_annotations tt_package_annotations := a_package_annotations.annotations; - l_package_ann_index tt_annotations_index; - l_suite ut_suite; + l_annotations t_annotations_info := a_annotations; + l_annotation_pos t_annotation_position; + l_suite ut_suite; begin - l_package_ann_index := build_annotation_index(l_annotations); - if l_package_ann_index.exists(gc_suite) then + if l_annotations.by_name.exists( gc_suite) then --create an incomplete suite - l_suite := ut_suite(a_package_annotations.owner, a_package_annotations.name); + l_suite := ut_suite(l_annotations.owner, l_annotations.name); + l_annotation_pos := l_annotations.by_name( gc_suite).first; + l_suite.description := l_annotations.by_name( gc_suite)( l_annotation_pos); - l_suite.description := l_annotations(l_package_ann_index(gc_suite).first).text; - warning_on_duplicate_annot(l_suite, l_package_ann_index, gc_suite); + warning_on_duplicate_annot( l_suite, l_annotations.by_name, gc_suite ); - add_suite_contexts( l_suite, l_annotations, l_package_ann_index ); + build_suitepath( l_suite, l_annotations ); + + add_suite_contexts( l_suite, l_annotations ); --by this time all contexts were consumed and l_annotations should not have any context/endcontext annotation in it. - warning_on_incomplete_context( l_suite, l_annotations, l_package_ann_index ); + warning_on_incomplete_context( l_suite, l_annotations.by_name ); - populate_suite_contents( l_suite, l_annotations, l_package_ann_index ); + populate_suite_contents( l_suite, l_annotations ); end if; return l_suite; end; - function create_suite(a_object ut_annotated_object) return ut_logical_suite is - begin - return create_suite( convert_package_annotations(a_object) ); - end create_suite; - function build_suites_hierarchy(a_suites_by_path tt_schema_suites) return tt_schema_suites is l_result tt_schema_suites; l_suite_path varchar2(4000 char); @@ -867,12 +834,38 @@ create or replace package body ut_suite_builder is l_annotated_objects ut_annotated_objects; l_all_suites tt_schema_suites; l_result t_schema_suites_info; + + function convert_package_annotations(a_object ut_annotated_object) return t_annotations_info is + l_result t_annotations_info; + l_annotation t_annotation; + l_annotation_no binary_integer; + l_annotation_pos binary_integer; + begin + l_result.owner := a_object.object_owner; + l_result.name := lower(trim(a_object.object_name)); + l_annotation_no := a_object.annotations.first; + while l_annotation_no is not null loop + l_annotation_pos := a_object.annotations(l_annotation_no).position; + l_annotation.name := a_object.annotations(l_annotation_no).name; + l_annotation.text := a_object.annotations(l_annotation_no).text; + l_annotation.procedure_name := lower(trim(a_object.annotations(l_annotation_no).subobject_name)); + l_result.by_line( l_annotation_pos) := l_annotation; + if l_annotation.procedure_name is null then + l_result.by_name( l_annotation.name)( l_annotation_pos) := l_annotation.text; + else + l_result.by_proc(l_annotation.procedure_name)(l_annotation.name)(l_annotation_pos) := l_annotation.text; + end if; + l_annotation_no := a_object.annotations.next(l_annotation_no); + end loop; + return l_result; + end; + begin fetch a_annotated_objects bulk collect into l_annotated_objects; close a_annotated_objects; for i in 1 .. l_annotated_objects.count loop - l_suite := create_suite(l_annotated_objects(i)); + l_suite := create_suite(convert_package_annotations(l_annotated_objects(i))); if l_suite is not null then l_all_suites(l_suite.path) := l_suite; l_result.suite_paths(l_suite.object_name) := l_suite.path; diff --git a/test/api/test_ut_run.pkb b/test/api/test_ut_run.pkb index 9c00fcc93..cee41c085 100644 --- a/test/api/test_ut_run.pkb +++ b/test/api/test_ut_run.pkb @@ -14,37 +14,22 @@ create or replace package body test_ut_run is --%suitepath(test_state) --%test - procedure stateful_success; - - --%test - --%beforetest(recompile_in_background) + --%beforetest(acquire_state,recompile_in_background) procedure failing_stateful_test; procedure recompile_in_background; - - --%test - procedure dummy_success; + procedure acquire_state; end; ]'; execute immediate q'{ create or replace package body test_stateful as - procedure stateful_success is - begin - ut3.ut.expect(stateful_package.g_state).to_equal('A'); - end; - procedure failing_stateful_test is begin ut3.ut.expect(stateful_package.g_state).to_equal('abc'); end; - procedure dummy_success is - begin - ut3.ut.expect(1).to_equal(1); - end; - procedure recompile_in_background is l_job_name varchar2(30) := 'recreate_stateful_package'; l_cnt integer := 1; @@ -65,13 +50,17 @@ create or replace package body test_ut_run is auto_drop => TRUE, comments => 'one-time job' ); - dbms_lock.sleep(0.2); + dbms_lock.sleep(1); while l_cnt > 0 loop select count(1) into l_cnt from dba_scheduler_running_jobs srj where srj.job_name = l_job_name; end loop; end; + procedure acquire_state is + begin + dbms_output.put_line('stateful_package.g_state='||stateful_package.g_state); + end; end; }'; @@ -84,22 +73,21 @@ create or replace package body test_ut_run is --Arrange l_expected := 'test_state test_stateful - stateful_success [% sec] - failing_stateful_test [% sec] (FAILED - 1) - dummy_success [% sec]% + failing_stateful_test [% sec] (FAILED - 1)% Failures:% 1) failing_stateful_test ORA-04061: existing state of package "UT3_TESTER.STATEFUL_PACKAGE" has been invalidated ORA-04065: not executed, altered or dropped package "UT3_TESTER.STATEFUL_PACKAGE" ORA-06508: PL/SQL: could not find program unit being called: "UT3_TESTER.STATEFUL_PACKAGE" - ORA-06512: at "UT3_TESTER.TEST_STATEFUL", line 10% + ORA-06512: at "UT3_TESTER.TEST_STATEFUL", line 5% ORA-06512: at line 6% -3 tests, 0 failed, 1 errored, 0 disabled, 0 warning(s)%'; +1 tests, 0 failed, 1 errored, 0 disabled, 0 warning(s)%'; --Act select * bulk collect into l_results from table(ut3.ut.run('test_stateful')); --Assert + ut.expect( ut3.ut_utils.table_to_clob(l_results) ).to_be_like( l_expected ); ut.fail('Expected exception but nothing was raised'); exception when others then diff --git a/test/core/test_suite_builder.pkb b/test/core/test_suite_builder.pkb index c159be4f0..7a98d576b 100644 --- a/test/core/test_suite_builder.pkb +++ b/test/core/test_suite_builder.pkb @@ -150,6 +150,25 @@ create or replace package body test_suite_builder is ); end; + procedure test_annotation is + l_actual clob; + l_annotations ut3.ut_annotations; + begin + --Arrange + l_annotations := ut3.ut_annotations( + ut3.ut_annotation(2, 'suite','Cool', null), + ut3.ut_annotation(8, 'test','Some test', 'test_procedure') + ); + --Act + l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); + --Assert + ut.expect(l_actual).to_be_like( + '%' || + '%test_procedureSome testsome_package.test_procedure' || + '%%' + ); + end; + procedure test_annot_duplicated is l_actual clob; l_annotations ut3.ut_annotations; @@ -415,6 +434,61 @@ create or replace package body test_suite_builder is ); end; + procedure multiple_standalone_bef_aft is + l_actual clob; + l_annotations ut3.ut_annotations; + begin + --Arrange + l_annotations := ut3.ut_annotations( + ut3.ut_annotation(1, 'suite','Cool', null), + ut3.ut_annotation(2, 'beforeall', 'some_package.first_before_all',null), + ut3.ut_annotation(3, 'beforeall', 'different_package.another_before_all',null), + ut3.ut_annotation(4, 'beforeeach', 'first_before_each',null), + ut3.ut_annotation(5, 'beforeeach', 'different_owner.different_package.another_before_each',null), + ut3.ut_annotation(6, 'aftereach', 'first_after_each',null), + ut3.ut_annotation(7, 'aftereach', 'another_after_each,different_owner.different_package.one_more_after_each',null), + ut3.ut_annotation(8, 'afterall', 'first_after_all',null), + ut3.ut_annotation(9, 'afterall', 'another_after_all',null), + ut3.ut_annotation(14, 'test','A test', 'some_test'), + ut3.ut_annotation(15, 'beforetest','before_test_proc', 'some_test'), + ut3.ut_annotation(16, 'beforetest','before_test_proc2', 'some_test'), + ut3.ut_annotation(18, 'aftertest','after_test_proc', 'some_test'), + ut3.ut_annotation(20, 'aftertest','after_test_proc2', 'some_test') + ); + --Act + l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); + --Assert + ut.expect(l_actual).to_be_like( + '%%some_package%some_test' || + '%' || + '%some_packagefirst_before_each' || + '%different_ownerdifferent_packageanother_before_each' || + '%' || + '%' || + '%some_packagebefore_test_proc' || + '%some_packagebefore_test_proc2' || + '%' || + '%' || + '%some_packageafter_test_proc' || + '%some_packageafter_test_proc2' || + '%' || + '%' || + '%some_packagefirst_after_each' || + '%some_packageanother_after_each' || + '%different_ownerdifferent_packageone_more_after_each' || + '%' || + '%' || + '%' || + '%some_packagefirst_before_all' || + '%different_packageanother_before_all' || + '%' || + '%' || + '%some_packagefirst_after_all' || + '%some_packageanother_after_all' || + '%%' + ); + end; + procedure before_after_on_single_proc is l_actual clob; l_annotations ut3.ut_annotations; @@ -710,38 +784,179 @@ create or replace package body test_suite_builder is procedure throws_value_empty is l_actual clob; l_annotations ut3.ut_annotations; - begin - --Arrange - l_annotations := ut3.ut_annotations( - ut3.ut_annotation(1, 'suite','Cool', null), - ut3.ut_annotation(3, 'test','A test with empty throws annotation', 'A_TEST_PROCEDURE'), - ut3.ut_annotation(3, 'throws',null, 'A_TEST_PROCEDURE') - ); - --Act - l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); - --Assert - ut.expect(l_actual).to_be_like( - '%%"--%throws" annotation requires a parameter. Annotation ignored.%%' - ); - end; + begin + --Arrange + l_annotations := ut3.ut_annotations( + ut3.ut_annotation(1, 'suite','Cool', null), + ut3.ut_annotation(3, 'test','A test with empty throws annotation', 'A_TEST_PROCEDURE'), + ut3.ut_annotation(3, 'throws',null, 'A_TEST_PROCEDURE') + ); + --Act + l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); + --Assert + ut.expect(l_actual).to_be_like( + '%%"--%throws" annotation requires a parameter. Annotation ignored.%%' + ); + end; procedure throws_value_invalid is l_actual clob; l_annotations ut3.ut_annotations; - begin - --Arrange - l_annotations := ut3.ut_annotations( - ut3.ut_annotation(1, 'suite','Cool', null), - ut3.ut_annotation(3, 'test','A test with invalid throws annotation', 'A_TEST_PROCEDURE'), - ut3.ut_annotation(3, 'throws',' -20145 , bad_variable_name ', 'A_TEST_PROCEDURE') - ); - --Act - l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); - --Assert - ut.expect(l_actual).to_be_like( - '%%Invalid parameter value "bad_variable_name" for "--%throws" annotation. Parameter ignored.%%' - ); - end; + begin + --Arrange + l_annotations := ut3.ut_annotations( + ut3.ut_annotation(1, 'suite','Cool', null), + ut3.ut_annotation(3, 'test','A test with invalid throws annotation', 'A_TEST_PROCEDURE'), + ut3.ut_annotation(3, 'throws',' -20145 , bad_variable_name ', 'A_TEST_PROCEDURE') + ); + --Act + l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); + --Assert + ut.expect(l_actual).to_be_like( + '%%Invalid parameter value "bad_variable_name" for "--%throws" annotation. Parameter ignored.%%' + ); + end; + + + procedure before_aftertest_multi is + l_actual clob; + l_annotations ut3.ut_annotations; + begin + --Arrange + l_annotations := ut3.ut_annotations( + ut3.ut_annotation(1, 'suite','Cool', null), + ut3.ut_annotation(14, 'test','A test', 'some_test'), + ut3.ut_annotation(15, 'beforetest','before_test_proc', 'some_test'), + ut3.ut_annotation(16, 'beforetest','before_test_proc2', 'some_test'), + ut3.ut_annotation(18, 'aftertest','after_test_proc', 'some_test'), + ut3.ut_annotation(20, 'aftertest','after_test_proc2', 'some_test') + ); + --Act + l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); + --Assert + ut.expect(l_actual).to_be_like( + '%%some_package%some_test' || + '%' || + '%some_packagebefore_test_proc' || + '%some_packagebefore_test_proc2' || + '%' || + '%' || + '%some_packageafter_test_proc' || + '%some_packageafter_test_proc2' || + '%' || + '%%' + ); + end; + + procedure before_aftertest_twice is + l_actual clob; + l_annotations ut3.ut_annotations; + begin + --Arrange + l_annotations := ut3.ut_annotations( + ut3.ut_annotation(1, 'suite','Cool', null), + ut3.ut_annotation(14, 'test','A test', 'some_test'), + ut3.ut_annotation(15, 'beforetest','before_test_proc, before_test_proc2', 'some_test'), + ut3.ut_annotation(16, 'beforetest','before_test_proc3', 'some_test'), + ut3.ut_annotation(18, 'aftertest','after_test_proc,after_test_proc2', 'some_test'), + ut3.ut_annotation(20, 'aftertest','after_test_proc3', 'some_test') + ); + --Act + l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); + --Assert + ut.expect(l_actual).to_be_like( + '%%some_package%some_test' || + '%' || + '%some_packagebefore_test_proc' || + '%some_packagebefore_test_proc2' || + '%some_packagebefore_test_proc3' || + '%' || + '%' || + '%some_packageafter_test_proc' || + '%some_packageafter_test_proc2' || + '%some_packageafter_test_proc3' || + '%' || + '%%' + ); + end; + + procedure before_aftertest_pkg_proc is + l_actual clob; + l_annotations ut3.ut_annotations; + begin + --Arrange + l_annotations := ut3.ut_annotations( + ut3.ut_annotation(1, 'suite','Cool', null), + ut3.ut_annotation(14, 'test','A test', 'some_test'), + ut3.ut_annotation(15, 'beforetest','external_package.before_test_proc', 'some_test'), + ut3.ut_annotation(18, 'aftertest','external_package.after_test_proc', 'some_test') + ); + --Act + l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); + --Assert + ut.expect(l_actual).to_be_like( + '%%some_package%some_test' || + '%' || + '%external_packagebefore_test_proc' || + '%' || + '%' || + '%external_packageafter_test_proc' || + '%' || + '%%' + ); + end; + + procedure before_aftertest_mixed_syntax is + l_actual clob; + l_annotations ut3.ut_annotations; + begin + --Arrange + l_annotations := ut3.ut_annotations( + ut3.ut_annotation(1, 'suite','Cool', null), + ut3.ut_annotation(14, 'test','A test', 'some_test'), + ut3.ut_annotation(15, 'beforetest','external_package.before_test_proc, before_test_proc2', 'some_test'), + ut3.ut_annotation(18, 'aftertest','external_package.after_test_proc, after_test_proc2', 'some_test') + ); + --Act + l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); + --Assert + ut.expect(l_actual).to_be_like( + '%%some_package%some_test' || + '%' || + '%external_packagebefore_test_proc' || + '%some_packagebefore_test_proc2' || + '%' || + '%' || + '%external_packageafter_test_proc' || + '%some_packageafter_test_proc2' || + '%' || + '%%' + ); + end; + + procedure test_annotation_ordering is + l_actual clob; + l_annotations ut3.ut_annotations; + begin + --Arrange + l_annotations := ut3.ut_annotations( + ut3.ut_annotation(1, 'suite','Cool', null), + ut3.ut_annotation(4, 'test','B test', 'b_test'), + ut3.ut_annotation(10, 'test','Z test', 'z_test'), + ut3.ut_annotation(14, 'test','A test', 'a_test') + ); + --Act + l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); + --Assert + ut.expect(l_actual).to_be_like( + '%%some_package%b_test' || + '%%'|| + '%%some_package%z_test' || + '%%'|| + '%%some_package%a_test' || + '%%' + ); + end; end; / diff --git a/test/core/test_suite_builder.pks b/test/core/test_suite_builder.pks index 6eef1ee2c..95cf6f812 100644 --- a/test/core/test_suite_builder.pks +++ b/test/core/test_suite_builder.pks @@ -2,56 +2,70 @@ create or replace package test_suite_builder is --%suite(suite_builder) --%suitepath(utplsql.core) + --%context(suite) + --%displayname(--%suite annotation) + --%test(Sets suite name from package name and leaves description empty) procedure no_suite_description; --%test(Sets suite description using first --%suite annotation) procedure suite_description_from_suite; - --%test(Sets suite path using first --%suitepath annotation) - procedure suitepath_from_non_empty_path; + --%test(Gives warning if more than one --%suite annotation used) + procedure suite_annot_duplicated; + + --%endcontext + + --%context(displayname) + --%displayname(--%displayname annotation) --%test(Overrides suite description using first --%displayname annotation) procedure suite_descr_from_displayname; - --%test(Sets rollback type using first --%rollback annotation) - procedure rollback_type_valid; + --%test(Gives warning if more than one --%displayname annotation used) + procedure displayname_annot_duplicated; - --%test(Gives warning if more than one --%rollback annotation used) - procedure rollback_type_duplicated; + --%test(Gives warning if --%displayname annotation has no value) + procedure displayname_annot_empty; - --%test(Gives warning if more than one --%suite annotation used) - procedure suite_annot_duplicated; + --%endcontext + + --%context(test) + --%displayname(--%test annotation) + + --%test(Creates a test item for procedure annotated with --%test annotation) + procedure test_annotation; --%test(Gives warning if more than one --%test annotation used) procedure test_annot_duplicated; - --%test(Gives warning if more than one --%beforeall annotation used) - procedure beforeall_annot_duplicated; - - --%test(Gives warning if more than one --%beforeeach annotation used) - procedure beforeeach_annot_duplicated; + --%endcontext - --%test(Gives warning if more than one --%afterall annotation used) - procedure afterall_annot_duplicated; + --%context(suitepath) + --%displayname(--%suitepath annotation) - --%test(Gives warning if more than one --%aftereach annotation used) - procedure aftereach_annot_duplicated; + --%test(Sets suite path using first --%suitepath annotation) + procedure suitepath_from_non_empty_path; --%test(Gives warning if more than one --%suitepath annotation used) procedure suitepath_annot_duplicated; - --%test(Gives warning if more than one --%displayname annotation used) - procedure displayname_annot_duplicated; - --%test(Gives warning if --%suitepath annotation has no value) procedure suitepath_annot_empty; --%test(Gives warning if --%suitepath annotation has invalid value) procedure suitepath_annot_invalid_path; - --%test(Gives warning if --%displayname annotation has no value) - procedure displayname_annot_empty; + --%endcontext + + --%context(rollback) + --%displayname(--%rollback annotation) + + --%test(Sets rollback type using first --%rollback annotation) + procedure rollback_type_valid; + + --%test(Gives warning if more than one --%rollback annotation used) + procedure rollback_type_duplicated; --%test(Gives warning if --%rollback annotation has no value) procedure rollback_type_empty; @@ -59,15 +73,40 @@ create or replace package test_suite_builder is --%test(Gives warning if --%rollback annotation has invalid value) procedure rollback_type_invalid; - --%test(Supports multiple before/after definitions) + --%endcontext + + --%context(before_after_all_each) + --%displayname(--%before/after all/each annotations) + + --%test(Supports multiple before/after all/each procedure level definitions) procedure multiple_before_after; - --%test(Supports before/after all/each annotations on single procedure) + --%test(Supports multiple before/after all/each standalone level definitions) + procedure multiple_standalone_bef_aft; + + --%test(Supports mixing before/after all/each annotations on single procedure) procedure before_after_on_single_proc; + --%test(Gives warning if more than one --%beforeall annotation used on procedure) + procedure beforeall_annot_duplicated; + + --%test(Gives warning if more than one --%beforeeach annotation used on procedure) + procedure beforeeach_annot_duplicated; + + --%test(Gives warning if more than one --%afterall annotation used on procedure) + procedure afterall_annot_duplicated; + + --%test(Gives warning if more than one --%aftereach annotation used on procedure) + procedure aftereach_annot_duplicated; + --%test(Gives warning on before/after all/each annotations mixed with test) procedure before_after_mixed_with_test; + --%endcontext + + --%context(context) + --%displayname(--%context annotation) + --%test(Creates nested suite for content between context/endcontext annotations) procedure suite_from_context; @@ -83,11 +122,43 @@ create or replace package test_suite_builder is --%test(Gives warning if --%endcontext is missing a preceding --%context) procedure endcontext_without_context; + --%endcontext + + --%context(throws) + --%displayname(--%throws annotation) + --%test(Gives warning if --%throws annotation has no value) procedure throws_value_empty; --%test(Gives warning if --%throws annotation has invalid value) procedure throws_value_invalid; + --%endcontext + + --%context(beforetest_aftertest) + --%displayname(--%beforetest/aftertest annotation) + + --%test(Supports multiple occurrences of beforetest/aftertest for a test) + procedure before_aftertest_multi; + + --%test(Supports same procedure defined twice) + procedure before_aftertest_twice; + + --%test(Supports beforetest from external package) + procedure before_aftertest_pkg_proc; + + --%test(Supports mix of procedure and package.procedure) + procedure before_aftertest_mixed_syntax; + + --%endcontext + + --%context(test) + --%displayname(--%test annontation) + + --%test(Is added to suite according to annotation order in package spec) + procedure test_annotation_ordering; + + --%endcontext + end; / From 6ece42c17d35ade8aa684a0875332cde2e8c19f2 Mon Sep 17 00:00:00 2001 From: Jacek Gebal Date: Sun, 8 Jul 2018 15:21:38 +0100 Subject: [PATCH 121/184] Added additional test for mixed use case of before/after on both procedure level as well as standalone. --- test/core/test_suite_builder.pkb | 62 ++++++++++++++++++++++++++++++++ test/core/test_suite_builder.pks | 3 ++ test/install_and_run_tests.sh | 1 + 3 files changed, 66 insertions(+) diff --git a/test/core/test_suite_builder.pkb b/test/core/test_suite_builder.pkb index 7a98d576b..90c6c166f 100644 --- a/test/core/test_suite_builder.pkb +++ b/test/core/test_suite_builder.pkb @@ -523,6 +523,68 @@ create or replace package body test_suite_builder is ); end; + procedure multiple_mixed_bef_aft is + l_actual clob; + l_annotations ut3.ut_annotations; + begin + --Arrange + l_annotations := ut3.ut_annotations( + ut3.ut_annotation(1, 'suite','Cool', null), + ut3.ut_annotation(2, 'beforeall', null,'first_before_all'), + ut3.ut_annotation(3, 'beforeall', 'different_package.another_before_all',null), + ut3.ut_annotation(4, 'beforeeach', 'first_before_each',null), + ut3.ut_annotation(5, 'beforeeach', 'different_owner.different_package.another_before_each',null), + ut3.ut_annotation(6, 'aftereach', null, 'first_after_each'), + ut3.ut_annotation(7, 'aftereach', 'another_after_each,different_owner.different_package.one_more_after_each',null), + ut3.ut_annotation(8, 'afterall', 'first_after_all',null), + ut3.ut_annotation(9, 'afterall', 'another_after_all',null), + ut3.ut_annotation(14, 'test','A test', 'some_test'), + ut3.ut_annotation(15, 'beforetest','before_test_proc', 'some_test'), + ut3.ut_annotation(16, 'beforetest','before_test_proc2', 'some_test'), + ut3.ut_annotation(18, 'aftertest','after_test_proc', 'some_test'), + ut3.ut_annotation(20, 'aftertest','after_test_proc2', 'some_test'), + ut3.ut_annotation(21, 'beforeall', null,'last_before_all'), + ut3.ut_annotation(22, 'aftereach', null, 'last_after_each'), + ut3.ut_annotation(23, 'afterall', null, 'last_after_all') + ); + --Act + l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); + --Assert + ut.expect(l_actual).to_be_like( + '%%some_package%some_test' || + '%' || + '%some_packagefirst_before_each' || + '%different_ownerdifferent_packageanother_before_each' || + '%' || + '%' || + '%some_packagebefore_test_proc' || + '%some_packagebefore_test_proc2' || + '%' || + '%' || + '%some_packageafter_test_proc' || + '%some_packageafter_test_proc2' || + '%' || + '%' || + '%some_packagefirst_after_each' || + '%some_packageanother_after_each' || + '%different_ownerdifferent_packageone_more_after_each' || + '%some_packagelast_after_each' || + '%' || + '%' || + '%' || + '%some_packagefirst_before_all' || + '%different_packageanother_before_all' || + '%some_packagelast_before_all' || + '%' || + '%' || + '%some_packagefirst_after_all' || + '%some_packageanother_after_all' || + '%some_packagelast_after_all' || + '%%' + ); + end; + + procedure before_after_mixed_with_test is l_actual clob; l_annotations ut3.ut_annotations; diff --git a/test/core/test_suite_builder.pks b/test/core/test_suite_builder.pks index 95cf6f812..f9548afd3 100644 --- a/test/core/test_suite_builder.pks +++ b/test/core/test_suite_builder.pks @@ -87,6 +87,9 @@ create or replace package test_suite_builder is --%test(Supports mixing before/after all/each annotations on single procedure) procedure before_after_on_single_proc; + --%test(Supports mixed before/after all/each as standalone and procedure level definitions) + procedure multiple_mixed_bef_aft; + --%test(Gives warning if more than one --%beforeall annotation used on procedure) procedure beforeall_annot_duplicated; diff --git a/test/install_and_run_tests.sh b/test/install_and_run_tests.sh index 2c6f78ae1..ef025da82 100644 --- a/test/install_and_run_tests.sh +++ b/test/install_and_run_tests.sh @@ -13,6 +13,7 @@ cd test cd .. utPLSQL-cli/bin/utplsql run ${UT3_TESTER}/${UT3_TESTER_PASSWORD}@${CONNECTION_STR} \ +-p=test_suite_builder \ -source_path=source -owner=ut3 \ -test_path=test -c \ -f=ut_documentation_reporter -o=test_results.log -s \ From 02468f2aea07dd193bcc4069297d3c9cdc4867b0 Mon Sep 17 00:00:00 2001 From: Jacek Gebal Date: Sun, 8 Jul 2018 17:33:55 +0100 Subject: [PATCH 122/184] Updated documentation for before/after annotations to indicate that: - multiple instances of annotation can be used - multiple procedures can be mentioned as parameters for annotation --- docs/userguide/annotations.md | 261 ++++++++++++++++++++++++---------- 1 file changed, 184 insertions(+), 77 deletions(-) diff --git a/docs/userguide/annotations.md b/docs/userguide/annotations.md index 9c9df44ea..9bcb7907f 100644 --- a/docs/userguide/annotations.md +++ b/docs/userguide/annotations.md @@ -23,11 +23,15 @@ We strongly recommend putting package level annotations at the very top of packa | `--%test()` | Procedure | Denotes that the annotated procedure is a unit test procedure. Optional test description can by provided (see `displayname`). | | `--%throws([,[,...]])`| Procedure | Denotes that the annotated procedure must throw one of the exception numbers provided. If no valid numbers were provided as annotation parameters the annotation is ignored. Applicable to test procedures only. | | `--%beforeall` | Procedure | Denotes that the annotated procedure should be executed once before all elements of the suite. | +| `--%beforeall([[.].][,...])` | Package | Denotes that the mentioned procedure(s) should be executed once before all elements of the suite. | | `--%afterall` | Procedure | Denotes that the annotated procedure should be executed once after all elements of the suite. | +| `--%afterall([[.].][,...])` | Package | Denotes that the mentioned procedure(s) should be executed once after all elements of the suite. | | `--%beforeeach` | Procedure | Denotes that the annotated procedure should be executed before each `%test` procedure in the suite. | +| `--%beforeeach([[.].][,...])` | Package | Denotes that the mentioned procedure(s) should be executed before each `%test` procedure in the suite. | | `--%aftereach` | Procedure | Denotes that the annotated procedure should be executed after each `%test` procedure in the suite. | -| `--%beforetest(<[owner.[package.]]procedure_name>[,...])` | Procedure | Denotes that mentioned procedure(s) should be executed before the annotated `%test` procedure. | -| `--%aftertest(<[owner.[package.]]procedure_name>[,...]>)` | Procedure | Denotes that mentioned procedure(s) should be executed after the annotated `%test` procedure. | +| `--%aftereach([[.].][,...])` | Package | Denotes that the mentioned procedure(s) should be executed after each `%test` procedure in the suite. | +| `--%beforetest([[.].][,...])` | Procedure | Denotes that mentioned procedure(s) should be executed before the annotated `%test` procedure. | +| `--%aftertest([[.].][,...])` | Procedure | Denotes that mentioned procedure(s) should be executed after the annotated `%test` procedure. | | `--%rollback()` | Package/procedure | Defines transaction control. Supported values: `auto`(default) - a savepoint is created before invocation of each "before block" is and a rollback to specific savepoint is issued after each "after" block; `manual` - rollback is never issued automatically. Property can be overridden for child element (test in suite) | | `--%disabled` | Package/procedure | Used to disable a suite or a test. Disabled suites/tests do not get executed, they are however marked and reported as disabled in a test run. | | `--%context()` | Package | Denotes start of a named context (sub-suite) in a suite package | @@ -301,8 +305,35 @@ Finished in .005868 seconds ### Beforeall +There are two possible ways to use the `--%beforeall` annotation. + +As a procedure level annotation: +```sql +--%suite(Some test suite) + +--%beforeall +procedure to_be_executed_before_all; + +--%test +procedure some_test; +``` Marks annotated procedure to be executed before all test procedures in a suite. +As a package level annotation (not associated with any procedure). +```sql +--%suite(Some test suite) + +--%beforeall(to_be_executed_before_all, other_package.some_setup) + +--%test +procedure some_test; + +procedure to_be_executed_before_all; + +``` +Indicates that the procedure(s) mentioned as the annotation parameter are to be executed before all test procedures in a suite. + + If `--%beforeall` raises an exception, suite content cannot be safely executed as the setup was not executed successfully for the suite. If `--%beforeall` raises an exception the following will happen: @@ -357,42 +388,58 @@ Finished in .012292 seconds 2 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s) ``` -In the below example, procedure `another_setup` is invoked after `initial_setup`. -The `another_setup` still gets invoked before any test from that suite package is executed. +In the below example a combination pacakge and procedure level `--%beforeall` annotations is used. +The order of execution of the beforeall procedures is determined by the annotation position in package. +All of the `--%beforeall` procedures get invoked before any test is executed in a suite. ```sql - create or replace package test_package as - --%suite(Tests for a package) - - --%beforeall - procedure initial_setup; - - --%test(Description of tested behavior) - procedure some_test; - - --%test(Description of another behavior) - procedure other_test; + create or replace package test_package as + --%suite(Tests for a package) + + --%beforeall(initial_setup,test_package.another_setup) + + --%test(Description of tested behavior) + procedure some_test; + + --%test(Description of another behavior) + procedure other_test; + + --%beforeall + procedure next_setup; + + --%beforeall(one_more_setup) + + procedure another_setup; + procedure one_more_setup; + procedure initial_setup; - --%beforeall - procedure another_setup; - - end; - / - create or replace package body test_package as - procedure another_setup is - begin - dbms_output.put_line('--- ANOTHER_SETUP invoked ---'); - end; - - procedure initial_setup is - begin - dbms_output.put_line('--- INITIAL_SETUP invoked ---'); - end; - - procedure some_test is begin null; end; - - procedure other_test is begin null; end; - end; - / + end; + / + create or replace package body test_package as + procedure one_more_setup is + begin + dbms_output.put_line('--- ONE_MORE_SETUP invoked ---'); + end; + + procedure next_setup is + begin + dbms_output.put_line('--- NEXT_SETUP invoked ---'); + end; + + procedure another_setup is + begin + dbms_output.put_line('--- ANOTHER_SETUP invoked ---'); + end; + + procedure initial_setup is + begin + dbms_output.put_line('--- INITIAL_SETUP invoked ---'); + end; + + procedure some_test is begin null; end; + + procedure other_test is begin null; end; + end; + / ``` ```sql @@ -402,10 +449,12 @@ The `another_setup` still gets invoked before any test from that suite package i Tests for a package --- INITIAL_SETUP invoked --- --- ANOTHER_SETUP invoked --- - Description of tested behavior [.004 sec] - Description of another behavior [.004 sec] + --- NEXT_SETUP invoked --- + --- ONE_MORE_SETUP invoked --- + Description of tested behavior [.003 sec] + Description of another behavior [.002 sec] -Finished in .016672 seconds +Finished in .018944 seconds 2 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s) ``` @@ -468,8 +517,34 @@ Finished in .012158 seconds ### Afterall +There are two possible ways to use the `--%afterall` annotation. + +As a procedure level annotation: +```sql +--%suite(Some test suite) + +--%afterall +procedure to_be_executed_after_all; + +--%test +procedure some_test; +``` Marks annotated procedure to be executed after all test procedures in a suite. +As a package level annotation (not associated with any procedure). +```sql +--%suite(Some test suite) + +--%afterall(to_be_executed_after_all, other_package.some_cleanup) + +--%test +procedure some_test; + +procedure to_be_executed_after_all; + +``` +Indicates that the procedure(s) mentioned as the annotation parameter are to be executed after all test procedures in a suite. + If `--%afterall` raises an exception the following will happen: - a warning will be raised, indicating that `--%afterall` procedure has failed - execution will continue uninterrupted for rest of the suite @@ -526,11 +601,38 @@ Finished in .014161 seconds ### Beforeeach -Marks annotated procedure to be executed before each test procedure in a suite. - The procedure annotated as `--%beforeeach` is getting executed before each test in a suite. That means that the procedure will be executed as many times as there are test in suite package. +There are two possible ways to use the `--%beforeeach` annotation. + +As a procedure level annotation: +```sql +--%suite(Some test suite) + +--%beforeeach +procedure to_be_executed_before_each; + +--%test +procedure some_test; +``` +Marks annotated procedure to be executed before each test procedures in a suite. + +As a package level annotation (not associated with any procedure). +```sql +--%suite(Some test suite) + +--%beforeeach(to_be_executed_before_each, other_package.some_setup) + +--%test +procedure some_test; + +procedure to_be_executed_before_each; + +``` +Indicates that the procedure(s) mentioned as the annotation parameter are to be executed before each test procedure in a suite. + + If a test is marked as disabled the `--%beforeeach` procedure is not invoked for that test. If `--%beforeeach` raises an unhandled exception the following will happen: @@ -604,6 +706,7 @@ Finished in .014683 seconds 2 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s) ``` +See [beforeall](#Beforeall) for more examples. ### Aftereach @@ -612,6 +715,34 @@ Marks annotated procedure to be executed after each test procedure in a suite. The procedure annotated as `--%aftereach` is getting executed after each test in a suite. That means that the procedure will be executed as many times as there are test in suite package. +There are two possible ways to use the `--%aftereach` annotation. + +As a procedure level annotation: +```sql +--%suite(Some test suite) + +--%aftereach +procedure to_be_executed_after_each; + +--%test +procedure some_test; +``` +Marks annotated procedure to be executed after each test procedures in a suite. + +As a package level annotation (not associated with any procedure). +```sql +--%suite(Some test suite) + +--%aftereach(to_be_executed_after_each, other_package.some_setup) + +--%test +procedure some_test; + +procedure to_be_executed_after_each; + +``` +Indicates that the procedure(s) mentioned as the annotation parameter are to be executed after each test procedure in a suite. + If a test is marked as disabled the `--%aftereach` procedure is not invoked for that test. If `--%aftereach` raises an unhandled exception the following will happen: @@ -683,6 +814,8 @@ Finished in .018115 seconds 2 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s) ``` +See [beforeall](#Beforeall) for more examples. + ### Beforetest Indicates specific setup procedure(s) to be executed for a test. The procedure(s) can be located either: @@ -711,29 +844,16 @@ The order of execution for `--%beforetest` procedures is defined by: As a rule, the `--%beforetest` execution gets aborted if preceding `--%beforeeach` or `--%beforetest` failed. ```sql -create or replace package shared_package as - procedure do_some_stuff; -end; -/ - -create or replace package body shared_package as - procedure do_some_stuff is - begin - dbms_output.put_line('---DO_SOME_STUFF invoked ---'); - end; -end; -/ - create or replace package test_package as --%suite(Tests for a package) --%test(Description of tested behavior) - --%beforetest(setup_for_a_test, shared_package.do_some_stuff) + --%beforetest(test_package.setup_for_a_test) --%beforetest(another_setup_for_a_test) procedure some_test; --%test(Description of another behavior) - --%beforetest(setup_for_a_test) + --%beforetest(test_package.setup_for_a_test, another_setup_for_a_test) procedure other_test; procedure another_setup_for_a_test; @@ -770,16 +890,16 @@ exec ut.run('test_package'); ``` ``` Tests for a package - Description of tested behavior [.011 sec] + Description of tested behavior [.008 sec] ---SETUP_FOR_A_TEST invoked --- - ---DO_SOME_STUFF invoked --- ---ANOTHER_SETUP_FOR_A_TEST invoked --- ---SOME_TEST invoked --- Description of another behavior [.005 sec] ---SETUP_FOR_A_TEST invoked --- + ---ANOTHER_SETUP_FOR_A_TEST invoked --- ---OTHER_TEST invoked --- -Finished in .018446 seconds +Finished in .015185 seconds 2 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s) ``` @@ -809,29 +929,16 @@ The order of execution for `--%aftertest` procedures is defined by: As a rule, the `--%aftertest` gets executed even if the associated `--%beforeeach`, `--%beforetest`, `--%test` or other `--%aftertest` procedures have raised unhandled exceptions. ```sql -create or replace package shared_package as - procedure do_some_stuff; -end; -/ - -create or replace package body shared_package as - procedure do_some_stuff is - begin - dbms_output.put_line('---DO_SOME_STUFF invoked ---'); - end; -end; -/ - create or replace package test_package as --%suite(Tests for a package) --%test(Description of tested behavior) - --%aftertest(cleanup_for_a_test, shared_package.do_some_stuff) + --%aftertest(test_package.cleanup_for_a_test) --%aftertest(another_cleanup_for_a_test) procedure some_test; --%test(Description of another behavior) - --%aftertest(cleanup_for_a_test) + --%aftertest(test_package.cleanup_for_a_test, another_cleanup_for_a_test) procedure other_test; procedure another_cleanup_for_a_test; @@ -868,16 +975,16 @@ exec ut.run('test_package'); ``` ``` Tests for a package - Description of tested behavior [.01 sec] + Description of tested behavior [.008 sec] ---SOME_TEST invoked --- ---CLEANUP_FOR_A_TEST invoked --- - ---DO_SOME_STUFF invoked --- ---ANOTHER_CLEANUP_FOR_A_TEST invoked --- Description of another behavior [.006 sec] ---OTHER_TEST invoked --- ---CLEANUP_FOR_A_TEST invoked --- + ---ANOTHER_CLEANUP_FOR_A_TEST invoked --- -Finished in .018691 seconds +Finished in .016873 seconds 2 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s) ``` From d883acf0024879322f8328deaf3476a1491a6f4e Mon Sep 17 00:00:00 2001 From: Jacek Gebal Date: Sun, 8 Jul 2018 22:54:33 +0100 Subject: [PATCH 123/184] Added missing update of project version before pushing it to develop branch. --- .travis.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index e9d632e70..a968cd124 100644 --- a/.travis.yml +++ b/.travis.yml @@ -64,7 +64,7 @@ cache: - $MAVEN_CFG before_install: - #The update_project_version is done before deployment to validate that the change of project files does not break installation + #The update_project_version.sh is done before deployment to validate that the change of project files does not break installation - bash .travis/update_project_version.sh - git config --global user.email "builds@travis-ci.com" - git config --global user.name "${UTPLSQL_BUILD_USER_NAME}" @@ -117,6 +117,8 @@ jobs: before_script: skip script: - if [[ ($TRAVIS_BRANCH == develop) && ($TRAVIS_PULL_REQUEST == false) ]]; then bash .travis/trigger_travis.sh $TRAVIS_ACCESS_TOKEN; fi + - #The update_project_version.sh needs to be done before pushing changes to develop branch + - bash .travis/update_project_version.sh - if [[ ! $TRAVIS_TAG ]]; then bash .travis/push_release_version.sh; fi - bash .travis/build_docs.sh - bash .travis/push_docs_to_gh_pages.sh From 40e16738421fcf21f0b8075bbfdcf16404019d8b Mon Sep 17 00:00:00 2001 From: Jacek Gebal Date: Sun, 8 Jul 2018 23:17:55 +0100 Subject: [PATCH 124/184] Adding missing git config to deploy stage. --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index a968cd124..240ebd513 100644 --- a/.travis.yml +++ b/.travis.yml @@ -119,6 +119,10 @@ jobs: - if [[ ($TRAVIS_BRANCH == develop) && ($TRAVIS_PULL_REQUEST == false) ]]; then bash .travis/trigger_travis.sh $TRAVIS_ACCESS_TOKEN; fi - #The update_project_version.sh needs to be done before pushing changes to develop branch - bash .travis/update_project_version.sh + - git config --global user.email "builds@travis-ci.com" + - git config --global user.name "${UTPLSQL_BUILD_USER_NAME}" + - git remote rm origin + - git remote add origin https://${github_api_token}@github.com/${UTPLSQL_REPO} - if [[ ! $TRAVIS_TAG ]]; then bash .travis/push_release_version.sh; fi - bash .travis/build_docs.sh - bash .travis/push_docs_to_gh_pages.sh From 1dd59b064204f08c32ceca7e8e635ecdd6086de3 Mon Sep 17 00:00:00 2001 From: Travis CI Date: Sun, 8 Jul 2018 22:54:11 +0000 Subject: [PATCH 125/184] Updated project version after build [skip ci] --- source/core/ut_utils.pks | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/core/ut_utils.pks b/source/core/ut_utils.pks index 96236d3ff..b6fddd94e 100644 --- a/source/core/ut_utils.pks +++ b/source/core/ut_utils.pks @@ -21,7 +21,7 @@ create or replace package ut_utils authid definer is * */ - gc_version constant varchar2(50) := 'v3.1.2.2016-develop'; + gc_version constant varchar2(50) := 'v3.1.2.2041-develop'; /* Constants: Event names */ subtype t_event_name is varchar2(30); From 1d65abf82aa31de02336d3ed126263dc3e6d3c6c Mon Sep 17 00:00:00 2001 From: Jacek Gebal Date: Mon, 9 Jul 2018 00:09:37 +0100 Subject: [PATCH 126/184] Reverting rest-runner config change. --- test/install_and_run_tests.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/test/install_and_run_tests.sh b/test/install_and_run_tests.sh index ef025da82..2c6f78ae1 100644 --- a/test/install_and_run_tests.sh +++ b/test/install_and_run_tests.sh @@ -13,7 +13,6 @@ cd test cd .. utPLSQL-cli/bin/utplsql run ${UT3_TESTER}/${UT3_TESTER_PASSWORD}@${CONNECTION_STR} \ --p=test_suite_builder \ -source_path=source -owner=ut3 \ -test_path=test -c \ -f=ut_documentation_reporter -o=test_results.log -s \ From a154b1de8fcdbe023c91dbbe454ef4fcf36dac27 Mon Sep 17 00:00:00 2001 From: Jacek Gebal Date: Sun, 8 Jul 2018 23:44:01 +0100 Subject: [PATCH 127/184] Removed unnieeded git config from default stage. --- .travis.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 240ebd513..8ec9c35d0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -66,10 +66,6 @@ cache: before_install: #The update_project_version.sh is done before deployment to validate that the change of project files does not break installation - bash .travis/update_project_version.sh - - git config --global user.email "builds@travis-ci.com" - - git config --global user.name "${UTPLSQL_BUILD_USER_NAME}" - - git remote rm origin - - git remote add origin https://${github_api_token}@github.com/${UTPLSQL_REPO} # download latest utPLSQL release #- curl -LOk $(curl --silent https://api.github.com/repos/utPLSQL/utPLSQL/releases/latest | awk '/browser_download_url/ { print $2 }' | grep ".zip" | sed 's/"//g') - git clone --depth=1 --branch=${SELFTESTING_BRANCH:-master} https://github.com/utPLSQL/utPLSQL.git $UTPLSQL_DIR From f0c90ddbd2951201eb4add476debc099bea5f223 Mon Sep 17 00:00:00 2001 From: Travis CI Date: Sun, 8 Jul 2018 23:45:00 +0000 Subject: [PATCH 128/184] Updated project version after build [skip ci] --- source/core/ut_utils.pks | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/core/ut_utils.pks b/source/core/ut_utils.pks index b6fddd94e..21d87738d 100644 --- a/source/core/ut_utils.pks +++ b/source/core/ut_utils.pks @@ -21,7 +21,7 @@ create or replace package ut_utils authid definer is * */ - gc_version constant varchar2(50) := 'v3.1.2.2041-develop'; + gc_version constant varchar2(50) := 'v3.1.2.2044-develop'; /* Constants: Event names */ subtype t_event_name is varchar2(30); From e51c42456c592eb07d63547bbfb59a037c89c84d Mon Sep 17 00:00:00 2001 From: Jacek Gebal Date: Mon, 9 Jul 2018 01:16:12 +0100 Subject: [PATCH 129/184] Resolves #693 Added scripts to validate privileges before install. --- source/check_object_grants.sql | 40 ++++++++++++++++++++++++++++++++++ source/check_sys_grants.sql | 33 ++++++++++++++++++++++++++++ source/install.sql | 3 +++ 3 files changed, 76 insertions(+) create mode 100644 source/check_object_grants.sql create mode 100644 source/check_sys_grants.sql diff --git a/source/check_object_grants.sql b/source/check_object_grants.sql new file mode 100644 index 000000000..cf7a8f46f --- /dev/null +++ b/source/check_object_grants.sql @@ -0,0 +1,40 @@ +declare + c_expected_grants constant dbmsoutput_linesarray := dbmsoutput_linesarray('DBMS_LOCK','DBMS_CRYPTO'); + + l_missing_grants varchar2(4000); + + function get_view(a_dba_view_name varchar2) return varchar2 is + l_invalid_object_name exception; + l_result varchar2(128) := lower(a_dba_view_name); + pragma exception_init(l_invalid_object_name,-44002); + begin + l_result := dbms_assert.sql_object_name(l_result); + return l_result; + exception + when l_invalid_object_name then + return replace(l_result,'dba_','all_'); + end; + +begin + execute immediate q'[ + select listagg(' - '||object_name,CHR(10)) within group(order by object_name) + from ( + select column_value as object_name + from table(:l_expected_grants) + minus + select table_name as object_name + from ]'||get_view('dba_tab_privs')||q'[ + where grantee = SYS_CONTEXT('userenv','current_schema') + and owner = 'SYS')]' + into l_missing_grants using c_expected_grants; + if l_missing_grants is not null then + raise_application_error( + -20000 + , 'The following object grants are missing for user "'||SYS_CONTEXT('userenv','current_schema')||'" to install utPLSQL:'||CHR(10) + ||l_missing_grants||CHR(10) + ||'Please read the installation documentation at http://utplsql.org/utPLSQL/' + ); + end if; +end; +/ + diff --git a/source/check_sys_grants.sql b/source/check_sys_grants.sql new file mode 100644 index 000000000..863727f00 --- /dev/null +++ b/source/check_sys_grants.sql @@ -0,0 +1,33 @@ +declare + c_expected_grants constant dbmsoutput_linesarray + := dbmsoutput_linesarray( + 'CREATE TYPE','CREATE VIEW','CREATE SYNONYM','CREATE SEQUENCE','CREATE PROCEDURE','CREATE TABLE' + ); + + l_expected_grants dbmsoutput_linesarray := c_expected_grants; + l_missing_grants varchar2(4000); +begin + if user != SYS_CONTEXT('userenv','current_schema') then + for i in 1 .. l_expected_grants.count loop + l_expected_grants(i) := replace(l_expected_grants(i),' ',' ANY '); + end loop; + end if; + select listagg(' - '||privilege,CHR(10)) within group(order by privilege) + into l_missing_grants + from ( + select column_value as privilege + from table(l_expected_grants) + minus + select privilege + from user_sys_privs + ); + if l_missing_grants is not null then + raise_application_error( + -20000 + , 'The following privileges are required for user "'||user||'" to install into schema "'||SYS_CONTEXT('userenv','current_schema')||'"'||CHR(10) + ||l_missing_grants + ||'Please read the installation documentation at http://utplsql.org/utPLSQL/' + ); + end if; +end; +/ diff --git a/source/install.sql b/source/install.sql index 7a8d89614..07227c316 100644 --- a/source/install.sql +++ b/source/install.sql @@ -29,6 +29,9 @@ whenever oserror exit failure rollback prompt Switching current schema to &&ut3_owner prompt &&line_separator alter session set current_schema = &&ut3_owner; + +@@check_object_grants.sql +@@check_sys_grants.sql --set define off --dbms_output buffer cache table From 1b4df16547a2e46bbdb42bc8f4963615d9c39500 Mon Sep 17 00:00:00 2001 From: Jacek Gebal Date: Mon, 9 Jul 2018 01:29:54 +0100 Subject: [PATCH 130/184] Resolves #675 Added grants and synonyms for `ut_expectation` and `ut_expectation_compound` --- source/create_synonyms_and_grants_for_public.sql | 4 ++++ source/create_user_grants.sql | 2 ++ source/create_user_synonyms.sql | 2 ++ 3 files changed, 8 insertions(+) diff --git a/source/create_synonyms_and_grants_for_public.sql b/source/create_synonyms_and_grants_for_public.sql index e34df182e..e2cc450f5 100644 --- a/source/create_synonyms_and_grants_for_public.sql +++ b/source/create_synonyms_and_grants_for_public.sql @@ -31,6 +31,8 @@ whenever oserror exit failure rollback alter session set current_schema = &&ut3_owner; +grant execute on &&ut3_owner..ut_expectation to public; +grant execute on &&ut3_owner..ut_expectation_compound to public; grant execute on &&ut3_owner..ut_be_between to public; grant execute on &&ut3_owner..ut_be_empty to public; grant execute on &&ut3_owner..ut_be_false to public; @@ -101,6 +103,8 @@ end; prompt Creating synonyms for UTPLSQL objects in &&ut3_owner schema to PUBLIC +create public synonym ut_expectation for &&ut3_owner..ut_expectation; +create public synonym ut_expectation_compound for &&ut3_owner..ut_expectation_compound; create public synonym be_between for &&ut3_owner..ut_be_between; create public synonym be_empty for &&ut3_owner..ut_be_empty; create public synonym be_false for &&ut3_owner..ut_be_false; diff --git a/source/create_user_grants.sql b/source/create_user_grants.sql index 76406ece9..112317027 100644 --- a/source/create_user_grants.sql +++ b/source/create_user_grants.sql @@ -51,6 +51,8 @@ whenever oserror exit failure rollback alter session set current_schema = &&ut3_owner; +grant execute on &&ut3_owner..ut_expectation to &ut3_user; +grant execute on &&ut3_owner..ut_expectation_compound to &ut3_user; grant execute on &&ut3_owner..ut_be_between to &ut3_user; grant execute on &&ut3_owner..ut_be_empty to &ut3_user; grant execute on &&ut3_owner..ut_be_false to &ut3_user; diff --git a/source/create_user_synonyms.sql b/source/create_user_synonyms.sql index 5e15c7ded..b16b0683c 100644 --- a/source/create_user_synonyms.sql +++ b/source/create_user_synonyms.sql @@ -53,6 +53,8 @@ alter session set current_schema = &&ut3_owner; prompt Creating synonyms for UTPLSQL objects in &&ut3_owner schema to user &&ut3_user +create or replace synonym &ut3_user..ut_expectation for &&ut3_owner..ut_expectation; +create or replace synonym &ut3_user..ut_expectation_compound for &&ut3_owner..ut_expectation_compound; create or replace synonym &ut3_user..be_between for &&ut3_owner..be_between; create or replace synonym &ut3_user..be_empty for &&ut3_owner..be_empty; create or replace synonym &ut3_user..be_false for &&ut3_owner..be_false; From 4fca43ec53df9594603b6d49cc4ac369c2ceb005 Mon Sep 17 00:00:00 2001 From: Travis CI Date: Mon, 9 Jul 2018 02:05:06 +0000 Subject: [PATCH 131/184] Updated project version after build [skip ci] --- source/core/ut_utils.pks | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/core/ut_utils.pks b/source/core/ut_utils.pks index 21d87738d..3d58b0c60 100644 --- a/source/core/ut_utils.pks +++ b/source/core/ut_utils.pks @@ -21,7 +21,7 @@ create or replace package ut_utils authid definer is * */ - gc_version constant varchar2(50) := 'v3.1.2.2044-develop'; + gc_version constant varchar2(50) := 'v3.1.2.2053-develop'; /* Constants: Event names */ subtype t_event_name is varchar2(30); From 93a45d20fcfc9d5243cb516d632e6302f7b067cb Mon Sep 17 00:00:00 2001 From: Jacek Gebal Date: Wed, 11 Jul 2018 01:51:41 +0100 Subject: [PATCH 132/184] Added support for BLOB/CLOB in `ut_be_empty` Resolves #707 Cleaned-up code. Moved some tests to improve the way tests are organized. Removed redundant tests. --- docs/userguide/expectations.md | 8 +- old_tests/RunAll.sql | 18 -- .../ut_utils/ut_utils.to_string.Blob.sql | 18 -- .../ut_utils/ut_utils.to_string.Clob.sql | 17 -- .../ut_utils/ut_utils.to_string.Date.sql | 16 -- .../ut_utils/ut_utils.to_string.NullBlob.sql | 15 -- .../ut_utils/ut_utils.to_string.NullClob.sql | 15 -- .../ut_utils/ut_utils.to_string.NullDate.sql | 15 -- .../ut_utils.to_string.NullNumber.sql | 15 -- .../ut_utils.to_string.NullTimestamp.sql | 15 -- .../ut_utils.to_string.NullVarchar2.sql | 15 -- .../ut_utils/ut_utils.to_string.Timestamp.sql | 19 -- ...s.to_string.TimestampWithLocalTimeZone.sql | 19 -- ..._utils.to_string.TimestampWithTimeZone.sql | 19 -- .../ut_utils/ut_utils.to_string.Varchar2.sql | 17 -- .../ut_utils.to_string.veryBigBlob.sql | 42 ---- .../ut_utils.to_string.veryBigClob.sql | 18 -- .../ut_utils.to_string.veryBigNumber.sql | 16 -- .../ut_utils.to_string.veryBigVarchar2.sql | 18 -- .../ut_utils.to_string.verySmallNumber.sql | 21 -- source/core/ut_utils.pkb | 8 +- source/core/ut_utils.pks | 1 + .../data_values/ut_compound_data_value.tpb | 7 +- .../data_values/ut_compound_data_value.tps | 1 - .../data_values/ut_data_value.tpb | 7 +- .../data_values/ut_data_value.tps | 1 + .../data_values/ut_data_value_blob.tpb | 9 + .../data_values/ut_data_value_blob.tps | 1 + .../data_values/ut_data_value_clob.tpb | 9 + .../data_values/ut_data_value_clob.tps | 1 + .../data_values/ut_data_value_collection.tpb | 4 +- .../data_values/ut_data_value_collection.tps | 3 +- .../data_values/ut_data_value_object.tpb | 5 - .../data_values/ut_data_value_object.tps | 3 +- .../data_values/ut_data_value_refcursor.tpb | 5 + .../data_values/ut_data_value_refcursor.tps | 4 +- source/expectations/matchers/ut_be_empty.tpb | 12 +- .../ut_coverage_report_html_helper.pkb | 2 +- .../binary/test_be_greater_or_equal.pkb | 0 .../binary/test_be_greater_or_equal.pks | 2 +- .../binary/test_be_greater_than.pkb | 0 .../binary/test_be_greater_than.pks | 2 +- .../binary/test_be_less_or_equal.pkb | 0 .../binary/test_be_less_or_equal.pks | 2 +- .../{scalar_data => }/binary/test_equal.pkb | 0 .../{scalar_data => }/binary/test_equal.pks | 2 +- .../binary/test_expect_to_be_less_than.pkb | 0 .../binary/test_expect_to_be_less_than.pks | 2 +- .../unary/test_expect_to_be_null.pks | 97 -------- .../test_expectation_anydata.pkb | 0 .../test_expectation_anydata.pks | 2 +- .../test_expectations_cursor.pkb | 0 .../test_expectations_cursor.pks | 4 +- .../unary/test_expect_not_to_be_null.pkb | 0 .../unary/test_expect_not_to_be_null.pks | 2 +- .../test_expect_to_be_empty.pkb | 65 +++++ .../test_expect_to_be_empty.pks | 72 ++++-- .../unary/test_expect_to_be_not_null.pkb | 4 +- .../unary/test_expect_to_be_not_null.pks | 10 +- .../unary/test_expect_to_be_null.pkb | 4 +- .../unary/test_expect_to_be_null.pks | 97 ++++++++ .../unary/test_expect_to_be_true_false.pkb | 0 .../unary/test_expect_to_be_true_false.pks | 2 +- .../test_expect_to_have_count.pkb | 0 .../test_expect_to_have_count.pks | 2 +- test/core/test_ut_utils.pkb | 233 ++++++++++-------- test/core/test_ut_utils.pks | 109 +++++--- test/install_tests.sql | 52 ++-- 68 files changed, 524 insertions(+), 680 deletions(-) delete mode 100644 old_tests/ut_utils/ut_utils.to_string.Blob.sql delete mode 100644 old_tests/ut_utils/ut_utils.to_string.Clob.sql delete mode 100644 old_tests/ut_utils/ut_utils.to_string.Date.sql delete mode 100644 old_tests/ut_utils/ut_utils.to_string.NullBlob.sql delete mode 100644 old_tests/ut_utils/ut_utils.to_string.NullClob.sql delete mode 100644 old_tests/ut_utils/ut_utils.to_string.NullDate.sql delete mode 100644 old_tests/ut_utils/ut_utils.to_string.NullNumber.sql delete mode 100644 old_tests/ut_utils/ut_utils.to_string.NullTimestamp.sql delete mode 100644 old_tests/ut_utils/ut_utils.to_string.NullVarchar2.sql delete mode 100644 old_tests/ut_utils/ut_utils.to_string.Timestamp.sql delete mode 100644 old_tests/ut_utils/ut_utils.to_string.TimestampWithLocalTimeZone.sql delete mode 100644 old_tests/ut_utils/ut_utils.to_string.TimestampWithTimeZone.sql delete mode 100644 old_tests/ut_utils/ut_utils.to_string.Varchar2.sql delete mode 100644 old_tests/ut_utils/ut_utils.to_string.veryBigBlob.sql delete mode 100644 old_tests/ut_utils/ut_utils.to_string.veryBigClob.sql delete mode 100644 old_tests/ut_utils/ut_utils.to_string.veryBigNumber.sql delete mode 100644 old_tests/ut_utils/ut_utils.to_string.veryBigVarchar2.sql delete mode 100644 old_tests/ut_utils/ut_utils.to_string.verySmallNumber.sql rename test/core/expectations/{scalar_data => }/binary/test_be_greater_or_equal.pkb (100%) rename test/core/expectations/{scalar_data => }/binary/test_be_greater_or_equal.pks (98%) rename test/core/expectations/{scalar_data => }/binary/test_be_greater_than.pkb (100%) rename test/core/expectations/{scalar_data => }/binary/test_be_greater_than.pks (98%) rename test/core/expectations/{scalar_data => }/binary/test_be_less_or_equal.pkb (100%) rename test/core/expectations/{scalar_data => }/binary/test_be_less_or_equal.pks (98%) rename test/core/expectations/{scalar_data => }/binary/test_equal.pkb (100%) rename test/core/expectations/{scalar_data => }/binary/test_equal.pks (95%) rename test/core/expectations/{scalar_data => }/binary/test_expect_to_be_less_than.pkb (100%) rename test/core/expectations/{scalar_data => }/binary/test_expect_to_be_less_than.pks (98%) delete mode 100644 test/core/expectations/scalar_data/unary/test_expect_to_be_null.pks rename test/core/expectations/{compound_data => }/test_expectation_anydata.pkb (100%) rename test/core/expectations/{compound_data => }/test_expectation_anydata.pks (98%) rename test/core/expectations/{compound_data => }/test_expectations_cursor.pkb (100%) rename test/core/expectations/{compound_data => }/test_expectations_cursor.pks (99%) rename test/core/expectations/{scalar_data => }/unary/test_expect_not_to_be_null.pkb (100%) rename test/core/expectations/{scalar_data => }/unary/test_expect_not_to_be_null.pks (97%) rename test/core/expectations/{compound_data => unary}/test_expect_to_be_empty.pkb (75%) rename test/core/expectations/{compound_data => unary}/test_expect_to_be_empty.pks (51%) rename test/core/expectations/{scalar_data => }/unary/test_expect_to_be_not_null.pkb (99%) rename test/core/expectations/{scalar_data => }/unary/test_expect_to_be_not_null.pks (91%) rename test/core/expectations/{scalar_data => }/unary/test_expect_to_be_null.pkb (99%) create mode 100644 test/core/expectations/unary/test_expect_to_be_null.pks rename test/core/expectations/{scalar_data => }/unary/test_expect_to_be_true_false.pkb (100%) rename test/core/expectations/{scalar_data => }/unary/test_expect_to_be_true_false.pks (96%) rename test/core/expectations/{compound_data => unary}/test_expect_to_have_count.pkb (100%) rename test/core/expectations/{compound_data => unary}/test_expect_to_have_count.pks (96%) diff --git a/docs/userguide/expectations.md b/docs/userguide/expectations.md index ae1176be5..4c6f3aa68 100644 --- a/docs/userguide/expectations.md +++ b/docs/userguide/expectations.md @@ -165,7 +165,11 @@ end; ## be_empty Unary matcher that validates if the provided dataset is empty. -Can be used with `refcursor` or `nested table`/`varray` passed as `ANYDATA` +Can be used with `BLOB`,`CLOB`, `refcursor` or `nested table`/`varray` passed as `ANYDATA` + +**Note:** +BLOB/CLOB that is initialized is not NULL but it is actually equal to `empty_blob()`/`empty_clob()`. + Usage: ```sql @@ -794,7 +798,7 @@ The matrix below illustrates the data types supported by different matchers. |**equal** | X | X | X | X | X | X | X | X | X | X | X | X | X | X | |**match** | | | X | | | | | | X | | | | | | |**be_like** | | | X | | | | | | X | | | | | | -|**be_empty** | | | | | | | | | | | | X | X | | +|**be_empty** | X | | X | | | | | | | | | X | X | | |**have_count** | | | | | | | | | | | | X | X | | diff --git a/old_tests/RunAll.sql b/old_tests/RunAll.sql index 206c01a1b..031f10574 100644 --- a/old_tests/RunAll.sql +++ b/old_tests/RunAll.sql @@ -166,24 +166,6 @@ exec ut_coverage.set_develop_mode(true); @@lib/RunTest.sql ut_utils/ut_utils.test_result_to_char.RunsWithInvalidValues.sql @@lib/RunTest.sql ut_utils/ut_utils.test_result_to_char.RunsWithNullValue.sql @@lib/RunTest.sql ut_utils/ut_utils.test_result_to_char.Success.sql -@@lib/RunTest.sql ut_utils/ut_utils.to_string.Blob.sql -@@lib/RunTest.sql ut_utils/ut_utils.to_string.Clob.sql -@@lib/RunTest.sql ut_utils/ut_utils.to_string.Date.sql -@@lib/RunTest.sql ut_utils/ut_utils.to_string.NullBlob.sql -@@lib/RunTest.sql ut_utils/ut_utils.to_string.NullClob.sql -@@lib/RunTest.sql ut_utils/ut_utils.to_string.NullDate.sql -@@lib/RunTest.sql ut_utils/ut_utils.to_string.NullNumber.sql -@@lib/RunTest.sql ut_utils/ut_utils.to_string.NullTimestamp.sql -@@lib/RunTest.sql ut_utils/ut_utils.to_string.NullVarchar2.sql -@@lib/RunTest.sql ut_utils/ut_utils.to_string.Timestamp.sql -@@lib/RunTest.sql ut_utils/ut_utils.to_string.TimestampWithLocalTimeZone.sql -@@lib/RunTest.sql ut_utils/ut_utils.to_string.TimestampWithTimeZone.sql -@@lib/RunTest.sql ut_utils/ut_utils.to_string.Varchar2.sql -@@lib/RunTest.sql ut_utils/ut_utils.to_string.veryBigBlob.sql -@@lib/RunTest.sql ut_utils/ut_utils.to_string.veryBigClob.sql -@@lib/RunTest.sql ut_utils/ut_utils.to_string.veryBigNumber.sql -@@lib/RunTest.sql ut_utils/ut_utils.to_string.veryBigVarchar2.sql -@@lib/RunTest.sql ut_utils/ut_utils.to_string.verySmallNumber.sql --Finally @@lib/RunSummary diff --git a/old_tests/ut_utils/ut_utils.to_string.Blob.sql b/old_tests/ut_utils/ut_utils.to_string.Blob.sql deleted file mode 100644 index 10ca127e3..000000000 --- a/old_tests/ut_utils/ut_utils.to_string.Blob.sql +++ /dev/null @@ -1,18 +0,0 @@ ---Arrange -declare - l_text varchar2(32767) := 'A test char'; - l_value blob := utl_raw.cast_to_raw(l_text); - l_expected varchar2(32767) := ''''||rawtohex(l_value)||''''; - l_result varchar2(32767); - l_delimiter varchar2(1); -begin ---Act - l_result := ut_utils.to_String(l_value); ---Assert - if l_result = l_expected then - :test_result := ut_utils.gc_success; - else - dbms_output.put_line('expected: '||l_expected||', got: '||l_result ); - end if; -end; -/ diff --git a/old_tests/ut_utils/ut_utils.to_string.Clob.sql b/old_tests/ut_utils/ut_utils.to_string.Clob.sql deleted file mode 100644 index 329059f53..000000000 --- a/old_tests/ut_utils/ut_utils.to_string.Clob.sql +++ /dev/null @@ -1,17 +0,0 @@ ---Arrange -declare - l_value clob := 'A test char'; - l_expected varchar2(32767) := ''''||l_value||''''; - l_result varchar2(32767); - l_delimiter varchar2(1); -begin ---Act - l_result := ut_utils.to_String(l_value); ---Assert - if l_result = l_expected then - :test_result := ut_utils.gc_success; - else - dbms_output.put_line('expected: '||l_expected||', got: '||l_result ); - end if; -end; -/ diff --git a/old_tests/ut_utils/ut_utils.to_string.Date.sql b/old_tests/ut_utils/ut_utils.to_string.Date.sql deleted file mode 100644 index 7d52f6cce..000000000 --- a/old_tests/ut_utils/ut_utils.to_string.Date.sql +++ /dev/null @@ -1,16 +0,0 @@ ---Arrange -declare - l_value date := to_date('2016-12-31 23:59:59', 'yyyy-mm-dd hh24:mi:ss'); - l_expected varchar2(100) := '2016-12-31T23:59:59'; - l_result varchar2(100); -begin ---Act - l_result := ut_utils.to_String(l_value); ---Assert - if l_result = l_expected then - :test_result := ut_utils.gc_success; - else - dbms_output.put_line('expected: '||l_expected||', got: '||l_result ); - end if; -end; -/ diff --git a/old_tests/ut_utils/ut_utils.to_string.NullBlob.sql b/old_tests/ut_utils/ut_utils.to_string.NullBlob.sql deleted file mode 100644 index c49a07fc0..000000000 --- a/old_tests/ut_utils/ut_utils.to_string.NullBlob.sql +++ /dev/null @@ -1,15 +0,0 @@ ---Arrange -declare - l_expected varchar2(100) := 'NULL'; - l_result varchar2(100); -begin ---Act - l_result := ut_utils.to_String(to_blob(NULL)); ---Assert - if l_result = l_expected then - :test_result := ut_utils.gc_success; - else - dbms_output.put_line('expected: '||l_expected||', got: '||l_result ); - end if; -end; -/ diff --git a/old_tests/ut_utils/ut_utils.to_string.NullClob.sql b/old_tests/ut_utils/ut_utils.to_string.NullClob.sql deleted file mode 100644 index f2e537505..000000000 --- a/old_tests/ut_utils/ut_utils.to_string.NullClob.sql +++ /dev/null @@ -1,15 +0,0 @@ ---Arrange -declare - l_expected varchar2(100) := 'NULL'; - l_result varchar2(100); -begin ---Act - l_result := ut_utils.to_String(to_clob(NULL)); ---Assert - if l_result = l_expected then - :test_result := ut_utils.gc_success; - else - dbms_output.put_line('expected: '||l_expected||', got: '||l_result ); - end if; -end; -/ diff --git a/old_tests/ut_utils/ut_utils.to_string.NullDate.sql b/old_tests/ut_utils/ut_utils.to_string.NullDate.sql deleted file mode 100644 index e4a9758d7..000000000 --- a/old_tests/ut_utils/ut_utils.to_string.NullDate.sql +++ /dev/null @@ -1,15 +0,0 @@ ---Arrange -declare - l_expected varchar2(100) := 'NULL'; - l_result varchar2(100); -begin ---Act - l_result := ut_utils.to_String(to_date(NULL)); ---Assert - if l_result = l_expected then - :test_result := ut_utils.gc_success; - else - dbms_output.put_line('expected: '||l_expected||', got: '||l_result ); - end if; -end; -/ diff --git a/old_tests/ut_utils/ut_utils.to_string.NullNumber.sql b/old_tests/ut_utils/ut_utils.to_string.NullNumber.sql deleted file mode 100644 index b33712050..000000000 --- a/old_tests/ut_utils/ut_utils.to_string.NullNumber.sql +++ /dev/null @@ -1,15 +0,0 @@ ---Arrange -declare - l_expected varchar2(100) := 'NULL'; - l_result varchar2(100); -begin ---Act - l_result := ut_utils.to_String(to_number(NULL)); ---Assert - if l_result = l_expected then - :test_result := ut_utils.gc_success; - else - dbms_output.put_line('expected: '||l_expected||', got: '||l_result ); - end if; -end; -/ diff --git a/old_tests/ut_utils/ut_utils.to_string.NullTimestamp.sql b/old_tests/ut_utils/ut_utils.to_string.NullTimestamp.sql deleted file mode 100644 index b1c9d99a3..000000000 --- a/old_tests/ut_utils/ut_utils.to_string.NullTimestamp.sql +++ /dev/null @@ -1,15 +0,0 @@ ---Arrange -declare - l_expected varchar2(100) := 'NULL'; - l_result varchar2(100); -begin ---Act - l_result := ut_utils.to_String(to_timestamp(NULL)); ---Assert - if l_result = l_expected then - :test_result := ut_utils.gc_success; - else - dbms_output.put_line('expected: '||l_expected||', got: '||l_result ); - end if; -end; -/ diff --git a/old_tests/ut_utils/ut_utils.to_string.NullVarchar2.sql b/old_tests/ut_utils/ut_utils.to_string.NullVarchar2.sql deleted file mode 100644 index 01f2286fc..000000000 --- a/old_tests/ut_utils/ut_utils.to_string.NullVarchar2.sql +++ /dev/null @@ -1,15 +0,0 @@ ---Arrange -declare - l_expected varchar2(100) := 'NULL'; - l_result varchar2(100); -begin ---Act - l_result := ut_utils.to_String(to_char(NULL)); ---Assert - if l_result = l_expected then - :test_result := ut_utils.gc_success; - else - dbms_output.put_line('expected: '||l_expected||', got: '||l_result ); - end if; -end; -/ diff --git a/old_tests/ut_utils/ut_utils.to_string.Timestamp.sql b/old_tests/ut_utils/ut_utils.to_string.Timestamp.sql deleted file mode 100644 index 63ae8fa3b..000000000 --- a/old_tests/ut_utils/ut_utils.to_string.Timestamp.sql +++ /dev/null @@ -1,19 +0,0 @@ ---Arrange -declare - l_value timestamp(9) := to_timestamp('2016-12-31 23:59:59.123456789', 'yyyy-mm-dd hh24:mi:ss.ff'); - l_expected varchar2(100); - l_result varchar2(100); - l_delimiter varchar2(1); -begin - select substr(value, 1, 1) into l_delimiter from nls_session_parameters t where t.parameter = 'NLS_NUMERIC_CHARACTERS'; - l_expected := '2016-12-31T23:59:59'||l_delimiter||'123456789'; ---Act - l_result := ut_utils.to_String(l_value); ---Assert - if l_result = l_expected then - :test_result := ut_utils.gc_success; - else - dbms_output.put_line('expected: '||l_expected||', got: '||l_result ); - end if; -end; -/ diff --git a/old_tests/ut_utils/ut_utils.to_string.TimestampWithLocalTimeZone.sql b/old_tests/ut_utils/ut_utils.to_string.TimestampWithLocalTimeZone.sql deleted file mode 100644 index 67c21e358..000000000 --- a/old_tests/ut_utils/ut_utils.to_string.TimestampWithLocalTimeZone.sql +++ /dev/null @@ -1,19 +0,0 @@ ---Arrange -declare - l_value timestamp(9) with local time zone:= to_timestamp('2016-12-31 23:59:59.123456789', 'yyyy-mm-dd hh24:mi:ss.ff'); - l_expected varchar2(100); - l_result varchar2(100); - l_delimiter varchar2(1); -begin - select substr(value, 1, 1) into l_delimiter from nls_session_parameters t where t.parameter = 'NLS_NUMERIC_CHARACTERS'; - l_expected := '2016-12-31T23:59:59'||l_delimiter||'123456789'; ---Act - l_result := ut_utils.to_String(l_value); ---Assert - if l_result = l_expected then - :test_result := ut_utils.gc_success; - else - dbms_output.put_line('expected: '||l_expected||', got: '||l_result ); - end if; -end; -/ diff --git a/old_tests/ut_utils/ut_utils.to_string.TimestampWithTimeZone.sql b/old_tests/ut_utils/ut_utils.to_string.TimestampWithTimeZone.sql deleted file mode 100644 index 608b16dae..000000000 --- a/old_tests/ut_utils/ut_utils.to_string.TimestampWithTimeZone.sql +++ /dev/null @@ -1,19 +0,0 @@ ---Arrange -declare - l_value timestamp(9) with time zone := to_timestamp_tz('2016-12-31 23:59:59.123456789 -8:00', 'yyyy-mm-dd hh24:mi:ss.ff tzh:tzm'); - l_expected varchar2(100); - l_result varchar2(100); - l_delimiter varchar2(1); -begin - select substr(value, 1, 1) into l_delimiter from nls_session_parameters t where t.parameter = 'NLS_NUMERIC_CHARACTERS'; - l_expected := '2016-12-31T23:59:59'||l_delimiter||'123456789 -08:00'; ---Act - l_result := ut_utils.to_String(l_value); ---Assert - if l_result = l_expected then - :test_result := ut_utils.gc_success; - else - dbms_output.put_line('expected: '||l_expected||', got: '||l_result ); - end if; -end; -/ diff --git a/old_tests/ut_utils/ut_utils.to_string.Varchar2.sql b/old_tests/ut_utils/ut_utils.to_string.Varchar2.sql deleted file mode 100644 index 72e60f724..000000000 --- a/old_tests/ut_utils/ut_utils.to_string.Varchar2.sql +++ /dev/null @@ -1,17 +0,0 @@ ---Arrange -declare - l_value varchar2(20) := 'A test char'; - l_expected varchar2(100) := ''''||l_value||''''; - l_result varchar2(100); - l_delimiter varchar2(1); -begin ---Act - l_result := ut_utils.to_String(l_value); ---Assert - if l_result = l_expected then - :test_result := ut_utils.gc_success; - else - dbms_output.put_line('expected: '||l_expected||', got: '||l_result ); - end if; -end; -/ diff --git a/old_tests/ut_utils/ut_utils.to_string.veryBigBlob.sql b/old_tests/ut_utils/ut_utils.to_string.veryBigBlob.sql deleted file mode 100644 index c213a5f05..000000000 --- a/old_tests/ut_utils/ut_utils.to_string.veryBigBlob.sql +++ /dev/null @@ -1,42 +0,0 @@ ---Arrange -declare - l_text clob := lpad('A test char',32767,'1')||lpad('1',32767,'1'); - l_value blob; - l_result varchar2(32767); - l_delimiter varchar2(1); - function clob_to_blob(p_clob clob) return blob - as - l_blob blob; - l_dest_offset integer := 1; - l_source_offset integer := 1; - l_lang_context integer := dbms_lob.default_lang_ctx; - l_warning integer := dbms_lob.warn_inconvertible_char; - begin - dbms_lob.createtemporary(l_blob, true); - dbms_lob.converttoblob( - dest_lob =>l_blob, - src_clob =>p_clob, - amount =>DBMS_LOB.LOBMAXSIZE, - dest_offset =>l_dest_offset, - src_offset =>l_source_offset, - blob_csid =>DBMS_LOB.DEFAULT_CSID, - lang_context=>l_lang_context, - warning =>l_warning - ); - return l_blob; - end; -begin - l_value := clob_to_blob(l_text); - ---Act - l_result := ut_utils.to_String(l_value); ---Assert - if length(l_result) != ut_utils.gc_max_output_string_length then - dbms_output.put_line('expected: length(l_result)='||ut_utils.gc_max_output_string_length||', got: '||length(l_result) ); - elsif l_result not like '%'||ut_utils.gc_more_data_string then - dbms_output.put_line('expected: l_result to match %'''||ut_utils.gc_more_data_string||', got: '||substr(l_result,-10) ); - else - :test_result := ut_utils.gc_success; - end if; -end; -/ diff --git a/old_tests/ut_utils/ut_utils.to_string.veryBigClob.sql b/old_tests/ut_utils/ut_utils.to_string.veryBigClob.sql deleted file mode 100644 index 61ebb1d3f..000000000 --- a/old_tests/ut_utils/ut_utils.to_string.veryBigClob.sql +++ /dev/null @@ -1,18 +0,0 @@ ---Arrange -declare - l_value clob := lpad('A test char',32767,'1')||lpad('1',32767,'1'); - l_result varchar2(32767); - l_delimiter varchar2(1); -begin ---Act - l_result := ut_utils.to_String(l_value); ---Assert - if length(l_result) != ut_utils.gc_max_output_string_length then - dbms_output.put_line('expected: length(l_result)='||ut_utils.gc_max_output_string_length||', got: '||length(l_result) ); - elsif l_result not like '%'||ut_utils.gc_more_data_string then - dbms_output.put_line('expected: l_result to match %'||ut_utils.gc_more_data_string||', got: '||substr(l_result,-10) ); - else - :test_result := ut_utils.gc_success; - end if; -end; -/ diff --git a/old_tests/ut_utils/ut_utils.to_string.veryBigNumber.sql b/old_tests/ut_utils/ut_utils.to_string.veryBigNumber.sql deleted file mode 100644 index 02d40961d..000000000 --- a/old_tests/ut_utils/ut_utils.to_string.veryBigNumber.sql +++ /dev/null @@ -1,16 +0,0 @@ ---Arrange -declare - l_value number := 1234567890123456789012345678901234567890; - l_expected varchar2(100) := '1234567890123456789012345678901234567890'; - l_result varchar2(100); -begin ---Act - l_result := ut_utils.to_String(l_value); ---Assert - if l_result = l_expected then - :test_result := ut_utils.gc_success; - else - dbms_output.put_line('expected: '||l_expected||', got: '||l_result ); - end if; -end; -/ diff --git a/old_tests/ut_utils/ut_utils.to_string.veryBigVarchar2.sql b/old_tests/ut_utils/ut_utils.to_string.veryBigVarchar2.sql deleted file mode 100644 index 2ef83611f..000000000 --- a/old_tests/ut_utils/ut_utils.to_string.veryBigVarchar2.sql +++ /dev/null @@ -1,18 +0,0 @@ ---Arrange -declare - l_value varchar2(32767) := lpad('A test char',32767,'1'); - l_result varchar2(32767); - l_delimiter varchar2(1); -begin ---Act - l_result := ut_utils.to_String(l_value); ---Assert - if length(l_result) != ut_utils.gc_max_output_string_length then - dbms_output.put_line('expected: length(l_result)='||ut_utils.gc_max_output_string_length||', got: '||length(l_result) ); - elsif l_result not like '%'||ut_utils.gc_more_data_string then - dbms_output.put_line('expected: l_result to match %'||ut_utils.gc_more_data_string||', got: '||substr(l_result,-10) ); - else - :test_result := ut_utils.gc_success; - end if; -end; -/ diff --git a/old_tests/ut_utils/ut_utils.to_string.verySmallNumber.sql b/old_tests/ut_utils/ut_utils.to_string.verySmallNumber.sql deleted file mode 100644 index abc98cb3b..000000000 --- a/old_tests/ut_utils/ut_utils.to_string.verySmallNumber.sql +++ /dev/null @@ -1,21 +0,0 @@ ---Arrange -declare - l_value number := 0.123456789012345678901234567890123456789; - l_expected varchar2(100) := '.123456789012345678901234567890123456789'; - l_result varchar2(100); - l_delimiter varchar2(1); -begin ---Act - select substr(value, 1, 1) into l_delimiter from nls_session_parameters t where t.parameter = 'NLS_NUMERIC_CHARACTERS'; - l_expected := l_delimiter||'123456789012345678901234567890123456789'; - - l_result := ut_utils.to_String(l_value); - ---Assert - if l_result = l_expected then - :test_result := ut_utils.gc_success; - else - dbms_output.put_line('expected: '||l_expected||', got: '||l_result ); - end if; -end; -/ diff --git a/source/core/ut_utils.pkb b/source/core/ut_utils.pkb index bbed8d348..7130ff6c5 100644 --- a/source/core/ut_utils.pkb +++ b/source/core/ut_utils.pkb @@ -107,8 +107,10 @@ create or replace package body ut_utils is l_len integer := coalesce(dbms_lob.getlength(a_value), 0); l_result varchar2(32767); begin - if l_len = 0 then + if a_value is null then l_result := gc_null_string; + elsif l_len = 0 then + l_result := gc_empty_string; elsif l_len <= gc_max_input_string_length then l_result := surround_with(a_value,a_qoute_char); else @@ -121,8 +123,10 @@ create or replace package body ut_utils is l_len integer := coalesce(dbms_lob.getlength(a_value), 0); l_result varchar2(32767); begin - if l_len = 0 then + if a_value is null then l_result := gc_null_string; + elsif l_len = 0 then + l_result := gc_empty_string; elsif l_len <= gc_max_input_string_length then l_result := surround_with(rawtohex(a_value),a_qoute_char); else diff --git a/source/core/ut_utils.pks b/source/core/ut_utils.pks index 3d58b0c60..20502c485 100644 --- a/source/core/ut_utils.pks +++ b/source/core/ut_utils.pks @@ -124,6 +124,7 @@ create or replace package ut_utils authid definer is gc_timestamp_format constant varchar2(100) := 'yyyy-mm-dd"T"hh24:mi:ssxff'; gc_timestamp_tz_format constant varchar2(100) := 'yyyy-mm-dd"T"hh24:mi:ssxff tzh:tzm'; gc_null_string constant varchar2(4) := 'NULL'; + gc_empty_string constant varchar2(5) := 'EMPTY'; type t_version is record( major natural, diff --git a/source/expectations/data_values/ut_compound_data_value.tpb b/source/expectations/data_values/ut_compound_data_value.tpb index 0222c4fd0..2d7f5ff65 100644 --- a/source/expectations/data_values/ut_compound_data_value.tpb +++ b/source/expectations/data_values/ut_compound_data_value.tpb @@ -31,14 +31,9 @@ create or replace type body ut_compound_data_value as return true; end; - member function is_empty return boolean is - begin - return self.elements_count = 0; - end; - overriding member function is_multi_line return boolean is begin - return not self.is_null() and not self.is_empty(); + return not self.is_null(); end; overriding member function compare_implementation(a_other ut_data_value) return integer is diff --git a/source/expectations/data_values/ut_compound_data_value.tps b/source/expectations/data_values/ut_compound_data_value.tps index 003373271..f95fa478c 100644 --- a/source/expectations/data_values/ut_compound_data_value.tps +++ b/source/expectations/data_values/ut_compound_data_value.tps @@ -38,7 +38,6 @@ create or replace type ut_compound_data_value force under ut_data_value( overriding member function get_object_info return varchar2, overriding member function is_null return boolean, overriding member function is_diffable return boolean, - member function is_empty return boolean, overriding member function to_string return varchar2, overriding member function is_multi_line return boolean, overriding member function compare_implementation(a_other ut_data_value) return integer, diff --git a/source/expectations/data_values/ut_data_value.tpb b/source/expectations/data_values/ut_data_value.tpb index d5ec11092..db7d29763 100644 --- a/source/expectations/data_values/ut_data_value.tpb +++ b/source/expectations/data_values/ut_data_value.tpb @@ -24,7 +24,12 @@ create or replace type body ut_data_value as begin return false; end; - + + member function is_empty return boolean is + begin + raise value_error; + end; + member function diff( a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2, a_join_by_xpath varchar2, a_unordered boolean :=false ) return varchar2 is begin return null; diff --git a/source/expectations/data_values/ut_data_value.tps b/source/expectations/data_values/ut_data_value.tps index 79ac4eef9..e9ad68bba 100644 --- a/source/expectations/data_values/ut_data_value.tps +++ b/source/expectations/data_values/ut_data_value.tps @@ -24,6 +24,7 @@ create or replace type ut_data_value force authid current_user as object ( final member function to_string_report(a_add_new_line_for_multi_line boolean := false, a_with_object_info boolean := true) return varchar2, order member function compare( a_other ut_data_value ) return integer, member function is_diffable return boolean, + member function is_empty return boolean, member function diff( a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2, a_join_by_xpath varchar2, a_unordered boolean := false ) return varchar2, not instantiable member function compare_implementation( a_other ut_data_value ) return integer ) not final not instantiable diff --git a/source/expectations/data_values/ut_data_value_blob.tpb b/source/expectations/data_values/ut_data_value_blob.tpb index cd66f43fe..0f7f1d758 100644 --- a/source/expectations/data_values/ut_data_value_blob.tpb +++ b/source/expectations/data_values/ut_data_value_blob.tpb @@ -29,6 +29,15 @@ create or replace type body ut_data_value_blob as return (self.data_value is null); end; + overriding member function is_empty return boolean is + l_result boolean := false; + begin + if self.data_value is not null and dbms_lob.compare( self.data_value, empty_blob()) = 0 then + l_result := true; + end if; + return l_result; + end; + overriding member function to_string return varchar2 is begin return ut_utils.to_string(self.data_value); diff --git a/source/expectations/data_values/ut_data_value_blob.tps b/source/expectations/data_values/ut_data_value_blob.tps index ce8376cb3..8ebfffc3e 100644 --- a/source/expectations/data_values/ut_data_value_blob.tps +++ b/source/expectations/data_values/ut_data_value_blob.tps @@ -18,6 +18,7 @@ create or replace type ut_data_value_blob under ut_data_value( data_value blob, constructor function ut_data_value_blob(self in out nocopy ut_data_value_blob, a_value blob) return self as result, overriding member function is_null return boolean, + overriding member function is_empty return boolean, overriding member function to_string return varchar2, overriding member function is_multi_line return boolean, overriding member function compare_implementation(a_other ut_data_value) return integer diff --git a/source/expectations/data_values/ut_data_value_clob.tpb b/source/expectations/data_values/ut_data_value_clob.tpb index c8004ce83..289a3a73c 100644 --- a/source/expectations/data_values/ut_data_value_clob.tpb +++ b/source/expectations/data_values/ut_data_value_clob.tpb @@ -29,6 +29,15 @@ create or replace type body ut_data_value_clob as return (self.data_value is null); end; + overriding member function is_empty return boolean is + l_result boolean := false; + begin + if self.data_value is not null and dbms_lob.compare( self.data_value, empty_clob()) = 0 then + l_result := true; + end if; + return l_result; + end; + overriding member function to_string return varchar2 is begin return ut_utils.to_string(self.data_value); diff --git a/source/expectations/data_values/ut_data_value_clob.tps b/source/expectations/data_values/ut_data_value_clob.tps index 14735ed19..d72e05926 100644 --- a/source/expectations/data_values/ut_data_value_clob.tps +++ b/source/expectations/data_values/ut_data_value_clob.tps @@ -18,6 +18,7 @@ create or replace type ut_data_value_clob under ut_data_value( data_value clob, constructor function ut_data_value_clob(self in out nocopy ut_data_value_clob, a_value clob) return self as result, overriding member function is_null return boolean, + overriding member function is_empty return boolean, overriding member function to_string return varchar2, overriding member function is_multi_line return boolean, overriding member function compare_implementation(a_other ut_data_value) return integer diff --git a/source/expectations/data_values/ut_data_value_collection.tpb b/source/expectations/data_values/ut_data_value_collection.tpb index 156b5a73d..fa91a1fb4 100644 --- a/source/expectations/data_values/ut_data_value_collection.tpb +++ b/source/expectations/data_values/ut_data_value_collection.tpb @@ -36,9 +36,9 @@ create or replace type body ut_data_value_collection as return; end; - overriding member function is_multi_line return boolean is + overriding member function is_empty return boolean is begin - return not self.is_null(); + return self.elements_count = 0; end; end; diff --git a/source/expectations/data_values/ut_data_value_collection.tps b/source/expectations/data_values/ut_data_value_collection.tps index 243de3c64..e375e27d0 100644 --- a/source/expectations/data_values/ut_data_value_collection.tps +++ b/source/expectations/data_values/ut_data_value_collection.tps @@ -17,6 +17,7 @@ create or replace type ut_data_value_collection under ut_data_value_anydata( */ constructor function ut_data_value_collection(self in out nocopy ut_data_value_collection, a_value anydata) return self as result, - overriding member function is_multi_line return boolean + overriding member function is_empty return boolean + ) / diff --git a/source/expectations/data_values/ut_data_value_object.tpb b/source/expectations/data_values/ut_data_value_object.tpb index a683336c6..c3c26f4bc 100644 --- a/source/expectations/data_values/ut_data_value_object.tpb +++ b/source/expectations/data_values/ut_data_value_object.tpb @@ -28,10 +28,5 @@ create or replace type body ut_data_value_object as return self.data_type; end; - overriding member function is_multi_line return boolean is - begin - return not self.is_null(); - end; - end; / diff --git a/source/expectations/data_values/ut_data_value_object.tps b/source/expectations/data_values/ut_data_value_object.tps index 4457186a4..3cc6ee051 100644 --- a/source/expectations/data_values/ut_data_value_object.tps +++ b/source/expectations/data_values/ut_data_value_object.tps @@ -16,7 +16,6 @@ create or replace type ut_data_value_object under ut_data_value_anydata( limitations under the License. */ constructor function ut_data_value_object(self in out nocopy ut_data_value_object, a_value anydata) return self as result, - overriding member function get_object_info return varchar2, - overriding member function is_multi_line return boolean + overriding member function get_object_info return varchar2 ) / diff --git a/source/expectations/data_values/ut_data_value_refcursor.tpb b/source/expectations/data_values/ut_data_value_refcursor.tpb index 18b49bd73..701b01d3c 100644 --- a/source/expectations/data_values/ut_data_value_refcursor.tpb +++ b/source/expectations/data_values/ut_data_value_refcursor.tpb @@ -257,6 +257,11 @@ create or replace type body ut_data_value_refcursor as return l_result; end; + overriding member function is_empty return boolean is + begin + return self.elements_count = 0; + end; + end; / diff --git a/source/expectations/data_values/ut_data_value_refcursor.tps b/source/expectations/data_values/ut_data_value_refcursor.tps index 701272581..27f4a4d7c 100644 --- a/source/expectations/data_values/ut_data_value_refcursor.tps +++ b/source/expectations/data_values/ut_data_value_refcursor.tps @@ -44,6 +44,8 @@ create or replace type ut_data_value_refcursor under ut_compound_data_value( member procedure init(self in out nocopy ut_data_value_refcursor, a_value sys_refcursor), overriding member function to_string return varchar2, overriding member function diff( a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2, a_join_by_xpath varchar2, a_unordered boolean := false ) return varchar2, - overriding member function compare_implementation(a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2, a_join_by_xpath varchar2, a_unordered boolean) return integer + overriding member function compare_implementation(a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2, a_join_by_xpath varchar2, a_unordered boolean) return integer, + overriding member function is_empty return boolean + ) / diff --git a/source/expectations/matchers/ut_be_empty.tpb b/source/expectations/matchers/ut_be_empty.tpb index c5ab2261a..7bf9bdd84 100644 --- a/source/expectations/matchers/ut_be_empty.tpb +++ b/source/expectations/matchers/ut_be_empty.tpb @@ -30,14 +30,10 @@ create or replace type body ut_be_empty as overriding member function run_matcher(self in out nocopy ut_be_empty, a_actual ut_data_value) return boolean is l_result boolean; begin - if a_actual is of(ut_data_value_refcursor) then - l_result := treat(a_actual as ut_data_value_refcursor).is_empty; - elsif a_actual is of(ut_data_value_collection) then - l_result := treat(a_actual as ut_data_value_collection).is_empty; - else - l_result := (self as ut_matcher).run_matcher(a_actual); - end if; - return l_result; + return a_actual.is_empty(); + exception + when value_error then + return (self as ut_matcher).run_matcher(a_actual); end; end; diff --git a/source/reporters/ut_coverage_report_html_helper.pkb b/source/reporters/ut_coverage_report_html_helper.pkb index ea03e461b..6b310e1f8 100644 --- a/source/reporters/ut_coverage_report_html_helper.pkb +++ b/source/reporters/ut_coverage_report_html_helper.pkb @@ -297,7 +297,7 @@ function get_details_file_content(a_object_id varchar2, a_unit ut_object_name, a l_charset := coalesce(upper(a_charset),'UTF-8'); l_coverage_pct := coverage_pct(a_coverage_data.covered_lines, a_coverage_data.uncovered_lines); - l_time_str := ut_utils.to_string(sysdate); + l_time_str := to_char(sysdate,'yyyy-mm-dd"T"hh24:mi:ss'); l_using := case when a_command_line is not null then '
using ' || dbms_xmlgen.convert(a_command_line) diff --git a/test/core/expectations/scalar_data/binary/test_be_greater_or_equal.pkb b/test/core/expectations/binary/test_be_greater_or_equal.pkb similarity index 100% rename from test/core/expectations/scalar_data/binary/test_be_greater_or_equal.pkb rename to test/core/expectations/binary/test_be_greater_or_equal.pkb diff --git a/test/core/expectations/scalar_data/binary/test_be_greater_or_equal.pks b/test/core/expectations/binary/test_be_greater_or_equal.pks similarity index 98% rename from test/core/expectations/scalar_data/binary/test_be_greater_or_equal.pks rename to test/core/expectations/binary/test_be_greater_or_equal.pks index a9f0e0c75..3aa21b486 100644 --- a/test/core/expectations/scalar_data/binary/test_be_greater_or_equal.pks +++ b/test/core/expectations/binary/test_be_greater_or_equal.pks @@ -1,7 +1,7 @@ create or replace package test_be_greater_or_equal is --%suite((not)to_be_greater_or_equal) - --%suitepath(utplsql.core.expectations.scalar_data.binary) + --%suitepath(utplsql.core.expectations.binary) --%aftereach procedure cleanup_expectations; diff --git a/test/core/expectations/scalar_data/binary/test_be_greater_than.pkb b/test/core/expectations/binary/test_be_greater_than.pkb similarity index 100% rename from test/core/expectations/scalar_data/binary/test_be_greater_than.pkb rename to test/core/expectations/binary/test_be_greater_than.pkb diff --git a/test/core/expectations/scalar_data/binary/test_be_greater_than.pks b/test/core/expectations/binary/test_be_greater_than.pks similarity index 98% rename from test/core/expectations/scalar_data/binary/test_be_greater_than.pks rename to test/core/expectations/binary/test_be_greater_than.pks index 6563addd0..cb3f666d5 100644 --- a/test/core/expectations/scalar_data/binary/test_be_greater_than.pks +++ b/test/core/expectations/binary/test_be_greater_than.pks @@ -1,7 +1,7 @@ create or replace package test_be_greater_than is --%suite((not)to_be_greater_than) - --%suitepath(utplsql.core.expectations.scalar_data.binary) + --%suitepath(utplsql.core.expectations.binary) --%aftereach procedure cleanup_expectations; diff --git a/test/core/expectations/scalar_data/binary/test_be_less_or_equal.pkb b/test/core/expectations/binary/test_be_less_or_equal.pkb similarity index 100% rename from test/core/expectations/scalar_data/binary/test_be_less_or_equal.pkb rename to test/core/expectations/binary/test_be_less_or_equal.pkb diff --git a/test/core/expectations/scalar_data/binary/test_be_less_or_equal.pks b/test/core/expectations/binary/test_be_less_or_equal.pks similarity index 98% rename from test/core/expectations/scalar_data/binary/test_be_less_or_equal.pks rename to test/core/expectations/binary/test_be_less_or_equal.pks index 4cfdd0af6..74f98a412 100644 --- a/test/core/expectations/scalar_data/binary/test_be_less_or_equal.pks +++ b/test/core/expectations/binary/test_be_less_or_equal.pks @@ -1,7 +1,7 @@ create or replace package test_be_less_or_equal is --%suite((not)to_be_less_or_equal) - --%suitepath(utplsql.core.expectations.scalar_data.binary) + --%suitepath(utplsql.core.expectations.binary) --%aftereach procedure cleanup_expectations; diff --git a/test/core/expectations/scalar_data/binary/test_equal.pkb b/test/core/expectations/binary/test_equal.pkb similarity index 100% rename from test/core/expectations/scalar_data/binary/test_equal.pkb rename to test/core/expectations/binary/test_equal.pkb diff --git a/test/core/expectations/scalar_data/binary/test_equal.pks b/test/core/expectations/binary/test_equal.pks similarity index 95% rename from test/core/expectations/scalar_data/binary/test_equal.pks rename to test/core/expectations/binary/test_equal.pks index 80b00eefb..c0280c288 100644 --- a/test/core/expectations/scalar_data/binary/test_equal.pks +++ b/test/core/expectations/binary/test_equal.pks @@ -1,7 +1,7 @@ create or replace package test_equal is --%suite((not)to_be_equal) - --%suitepath(utplsql.core.expectations.scalar_data.binary) + --%suitepath(utplsql.core.expectations.binary) procedure reset_nulls_equal; diff --git a/test/core/expectations/scalar_data/binary/test_expect_to_be_less_than.pkb b/test/core/expectations/binary/test_expect_to_be_less_than.pkb similarity index 100% rename from test/core/expectations/scalar_data/binary/test_expect_to_be_less_than.pkb rename to test/core/expectations/binary/test_expect_to_be_less_than.pkb diff --git a/test/core/expectations/scalar_data/binary/test_expect_to_be_less_than.pks b/test/core/expectations/binary/test_expect_to_be_less_than.pks similarity index 98% rename from test/core/expectations/scalar_data/binary/test_expect_to_be_less_than.pks rename to test/core/expectations/binary/test_expect_to_be_less_than.pks index 555de2fb4..785c5c122 100644 --- a/test/core/expectations/scalar_data/binary/test_expect_to_be_less_than.pks +++ b/test/core/expectations/binary/test_expect_to_be_less_than.pks @@ -1,7 +1,7 @@ create or replace package test_expect_to_be_less_than is --%suite((not)to_be_less_than) - --%suitepath(utplsql.core.expectations.scalar_data.binary) + --%suitepath(utplsql.core.expectations.binary) --%aftereach procedure cleanup_expectations; diff --git a/test/core/expectations/scalar_data/unary/test_expect_to_be_null.pks b/test/core/expectations/scalar_data/unary/test_expect_to_be_null.pks deleted file mode 100644 index d6cc6433d..000000000 --- a/test/core/expectations/scalar_data/unary/test_expect_to_be_null.pks +++ /dev/null @@ -1,97 +0,0 @@ -create or replace package test_expect_to_be_null -is - --%suite(to_be_null) - --%suitepath(utplsql.core.expectations.scalar_data.unary) - - --%aftereach - procedure cleanup_expectations; - - --%beforeall - procedure create_types; - - --%afterall - procedure drop_types; - - --%test(Gives success with null blob) - procedure null_blob; - - --%test(Gives success with null boolean) - procedure null_boolean; - - --%test(Gives success with null clob) - procedure null_clob; - - --%test(Gives success with null date) - procedure null_date; - - --%test(Gives success with null number) - procedure null_number; - - --%test(Gives success null timestamp) - procedure null_timestamp; - - --%test(Gives success with null timestamp with local time zone) - procedure null_timestamp_with_ltz; - - --%test(Gives success with null timestamp with time zone) - procedure null_timestamp_with_tz; - - --%test(Gives success with null varchar2) - procedure null_varchar2; - - --%test(Gives success with null anydata) - procedure null_anydata; - - --%test(Gives success with uninitialized object within anydata) - procedure uninit_object_in_anydata; - - --%test(Gives success with uninitialized nested table within anydata) - procedure uninit_nested_table_in_anydata; - - --%test(Gives success with uninitialized varray within anydata) - procedure uninit_varray_in_anydata; - - --%test(Gives failure for not null blob) - procedure blob_not_null; - - --%test(Gives failure for blob with length 0) - procedure blob_0_length; - - --%test(Gives failure for not null boolean) - procedure boolean_not_null; - - --%test(Gives failure for not null clob) - procedure clob_not_null; - - --%test(Gives failure for clob with length 0) - procedure clob_0_length; - - --%test(Gives failure for not null date) - procedure date_not_null; - - --%test(Gives failure for not null number) - procedure number_not_null; - - --%test(Gives failure for not null timestamp) - procedure timestamp_not_null; - - --%test(Gives failure for not null timestamp with local time zone) - procedure timestamp_with_ltz_not_null; - - --%test(Gives failure for not null timestamp with time zone) - procedure timestamp_with_tz_not_null; - - --%test(Gives failure for not null varchar2) - procedure varchar2_not_null; - - --%test(Gives failure for initialized object within anydata) - procedure initialized_object; - - --%test(Gives failure for initialized nested table within anydata) - procedure initialized_nested_table; - - --%test(Gives failure for initialized varray within anydata) - procedure initialized_varray; - -end test_expect_to_be_null; -/ diff --git a/test/core/expectations/compound_data/test_expectation_anydata.pkb b/test/core/expectations/test_expectation_anydata.pkb similarity index 100% rename from test/core/expectations/compound_data/test_expectation_anydata.pkb rename to test/core/expectations/test_expectation_anydata.pkb diff --git a/test/core/expectations/compound_data/test_expectation_anydata.pks b/test/core/expectations/test_expectation_anydata.pks similarity index 98% rename from test/core/expectations/compound_data/test_expectation_anydata.pks rename to test/core/expectations/test_expectation_anydata.pks index 95df59512..fedec586c 100644 --- a/test/core/expectations/compound_data/test_expectation_anydata.pks +++ b/test/core/expectations/test_expectation_anydata.pks @@ -1,7 +1,7 @@ create or replace package test_expectation_anydata is --%suite(equal on anydata) - --%suitepath(utplsql.core.expectations.compound_data) + --%suitepath(utplsql.core.expectations) --%aftereach procedure cleanup; diff --git a/test/core/expectations/compound_data/test_expectations_cursor.pkb b/test/core/expectations/test_expectations_cursor.pkb similarity index 100% rename from test/core/expectations/compound_data/test_expectations_cursor.pkb rename to test/core/expectations/test_expectations_cursor.pkb diff --git a/test/core/expectations/compound_data/test_expectations_cursor.pks b/test/core/expectations/test_expectations_cursor.pks similarity index 99% rename from test/core/expectations/compound_data/test_expectations_cursor.pks rename to test/core/expectations/test_expectations_cursor.pks index b95c73735..a1cff85d9 100644 --- a/test/core/expectations/compound_data/test_expectations_cursor.pks +++ b/test/core/expectations/test_expectations_cursor.pks @@ -1,7 +1,7 @@ create or replace package test_expectations_cursor is - --%suite(cursor) - --%suitepath(utplsql.core.expectations.compound_data) + --%suite(cursor expectations) + --%suitepath(utplsql.core.expectations) --%aftereach procedure cleanup_expectations; diff --git a/test/core/expectations/scalar_data/unary/test_expect_not_to_be_null.pkb b/test/core/expectations/unary/test_expect_not_to_be_null.pkb similarity index 100% rename from test/core/expectations/scalar_data/unary/test_expect_not_to_be_null.pkb rename to test/core/expectations/unary/test_expect_not_to_be_null.pkb diff --git a/test/core/expectations/scalar_data/unary/test_expect_not_to_be_null.pks b/test/core/expectations/unary/test_expect_not_to_be_null.pks similarity index 97% rename from test/core/expectations/scalar_data/unary/test_expect_not_to_be_null.pks rename to test/core/expectations/unary/test_expect_not_to_be_null.pks index 867f9274b..fa2d6193f 100644 --- a/test/core/expectations/scalar_data/unary/test_expect_not_to_be_null.pks +++ b/test/core/expectations/unary/test_expect_not_to_be_null.pks @@ -1,7 +1,7 @@ create or replace package test_expect_not_to_be_null is --%suite(not_to_be_null) - --%suitepath(utplsql.core.expectations.scalar_data.unary) + --%suitepath(utplsql.core.expectations.unary) --%aftereach procedure cleanup_expectations; diff --git a/test/core/expectations/compound_data/test_expect_to_be_empty.pkb b/test/core/expectations/unary/test_expect_to_be_empty.pkb similarity index 75% rename from test/core/expectations/compound_data/test_expect_to_be_empty.pkb rename to test/core/expectations/unary/test_expect_to_be_empty.pkb index 05e05a706..ef4c34c12 100644 --- a/test/core/expectations/compound_data/test_expect_to_be_empty.pkb +++ b/test/core/expectations/unary/test_expect_to_be_empty.pkb @@ -198,5 +198,70 @@ was expected to be empty%%]'; ut.expect(expectations.failed_expectations_data()).not_to_be_empty(); end; + procedure success_be_empty_clob is + begin + -- Act + ut3.ut.expect( empty_clob() ).to_( ut3.be_empty() ); + --Assert + ut.expect(expectations.failed_expectations_data()).to_be_empty(); + end; + + procedure fail_be_empty_clob is + begin + -- Act + ut3.ut.expect( to_clob(' ') ).to_( ut3.be_empty() ); + --Assert + ut.expect(expectations.failed_expectations_data()).not_to_be_empty(); + end; + + procedure success_be_empty_blob is + begin + -- Act + ut3.ut.expect( empty_blob() ).to_( ut3.be_empty() ); + --Assert + ut.expect(expectations.failed_expectations_data()).to_be_empty(); + end; + + procedure fail_be_empty_blob is + begin + -- Act + ut3.ut.expect( to_blob('AA') ).to_( ut3.be_empty() ); + --Assert + ut.expect(expectations.failed_expectations_data()).not_to_be_empty(); + end; + + + procedure fail_not_be_empty_clob is + begin + -- Act + ut3.ut.expect( empty_clob() ).not_to( ut3.be_empty() ); + --Assert + ut.expect(expectations.failed_expectations_data()).not_to_be_empty(); + end; + + procedure success_not_be_empty_clob is + begin + -- Act + ut3.ut.expect( to_clob(' ') ).not_to( ut3.be_empty() ); + --Assert + ut.expect(expectations.failed_expectations_data()).to_be_empty(); + end; + + procedure fail_not_be_empty_blob is + begin + -- Act + ut3.ut.expect( empty_blob() ).not_to( ut3.be_empty() ); + --Assert + ut.expect(expectations.failed_expectations_data()).not_to_be_empty(); + end; + + procedure success_not_be_empty_blob is + begin + -- Act + ut3.ut.expect( to_blob('AA') ).not_to( ut3.be_empty() ); + --Assert + ut.expect(expectations.failed_expectations_data()).to_be_empty(); + end; + end; / \ No newline at end of file diff --git a/test/core/expectations/compound_data/test_expect_to_be_empty.pks b/test/core/expectations/unary/test_expect_to_be_empty.pks similarity index 51% rename from test/core/expectations/compound_data/test_expect_to_be_empty.pks rename to test/core/expectations/unary/test_expect_to_be_empty.pks index f81a78670..f48db600f 100644 --- a/test/core/expectations/compound_data/test_expect_to_be_empty.pks +++ b/test/core/expectations/unary/test_expect_to_be_empty.pks @@ -1,11 +1,13 @@ create or replace package test_expect_to_be_empty is - --%suite((not)to_be_empty) - --%suitepath(utplsql.core.expectations.compound_data) + --%suite + --%suitepath(utplsql.core.expectations.unary) --%aftereach procedure cleanup_expectations; + --%context(to_be_empty) + --%test(Gives success for an empty cursor) procedure success_be_empty_cursor; @@ -15,30 +17,15 @@ create or replace package test_expect_to_be_empty is --%test(Reports the content of cursor when cursor is not empty) procedure fail_be_empty_cursor_report; - --%test(Negated - Gives success for a non empty cursor) - procedure success_not_be_empty_cursor; - - --%test(Negated - Gives failure for an empty cursor) - procedure fail_not_be_empty_cursor; - --%test(Gives success for an empty collection) procedure success_be_empty_collection; --%test(Gives failure for a non empty collection) procedure fail_be_empty_collection; - --%test(Negated - Gives success for a non empty collection) - procedure success_not_be_empty_coll; - - --%test(Negated - Gives failure for an empty collection) - procedure fail_not_be_empty_collection; - --%test(Gives failure for a NULL collection) procedure fail_be_empty_null_collection; - --%test(Negated - Gives failure for an empty collection) - procedure fail_not_be_empty_null_coll; - --%test(Gives failure for an object) procedure fail_be_empty_object; @@ -48,14 +35,59 @@ create or replace package test_expect_to_be_empty is --%test(Gives failure for number) procedure fail_be_empty_number; - --%test(Negated - Gives failure for an object) + --%test(Gives success for an empty CLOB) + procedure success_be_empty_clob; + + --%test(Gives failure for a non empty CLOB) + procedure fail_be_empty_clob; + + --%test(Gives success for an empty BLOB) + procedure success_be_empty_blob; + + --%test(Gives failure for a non empty BLOB) + procedure fail_be_empty_blob; + + --%endcontext + + --%context(not_to_be_empty) + + --%test(Gives failure for an empty cursor) + procedure fail_not_be_empty_cursor; + + --%test(Gives success for a non empty cursor) + procedure success_not_be_empty_cursor; + + --%test(Gives success for a non empty collection) + procedure success_not_be_empty_coll; + + --%test(Gives failure for an empty collection) + procedure fail_not_be_empty_collection; + + --%test(Gives failure for an empty collection) + procedure fail_not_be_empty_null_coll; + + --%test(Gives failure for an object) procedure fail_not_be_empty_object; - --%test(Negated - Gives failure for a null object) + --%test(Gives failure for a null object) procedure fail_not_be_empty_null_object; - --%test(Negated - Gives failure for number) + --%test(Gives failure for number) procedure fail_not_be_empty_number; + --%test(Gives failure for an empty CLOB) + procedure fail_not_be_empty_clob; + + --%test(Gives success for a non empty CLOB) + procedure success_not_be_empty_clob; + + --%test(Gives failure for an empty BLOB) + procedure fail_not_be_empty_blob; + + --%test(Gives success for a non empty BLOB) + procedure success_not_be_empty_blob; + + --%endcontext + end; / diff --git a/test/core/expectations/scalar_data/unary/test_expect_to_be_not_null.pkb b/test/core/expectations/unary/test_expect_to_be_not_null.pkb similarity index 99% rename from test/core/expectations/scalar_data/unary/test_expect_to_be_not_null.pkb rename to test/core/expectations/unary/test_expect_to_be_not_null.pkb index 5926a7d87..be6b3f2f8 100644 --- a/test/core/expectations/scalar_data/unary/test_expect_to_be_not_null.pkb +++ b/test/core/expectations/unary/test_expect_to_be_not_null.pkb @@ -33,7 +33,7 @@ is ut.expect(expectations.failed_expectations_data()).to_be_empty(); end; - procedure blob_0_length is + procedure empty_blob is begin --Act execute immediate expectations.unary_expectation_block('to_be_not_null', 'blob', 'empty_blob()'); @@ -57,7 +57,7 @@ is ut.expect(expectations.failed_expectations_data()).to_be_empty(); end; - procedure clob_0_length is + procedure empty_clob is begin --Act execute immediate expectations.unary_expectation_block('to_be_not_null', 'clob', 'empty_clob()'); diff --git a/test/core/expectations/scalar_data/unary/test_expect_to_be_not_null.pks b/test/core/expectations/unary/test_expect_to_be_not_null.pks similarity index 91% rename from test/core/expectations/scalar_data/unary/test_expect_to_be_not_null.pks rename to test/core/expectations/unary/test_expect_to_be_not_null.pks index f28a88af2..351482fee 100644 --- a/test/core/expectations/scalar_data/unary/test_expect_to_be_not_null.pks +++ b/test/core/expectations/unary/test_expect_to_be_not_null.pks @@ -1,7 +1,7 @@ create or replace package test_expect_to_be_not_null is --%suite(to_be_not_null) - --%suitepath(utplsql.core.expectations.scalar_data.unary) + --%suitepath(utplsql.core.expectations.unary) --%aftereach procedure cleanup_expectations; @@ -15,8 +15,8 @@ is --%test(Gives success for not null blob) procedure blob_not_null; - --%test(Gives success for blob with length 0) - procedure blob_0_length; + --%test(Gives success for empty blob) + procedure empty_blob; --%test(Gives success for not null boolean) procedure boolean_not_null; @@ -24,8 +24,8 @@ is --%test(Gives success for not null clob) procedure clob_not_null; - --%test(Gives success for clob with length 0) - procedure clob_0_length; + --%test(Gives success for empty clob) + procedure empty_clob; --%test(Gives success for not null date) procedure date_not_null; diff --git a/test/core/expectations/scalar_data/unary/test_expect_to_be_null.pkb b/test/core/expectations/unary/test_expect_to_be_null.pkb similarity index 99% rename from test/core/expectations/scalar_data/unary/test_expect_to_be_null.pkb rename to test/core/expectations/unary/test_expect_to_be_null.pkb index 09c461597..4179bfbe6 100644 --- a/test/core/expectations/scalar_data/unary/test_expect_to_be_null.pkb +++ b/test/core/expectations/unary/test_expect_to_be_null.pkb @@ -142,7 +142,7 @@ is ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); end; - procedure blob_0_length is + procedure empty_blob is begin --Act execute immediate expectations.unary_expectation_block( 'to_be_null', 'blob', 'empty_blob()' ); @@ -166,7 +166,7 @@ is ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); end; - procedure clob_0_length is + procedure empty_clob is begin --Act execute immediate expectations.unary_expectation_block( 'to_be_null', 'clob', 'empty_clob()' ); diff --git a/test/core/expectations/unary/test_expect_to_be_null.pks b/test/core/expectations/unary/test_expect_to_be_null.pks new file mode 100644 index 000000000..8b34e1279 --- /dev/null +++ b/test/core/expectations/unary/test_expect_to_be_null.pks @@ -0,0 +1,97 @@ +create or replace package test_expect_to_be_null +is + --%suite(to_be_null) + --%suitepath(utplsql.core.expectations.unary) + + --%aftereach + procedure cleanup_expectations; + + --%beforeall + procedure create_types; + + --%afterall + procedure drop_types; + + --%test(Gives success with null blob) + procedure null_blob; + + --%test(Gives success with null boolean) + procedure null_boolean; + + --%test(Gives success with null clob) + procedure null_clob; + + --%test(Gives success with null date) + procedure null_date; + + --%test(Gives success with null number) + procedure null_number; + + --%test(Gives success null timestamp) + procedure null_timestamp; + + --%test(Gives success with null timestamp with local time zone) + procedure null_timestamp_with_ltz; + + --%test(Gives success with null timestamp with time zone) + procedure null_timestamp_with_tz; + + --%test(Gives success with null varchar2) + procedure null_varchar2; + + --%test(Gives success with null anydata) + procedure null_anydata; + + --%test(Gives success with uninitialized object within anydata) + procedure uninit_object_in_anydata; + + --%test(Gives success with uninitialized nested table within anydata) + procedure uninit_nested_table_in_anydata; + + --%test(Gives success with uninitialized varray within anydata) + procedure uninit_varray_in_anydata; + + --%test(Gives failure for not null blob) + procedure blob_not_null; + + --%test(Gives failure with empty blob) + procedure empty_blob; + + --%test(Gives failure for not null boolean) + procedure boolean_not_null; + + --%test(Gives failure for not null clob) + procedure clob_not_null; + + --%test(Gives failure with empty clob) + procedure empty_clob; + + --%test(Gives failure for not null date) + procedure date_not_null; + + --%test(Gives failure for not null number) + procedure number_not_null; + + --%test(Gives failure for not null timestamp) + procedure timestamp_not_null; + + --%test(Gives failure for not null timestamp with local time zone) + procedure timestamp_with_ltz_not_null; + + --%test(Gives failure for not null timestamp with time zone) + procedure timestamp_with_tz_not_null; + + --%test(Gives failure for not null varchar2) + procedure varchar2_not_null; + + --%test(Gives failure for initialized object within anydata) + procedure initialized_object; + + --%test(Gives failure for initialized nested table within anydata) + procedure initialized_nested_table; + + --%test(Gives failure for initialized varray within anydata) + procedure initialized_varray; + +end test_expect_to_be_null; +/ diff --git a/test/core/expectations/scalar_data/unary/test_expect_to_be_true_false.pkb b/test/core/expectations/unary/test_expect_to_be_true_false.pkb similarity index 100% rename from test/core/expectations/scalar_data/unary/test_expect_to_be_true_false.pkb rename to test/core/expectations/unary/test_expect_to_be_true_false.pkb diff --git a/test/core/expectations/scalar_data/unary/test_expect_to_be_true_false.pks b/test/core/expectations/unary/test_expect_to_be_true_false.pks similarity index 96% rename from test/core/expectations/scalar_data/unary/test_expect_to_be_true_false.pks rename to test/core/expectations/unary/test_expect_to_be_true_false.pks index e30338b83..abdbf44b6 100644 --- a/test/core/expectations/scalar_data/unary/test_expect_to_be_true_false.pks +++ b/test/core/expectations/unary/test_expect_to_be_true_false.pks @@ -1,7 +1,7 @@ create or replace package test_expect_to_be_true_false is --%suite(to_be_true/false) - --%suitepath(utplsql.core.expectations.scalar_data.unary) + --%suitepath(utplsql.core.expectations.unary) --%aftereach procedure cleanup_expectations; diff --git a/test/core/expectations/compound_data/test_expect_to_have_count.pkb b/test/core/expectations/unary/test_expect_to_have_count.pkb similarity index 100% rename from test/core/expectations/compound_data/test_expect_to_have_count.pkb rename to test/core/expectations/unary/test_expect_to_have_count.pkb diff --git a/test/core/expectations/compound_data/test_expect_to_have_count.pks b/test/core/expectations/unary/test_expect_to_have_count.pks similarity index 96% rename from test/core/expectations/compound_data/test_expect_to_have_count.pks rename to test/core/expectations/unary/test_expect_to_have_count.pks index e89ca2fc5..636f98ba4 100644 --- a/test/core/expectations/compound_data/test_expect_to_have_count.pks +++ b/test/core/expectations/unary/test_expect_to_have_count.pks @@ -1,7 +1,7 @@ create or replace package test_expect_to_have_count is --%suite((not)to_have_count) - --%suitepath(utplsql.core.expectations.compound_data) + --%suitepath(utplsql.core.expectations.unary) --%aftereach procedure cleanup_expectations; diff --git a/test/core/test_ut_utils.pkb b/test/core/test_ut_utils.pkb index 36f849aae..326f5a49b 100644 --- a/test/core/test_ut_utils.pkb +++ b/test/core/test_ut_utils.pkb @@ -2,6 +2,37 @@ create or replace package body test_ut_utils is gv_nls_value nls_session_parameters.value%type; + gc_delimiter varchar2(1) := get_numeric_delimiter(); + + function get_numeric_delimiter return varchar2 is + l_result varchar2(1); + begin + select substr(value, 1, 1) into l_result from nls_session_parameters t where t.parameter = 'NLS_NUMERIC_CHARACTERS'; + return l_result; + end; + + function clob_to_blob(p_clob clob) return blob is + l_blob blob; + l_dest_offset integer := 1; + l_source_offset integer := 1; + l_lang_context integer := dbms_lob.default_lang_ctx; + l_warning integer := dbms_lob.warn_inconvertible_char; + begin + dbms_lob.createtemporary(l_blob, true); + dbms_lob.converttoblob( + dest_lob =>l_blob, + src_clob =>p_clob, + amount =>DBMS_LOB.LOBMAXSIZE, + dest_offset =>l_dest_offset, + src_offset =>l_source_offset, + blob_csid =>DBMS_LOB.DEFAULT_CSID, + lang_context=>l_lang_context, + warning =>l_warning + ); + return l_blob; + end; + + procedure common_clob_to_table_exec(p_clob varchar2, p_delimiter varchar2, p_expected_list ut3.ut_varchar2_list, p_limit number) is begin execute immediate 'declare @@ -54,163 +85,149 @@ end;]' using p_expected_list; common_clob_to_table_exec( ',a,,c,d,', ',', ut3.ut_varchar2_list('','a','','c','d',''), 1000); end; - procedure test_to_char is + procedure test_test_result_to_char is begin ut.expect(ut3.ut_utils.test_result_to_char(-1),'test unknown').to_equal('Unknown(-1)'); ut.expect(ut3.ut_utils.test_result_to_char(null),'test unknown').to_equal('Unknown(NULL)'); ut.expect(ut3.ut_utils.test_result_to_char(ut3.ut_utils.gc_success),'test unknown').to_equal(ut3.ut_utils.gc_success_char); end; - procedure test_to_string_blob is - l_text varchar2(32767) := 'A test char'; - l_value blob := utl_raw.cast_to_raw(l_text); - l_expected varchar2(32767) := ''''||rawtohex(l_value)||''''; - l_result varchar2(32767); + procedure to_string_emptyblob is begin - l_result := ut3.ut_utils.to_String(l_value); - ut.expect(l_result).to_equal(l_expected); + ut.expect(ut3.ut_data_value_blob(empty_blob()).to_string()).to_equal('EMPTY'); end; - procedure test_to_string_clob is - l_value clob := 'A test char'; - l_expected varchar2(32767) := ''''||l_value||''''; - l_result varchar2(32767); + procedure to_string_emptyclob is begin - l_result := ut3.ut_utils.to_String(l_value); - ut.expect(l_result).to_equal(l_expected); + ut.expect(ut3.ut_data_value_clob(empty_clob()).to_string()).to_equal('EMPTY'); end; - procedure test_to_string_date is - l_value date := to_date('2016-12-31 23:59:59', 'yyyy-mm-dd hh24:mi:ss'); - l_expected varchar2(100) := '2016-12-31T23:59:59'; - l_result varchar2(32767); + procedure to_string_nullblob is begin - l_result := ut3.ut_utils.to_String(l_value); - ut.expect(l_result).to_equal(l_expected); + ut.expect(ut3.ut_data_value_blob(null).to_string()).to_equal('NULL'); end; - procedure to_string_null is + procedure to_string_nullclob is begin - ut.expect(ut3.ut_utils.to_String(to_blob(NULL))).to_equal('NULL'); - ut.expect(ut3.ut_utils.to_String(to_clob(NULL))).to_equal('NULL'); - ut.expect(ut3.ut_utils.to_String(to_date(NULL))).to_equal('NULL'); - ut.expect(ut3.ut_utils.to_String(to_number(NULL))).to_equal('NULL'); - ut.expect(ut3.ut_utils.to_String(to_timestamp(NULL))).to_equal('NULL'); + ut.expect(ut3.ut_data_value_clob(null).to_string()).to_equal('NULL'); end; - procedure to_string is - l_value timestamp(9) := to_timestamp('2016-12-31 23:59:59.123456789', 'yyyy-mm-dd hh24:mi:ss.ff'); - l_value2 timestamp(9) with local time zone:= to_timestamp('2016-12-31 23:59:59.123456789', 'yyyy-mm-dd hh24:mi:ss.ff'); - l_value3 timestamp(9) with time zone := to_timestamp_tz('2016-12-31 23:59:59.123456789 -8:00', 'yyyy-mm-dd hh24:mi:ss.ff tzh:tzm'); - l_value4 varchar2(20) := 'A test char'; - l_expected varchar2(100); - l_result varchar2(100); - l_delimiter varchar2(10); + procedure to_string_nulldate is + begin + ut.expect(ut3.ut_data_value_date(null).to_string()).to_equal('NULL'); + end; + + procedure to_string_nullnumber is + begin + ut.expect(ut3.ut_data_value_number(null).to_string()).to_equal('NULL'); + end; + + procedure to_string_nulltimestamp is + begin + ut.expect(ut3.ut_data_value_timestamp(null).to_string()).to_equal('NULL'); + end; + + procedure to_string_nulltimestamp_ltz is + begin + ut.expect(ut3.ut_data_value_timestamp_ltz(null).to_string()).to_equal('NULL'); + end; + + procedure to_string_nulltimestamp_tz is + begin + ut.expect(ut3.ut_data_value_timestamp_tz(null).to_string()).to_equal('NULL'); + end; + + procedure to_string_nullvarchar2 is + begin + ut.expect(ut3.ut_data_value_varchar2(null).to_string()).to_equal('NULL'); + end; + + procedure to_string_blob is + l_text varchar2(32767) := 'A test char'; + l_value blob := utl_raw.cast_to_raw(l_text); + l_expected varchar2(32767) := ''''||rawtohex(l_value)||''''; begin - select substr(value, 1, 1) into l_delimiter from nls_session_parameters t where t.parameter = 'NLS_NUMERIC_CHARACTERS'; - l_expected := '2016-12-31T23:59:59'||l_delimiter||'123456789'; + ut.expect(ut3.ut_data_value_blob(l_value).to_string()).to_equal(l_expected); + end; - l_result := ut3.ut_utils.to_String(l_value); - ut.expect(l_result,'Returns a full string representation of a timestamp with maximum precission').to_equal(l_expected); + procedure to_string_clob is + l_value clob := 'A test char'; + l_expected varchar2(32767) := ''''||l_value||''''; + begin + ut.expect(ut3.ut_data_value_clob(l_value).to_string()).to_equal(l_expected); + end; - l_expected := '2016-12-31T23:59:59'||l_delimiter||'123456789'; - l_result := ut3.ut_utils.to_String(l_value2); - ut.expect(l_result,'Returns a full string representation of a timestamp with maximum precission').to_equal(l_expected); + procedure to_string_date is + l_value date := to_date('2016-12-31 23:59:59', 'yyyy-mm-dd hh24:mi:ss'); + l_expected varchar2(100) := '2016-12-31T23:59:59'; + begin + ut.expect(ut3.ut_data_value_date(l_value).to_string()).to_equal(l_expected); + end; - l_expected := '2016-12-31T23:59:59'||l_delimiter||'123456789 -08:00'; + procedure to_string_timestamp is + l_value timestamp(9) := to_timestamp('2016-12-31 23:59:59.123456789', 'yyyy-mm-dd hh24:mi:ss.ff'); + l_expected varchar2(100) := '2016-12-31T23:59:59'||gc_delimiter||'123456789'; + begin + ut.expect(ut3.ut_data_value_timestamp(l_value).to_string()).to_equal(l_expected); + end; - l_result := ut3.ut_utils.to_String(l_value3); - ut.expect(l_result,'Returns a full string representation of a timestamp with maximum precission').to_equal(l_expected); + procedure to_string_timestamp_ltz is + l_value timestamp(9) with local time zone := to_timestamp('2016-12-31 23:59:59.123456789', 'yyyy-mm-dd hh24:mi:ss.ff'); + l_expected varchar2(100) := '2016-12-31T23:59:59'||gc_delimiter||'123456789'; + begin + ut.expect(ut3.ut_data_value_timestamp_ltz(l_value).to_string()).to_equal(l_expected); + end; - l_expected := ''''||l_value4||''''; - l_result := ut3.ut_utils.to_String(l_value4); - ut.expect(l_result,'Returns a varchar2 eclosed in quotes').to_equal(l_expected); + procedure to_string_timestamp_tz is + l_value timestamp(9) with time zone := to_timestamp_tz('2016-12-31 23:59:59.123456789 -8:00', 'yyyy-mm-dd hh24:mi:ss.ff tzh:tzm'); + l_expected varchar2(100) := '2016-12-31T23:59:59'||gc_delimiter||'123456789 -08:00'; + begin + ut.expect(ut3.ut_data_value_timestamp_tz(l_value).to_string()).to_equal(l_expected); + end; + procedure to_string_varchar2 is + l_value varchar2(20) := 'A test char'; + l_expected varchar2(100) := ''''||l_value||''''; + begin + ut.expect(ut3.ut_data_value_varchar2(l_value).to_string()).to_equal(l_expected); end; - procedure to_string_big_blob is + procedure to_string_verybigblob is l_text clob := lpad('A test char',32767,'1')||lpad('1',32767,'1'); l_value blob; - l_result varchar2(32767); - function clob_to_blob(p_clob clob) return blob - as - l_blob blob; - l_dest_offset integer := 1; - l_source_offset integer := 1; - l_lang_context integer := dbms_lob.default_lang_ctx; - l_warning integer := dbms_lob.warn_inconvertible_char; - begin - dbms_lob.createtemporary(l_blob, true); - dbms_lob.converttoblob( - dest_lob =>l_blob, - src_clob =>p_clob, - amount =>DBMS_LOB.LOBMAXSIZE, - dest_offset =>l_dest_offset, - src_offset =>l_source_offset, - blob_csid =>DBMS_LOB.DEFAULT_CSID, - lang_context=>l_lang_context, - warning =>l_warning - ); - return l_blob; - end; begin l_value := clob_to_blob(l_text); - --Act - l_result := ut3.ut_utils.to_String(l_value); - --Assert - ut.EXPECT(length(l_result)).to_equal(ut3.ut_utils.gc_max_output_string_length); - ut.EXPECT(l_result).to_be_like('%'||ut3.ut_utils.gc_more_data_string); - + ut.expect(length(ut3.ut_data_value_blob(l_value).to_string())).to_equal(ut3.ut_utils.gc_max_output_string_length); + ut.expect(ut3.ut_data_value_blob(l_value).to_string()).to_be_like('%'||ut3.ut_utils.gc_more_data_string); end; - procedure to_string_big_clob is + procedure to_string_verybigclob is l_value clob := lpad('A test char',32767,'1')||lpad('1',32767,'1'); - l_result varchar2(32767); begin - --Act - l_result := ut3.ut_utils.to_String(l_value); - --Assert - ut.EXPECT(length(l_result)).to_equal(ut3.ut_utils.gc_max_output_string_length); - ut.EXPECT(l_result).to_be_like('%'||ut3.ut_utils.gc_more_data_string); + ut.expect(length(ut3.ut_data_value_clob(l_value).to_string())).to_equal(ut3.ut_utils.gc_max_output_string_length); + ut.expect(ut3.ut_data_value_clob(l_value).to_string()).to_be_like('%'||ut3.ut_utils.gc_more_data_string); end; - procedure to_string_big_number is + procedure to_string_verybignumber is l_value number := 1234567890123456789012345678901234567890; l_expected varchar2(100) := '1234567890123456789012345678901234567890'; - l_result varchar2(100); begin - --Act - l_result := ut3.ut_utils.to_String(l_value); - --Assert - ut.expect(l_result).TO_equal(l_expected); + ut.expect(ut3.ut_data_value_number(l_value).to_string()).to_equal(l_expected); end; - procedure to_string_big_varchar2 is + procedure to_string_verybigvarchar2 is l_value varchar2(32767) := lpad('A test char',32767,'1'); l_result varchar2(32767); begin - --Act - l_result := ut3.ut_utils.to_String(l_value); - --Assert - ut.EXPECT(length(l_result)).to_equal(ut3.ut_utils.gc_max_output_string_length); - ut.EXPECT(l_result).to_be_like('%'||ut3.ut_utils.gc_more_data_string); + ut.expect(length(ut3.ut_data_value_varchar2(l_value).to_string())).to_equal(ut3.ut_utils.gc_max_output_string_length); + ut.expect(ut3.ut_data_value_varchar2(l_value).to_string()).to_be_like('%'||ut3.ut_utils.gc_more_data_string); end; - procedure to_string_big_tiny_number is + procedure to_string_verysmallnumber is l_value number := 0.123456789012345678901234567890123456789; - l_expected varchar2(100); - l_result varchar2(100); - l_delimiter varchar2(1); + l_expected varchar2(100) := gc_delimiter||'123456789012345678901234567890123456789'; begin - --Act - select substr(value, 1, 1) into l_delimiter from nls_session_parameters t where t.parameter = 'NLS_NUMERIC_CHARACTERS'; - l_expected := l_delimiter||'123456789012345678901234567890123456789'; - - l_result := ut3.ut_utils.to_String(l_value); - - --Assert - ut.expect(l_result).TO_equal(l_expected); - + ut.expect(ut3.ut_data_value_number(l_value).to_string()).to_equal(l_expected); end; procedure test_table_to_clob is diff --git a/test/core/test_ut_utils.pks b/test/core/test_ut_utils.pks index 4d5ce56af..8452f84c3 100644 --- a/test/core/test_ut_utils.pks +++ b/test/core/test_ut_utils.pks @@ -1,61 +1,106 @@ create or replace package test_ut_utils is - --%suite + --%suite(ut_utils) --%suitepath(utplsql.core) - --%test + function get_numeric_delimiter return varchar2; + + --%test(clob_to_table - Converts a clob into ut_varchar2_list using specified delimiter) procedure test_clob_to_table; - --%test - procedure test_to_char; + --%test(test_result_to_char - Converts numeric test result to character representation) + procedure test_test_result_to_char; + + + --%context(to_string) + + --%test(Returns 'EMPTY' string for NULL BLOB) + procedure to_string_emptyblob; + + --%test(Returns 'EMPTY' string for NULL CLOB) + procedure to_string_emptyclob; + + --%test(Returns 'NULL' string for NULL BLOB) + procedure to_string_nullblob; + + --%test(Returns 'NULL' string for NULL CLOB) + procedure to_string_nullclob; + + --%test(Returns 'NULL' string for NULL date) + procedure to_string_nulldate; + + --%test(Returns 'NULL' string for NULL number) + procedure to_string_nullnumber; + + --%test(Returns 'NULL' string for NULL timestamp) + procedure to_string_nulltimestamp; - --%test - procedure test_to_string_blob; + --%test(Returns 'NULL' string for NULL timestamp with local timezone) + procedure to_string_nulltimestamp_ltz; - --%test - procedure test_to_string_clob; + --%test(Returns 'NULL' string for NULL timestamp with timezone) + procedure to_string_nulltimestamp_tz; - --%test - procedure test_to_string_date; + --%test(Returns 'NULL' string for NULL varchar) + procedure to_string_nullvarchar2; - --%test - procedure to_string_null; + --%test(Returns string representation of BLOB) + procedure to_string_blob; - --%test - procedure to_string; + --%test(Returns string representation of CLOB) + procedure to_string_clob; - --%test(Trims long Blob to max lenght and appends '[...]' at the end of string) - procedure to_string_big_blob; + --%test(Returns string representation of date) + procedure to_string_date; - --%test(Trims long Clob to max lenght and appends '[...]' at the end of string) - procedure to_string_big_clob; + --%test(Returns string representation of timestamp) + procedure to_string_timestamp; - --%test(Returns a full string representation of a very big number) - procedure to_string_big_number; + --%test(Returns string representation of timestamp with local timezone) + procedure to_string_timestamp_ltz; - --%test(Trims long varchars to max lenght and appends '[...]' at the end of string) - procedure to_string_big_varchar2; + --%test(Returns string representation of timestamp with timezone) + procedure to_string_timestamp_tz; - --%test(Returns a full string representation of a very small number) - procedure to_string_big_tiny_number; + --%test(Returns varchar value) + procedure to_string_varchar2; - --%test(Table to clob function test) + --%test(Returns BLOB trimmed to 4000 chars with trailing [...]) + procedure to_string_verybigblob; + +--%test(Returns CLOB trimmed to 4000 chars with trailing [...]) + procedure to_string_verybigclob; + + --%test(Returns string representation of large number) + procedure to_string_verybignumber; + + --%test(Returns varchar2 trimmed to 4000 chars with trailing [...]) + procedure to_string_verybigvarchar2; + + --%test(Returns string representation of small number) + procedure to_string_verysmallnumber; + + --%endcontext + + --%test(table_to_clob - converts ut_varchar2_list into a CLOB value) procedure test_table_to_clob; - --%test(append_to_clob works With Multi Byte Chars) + --%test(append_to_clob - adds multibyte varchar to CLOB) --%beforetest(setup_append_with_multibyte) --%aftertest(clean_append_with_multibyte) procedure test_append_with_multibyte; procedure setup_append_with_multibyte; procedure clean_append_with_multibyte; - --%test(clob_to_table multibyte) + --%test(clob_to_table - converts multibyte CLOB to ut_varchar2_list) --%disabled(We cannot run this test successfully on 12.1 until we change NLSCHARACTERSET from US7ASCII to AL32UTF8) procedure test_clob_to_table_multibyte; - --%test(to_version splits version string into individual version components) + --%test(to_version - splits version string into individual version components) procedure test_to_version_split; + --%context(trim_list_elements) + --%test(Trims the elements of a collection) procedure test_trim_list_elements; @@ -65,6 +110,10 @@ create or replace package test_ut_utils is --%test(Trim list elements with empty collection) procedure trim_list_elemts_empty_collect; + --%endcontext + + --%context(filter_list) + --%test(Filters the collection's elements) procedure test_filter_list; @@ -74,7 +123,9 @@ create or replace package test_ut_utils is --%test(Filter list elements with empty collection) procedure filter_list_empty_collection; - --%test(Replace multi-line comments with empty lines) + --%endcontext + + --%test(replace_multiline_comments - replaces multi-line comments with empty lines) procedure replace_multiline_comments; end test_ut_utils; diff --git a/test/install_tests.sql b/test/install_tests.sql index fe2f4843a..1640c6794 100644 --- a/test/install_tests.sql +++ b/test/install_tests.sql @@ -44,19 +44,19 @@ set define off @@core/reporters/test_tfs_junit_reporter.pks @@core/reporters/test_sonar_test_reporter.pks @@core/expectations.pks -@@core/expectations/scalar_data/binary/test_be_greater_or_equal.pks -@@core/expectations/scalar_data/binary/test_be_greater_than.pks -@@core/expectations/scalar_data/binary/test_be_less_or_equal.pks -@@core/expectations/scalar_data/binary/test_equal.pks -@@core/expectations/scalar_data/binary/test_expect_to_be_less_than.pks -@@core/expectations/compound_data/test_expect_to_be_empty.pks -@@core/expectations/compound_data/test_expect_to_have_count.pks -@@core/expectations/compound_data/test_expectations_cursor.pks -@@core/expectations/compound_data/test_expectation_anydata.pks -@@core/expectations/scalar_data/unary/test_expect_not_to_be_null.pks -@@core/expectations/scalar_data/unary/test_expect_to_be_not_null.pks -@@core/expectations/scalar_data/unary/test_expect_to_be_null.pks -@@core/expectations/scalar_data/unary/test_expect_to_be_true_false.pks +@@core/expectations/binary/test_be_greater_or_equal.pks +@@core/expectations/binary/test_be_greater_than.pks +@@core/expectations/binary/test_be_less_or_equal.pks +@@core/expectations/binary/test_equal.pks +@@core/expectations/binary/test_expect_to_be_less_than.pks +@@core/expectations/unary/test_expect_to_be_empty.pks +@@core/expectations/unary/test_expect_to_have_count.pks +@@core/expectations/unary/test_expect_not_to_be_null.pks +@@core/expectations/unary/test_expect_to_be_not_null.pks +@@core/expectations/unary/test_expect_to_be_null.pks +@@core/expectations/unary/test_expect_to_be_true_false.pks +@@core/expectations/test_expectations_cursor.pks +@@core/expectations/test_expectation_anydata.pks @@core/annotations/test_annot_throws_exception.pks @@core.pkb @@ -89,19 +89,19 @@ set define off @@core/reporters/test_tfs_junit_reporter.pkb @@core/reporters/test_sonar_test_reporter.pkb @@core/expectations.pkb -@@core/expectations/scalar_data/binary/test_be_greater_or_equal.pkb -@@core/expectations/scalar_data/binary/test_be_greater_than.pkb -@@core/expectations/scalar_data/binary/test_be_less_or_equal.pkb -@@core/expectations/scalar_data/binary/test_equal.pkb -@@core/expectations/scalar_data/binary/test_expect_to_be_less_than.pkb -@@core/expectations/compound_data/test_expect_to_be_empty.pkb -@@core/expectations/compound_data/test_expect_to_have_count.pkb -@@core/expectations/compound_data/test_expectations_cursor.pkb -@@core/expectations/compound_data/test_expectation_anydata.pkb -@@core/expectations/scalar_data/unary/test_expect_not_to_be_null.pkb -@@core/expectations/scalar_data/unary/test_expect_to_be_not_null.pkb -@@core/expectations/scalar_data/unary/test_expect_to_be_null.pkb -@@core/expectations/scalar_data/unary/test_expect_to_be_true_false.pkb +@@core/expectations/binary/test_be_greater_or_equal.pkb +@@core/expectations/binary/test_be_greater_than.pkb +@@core/expectations/binary/test_be_less_or_equal.pkb +@@core/expectations/binary/test_equal.pkb +@@core/expectations/binary/test_expect_to_be_less_than.pkb +@@core/expectations/unary/test_expect_to_be_empty.pkb +@@core/expectations/unary/test_expect_to_have_count.pkb +@@core/expectations/unary/test_expect_not_to_be_null.pkb +@@core/expectations/unary/test_expect_to_be_not_null.pkb +@@core/expectations/unary/test_expect_to_be_null.pkb +@@core/expectations/unary/test_expect_to_be_true_false.pkb +@@core/expectations/test_expectations_cursor.pkb +@@core/expectations/test_expectation_anydata.pkb @@core/annotations/test_annot_throws_exception.pkb set linesize 200 From ac9215603bd3be0e59b76a44eff0e60967c0afe7 Mon Sep 17 00:00:00 2001 From: Jacek Gebal Date: Wed, 11 Jul 2018 02:01:55 +0100 Subject: [PATCH 133/184] Update of `sonarcloud.io` badge and url. --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 81bd24738..18cc50f3b 100644 --- a/readme.md +++ b/readme.md @@ -7,7 +7,7 @@ [![build](https://img.shields.io/travis/utPLSQL/utPLSQL/master.svg?label=master%20branch)](https://travis-ci.org/utPLSQL/utPLSQL) [![build](https://img.shields.io/travis/utPLSQL/utPLSQL/develop.svg?label=develop%20branch)](https://travis-ci.org/utPLSQL/utPLSQL) -[![sonar](https://sonarcloud.io/api/badges/gate?key=utPLSQL%3Adevelop)](https://sonarcloud.io/dashboard/index?id=utPLSQL%3Adevelop) +[![sonar](https://sonarcloud.io/api/project_badges/measure?project=utPLSQL&metric=sqale_rating)](https://sonarcloud.io/dashboard/index?id=utPLSQL) [![Coveralls coverage](https://coveralls.io/repos/github/utPLSQL/utPLSQL/badge.svg?branch=develop)](https://coveralls.io/github/utPLSQL/utPLSQL?branch=develop) ---------- From 8846415597ac645a88f44fd493209b14955513c2 Mon Sep 17 00:00:00 2001 From: Jacek Gebal Date: Wed, 11 Jul 2018 02:07:03 +0100 Subject: [PATCH 134/184] Added `df -h` before download and start of oracle docker image. --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 8ec9c35d0..ca92c6127 100644 --- a/.travis.yml +++ b/.travis.yml @@ -80,6 +80,7 @@ install: - bash .travis/install_sqlcl.sh - sudo mkdir -p /dev/pdbs - sudo chmod -R 777 /dev/pdbs + - df -h - if [[ ! $TRAVIS_TAG ]]; then bash .travis/start_db.sh; fi - df -h From 9709277fdf5e1a64497c5025f2c146ec3354ca45 Mon Sep 17 00:00:00 2001 From: Travis CI Date: Wed, 11 Jul 2018 01:32:47 +0000 Subject: [PATCH 135/184] Updated project version after build [skip ci] --- source/core/ut_utils.pks | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/core/ut_utils.pks b/source/core/ut_utils.pks index 3d58b0c60..6fc70acb2 100644 --- a/source/core/ut_utils.pks +++ b/source/core/ut_utils.pks @@ -21,7 +21,7 @@ create or replace package ut_utils authid definer is * */ - gc_version constant varchar2(50) := 'v3.1.2.2053-develop'; + gc_version constant varchar2(50) := 'v3.1.2.2058-develop'; /* Constants: Event names */ subtype t_event_name is varchar2(30); From c5f640b306f95a538109d25b27aa950e8e1fe563 Mon Sep 17 00:00:00 2001 From: Travis CI Date: Wed, 11 Jul 2018 02:14:57 +0000 Subject: [PATCH 136/184] Updated project version after build [skip ci] --- source/core/ut_utils.pks | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/core/ut_utils.pks b/source/core/ut_utils.pks index da8f7b820..cdb02a368 100644 --- a/source/core/ut_utils.pks +++ b/source/core/ut_utils.pks @@ -21,7 +21,7 @@ create or replace package ut_utils authid definer is * */ - gc_version constant varchar2(50) := 'v3.1.2.2058-develop'; + gc_version constant varchar2(50) := 'v3.1.2.2059-develop'; /* Constants: Event names */ subtype t_event_name is varchar2(30); From efb2e1151bcfe42e4863ebbfef812a422d8c5439 Mon Sep 17 00:00:00 2001 From: lwasylow Date: Thu, 12 Jul 2018 13:54:40 +0100 Subject: [PATCH 137/184] Initial checkin --- source/api/ut.pkb | 8 +-- test/api/test_ut_run.pkb | 124 +++++++++++++++++++++++++++++++++++++++ test/api/test_ut_run.pks | 23 ++++++++ 3 files changed, 151 insertions(+), 4 deletions(-) diff --git a/source/api/ut.pkb b/source/api/ut.pkb index 94ff1e2b5..27982d513 100644 --- a/source/api/ut.pkb +++ b/source/api/ut.pkb @@ -332,7 +332,7 @@ create or replace package body ut is ) return ut_varchar2_rows pipelined is l_reporter ut_reporter_base := coalesce(a_reporter, ut_documentation_reporter()); - l_paths ut_varchar2_list := ut_varchar2_list(coalesce(a_path, sys_context('userenv', 'current_schema'))); + l_paths ut_varchar2_list := coalesce(ut_utils.string_to_table(a_string => a_path,a_delimiter => ','),ut_varchar2_list(sys_context('userenv', 'current_schema'))); l_lines sys_refcursor; l_line varchar2(4000); begin @@ -372,7 +372,7 @@ create or replace package body ut is a_client_character_set varchar2 := null ) return ut_varchar2_rows pipelined is l_reporter ut_reporter_base := coalesce(a_reporter, ut_documentation_reporter()); - l_paths ut_varchar2_list := ut_varchar2_list(coalesce(a_path, sys_context('userenv', 'current_schema'))); + l_paths ut_varchar2_list := coalesce(ut_utils.string_to_table(a_string => a_path,a_delimiter => ','),ut_varchar2_list(sys_context('userenv', 'current_schema'))); l_lines sys_refcursor; l_line varchar2(4000); begin @@ -519,7 +519,7 @@ create or replace package body ut is a_exclude_objects ut_varchar2_list := null, a_client_character_set varchar2 := null ) is - l_paths ut_varchar2_list := ut_varchar2_list(coalesce(a_path, sys_context('userenv', 'current_schema'))); + l_paths ut_varchar2_list := coalesce(ut_utils.string_to_table(a_string => a_path,a_delimiter => ','),ut_varchar2_list(sys_context('userenv', 'current_schema'))); begin ut.run( l_paths, @@ -545,7 +545,7 @@ create or replace package body ut is a_exclude_objects ut_varchar2_list := null, a_client_character_set varchar2 := null ) is - l_paths ut_varchar2_list := ut_varchar2_list(coalesce(a_path, sys_context('userenv', 'current_schema'))); + l_paths ut_varchar2_list := coalesce(ut_utils.string_to_table(a_string => a_path,a_delimiter => ','),ut_varchar2_list(sys_context('userenv', 'current_schema'))); begin ut.run( l_paths, diff --git a/test/api/test_ut_run.pkb b/test/api/test_ut_run.pkb index cee41c085..b3b876c80 100644 --- a/test/api/test_ut_run.pkb +++ b/test/api/test_ut_run.pkb @@ -202,6 +202,130 @@ end;]'; begin execute immediate 'drop package invalid_pckag_that_revalidates'; execute immediate 'drop package parent_specs'; + end; + + procedure create_test_csl_packages is + pragma autonomous_transaction; + begin + execute immediate q'[ + create or replace package test_csl_names1 as + --%suite + --%suitepath(test_csl_names) + + --%test + procedure one_is_one; + + --%test + procedure two_is_two; + + end; + ]'; + + execute immediate q'{ + create or replace package body test_csl_names1 as + + procedure one_is_one is + begin + ut3.ut.expect(1).to_equal(1); + end; + + procedure two_is_two is + begin + ut3.ut.expect(2).to_equal(2); + end; + + end; + }'; + + execute immediate q'[ + create or replace package test_csl_names2 as + --%suite + --%suitepath(test_csl_names) + + --%test + procedure one_is_one; + + --%test + procedure two_is_two; + + end; + ]'; + + execute immediate q'{ + create or replace package body test_csl_names2 as + + procedure one_is_one is + begin + ut3.ut.expect(1).to_equal(1); + end; + + procedure two_is_two is + begin + ut3.ut.expect(2).to_equal(2); + end; + + end; + }'; + + end; + + procedure drop_test_csl_packages is + pragma autonomous_transaction; + begin + execute immediate 'drop package test_csl_names1'; + execute immediate 'drop package test_csl_names2'; + end; + + procedure pass_varchar2_name_list is + l_results ut3.ut_varchar2_list; + l_actual clob; + begin + select * + bulk collect into l_results + from table(ut3.ut.run(ut3.ut_varchar2_list('test_csl_names1','test_csl_names2'))); + + l_actual := ut3.ut_utils.table_to_clob(l_results); + ut.expect(l_actual).to_be_like('%Finished in % seconds +%4 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)%'); + end; + + procedure pass_varchar2_name is + l_results ut3.ut_varchar2_list; + l_actual clob; + begin + select * + bulk collect into l_results + from table(ut3.ut.run('test_csl_names1')); + + l_actual := ut3.ut_utils.table_to_clob(l_results); + ut.expect(l_actual).to_be_like('%Finished in % seconds +%2 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)%'); + end; + + procedure pass_varchar2_suite_csl is + l_results ut3.ut_varchar2_list; + l_actual clob; + begin + select * + bulk collect into l_results + from table(ut3.ut.run('test_csl_names1,test_csl_names2')); + + l_actual := ut3.ut_utils.table_to_clob(l_results); + ut.expect(l_actual).to_be_like('%Finished in % seconds +%4 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)%'); + end; + + procedure pass_varchar2_test_csl is + l_results ut3.ut_varchar2_list; + l_actual clob; + begin + select * + bulk collect into l_results + from table(ut3.ut.run('test_csl_names1.one_is_one,test_csl_names2.one_is_one')); + + l_actual := ut3.ut_utils.table_to_clob(l_results); + ut.expect(l_actual).to_be_like('%Finished in % seconds +%2 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)%'); end; end; diff --git a/test/api/test_ut_run.pks b/test/api/test_ut_run.pks index 12c9e7fe0..aeb1ab0e4 100644 --- a/test/api/test_ut_run.pks +++ b/test/api/test_ut_run.pks @@ -22,6 +22,29 @@ create or replace package test_ut_run is procedure run_and_revalidate_specs; procedure generate_invalid_spec; procedure drop_test_package; + + procedure create_test_csl_packages; + procedure drop_test_csl_packages; + + --%test( Pass name of tests as varchar2_list ) + --%beforetest(create_test_csl_packages) + --%aftertest(drop_test_csl_packages) + procedure pass_varchar2_name_list; + + --%test( Pass single test name as varchar2 ) + --%beforetest(create_test_csl_packages) + --%aftertest(drop_test_csl_packages) + procedure pass_varchar2_name; + + --%test( Pass coma separated list of suite names ) + --%beforetest(create_test_csl_packages) + --%aftertest(drop_test_csl_packages) + procedure pass_varchar2_suite_csl; + + --%test( Pass coma separated list of test names ) + --%beforetest(create_test_csl_packages) + --%aftertest(drop_test_csl_packages) + procedure pass_varchar2_test_csl; end; / From 30563d9722efb4059291b7cd77537e64482bfe25 Mon Sep 17 00:00:00 2001 From: lwasylow Date: Thu, 12 Jul 2018 17:51:47 +0100 Subject: [PATCH 138/184] Adding sonar branch and PR analysis --- .travis.yml | 2 +- sonar-project.properties | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ca92c6127..4876abad5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -94,7 +94,7 @@ before_script: script: - if [[ ! $TRAVIS_TAG ]]; then bash test/install_and_run_tests.sh; fi - if [[ ! $TRAVIS_TAG ]]; then bash .travis/validate_report_files.sh; fi - - if [[ ! $TRAVIS_TAG ]] && [ "${TRAVIS_REPO_SLUG}" = "${UTPLSQL_REPO}" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then sonar-scanner; fi + - if [[ ! $TRAVIS_TAG ]] && [ "${TRAVIS_REPO_SLUG}" = "${UTPLSQL_REPO}" ]; then sonar-scanner; fi - if [[ ! $TRAVIS_TAG ]]; then bash .travis/coveralls_uploader.sh; fi notifications: diff --git a/sonar-project.properties b/sonar-project.properties index dc0f7633d..b585ba34b 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -21,3 +21,5 @@ sonar.language=plsql # Encoding of the source code. Default is default system encoding #sonar.sourceEncoding=UTF-8 +sonar.branch.name=test +sonar.branch.target=source_Test From 34db68ca1bf3684ac53cdfe4eccbe6586bba1461 Mon Sep 17 00:00:00 2001 From: lwasylow Date: Thu, 12 Jul 2018 17:53:56 +0100 Subject: [PATCH 139/184] Add sonar scanner to branches --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 4876abad5..259721d7e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -94,7 +94,7 @@ before_script: script: - if [[ ! $TRAVIS_TAG ]]; then bash test/install_and_run_tests.sh; fi - if [[ ! $TRAVIS_TAG ]]; then bash .travis/validate_report_files.sh; fi - - if [[ ! $TRAVIS_TAG ]] && [ "${TRAVIS_REPO_SLUG}" = "${UTPLSQL_REPO}" ]; then sonar-scanner; fi + - if [[ ! $TRAVIS_TAG ]] && [ "${TRAVIS_REPO_SLUG}" = "${UTPLSQL_REPO}" ]; .travis/run_sonar_scanner.sh; fi - if [[ ! $TRAVIS_TAG ]]; then bash .travis/coveralls_uploader.sh; fi notifications: From d505dfea763d349c981b643e58a1c9ddc45b5937 Mon Sep 17 00:00:00 2001 From: lwasylow Date: Thu, 12 Jul 2018 18:03:38 +0100 Subject: [PATCH 140/184] Added Sonnar branches --- .travis/run_sonar_scanner.sh | 43 ++++++++++++++++++++++++++++++++++++ sonar-project.properties | 4 +--- 2 files changed, 44 insertions(+), 3 deletions(-) create mode 100755 .travis/run_sonar_scanner.sh diff --git a/.travis/run_sonar_scanner.sh b/.travis/run_sonar_scanner.sh new file mode 100755 index 000000000..4f89d20f7 --- /dev/null +++ b/.travis/run_sonar_scanner.sh @@ -0,0 +1,43 @@ +#!/usr/bin/env bash + +MAIN_DEV_BRANCH="develop" +BRANCH_SONAR_PROPERTY="sonar.branch.name" +BRANCH_SONAR_TARGET_PROPERTY="sonar.branch.target" + +function add_sonar_property { + + echo "$1=$2" >> sonar-project.properties +} + +if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then + BRANCH=$TRAVIS_BRANCH; + PR_BRANCH="" + echo "BRANCH=$BRANCH" +else + BRANCH=$TRAVIS_PULL_REQUEST_BRANCH + PR_BRANCH=$TRAVIS_BRANCH + echo "TRAVIS_BRANCH=$TRAVIS_BRANCH, PR=$PR, BRANCH=$BRANCH" + +fi + + +# We are updating sonar_properties only when is not a develop +# if its a pull request we will create a separate +if [ "${TRAVIS_REPO_SLUG}" = "${UTPLSQL_REPO}" ] && [[ ! "${BRANCH}" =~ ^(release/v[0-9]+\.[0-9]+\.[0-9]+.*|"${MAIN_DEV_BRANCH}")$ ]]; then + echo "Updating sonar properties to include branch name" + + add_sonar_property "${BRANCH_SONAR_PROPERTY}" "${BRANCH}" + + if [ ! -z "$PR_BRANCH" ]; then + echo "Updating sonar properties to include pr target branch name" + add_sonar_property "${BRANCH_SONAR_TARGET_PROPERTY}" "${PR_BRANCH}" + else + add_sonar_property "${BRANCH_SONAR_TARGET_PROPERTY}" "${MAIN_DEV_BRANCH}" + fi + +else + echo "No need to update sonar we building on release or develop" +fi + +#Execute Sonar scanner +sonar-scanner \ No newline at end of file diff --git a/sonar-project.properties b/sonar-project.properties index b585ba34b..f74d466e2 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -20,6 +20,4 @@ sonar.plsql.file.suffixes=sql,tab,pkb,tpb sonar.language=plsql # Encoding of the source code. Default is default system encoding -#sonar.sourceEncoding=UTF-8 -sonar.branch.name=test -sonar.branch.target=source_Test +#sonar.sourceEncoding=UTF-8 \ No newline at end of file From bf00103c5dfd912ec008b690f0cfa13fba89f38f Mon Sep 17 00:00:00 2001 From: lwasylow Date: Thu, 12 Jul 2018 18:30:37 +0100 Subject: [PATCH 141/184] Fixes around syntax and adding a pull request token and properties --- .travis.yml | 2 +- .travis/run_sonar_scanner.sh | 3 ++- sonar-project.properties | 3 +++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 259721d7e..14eb5e4f5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -94,7 +94,7 @@ before_script: script: - if [[ ! $TRAVIS_TAG ]]; then bash test/install_and_run_tests.sh; fi - if [[ ! $TRAVIS_TAG ]]; then bash .travis/validate_report_files.sh; fi - - if [[ ! $TRAVIS_TAG ]] && [ "${TRAVIS_REPO_SLUG}" = "${UTPLSQL_REPO}" ]; .travis/run_sonar_scanner.sh; fi + - if [[ ! $TRAVIS_TAG ]] && [ "${TRAVIS_REPO_SLUG}" = "${UTPLSQL_REPO}" ]; then bash .travis/run_sonar_scanner.sh; fi - if [[ ! $TRAVIS_TAG ]]; then bash .travis/coveralls_uploader.sh; fi notifications: diff --git a/.travis/run_sonar_scanner.sh b/.travis/run_sonar_scanner.sh index 4f89d20f7..97326f225 100755 --- a/.travis/run_sonar_scanner.sh +++ b/.travis/run_sonar_scanner.sh @@ -20,12 +20,13 @@ else fi +add_sonar_property "sonar.pullrequest.github.token.secured" "${GITHUB_TRAVISCI_TOKEN}" # We are updating sonar_properties only when is not a develop # if its a pull request we will create a separate if [ "${TRAVIS_REPO_SLUG}" = "${UTPLSQL_REPO}" ] && [[ ! "${BRANCH}" =~ ^(release/v[0-9]+\.[0-9]+\.[0-9]+.*|"${MAIN_DEV_BRANCH}")$ ]]; then echo "Updating sonar properties to include branch name" - + add_sonar_property "${BRANCH_SONAR_PROPERTY}" "${BRANCH}" if [ ! -z "$PR_BRANCH" ]; then diff --git a/sonar-project.properties b/sonar-project.properties index f74d466e2..016b50d24 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -19,5 +19,8 @@ sonar.projectDescription=PL/SQL Unit Testing Framework sonar.plsql.file.suffixes=sql,tab,pkb,tpb sonar.language=plsql +sonar.pullrequest.github.endpoint=https://api.github.com/ +sonar.pullrequest.github.repository=utPLSQL/utPLSQL + # Encoding of the source code. Default is default system encoding #sonar.sourceEncoding=UTF-8 \ No newline at end of file From 2d09f43969c472328247604f02f35d09100ac419 Mon Sep 17 00:00:00 2001 From: lwasylow Date: Thu, 12 Jul 2018 18:41:58 +0100 Subject: [PATCH 142/184] Update sonar properties --- .travis.yml | 2 ++ .travis/run_sonar_scanner.sh | 38 +++++++++++++++++++++++------------- sonar-project.properties | 1 + 3 files changed, 27 insertions(+), 14 deletions(-) diff --git a/.travis.yml b/.travis.yml index 14eb5e4f5..dcc59c278 100644 --- a/.travis.yml +++ b/.travis.yml @@ -64,6 +64,8 @@ cache: - $MAVEN_CFG before_install: + #debug + - if [[ ! $TRAVIS_TAG ]] && [ "${TRAVIS_REPO_SLUG}" = "${UTPLSQL_REPO}" ]; then bash .travis/run_sonar_scanner.sh; fi #The update_project_version.sh is done before deployment to validate that the change of project files does not break installation - bash .travis/update_project_version.sh # download latest utPLSQL release diff --git a/.travis/run_sonar_scanner.sh b/.travis/run_sonar_scanner.sh index 97326f225..60f1afef9 100755 --- a/.travis/run_sonar_scanner.sh +++ b/.travis/run_sonar_scanner.sh @@ -1,14 +1,21 @@ #!/usr/bin/env bash MAIN_DEV_BRANCH="develop" + BRANCH_SONAR_PROPERTY="sonar.branch.name" BRANCH_SONAR_TARGET_PROPERTY="sonar.branch.target" -function add_sonar_property { +PR_SONAR_BRANCH_PROPERTY="sonar.pullrequest.branch" +PR_KEY_PROPERTY="sonar.pullrequest.key" +PR_SONAR_BASE_PROPERTY="sonar.pullrequest.base" +PR_SONAR_TOKEN_PROPERTY="sonar.pullrequest.github.token.secured" +#Add property to file +function add_sonar_property { echo "$1=$2" >> sonar-project.properties } + if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then BRANCH=$TRAVIS_BRANCH; PR_BRANCH="" @@ -20,25 +27,28 @@ else fi -add_sonar_property "sonar.pullrequest.github.token.secured" "${GITHUB_TRAVISCI_TOKEN}" -# We are updating sonar_properties only when is not a develop -# if its a pull request we will create a separate +#Are we running on develop branch ? +echo "Check if we running from develop or on branch" if [ "${TRAVIS_REPO_SLUG}" = "${UTPLSQL_REPO}" ] && [[ ! "${BRANCH}" =~ ^(release/v[0-9]+\.[0-9]+\.[0-9]+.*|"${MAIN_DEV_BRANCH}")$ ]]; then - echo "Updating sonar properties to include branch name" - - add_sonar_property "${BRANCH_SONAR_PROPERTY}" "${BRANCH}" - if [ ! -z "$PR_BRANCH" ]; then - echo "Updating sonar properties to include pr target branch name" - add_sonar_property "${BRANCH_SONAR_TARGET_PROPERTY}" "${PR_BRANCH}" - else + if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then + echo "Updating sonar properties to include branch name" + add_sonar_property "${BRANCH_SONAR_PROPERTY}" "${BRANCH}" add_sonar_property "${BRANCH_SONAR_TARGET_PROPERTY}" "${MAIN_DEV_BRANCH}" - fi - + else + echo "Updating sonar properties to include pull request name" + add_sonar_property "${PR_SONAR_TOKEN_PROPERTY}" "${GITHUB_TRAVISCI_TOKEN}" + add_sonar_property "${PR_SONAR_BRANCH_PROPERTY}" "${BRANCH}" + add_sonar_property "${PR_KEY_PROPERTY}" "${PR}" + add_sonar_property "${PR_SONAR_BASE_PROPERTY}" "${PR_BRANCH}" + fi else echo "No need to update sonar we building on release or develop" fi +#debug +cat sonar-project.properties + #Execute Sonar scanner -sonar-scanner \ No newline at end of file +#sonar-scanner \ No newline at end of file diff --git a/sonar-project.properties b/sonar-project.properties index 016b50d24..07870cebf 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -19,6 +19,7 @@ sonar.projectDescription=PL/SQL Unit Testing Framework sonar.plsql.file.suffixes=sql,tab,pkb,tpb sonar.language=plsql +sonar.pullrequest.provider=github sonar.pullrequest.github.endpoint=https://api.github.com/ sonar.pullrequest.github.repository=utPLSQL/utPLSQL From 565746399b66c963eb8495bd4c4dc7b48ee187a3 Mon Sep 17 00:00:00 2001 From: lwasylow Date: Thu, 12 Jul 2018 19:21:20 +0100 Subject: [PATCH 143/184] Update build to include pull requests --- .travis.yml | 2 -- .travis/run_sonar_scanner.sh | 10 ++++------ sonar-project.properties | 2 +- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index dcc59c278..14eb5e4f5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -64,8 +64,6 @@ cache: - $MAVEN_CFG before_install: - #debug - - if [[ ! $TRAVIS_TAG ]] && [ "${TRAVIS_REPO_SLUG}" = "${UTPLSQL_REPO}" ]; then bash .travis/run_sonar_scanner.sh; fi #The update_project_version.sh is done before deployment to validate that the change of project files does not break installation - bash .travis/update_project_version.sh # download latest utPLSQL release diff --git a/.travis/run_sonar_scanner.sh b/.travis/run_sonar_scanner.sh index 60f1afef9..4c03f9036 100755 --- a/.travis/run_sonar_scanner.sh +++ b/.travis/run_sonar_scanner.sh @@ -32,12 +32,13 @@ fi echo "Check if we running from develop or on branch" if [ "${TRAVIS_REPO_SLUG}" = "${UTPLSQL_REPO}" ] && [[ ! "${BRANCH}" =~ ^(release/v[0-9]+\.[0-9]+\.[0-9]+.*|"${MAIN_DEV_BRANCH}")$ ]]; then + echo "" >> sonar-project.properties if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then - echo "Updating sonar properties to include branch name" + echo "Updating sonar properties to include branch ${BRANCH}" add_sonar_property "${BRANCH_SONAR_PROPERTY}" "${BRANCH}" add_sonar_property "${BRANCH_SONAR_TARGET_PROPERTY}" "${MAIN_DEV_BRANCH}" else - echo "Updating sonar properties to include pull request name" + echo "Updating sonar properties to include pull request ${BRANCH}" add_sonar_property "${PR_SONAR_TOKEN_PROPERTY}" "${GITHUB_TRAVISCI_TOKEN}" add_sonar_property "${PR_SONAR_BRANCH_PROPERTY}" "${BRANCH}" add_sonar_property "${PR_KEY_PROPERTY}" "${PR}" @@ -47,8 +48,5 @@ else echo "No need to update sonar we building on release or develop" fi -#debug -cat sonar-project.properties - #Execute Sonar scanner -#sonar-scanner \ No newline at end of file +sonar-scanner \ No newline at end of file diff --git a/sonar-project.properties b/sonar-project.properties index 07870cebf..48e6fee2a 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -24,4 +24,4 @@ sonar.pullrequest.github.endpoint=https://api.github.com/ sonar.pullrequest.github.repository=utPLSQL/utPLSQL # Encoding of the source code. Default is default system encoding -#sonar.sourceEncoding=UTF-8 \ No newline at end of file +#sonar.sourceEncoding=UTF-8 From 81a1010e73ad535c9f2edeefa0e98c09ba65354e Mon Sep 17 00:00:00 2001 From: lwasylow Date: Thu, 12 Jul 2018 19:42:10 +0100 Subject: [PATCH 144/184] Allow to run analysis on all branches --- .travis.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 14eb5e4f5..c52153110 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,9 +12,6 @@ addons: organization: utplsql token: secure: ${SONAR_TOKEN} - branches: - - develop - - master services: - docker From 8ee2abe4e18679aac5715e651f81fc1f0361727d Mon Sep 17 00:00:00 2001 From: lwasylow Date: Thu, 12 Jul 2018 19:45:00 +0100 Subject: [PATCH 145/184] update --- .travis/run_sonar_scanner.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis/run_sonar_scanner.sh b/.travis/run_sonar_scanner.sh index 4c03f9036..d66ba5032 100755 --- a/.travis/run_sonar_scanner.sh +++ b/.travis/run_sonar_scanner.sh @@ -1,5 +1,7 @@ #!/usr/bin/env bash +#Run Sonar based on conditions + MAIN_DEV_BRANCH="develop" BRANCH_SONAR_PROPERTY="sonar.branch.name" From 9be330f608ab31d732679a017296d8b0275750be Mon Sep 17 00:00:00 2001 From: lwasylow Date: Thu, 12 Jul 2018 20:17:01 +0100 Subject: [PATCH 146/184] Test Sonar short lived branches analysis --- source/api/ut.pkb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/api/ut.pkb b/source/api/ut.pkb index 94ff1e2b5..c69b469d1 100644 --- a/source/api/ut.pkb +++ b/source/api/ut.pkb @@ -103,7 +103,9 @@ create or replace package body ut is raise e_package_invalidated; end if; end; - + + /*Test sonar rules*/ + procedure run_autonomous( a_paths ut_varchar2_list, a_reporter ut_reporter_base, From dc2ddc21ab636f6a0e80df03f89d0d389d759b58 Mon Sep 17 00:00:00 2001 From: lwasylow Date: Thu, 12 Jul 2018 20:43:50 +0100 Subject: [PATCH 147/184] Remove test line --- source/api/ut.pkb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/source/api/ut.pkb b/source/api/ut.pkb index c69b469d1..189eceb1c 100644 --- a/source/api/ut.pkb +++ b/source/api/ut.pkb @@ -103,9 +103,7 @@ create or replace package body ut is raise e_package_invalidated; end if; end; - - /*Test sonar rules*/ - + procedure run_autonomous( a_paths ut_varchar2_list, a_reporter ut_reporter_base, From 36b828fbc70878a76ab6fff593c6de70295eb7fd Mon Sep 17 00:00:00 2001 From: lwasylow Date: Thu, 12 Jul 2018 21:09:49 +0100 Subject: [PATCH 148/184] Update PR build number --- .travis/run_sonar_scanner.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis/run_sonar_scanner.sh b/.travis/run_sonar_scanner.sh index d66ba5032..d05b5806e 100755 --- a/.travis/run_sonar_scanner.sh +++ b/.travis/run_sonar_scanner.sh @@ -25,7 +25,7 @@ if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then else BRANCH=$TRAVIS_PULL_REQUEST_BRANCH PR_BRANCH=$TRAVIS_BRANCH - echo "TRAVIS_BRANCH=$TRAVIS_BRANCH, PR=$PR, BRANCH=$BRANCH" + echo "TRAVIS_BRANCH=$TRAVIS_BRANCH, PR=$TRAVIS_PULL_REQUEST, BRANCH=$BRANCH" fi From 001daf4575ced7d886a7128cf81c56b519381b6e Mon Sep 17 00:00:00 2001 From: lwasylow Date: Thu, 12 Jul 2018 21:17:40 +0100 Subject: [PATCH 149/184] Test --- source/api/ut.pkb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/api/ut.pkb b/source/api/ut.pkb index 189eceb1c..f4b6c7478 100644 --- a/source/api/ut.pkb +++ b/source/api/ut.pkb @@ -103,7 +103,9 @@ create or replace package body ut is raise e_package_invalidated; end if; end; - + + /* Testing of PR sonar*/ + procedure run_autonomous( a_paths ut_varchar2_list, a_reporter ut_reporter_base, From e27987bf3f7d537b66501561f1fd0d4f162bb25c Mon Sep 17 00:00:00 2001 From: lwasylow Date: Thu, 12 Jul 2018 22:01:30 +0100 Subject: [PATCH 150/184] Added unshallow option --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index c52153110..4d455ea5e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -63,6 +63,8 @@ cache: before_install: #The update_project_version.sh is done before deployment to validate that the change of project files does not break installation - bash .travis/update_project_version.sh + #Allow for sonar to blame issues + - git fetch --unshallow # download latest utPLSQL release #- curl -LOk $(curl --silent https://api.github.com/repos/utPLSQL/utPLSQL/releases/latest | awk '/browser_download_url/ { print $2 }' | grep ".zip" | sed 's/"//g') - git clone --depth=1 --branch=${SELFTESTING_BRANCH:-master} https://github.com/utPLSQL/utPLSQL.git $UTPLSQL_DIR From a8fa36ca0757455882e09a0ffe453b58b4fc5cbe Mon Sep 17 00:00:00 2001 From: lwasylow Date: Thu, 12 Jul 2018 22:28:54 +0100 Subject: [PATCH 151/184] Remove test line --- source/api/ut.pkb | 1 - 1 file changed, 1 deletion(-) diff --git a/source/api/ut.pkb b/source/api/ut.pkb index f4b6c7478..1159182fa 100644 --- a/source/api/ut.pkb +++ b/source/api/ut.pkb @@ -104,7 +104,6 @@ create or replace package body ut is end if; end; - /* Testing of PR sonar*/ procedure run_autonomous( a_paths ut_varchar2_list, From 429760b0b6f30678a5d65cd9224abd33e9112270 Mon Sep 17 00:00:00 2001 From: Pazus Date: Sat, 14 Jul 2018 09:34:16 +0300 Subject: [PATCH 152/184] fix check_object_grants bug on all_tab_privs. closes #712 --- source/check_object_grants.sql | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/source/check_object_grants.sql b/source/check_object_grants.sql index cf7a8f46f..729bdceda 100644 --- a/source/check_object_grants.sql +++ b/source/check_object_grants.sql @@ -2,6 +2,8 @@ declare c_expected_grants constant dbmsoutput_linesarray := dbmsoutput_linesarray('DBMS_LOCK','DBMS_CRYPTO'); l_missing_grants varchar2(4000); + l_target_table varchar2(128); + l_owner_column varchar2(128); function get_view(a_dba_view_name varchar2) return varchar2 is l_invalid_object_name exception; @@ -16,6 +18,8 @@ declare end; begin + l_target_table := get_view('dba_tab_privs'); + l_owner_column := case when l_target_table like 'DBA%' then 'owner' else 'table_schema' end; execute immediate q'[ select listagg(' - '||object_name,CHR(10)) within group(order by object_name) from ( @@ -23,9 +27,9 @@ begin from table(:l_expected_grants) minus select table_name as object_name - from ]'||get_view('dba_tab_privs')||q'[ + from ]'||l_target_table||q'[ where grantee = SYS_CONTEXT('userenv','current_schema') - and owner = 'SYS')]' + and ]'||l_owner_column||q'[ = 'SYS')]' into l_missing_grants using c_expected_grants; if l_missing_grants is not null then raise_application_error( @@ -37,4 +41,3 @@ begin end if; end; / - From 91c4b1311d3225054c0da924d015d7036dd5f30b Mon Sep 17 00:00:00 2001 From: Travis CI Date: Sat, 14 Jul 2018 11:04:59 +0000 Subject: [PATCH 153/184] Updated project version after build [skip ci] --- source/core/ut_utils.pks | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/core/ut_utils.pks b/source/core/ut_utils.pks index cdb02a368..e137b5e9d 100644 --- a/source/core/ut_utils.pks +++ b/source/core/ut_utils.pks @@ -21,7 +21,7 @@ create or replace package ut_utils authid definer is * */ - gc_version constant varchar2(50) := 'v3.1.2.2059-develop'; + gc_version constant varchar2(50) := 'v3.1.2.2081-develop'; /* Constants: Event names */ subtype t_event_name is varchar2(30); From 08af76bb5452abeec0ce0666ef112c033aec00ac Mon Sep 17 00:00:00 2001 From: lwasylow Date: Sun, 15 Jul 2018 09:21:50 +0100 Subject: [PATCH 154/184] update test and docs --- docs/userguide/running-unit-tests.md | 10 +++ test/api/test_ut_run.pkb | 106 +++++++++++++++++++++++++++ test/api/test_ut_run.pks | 32 ++++++-- 3 files changed, 140 insertions(+), 8 deletions(-) diff --git a/docs/userguide/running-unit-tests.md b/docs/userguide/running-unit-tests.md index f31c24912..eda27cedf 100644 --- a/docs/userguide/running-unit-tests.md +++ b/docs/userguide/running-unit-tests.md @@ -93,8 +93,18 @@ end; ``` Executes all tests from package _hr.test_apply_bonus_ and all tests from schema _cust_. +```sql +begin + ut.run('hr.test_apply_bonus,cust'); +end; +``` + +Executes all tests from package _hr.test_apply_bonus_ and all tests from schema _cust_. + Using a list of items to execute allows you to execute a fine-grained set of tests. +List can be passed as a comma separated list or a list of *ut_varchar2_list objects*. + **Note:** diff --git a/test/api/test_ut_run.pkb b/test/api/test_ut_run.pkb index b3b876c80..2333c6e18 100644 --- a/test/api/test_ut_run.pkb +++ b/test/api/test_ut_run.pkb @@ -328,5 +328,111 @@ end;]'; %2 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)%'); end; + procedure pass_varch_test_csl_spc is + l_results ut3.ut_varchar2_list; + l_actual clob; + begin + select * + bulk collect into l_results + from table(ut3.ut.run('test_csl_names1.one_is_one, test_csl_names2.one_is_one')); + + l_actual := ut3.ut_utils.table_to_clob(l_results); + ut.expect(l_actual).to_be_like('%Finished in % seconds +%2 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)%'); + end; + + procedure pass_csl_with_srcfile is + l_results ut3.ut_varchar2_list; + l_actual clob; + begin + + select * + bulk collect into l_results + from table( + ut3.ut.run( + a_path => 'test_csl_names1.one_is_one,test_csl_names2.one_is_one', + a_source_files => ut3.ut_varchar2_list('ut3.ut'), + a_test_files => ut3.ut_varchar2_list('ut3_tester.test_csl_names2') + ) + ); + + l_actual := ut3.ut_utils.table_to_clob(l_results); + ut.expect(l_actual).to_be_like('%Finished in % seconds +%2 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)%'); + end; + + procedure pass_singlevar_with_proc is + l_output_data dbms_output.chararr; + l_num_lines integer := 100000; + l_packages_executed integer := 0; + begin + --act + ut3.ut.run('test_csl_names1'); + dbms_output.get_lines( l_output_data, l_num_lines); + + for i in 1 .. l_num_lines loop + if l_output_data(i) like '%test_csl_names1%' then + l_packages_executed := l_packages_executed + 1; + end if; + end loop; + ut.expect(l_packages_executed ).to_equal(1); + end; + + procedure pass_vlist_with_proc is + l_output_data dbms_output.chararr; + l_num_lines integer := 100000; + l_packages_executed integer := 0; + begin + --act + ut3.ut.run(ut3.ut_varchar2_list('test_csl_names1','test_csl_names2')); + dbms_output.get_lines( l_output_data, l_num_lines); + + for i in 1 .. l_num_lines loop + if l_output_data(i) like '%test_csl_names1%' + or l_output_data(i) like '%test_csl_names2%' then + l_packages_executed := l_packages_executed + 1; + end if; + end loop; + ut.expect(l_packages_executed ).to_equal(2); + end; + + procedure pass_csl_with_proc is + l_output_data dbms_output.chararr; + l_num_lines integer := 100000; + l_packages_executed integer := 0; + begin + --act + ut3.ut.run('test_csl_names1,test_csl_names2'); + dbms_output.get_lines( l_output_data, l_num_lines); + + for i in 1 .. l_num_lines loop + if l_output_data(i) like '%test_csl_names1%' + or l_output_data(i) like '%test_csl_names2%' then + l_packages_executed := l_packages_executed + 1; + end if; + end loop; + ut.expect(l_packages_executed ).to_equal(2); + end; + + procedure pass_csl_src_proc is + l_output_data dbms_output.chararr; + l_num_lines integer := 100000; + l_packages_executed integer := 0; + begin + --act + ut3.ut.run(a_path => 'test_csl_names1,test_csl_names2', + a_source_files => ut3.ut_varchar2_list('ut3.ut'), + a_test_files => ut3.ut_varchar2_list('ut3_tester.test_csl_names2')); + dbms_output.get_lines( l_output_data, l_num_lines); + + for i in 1 .. l_num_lines loop + if l_output_data(i) like '%test_csl_names1%' + or l_output_data(i) like '%test_csl_names2%' then + l_packages_executed := l_packages_executed + 1; + end if; + end loop; + ut.expect(l_packages_executed ).to_equal(2); + end; + end; / diff --git a/test/api/test_ut_run.pks b/test/api/test_ut_run.pks index aeb1ab0e4..4e2a9b261 100644 --- a/test/api/test_ut_run.pks +++ b/test/api/test_ut_run.pks @@ -26,25 +26,41 @@ create or replace package test_ut_run is procedure create_test_csl_packages; procedure drop_test_csl_packages; + --%context(ut_run_coma_sep_list) + --%beforeall(create_test_csl_packages) + --%afterall(drop_test_csl_packages) + --%test( Pass name of tests as varchar2_list ) - --%beforetest(create_test_csl_packages) - --%aftertest(drop_test_csl_packages) procedure pass_varchar2_name_list; --%test( Pass single test name as varchar2 ) - --%beforetest(create_test_csl_packages) - --%aftertest(drop_test_csl_packages) procedure pass_varchar2_name; --%test( Pass coma separated list of suite names ) - --%beforetest(create_test_csl_packages) - --%aftertest(drop_test_csl_packages) procedure pass_varchar2_suite_csl; --%test( Pass coma separated list of test names ) - --%beforetest(create_test_csl_packages) - --%aftertest(drop_test_csl_packages) procedure pass_varchar2_test_csl; + + --%test( Pass coma separated list of test names with spaces ) + procedure pass_varch_test_csl_spc; + + --%test( Pass coma separated list and source and test files ) + procedure pass_csl_with_srcfile; + + --%test( Pass single varchar2 into procedure ) + procedure pass_singlevar_with_proc; + + --%test( Pass varchar2_list into procedure ) + procedure pass_vlist_with_proc; + + --%test( Pass coma separated list varchar2 into procedure ) + procedure pass_csl_with_proc; + + --%test( Pass coma separated list varchar2 into procedure with src file) + procedure pass_csl_src_proc; + + --%endcontext end; / From 6fcb366efdc6cc64fc713a905aa9f8704051a1bc Mon Sep 17 00:00:00 2001 From: Jacek Gebal Date: Mon, 9 Jul 2018 00:21:42 +0100 Subject: [PATCH 155/184] Cleanup of `ut_executable` - made come code private. Added test placeholders for `ut_executable`. Some tests referring the executable behavior should be removed with introduction of those tests. --- source/core/types/ut_executable.tpb | 75 ++++++++++++++--------------- source/core/types/ut_executable.tps | 2 - test/core/test_ut_executable.pkb | 56 +++++++++++++++++++++ test/core/test_ut_executable.pks | 41 ++++++++++++++++ test/install_tests.sql | 2 + 5 files changed, 135 insertions(+), 41 deletions(-) create mode 100644 test/core/test_ut_executable.pkb create mode 100644 test/core/test_ut_executable.pks diff --git a/source/core/types/ut_executable.tpb b/source/core/types/ut_executable.tpb index 610b7ab96..8c7772c7d 100644 --- a/source/core/types/ut_executable.tpb +++ b/source/core/types/ut_executable.tpb @@ -29,42 +29,6 @@ create or replace type body ut_executable is return; end; - member function is_defined(self in out nocopy ut_executable) return boolean is - l_result boolean := false; - l_message_part varchar2(4000) := 'Call params for ' || self.executable_type || ' are not valid: '; - begin - - if self.object_name is null then - self.error_stack := l_message_part || 'package is not defined'; - elsif self.procedure_name is null then - self.error_stack := l_message_part || 'procedure is not defined'; - else - l_result := true; - end if; - - return l_result; - end is_defined; - - /** - * We will check if error raised because package was invalid if not we let it propagate. - **/ - member function is_invalid(self in out nocopy ut_executable) return boolean is - l_result boolean := true; - l_message_part varchar2(4000) := 'Call params for ' || self.executable_type || ' are not valid: '; - begin - - if not ut_metadata.package_valid(self.owner_name, self.object_name) then - self.error_stack := l_message_part || 'package does not exist or is invalid: ' ||upper(self.owner_name||'.'||self.object_name); - elsif not ut_metadata.procedure_exists(self.owner_name, self.object_name, self.procedure_name) then - self.error_stack := l_message_part || 'procedure does not exist ' - || upper(self.owner_name || '.' || self.object_name || '.' ||self.procedure_name); - else - l_result := false; - end if; - - return l_result; - end is_invalid; - member function form_name return varchar2 is begin return ut_metadata.form_name(owner_name, object_name, procedure_name); @@ -84,7 +48,40 @@ create or replace type body ut_executable is l_failed_with_invalid_pck boolean := true; l_start_transaction_id varchar2(250); l_end_transaction_id varchar2(250); - + + function is_defined return boolean is + l_result boolean := false; + l_message_part varchar2(4000) := 'Call params for ' || self.executable_type || ' are not valid: '; + begin + + if self.object_name is null then + self.error_stack := l_message_part || 'package is not defined'; + elsif self.procedure_name is null then + self.error_stack := l_message_part || 'procedure is not defined'; + else + l_result := true; + end if; + + return l_result; + end is_defined; + + function is_invalid return boolean is + l_result boolean := true; + l_message_part varchar2(4000) := 'Call params for ' || self.executable_type || ' are not valid: '; + begin + + if not ut_metadata.package_valid(self.owner_name, self.object_name) then + self.error_stack := l_message_part || 'package does not exist or is invalid: ' ||upper(self.owner_name||'.'||self.object_name); + elsif not ut_metadata.procedure_exists(self.owner_name, self.object_name, self.procedure_name) then + self.error_stack := l_message_part || 'procedure does not exist ' + || upper(self.owner_name || '.' || self.object_name || '.' ||self.procedure_name); + else + l_result := false; + end if; + + return l_result; + end is_invalid; + procedure save_dbms_output is l_status number; l_line varchar2(32767); @@ -111,7 +108,7 @@ create or replace type body ut_executable is --listener - before call to executable ut_event_manager.trigger_event('before_'||self.executable_type, self); - l_completed_without_errors := self.is_defined(); + l_completed_without_errors := is_defined(); if l_completed_without_errors then l_statement := 'declare' || chr(10) || @@ -149,7 +146,7 @@ create or replace type body ut_executable is dbms_sql.close_cursor(l_cursor_number); exception when ut_utils.ex_invalid_package then - l_failed_with_invalid_pck := self.is_invalid(); + l_failed_with_invalid_pck := is_invalid(); dbms_sql.close_cursor(l_cursor_number); if not l_failed_with_invalid_pck then raise; diff --git a/source/core/types/ut_executable.tps b/source/core/types/ut_executable.tps index 5dbda5eff..976ccf396 100644 --- a/source/core/types/ut_executable.tps +++ b/source/core/types/ut_executable.tps @@ -26,8 +26,6 @@ create or replace type ut_executable under ut_event_item( error_stack varchar2(4000), serveroutput clob, 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 is_invalid(self in out nocopy ut_executable) return boolean, - member function is_defined(self in out nocopy ut_executable) return boolean, member function form_name return varchar2, member procedure do_execute(self in out nocopy ut_executable, a_item in out nocopy ut_suite_item), /** diff --git a/test/core/test_ut_executable.pkb b/test/core/test_ut_executable.pkb new file mode 100644 index 000000000..5adff1a10 --- /dev/null +++ b/test/core/test_ut_executable.pkb @@ -0,0 +1,56 @@ +create or replace package body test_ut_executable is + + --%suite(ut_executable) + --%suitepath(utplsql.core) + + --%beforeall + procedure create_dummy_package is + begin + null; + end; + + --%afterall + procedure drop_dummy_package is + begin + null; + end; + + --%context(do_execute) + + --%test(Executes procedure in current schema when user was not provided) + procedure exec_schema_package_proc is + begin + null; + end; + + --%test(Executes procedure and saves dbms_output) + procedure exec_package_proc is + begin + null; + end; + + --%test(Executes a procedure raising exception, saves dbms_output and exception stack trace) + procedure exec_failing_proc is + begin + null; + end; + + --%test(Sets state invalidation flag when executed procedure in a state-invalidated package, saves dbms_output and exception stack trace) + procedure exec_invalid_state_proc is + begin + null; + end; + + --%endcontext + + --%context(form_name) + + --%test(Builds a name for the executable test) + procedure form_name is + begin + null; + end; + --%endcontext + +end; +/ diff --git a/test/core/test_ut_executable.pks b/test/core/test_ut_executable.pks new file mode 100644 index 000000000..3ff5687a9 --- /dev/null +++ b/test/core/test_ut_executable.pks @@ -0,0 +1,41 @@ +create or replace package test_ut_executable is + + --%suite(ut_executable) + --%suitepath(utplsql.core) + + --%beforeall + procedure create_dummy_package; + + --%afterall + procedure drop_dummy_package; + + --%context(do_execute) + + --%test(Executes procedure in current schema when user was not provided) + --%disabled + procedure exec_schema_package_proc; + + --%test(Executes procedure and saves dbms_output) + --%disabled + procedure exec_package_proc; + + --%test(Executes a procedure raising exception, saves dbms_output and exception stack trace) + --%disabled + procedure exec_failing_proc; + + --%test(Sets state invalidation flag when executed procedure in a state-invalidated package, saves dbms_output and exception stack trace) + --%disabled + procedure exec_invalid_state_proc; + + --%endcontext + + --%context(form_name) + + --%test(Builds a name for the executable test) + --%disabled + procedure form_name; + + --%endcontext + +end; +/ diff --git a/test/install_tests.sql b/test/install_tests.sql index 1640c6794..e7c9e1f62 100644 --- a/test/install_tests.sql +++ b/test/install_tests.sql @@ -27,6 +27,7 @@ whenever oserror exit failure rollback @@core/test_output_buffer.pks @@core/test_file_mapper.pks @@core/test_suite_manager.pks +@@core/test_ut_executable.pks @@core/test_suite_builder.pks @@core/reporters.pks @@core/reporters/test_coverage.pks @@ -72,6 +73,7 @@ set define off @@core/test_output_buffer.pkb @@core/test_file_mapper.pkb @@core/test_suite_manager.pkb +@@core/test_ut_executable.pkb @@core/test_suite_builder.pkb @@core/reporters.pkb @@core/reporters/test_coverage.pkb From 331ff92ded5ac942915a1c8445af0d0a467b9c20 Mon Sep 17 00:00:00 2001 From: Jacek Gebal Date: Mon, 9 Jul 2018 20:25:06 +0100 Subject: [PATCH 156/184] Removed unused code from `ut_curr_usr_compound_helper` --- .../ut_curr_usr_compound_helper.pkb | 35 ------------------- .../ut_curr_usr_compound_helper.pks | 3 -- 2 files changed, 38 deletions(-) diff --git a/source/expectations/data_values/ut_curr_usr_compound_helper.pkb b/source/expectations/data_values/ut_curr_usr_compound_helper.pkb index c910aca65..b610ee13c 100644 --- a/source/expectations/data_values/ut_curr_usr_compound_helper.pkb +++ b/source/expectations/data_values/ut_curr_usr_compound_helper.pkb @@ -59,22 +59,6 @@ create or replace package body ut_curr_usr_compound_helper is return l_result; end; - function get_descr_cursor(a_cursor in out nocopy sys_refcursor, a_desc_user_types boolean := false) return ut_key_anyval_pairs is - l_cursor_number integer; - l_columns_count pls_integer; - l_columns_desc dbms_sql.desc_tab3; - l_columns_tab ut_key_anyval_pairs; - begin - if a_cursor is null or not a_cursor%isopen then - return null; - end if; - l_cursor_number := dbms_sql.to_cursor_number( a_cursor ); - dbms_sql.describe_columns3( l_cursor_number, l_columns_count, l_columns_desc ); - a_cursor := dbms_sql.to_refcursor( l_cursor_number ); - l_columns_tab := get_columns_info( l_columns_desc, l_columns_count, a_desc_user_types); - return l_columns_tab; - end; - procedure get_descr_cursor( a_cursor in out nocopy sys_refcursor, a_columns_tab in out nocopy ut_key_anyval_pairs, @@ -128,25 +112,6 @@ create or replace package body ut_curr_usr_compound_helper is a_contains_collection := ut_utils.boolean_to_int(g_is_collection); end; - function get_columns_info(a_cursor in out nocopy sys_refcursor, a_desc_user_types boolean := false) return xmltype is - l_result xmltype; - l_result_tmp xmltype; - l_columns_tab ut_key_anyval_pairs; - begin - l_columns_tab := get_descr_cursor(a_cursor,a_desc_user_types); - - for i in 1..l_columns_tab.COUNT - loop - l_result_tmp := ut_compound_data_helper.get_column_info_xml(l_columns_tab(i)); - select xmlconcat(l_result,l_result_tmp) into l_result from dual; - end loop; - - select XMLELEMENT("ROW",l_result ) - into l_result from dual; - - return l_result; - end; - function get_anytype_attribute_count (a_anytype anytype) return pls_integer is l_attribute_typecode pls_integer; l_schema_name varchar2(32767); diff --git a/source/expectations/data_values/ut_curr_usr_compound_helper.pks b/source/expectations/data_values/ut_curr_usr_compound_helper.pks index 4bf32cf31..d662f51f9 100644 --- a/source/expectations/data_values/ut_curr_usr_compound_helper.pks +++ b/source/expectations/data_values/ut_curr_usr_compound_helper.pks @@ -7,9 +7,6 @@ create or replace package ut_curr_usr_compound_helper authid current_user is a_contains_collection out nocopy number ); - function get_columns_info(a_cursor in out nocopy sys_refcursor, - a_desc_user_types boolean := false) return xmltype; - function get_user_defined_type(a_owner varchar2, a_type_name varchar2) return xmltype; end; From 2f39237b1edf119a8592988af9f7c6288e1d3fb9 Mon Sep 17 00:00:00 2001 From: Jacek Gebal Date: Tue, 10 Jul 2018 01:43:27 +0100 Subject: [PATCH 157/184] Added tests for `ut_executable`. Fixed issue with non-null serveroutput (empty_clob) created for every run. Removed unused code from `ut_suite_builder` --- source/core/types/ut_executable.tpb | 18 ++-- source/core/ut_suite_builder.pkb | 15 --- test/api/test_ut_run.pks | 4 +- test/core/test_ut_executable.pkb | 157 +++++++++++++++++++++++----- test/core/test_ut_executable.pks | 26 ++--- 5 files changed, 157 insertions(+), 63 deletions(-) diff --git a/source/core/types/ut_executable.tpb b/source/core/types/ut_executable.tpb index 8c7772c7d..a87df7988 100644 --- a/source/core/types/ut_executable.tpb +++ b/source/core/types/ut_executable.tpb @@ -86,17 +86,19 @@ create or replace type body ut_executable is l_status number; l_line varchar2(32767); begin - dbms_lob.createtemporary(self.serveroutput, true, dur => dbms_lob.session); - - loop - dbms_output.get_line(line => l_line, status => l_status); - exit when l_status = 1; + dbms_output.get_line(line => l_line, status => l_status); + if l_status != 1 then + dbms_lob.createtemporary(self.serveroutput, true, dur => dbms_lob.session); + end if; + while l_status != 1 loop if l_line is not null then ut_utils.append_to_clob(self.serveroutput, l_line); end if; - - dbms_lob.writeappend(self.serveroutput,1,chr(10)); + dbms_output.get_line(line => l_line, status => l_status); + if l_status != 1 then + dbms_lob.writeappend(self.serveroutput,1,chr(10)); + end if; end loop; end save_dbms_output; begin @@ -116,7 +118,7 @@ create or replace type body ut_executable is ' l_error_backtrace varchar2(32767);' || chr(10) || 'begin' || chr(10) || ' begin' || chr(10) || - ' ' || ut_metadata.form_name(self.owner_name, self.object_name, self.procedure_name) || ';' || chr(10) || + ' ' || self.form_name() || ';' || chr(10) || ' exception' || chr(10) || ' when others then ' || chr(10) || ' l_error_stack := dbms_utility.format_error_stack;' || chr(10) || diff --git a/source/core/ut_suite_builder.pkb b/source/core/ut_suite_builder.pkb index bc2d20b36..7ec518a9b 100644 --- a/source/core/ut_suite_builder.pkb +++ b/source/core/ut_suite_builder.pkb @@ -307,21 +307,6 @@ create or replace package body ut_suite_builder is return l_result; end; - procedure add_executable( - a_executables in out nocopy ut_executables, - a_owner t_object_name, - a_package_name t_object_name, - a_procedure_name t_object_name, - a_executable_type ut_utils.t_executable_type - ) is - begin - if a_executables is null then - a_executables := ut_executables(); - end if; - a_executables.extend; - a_executables(a_executables.last) := ut_executable(a_owner, a_package_name, a_procedure_name, a_executable_type); - end; - function add_executables( a_owner t_object_name, a_package_name t_object_name, diff --git a/test/api/test_ut_run.pks b/test/api/test_ut_run.pks index 12c9e7fe0..5dc6991e5 100644 --- a/test/api/test_ut_run.pks +++ b/test/api/test_ut_run.pks @@ -9,14 +9,14 @@ create or replace package test_ut_run is --%aftertest(drop_test_suite) procedure raise_in_invalid_state; - --%test(ut.run - run invalid package and fail expectation) + --%test(ut.run - Does not execute suite when specified package is not valid) --%beforetest(compile_invalid_package) --%aftertest(drop_invalid_package) procedure run_in_invalid_state; procedure compile_invalid_package; procedure drop_invalid_package; - --%test( Invalidate package specs via rebuild but still execute package) + --%test(Invalidate package specs via rebuild but still execute package) --%beforetest(generate_invalid_spec) --%aftertest(drop_test_package) procedure run_and_revalidate_specs; diff --git a/test/core/test_ut_executable.pkb b/test/core/test_ut_executable.pkb index 5adff1a10..4f78c4ad3 100644 --- a/test/core/test_ut_executable.pkb +++ b/test/core/test_ut_executable.pkb @@ -1,56 +1,163 @@ create or replace package body test_ut_executable is - --%suite(ut_executable) - --%suitepath(utplsql.core) + g_dbms_output_text varchar2(30) := 'Some output from procedure'; - --%beforeall - procedure create_dummy_package is + procedure exec_schema_package_proc is + l_executable ut3.ut_executable; + l_test ut3.ut_test; + l_result boolean; begin - null; + --Arrange + l_test := ut3.ut_test(a_object_name => 'test_ut_executable',a_name => 'test_ut_executable'); + l_executable := ut3.ut_executable_test( null, 'test_ut_executable', 'passing_proc', ut3.ut_utils.gc_test_execute ); + --Act + l_result := l_executable.do_execute(l_test); + --Assert + ut.expect(l_result).to_be_true; + ut.expect(l_executable.serveroutput).to_be_null; + ut.expect(l_executable.get_error_stack_trace()).to_be_null; end; - --%afterall - procedure drop_dummy_package is + procedure exec_package_proc_output is + l_executable ut3.ut_executable; + l_test ut3.ut_test; + l_result boolean; begin - null; + --Arrange + l_test := ut3.ut_test(a_object_name => 'test_ut_executable',a_name => 'test_ut_executable'); + l_executable := ut3.ut_executable_test( user, 'test_ut_executable', 'output_proc', ut3.ut_utils.gc_test_execute ); + --Act + l_result := l_executable.do_execute(l_test); + --Assert + ut.expect(l_result).to_be_true; + ut.expect(l_executable.serveroutput).to_equal(to_clob(g_dbms_output_text)); + ut.expect(l_executable.get_error_stack_trace()).to_be_null; end; - --%context(do_execute) + procedure exec_failing_proc is + l_executable ut3.ut_executable; + l_test ut3.ut_test; + l_result boolean; + begin + --Arrange + l_test := ut3.ut_test(a_object_name => 'test_ut_executable',a_name => 'test_ut_executable'); + l_executable := ut3.ut_executable_test( user, 'test_ut_executable', 'throwing_proc', ut3.ut_utils.gc_test_execute ); + --Act + l_result := l_executable.do_execute(l_test); + --Assert + ut.expect(l_result).to_be_false; + ut.expect(l_executable.serveroutput).to_be_null; + ut.expect(l_executable.get_error_stack_trace()).to_be_like('ORA-06501: PL/SQL: program error%'); + end; - --%test(Executes procedure in current schema when user was not provided) - procedure exec_schema_package_proc is + procedure create_state_dependant_pkg is + pragma autonomous_transaction; begin - null; + execute immediate q'[ + create or replace package stateful_package as + g_state varchar2(1) := 'A'; + end; + ]'; + execute immediate q'[ + create or replace package state_dependant_pkg as + procedure run; + end; + ]'; + execute immediate q'[ + create or replace package body state_dependant_pkg as + procedure run is + x varchar2(30); + begin + if stateful_package.g_state = 'A' then + dbms_output.put_line('stateful_package.g_state = "A"'); + end if; + end; + end; + ]'; end; - --%test(Executes procedure and saves dbms_output) - procedure exec_package_proc is + procedure modify_stateful_package is + l_job_name varchar2(30) := 'recreate_stateful_package'; + l_cnt integer := 1; + pragma autonomous_transaction; begin - null; + dbms_scheduler.create_job( + job_name => l_job_name, + job_type => 'PLSQL_BLOCK', + job_action => q'/ + begin + execute immediate q'[ + create or replace package stateful_package as + g_state varchar2(3) := 'abc'; + end;]'; + end;/', + start_date => localtimestamp, + enabled => TRUE, + auto_drop => TRUE, + comments => 'one-time job' + ); + dbms_lock.sleep(0.4); + while l_cnt > 0 loop + select count(1) into l_cnt + from dba_scheduler_running_jobs srj + where srj.job_name = l_job_name; + end loop; end; - --%test(Executes a procedure raising exception, saves dbms_output and exception stack trace) - procedure exec_failing_proc is + procedure drop_state_dependant_pkg is + pragma autonomous_transaction; begin - null; + execute immediate 'drop package state_dependant_pkg'; + execute immediate 'drop package stateful_package'; end; - --%test(Sets state invalidation flag when executed procedure in a state-invalidated package, saves dbms_output and exception stack trace) + procedure exec_invalid_state_proc is + l_executable ut3.ut_executable; + l_test ut3.ut_test; + l_result boolean; begin - null; - end; + --Arrange + l_test := ut3.ut_test(a_object_name => 'state_dependant_pkg',a_name => 'state_dependant_pkg'); + l_executable := ut3.ut_executable_test( user, 'state_dependant_pkg', 'run', ut3.ut_utils.gc_test_execute ); + l_result := l_executable.do_execute(l_test); + ut.expect(l_result).to_be_true; - --%endcontext + modify_stateful_package; - --%context(form_name) + l_test := ut3.ut_test(a_object_name => 'state_dependant_pkg',a_name => 'state_dependant_pkg'); + l_executable := ut3.ut_executable_test( user, 'state_dependant_pkg', 'run', ut3.ut_utils.gc_test_execute ); + --Act + l_result := l_executable.do_execute(l_test); + --Assert + ut.expect(l_result).to_be_false; + ut.expect(l_executable.serveroutput).to_be_null; + ut.expect(l_executable.get_error_stack_trace()).to_be_like('ORA-04061: existing state of package "UT3_TESTER.STATEFUL_PACKAGE" has been invalidated%'); + ut.expect(ut3.ut_expectation_processor.invalidation_exception_found()).to_be_true; + end; - --%test(Builds a name for the executable test) procedure form_name is + begin + ut.expect(ut3.ut_executable_test( user, 'package', 'proc', null ).form_name()).to_equal(user||'.package.proc'); + ut.expect(ut3.ut_executable_test( null, 'package', 'proc', null ).form_name()).to_equal('package.proc'); + ut.expect(ut3.ut_executable_test( null, 'proc', null, null ).form_name()).to_equal('proc'); + ut.expect(ut3.ut_executable_test( user, 'proc', null, null ).form_name()).to_equal(user||'.proc'); + end; + + procedure passing_proc is begin null; end; - --%endcontext + + procedure output_proc is + begin + dbms_output.put_line(g_dbms_output_text); + end; + + procedure throwing_proc is + begin + raise program_error; + end; end; / diff --git a/test/core/test_ut_executable.pks b/test/core/test_ut_executable.pks index 3ff5687a9..51641ecbf 100644 --- a/test/core/test_ut_executable.pks +++ b/test/core/test_ut_executable.pks @@ -3,39 +3,39 @@ create or replace package test_ut_executable is --%suite(ut_executable) --%suitepath(utplsql.core) - --%beforeall - procedure create_dummy_package; - - --%afterall - procedure drop_dummy_package; - --%context(do_execute) --%test(Executes procedure in current schema when user was not provided) - --%disabled procedure exec_schema_package_proc; --%test(Executes procedure and saves dbms_output) - --%disabled - procedure exec_package_proc; + procedure exec_package_proc_output; --%test(Executes a procedure raising exception, saves dbms_output and exception stack trace) - --%disabled procedure exec_failing_proc; - --%test(Sets state invalidation flag when executed procedure in a state-invalidated package, saves dbms_output and exception stack trace) - --%disabled + --%test(Sets state invalid flag when package-state invalidated and saves exception stack trace) + --%beforetest(create_state_dependant_pkg) + --%aftertest(drop_state_dependant_pkg) procedure exec_invalid_state_proc; + procedure create_state_dependant_pkg; + procedure drop_state_dependant_pkg; + --%endcontext --%context(form_name) --%test(Builds a name for the executable test) - --%disabled procedure form_name; --%endcontext + procedure passing_proc; + + procedure output_proc; + + procedure throwing_proc; + end; / From 3e052e7a7b74f29a0e2563bbd8409ea13a2452b6 Mon Sep 17 00:00:00 2001 From: Jacek Gebal Date: Sat, 14 Jul 2018 13:08:38 +0100 Subject: [PATCH 158/184] Fixed newline in `ut_executable` for dbms_output. --- source/core/types/ut_executable.tpb | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/source/core/types/ut_executable.tpb b/source/core/types/ut_executable.tpb index a87df7988..b31322331 100644 --- a/source/core/types/ut_executable.tpb +++ b/source/core/types/ut_executable.tpb @@ -93,12 +93,9 @@ create or replace type body ut_executable is end if; while l_status != 1 loop if l_line is not null then - ut_utils.append_to_clob(self.serveroutput, l_line); + ut_utils.append_to_clob(self.serveroutput, l_line||chr(10)); end if; dbms_output.get_line(line => l_line, status => l_status); - if l_status != 1 then - dbms_lob.writeappend(self.serveroutput,1,chr(10)); - end if; end loop; end save_dbms_output; begin From 01e100098369047f9fe78e8ce4905ffa262870a2 Mon Sep 17 00:00:00 2001 From: Jacek Gebal Date: Sat, 14 Jul 2018 13:42:43 +0100 Subject: [PATCH 159/184] Fixed newline in `ut_executable` for dbms_output. --- test/core/test_ut_executable.pkb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/core/test_ut_executable.pkb b/test/core/test_ut_executable.pkb index 4f78c4ad3..b5f372c32 100644 --- a/test/core/test_ut_executable.pkb +++ b/test/core/test_ut_executable.pkb @@ -30,7 +30,7 @@ create or replace package body test_ut_executable is l_result := l_executable.do_execute(l_test); --Assert ut.expect(l_result).to_be_true; - ut.expect(l_executable.serveroutput).to_equal(to_clob(g_dbms_output_text)); + ut.expect(l_executable.serveroutput).to_equal(to_clob(g_dbms_output_text||chr(10))); ut.expect(l_executable.get_error_stack_trace()).to_be_null; end; From ce9f52067563d424fafa12cc59eed0f0598d3d11 Mon Sep 17 00:00:00 2001 From: Jacek Gebal Date: Sun, 15 Jul 2018 22:35:43 +0100 Subject: [PATCH 160/184] Removed duplicated old tests. Moved functionality from old tests to ut3. Refactored parts of functionality of `ut`/`ut_runner`. Removed unused code. Added missing tests. --- .travis.yml | 1 - .../create_additional_grants_for_old_tests.sh | 23 - .travis/install.sh | 27 + development/install.sh | 4 - docs/userguide/coverage.md | 6 +- old_tests/RunAll.sql | 75 --- .../ut/ut.run.AcceptsCoverageFileList.sql | 30 - ...n.AcceptsCoverageFileListWithSutePaths.sql | 30 - old_tests/ut/ut.run.AcceptsSutePaths.sql | 27 - ...ut.run.ExecutesSuccesfullyAnEmptySuite.sql | 30 - ...run.FailsToExecuteAnInvalidPackageBody.sql | 35 -- ...ectutesAllInCurrentSchemaUsingReporter.sql | 27 - ...hNoParams.ExecutesAllFromCurrentSchema.sql | 27 - ...ackageName.ExecutesAllFromGivenPackage.sql | 27 - ...geName.ExecutesAllFromGivenPackageOnly.sql | 27 - ...hSchemaName.ExecutesAllFromGivenSchema.sql | 27 - ...WithSuitePath.ExecutesAllFromGivenPath.sql | 27 - ...t.run.function.AcceptsCoverageFileList.sql | 29 - ...n.AcceptsCoverageFileListWithSutePaths.sql | 29 - .../ut/ut.run.function.AcceptsSutePaths.sql | 26 - ...ectutesAllInCurrentSchemaUsingReporter.sql | 26 - ...hNoParams.ExecutesAllFromCurrentSchema.sql | 26 - ...ackageName.ExecutesAllFromGivenPackage.sql | 26 - ...geName.ExecutesAllFromGivenPackageOnly.sql | 26 - ...hSchemaName.ExecutesAllFromGivenSchema.sql | 26 - ...WithSuitePath.ExecutesAllFromGivenPath.sql | 26 - old_tests/ut/ut.version.sql | 11 - ...who_called_expectation.parseStackTrace.sql | 34 - ...lled_expectation.parseStackTraceWith0x.sql | 28 - .../ut.expect.not_to_equal.scalar.common.sql | 17 - ...pect.to_equal.different_scalars.common.sql | 20 - .../ut.expect.to_equal.scalar.common.sql | 17 - ...to_equal.scalar.null_value_text.common.sql | 17 - ...ct.to_equal.scalar.with_message.common.sql | 19 - ...o_equal.scalar.with_nulls_equal.common.sql | 19 - ...ot_to_equal.GivesFailureForEqualValues.sql | 15 - ...o_equal.GivesSuccessForDifferentValues.sql | 11 - ...a.GivesFailureWhenComparingTheSameData.sql | 17 - ....GivesFailureWhenExpessionIsNotBoolean.sql | 21 - ..._false.GivesFailureWhenExpessionIsNull.sql | 21 - ..._false.GivesFailureWhenExpessionIsTrue.sql | 21 - ...false.GivesSuccessWhenExpessionIsFalse.sql | 21 - ...to_be_like.FailsForUnsupportedDatatype.sql | 17 - ....anydata.GivesSuccessWhenAnydataIsNull.sql | 16 - ...GivesSuccessWhenCollectionPassedIsNull.sql | 16 - ...ata.GivesSuccessWhenObjectPassedIsNull.sql | 16 - ...refcursor.GivesSuccessWhenCursorIsNull.sql | 17 - ..._true.GivesFailureWhenExpessionIsFalse.sql | 21 - ....GivesFailureWhenExpessionIsNotBoolean.sql | 21 - ...e_true.GivesFailureWhenExpessionIsNull.sql | 21 - ...e_true.GivesSuccessWhenExpessionIsTrue.sql | 21 - ...esDefaultNLSSettingsForDatesFormatting.sql | 19 - ...t.to_equal.cursor.worksOnLargeDatasets.sql | 21 - ...t.to_match.FailsForUnsupportedDatatype.sql | 17 - ...re.Gives0WhenComparingIdenticalObjects.sql | 22 - old_tests/ut_matchers/be_between.sql | 72 --- old_tests/ut_matchers/be_like.sql | 19 - .../common/ut.expect.common.be_between.sql | 17 - .../common/ut.expect.to_be_like.common.sql | 17 - .../common/ut.expect.to_match.common.sql | 17 - old_tests/ut_matchers/match.sql | 19 - old_tests/ut_matchers/timestamp_between.sql | 17 - .../ut_matchers/timestamp_ltz_between.sql | 16 - .../ut_matchers/timestamp_ltz_not_between.sql | 17 - .../ut_matchers/timestamp_not_between.sql | 17 - .../ut_matchers/timestamp_tz_between.sql | 17 - .../ut_matchers/timestamp_tz_not_between.sql | 18 - ...RecievesALineFromBufferTableAndDeletes.sql | 33 - ...itsForMoreDataToAppearForSpecifiedTime.sql | 24 - ...aitsForTheDataToAppearForSpecifiedTime.sql | 22 - ...nd_line.DoesNotSendLineIfNullTextGiven.sql | 21 - .../send_line.SendsALineIntoBufferTable.sql | 24 - ...mcity_reporter.ProducesExpectedOutputs.sql | 52 -- ...tion_by_path.PrepareRunnerForTheSchema.sql | 44 -- ...h.PrepareRunnerForTheTop2PackageByName.sql | 36 -- ...reRunnerForTheTop2PackageByNameCurUser.sql | 36 -- ...h.PrepareRunnerForTheTop2PackageByPath.sql | 36 -- ...reRunnerForTheTop2PackageByPathCurUser.sql | 36 -- ...RunnerForTheTop2PackageProcedureByPath.sql | 52 -- ...orTheTop2PackageProcedureByPathCurUser.sql | 52 -- ...th.PrepareRunnerForTheTopPackageByName.sql | 65 -- ...areRunnerForTheTopPackageByNameCurUser.sql | 65 -- ...th.PrepareRunnerForTheTopPackageByPath.sql | 36 -- ...areRunnerForTheTopPackageByPathCurUser.sql | 36 -- ...eRunnerForTheTopPackageProcedureByPath.sql | 38 -- ...ForTheTopPackageProcedureByPathCurUser.sql | 38 -- ...PackageProcedureWithoutSubsuitesByName.sql | 36 -- ...ProcedureWithoutSubsuitesByNameCurUser.sql | 36 -- ...ForTheTopPackageWithoutSubsuitesByName.sql | 40 -- ...opPackageWithoutSubsuitesByNameCurUser.sql | 40 -- ...ForTheTopPackageWithoutSubsuitesByPath.sql | 40 -- ...opPackageWithoutSubsuitesByPathCurUser.sql | 40 -- source/api/ut.pkb | 50 +- source/api/ut_runner.pkb | 12 +- source/core/ut_file_mapper.pks | 6 +- .../data_values/ut_compound_data_helper.pkb | 4 +- test/api/test_ut_run.pkb | 584 +++++++++++++++++- test/api/test_ut_run.pks | 95 ++- .../binary/test_be_greater_or_equal.pkb | 8 + .../binary/test_be_greater_or_equal.pks | 3 + .../binary/test_be_greater_than.pkb | 8 + .../binary/test_be_greater_than.pks | 3 + .../binary/test_be_less_or_equal.pkb | 8 + .../binary/test_be_less_or_equal.pks | 3 + test/core/expectations/binary/test_equal.pkb | 5 + .../binary/test_expect_to_be_less_than.pkb | 8 + .../binary/test_expect_to_be_less_than.pks | 3 + .../test_expectation_processor.pkb | 71 +++ .../test_expectation_processor.pks | 17 + .../expectations/test_expectations_cursor.pkb | 4 +- test/core/expectations/test_matchers.pkb | 43 +- .../core/reporters/test_teamcity_reporter.pkb | 52 ++ .../core/reporters/test_teamcity_reporter.pks | 10 + test/core/test_output_buffer.pks | 2 +- test/core/test_suite_builder.pkb | 16 +- test/install_tests.sql | 4 + 116 files changed, 942 insertions(+), 2562 deletions(-) delete mode 100644 .travis/create_additional_grants_for_old_tests.sh delete mode 100644 old_tests/ut/ut.run.AcceptsCoverageFileList.sql delete mode 100644 old_tests/ut/ut.run.AcceptsCoverageFileListWithSutePaths.sql delete mode 100644 old_tests/ut/ut.run.AcceptsSutePaths.sql delete mode 100644 old_tests/ut/ut.run.ExecutesSuccesfullyAnEmptySuite.sql delete mode 100644 old_tests/ut/ut.run.FailsToExecuteAnInvalidPackageBody.sql delete mode 100644 old_tests/ut/ut.run.WithGivenReporter.ExectutesAllInCurrentSchemaUsingReporter.sql delete mode 100644 old_tests/ut/ut.run.WithNoParams.ExecutesAllFromCurrentSchema.sql delete mode 100644 old_tests/ut/ut.run.WithPackageName.ExecutesAllFromGivenPackage.sql delete mode 100644 old_tests/ut/ut.run.WithPackageName.ExecutesAllFromGivenPackageOnly.sql delete mode 100644 old_tests/ut/ut.run.WithSchemaName.ExecutesAllFromGivenSchema.sql delete mode 100644 old_tests/ut/ut.run.WithSuitePath.ExecutesAllFromGivenPath.sql delete mode 100644 old_tests/ut/ut.run.function.AcceptsCoverageFileList.sql delete mode 100644 old_tests/ut/ut.run.function.AcceptsCoverageFileListWithSutePaths.sql delete mode 100644 old_tests/ut/ut.run.function.AcceptsSutePaths.sql delete mode 100644 old_tests/ut/ut.run.function.WithGivenReporter.ExectutesAllInCurrentSchemaUsingReporter.sql delete mode 100644 old_tests/ut/ut.run.function.WithNoParams.ExecutesAllFromCurrentSchema.sql delete mode 100644 old_tests/ut/ut.run.function.WithPackageName.ExecutesAllFromGivenPackage.sql delete mode 100644 old_tests/ut/ut.run.function.WithPackageName.ExecutesAllFromGivenPackageOnly.sql delete mode 100644 old_tests/ut/ut.run.function.WithSchemaName.ExecutesAllFromGivenSchema.sql delete mode 100644 old_tests/ut/ut.run.function.WithSuitePath.ExecutesAllFromGivenPath.sql delete mode 100644 old_tests/ut/ut.version.sql delete mode 100644 old_tests/ut_expectation_processor/who_called_expectation.parseStackTrace.sql delete mode 100644 old_tests/ut_expectation_processor/who_called_expectation.parseStackTraceWith0x.sql delete mode 100644 old_tests/ut_expectations/common/ut.expect.not_to_equal.scalar.common.sql delete mode 100644 old_tests/ut_expectations/common/ut.expect.to_equal.different_scalars.common.sql delete mode 100644 old_tests/ut_expectations/common/ut.expect.to_equal.scalar.common.sql delete mode 100644 old_tests/ut_expectations/common/ut.expect.to_equal.scalar.null_value_text.common.sql delete mode 100644 old_tests/ut_expectations/common/ut.expect.to_equal.scalar.with_message.common.sql delete mode 100644 old_tests/ut_expectations/common/ut.expect.to_equal.scalar.with_nulls_equal.common.sql delete mode 100644 old_tests/ut_expectations/ut.expect.not_to_equal.GivesFailureForEqualValues.sql delete mode 100644 old_tests/ut_expectations/ut.expect.not_to_equal.GivesSuccessForDifferentValues.sql delete mode 100644 old_tests/ut_expectations/ut.expect.not_to_equal.anydata.GivesFailureWhenComparingTheSameData.sql delete mode 100644 old_tests/ut_expectations/ut.expect.to_be_false.GivesFailureWhenExpessionIsNotBoolean.sql delete mode 100644 old_tests/ut_expectations/ut.expect.to_be_false.GivesFailureWhenExpessionIsNull.sql delete mode 100644 old_tests/ut_expectations/ut.expect.to_be_false.GivesFailureWhenExpessionIsTrue.sql delete mode 100644 old_tests/ut_expectations/ut.expect.to_be_false.GivesSuccessWhenExpessionIsFalse.sql delete mode 100644 old_tests/ut_expectations/ut.expect.to_be_like.FailsForUnsupportedDatatype.sql delete mode 100644 old_tests/ut_expectations/ut.expect.to_be_null.anydata.GivesSuccessWhenAnydataIsNull.sql delete mode 100644 old_tests/ut_expectations/ut.expect.to_be_null.anydata.GivesSuccessWhenCollectionPassedIsNull.sql delete mode 100644 old_tests/ut_expectations/ut.expect.to_be_null.anydata.GivesSuccessWhenObjectPassedIsNull.sql delete mode 100644 old_tests/ut_expectations/ut.expect.to_be_null.refcursor.GivesSuccessWhenCursorIsNull.sql delete mode 100644 old_tests/ut_expectations/ut.expect.to_be_true.GivesFailureWhenExpessionIsFalse.sql delete mode 100644 old_tests/ut_expectations/ut.expect.to_be_true.GivesFailureWhenExpessionIsNotBoolean.sql delete mode 100644 old_tests/ut_expectations/ut.expect.to_be_true.GivesFailureWhenExpessionIsNull.sql delete mode 100644 old_tests/ut_expectations/ut.expect.to_be_true.GivesSuccessWhenExpessionIsTrue.sql delete mode 100644 old_tests/ut_expectations/ut.expect.to_equal.cursor.UsesDefaultNLSSettingsForDatesFormatting.sql delete mode 100644 old_tests/ut_expectations/ut.expect.to_equal.cursor.worksOnLargeDatasets.sql delete mode 100644 old_tests/ut_expectations/ut.expect.to_match.FailsForUnsupportedDatatype.sql delete mode 100644 old_tests/ut_expectations/ut_data_value_object.compare.Gives0WhenComparingIdenticalObjects.sql delete mode 100644 old_tests/ut_matchers/be_between.sql delete mode 100644 old_tests/ut_matchers/be_like.sql delete mode 100644 old_tests/ut_matchers/common/ut.expect.common.be_between.sql delete mode 100644 old_tests/ut_matchers/common/ut.expect.to_be_like.common.sql delete mode 100644 old_tests/ut_matchers/common/ut.expect.to_match.common.sql delete mode 100644 old_tests/ut_matchers/match.sql delete mode 100644 old_tests/ut_matchers/timestamp_between.sql delete mode 100644 old_tests/ut_matchers/timestamp_ltz_between.sql delete mode 100644 old_tests/ut_matchers/timestamp_ltz_not_between.sql delete mode 100644 old_tests/ut_matchers/timestamp_not_between.sql delete mode 100644 old_tests/ut_matchers/timestamp_tz_between.sql delete mode 100644 old_tests/ut_matchers/timestamp_tz_not_between.sql delete mode 100644 old_tests/ut_output_buffer/get_lines.RecievesALineFromBufferTableAndDeletes.sql delete mode 100644 old_tests/ut_output_buffer/get_lines.WaitsForMoreDataToAppearForSpecifiedTime.sql delete mode 100644 old_tests/ut_output_buffer/get_lines.WaitsForTheDataToAppearForSpecifiedTime.sql delete mode 100644 old_tests/ut_output_buffer/send_line.DoesNotSendLineIfNullTextGiven.sql delete mode 100644 old_tests/ut_output_buffer/send_line.SendsALineIntoBufferTable.sql delete mode 100644 old_tests/ut_reporters/ut_teamcity_reporter.ProducesExpectedOutputs.sql delete mode 100644 old_tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheSchema.sql delete mode 100644 old_tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTop2PackageByName.sql delete mode 100644 old_tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTop2PackageByNameCurUser.sql delete mode 100644 old_tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTop2PackageByPath.sql delete mode 100644 old_tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTop2PackageByPathCurUser.sql delete mode 100644 old_tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTop2PackageProcedureByPath.sql delete mode 100644 old_tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTop2PackageProcedureByPathCurUser.sql delete mode 100644 old_tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageByName.sql delete mode 100644 old_tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageByNameCurUser.sql delete mode 100644 old_tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageByPath.sql delete mode 100644 old_tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageByPathCurUser.sql delete mode 100644 old_tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageProcedureByPath.sql delete mode 100644 old_tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageProcedureByPathCurUser.sql delete mode 100644 old_tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageProcedureWithoutSubsuitesByName.sql delete mode 100644 old_tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageProcedureWithoutSubsuitesByNameCurUser.sql delete mode 100644 old_tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageWithoutSubsuitesByName.sql delete mode 100644 old_tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageWithoutSubsuitesByNameCurUser.sql delete mode 100644 old_tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageWithoutSubsuitesByPath.sql delete mode 100644 old_tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageWithoutSubsuitesByPathCurUser.sql create mode 100644 test/core/expectations/test_expectation_processor.pkb create mode 100644 test/core/expectations/test_expectation_processor.pks create mode 100644 test/core/reporters/test_teamcity_reporter.pkb create mode 100644 test/core/reporters/test_teamcity_reporter.pks diff --git a/.travis.yml b/.travis.yml index 4d455ea5e..b83a5380f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -86,7 +86,6 @@ install: before_script: - if [[ ! $TRAVIS_TAG ]]; then bash .travis/install.sh; fi - if [[ ! $TRAVIS_TAG ]]; then bash .travis/install_utplsql_release.sh; fi - - if [[ ! $TRAVIS_TAG ]]; then bash .travis/create_additional_grants_for_old_tests.sh; fi - if [[ ! $TRAVIS_TAG ]]; then bash .travis/run_examples.sh; fi - if [[ ! $TRAVIS_TAG ]]; then bash .travis/run_old_tests.sh; fi diff --git a/.travis/create_additional_grants_for_old_tests.sh b/.travis/create_additional_grants_for_old_tests.sh deleted file mode 100644 index c07bfc4a7..000000000 --- a/.travis/create_additional_grants_for_old_tests.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash - -cd source -set -ev - -#additional privileges to run scripted tests -"$SQLCLI" sys/$ORACLE_PWD@//$CONNECTION_STR AS SYSDBA <<-SQL -set feedback on ---needed for Mystats script to work -grant select any dictionary to $UT3_OWNER; ---Needed for testing a coverage outside ut3_owner. -grant create any procedure, drop any procedure, execute any procedure to $UT3_OWNER; - -exit -SQL - -#Create additional users -"$SQLCLI" sys/$ORACLE_PWD@//$CONNECTION_STR AS SYSDBA <<-SQL -set feedback off -@create_utplsql_owner.sql $UT3_USER $UT3_USER_PASSWORD $UT3_TABLESPACE - -exit -SQL \ No newline at end of file diff --git a/.travis/install.sh b/.travis/install.sh index 1c3e3ef7e..bb99a0e2d 100644 --- a/.travis/install.sh +++ b/.travis/install.sh @@ -69,3 +69,30 @@ revoke execute on dbms_crypto from $UT3_TESTER; grant create job to $UT3_TESTER; exit SQL + +#additional privileges to run tests +"$SQLCLI" sys/$ORACLE_PWD@//$CONNECTION_STR AS SYSDBA <<-SQL +set feedback on +--needed for Mystats script to work +grant select any dictionary to $UT3_OWNER; +--Needed for testing a coverage outside ut3_owner. +grant create any procedure, drop any procedure, execute any procedure to $UT3_OWNER; + +exit +SQL + +#Create additional users +"$SQLCLI" sys/$ORACLE_PWD@//$CONNECTION_STR AS SYSDBA <<-SQL +set feedback off +@create_utplsql_owner.sql $UT3_USER $UT3_USER_PASSWORD $UT3_TABLESPACE + +exit +SQL + +#Grant UT3 framework to UT3$USER# +"$SQLCLI" sys/$ORACLE_PWD@//$CONNECTION_STR AS SYSDBA <<-SQL +set feedback off +@create_user_grants.sql $UT3_OWNER $UT3_USER + +exit +SQL diff --git a/development/install.sh b/development/install.sh index 42bc88d85..4104e2672 100755 --- a/development/install.sh +++ b/development/install.sh @@ -18,7 +18,3 @@ if ! .travis/install_utplsql_release.sh; then echo -e ${header}"\nFailed to install utPLSQL from branch ${SELFTESTING_BRANCH} into ${UT3_RELEASE_VERSION_SCHEMA}\n"${header} exit 1 fi -if ! .travis/create_additional_grants_for_old_tests.sh; then - echo -e ${header}"Failed to add grants needed old_tests\n"${header} - exit 1 -fi diff --git a/docs/userguide/coverage.md b/docs/userguide/coverage.md index f123a0d22..1d4ca93c5 100644 --- a/docs/userguide/coverage.md +++ b/docs/userguide/coverage.md @@ -230,10 +230,10 @@ C: \hr.test_betwnstr.pks ``` -By default, utPLSQL will convert file paths into database objects using the following regular expression `/((\w+)\.)?(\w+)\.(\w{3})$` +By default, utPLSQL will convert file paths into database objects using the following regular expression `/(((\w|[$#])+)\.)?((\w|[$#])+)\.(\w{3})$` - object owner (if it is present) is identified by the expression in the second set of brackets -- object name is identified by the expression in the third set of brackets -- object type is identified by the expression in the fourth set of brackets +- object name is identified by the expression in the fourth set of brackets +- object type is identified by the expression in the sixth set of brackets **Note** diff --git a/old_tests/RunAll.sql b/old_tests/RunAll.sql index 031f10574..f785aabc1 100644 --- a/old_tests/RunAll.sql +++ b/old_tests/RunAll.sql @@ -37,94 +37,19 @@ create table ut$test_table (val varchar2(1)); exec ut_coverage.coverage_start(); exec ut_coverage.set_develop_mode(true); -@@lib/RunTest.sql ut_expectation_processor/who_called_expectation.parseStackTrace.sql -@@lib/RunTest.sql ut_expectation_processor/who_called_expectation.parseStackTraceWith0x.sql -@@lib/RunTest.sql ut_expectations/ut.expect.to_be_false.GivesFailureWhenExpessionIsNotBoolean.sql -@@lib/RunTest.sql ut_expectations/ut.expect.to_be_false.GivesFailureWhenExpessionIsNull.sql -@@lib/RunTest.sql ut_expectations/ut.expect.to_be_false.GivesFailureWhenExpessionIsTrue.sql -@@lib/RunTest.sql ut_expectations/ut.expect.to_be_false.GivesSuccessWhenExpessionIsFalse.sql -@@lib/RunTest.sql ut_expectations/ut.expect.to_be_like.FailsForUnsupportedDatatype.sql -@@lib/RunTest.sql ut_expectations/ut.expect.to_be_null.anydata.GivesSuccessWhenAnydataIsNull.sql -@@lib/RunTest.sql ut_expectations/ut.expect.to_be_null.anydata.GivesSuccessWhenCollectionPassedIsNull.sql -@@lib/RunTest.sql ut_expectations/ut.expect.to_be_null.anydata.GivesSuccessWhenObjectPassedIsNull.sql -@@lib/RunTest.sql ut_expectations/ut.expect.to_be_true.GivesFailureWhenExpessionIsFalse.sql -@@lib/RunTest.sql ut_expectations/ut.expect.to_be_true.GivesFailureWhenExpessionIsNotBoolean.sql -@@lib/RunTest.sql ut_expectations/ut.expect.to_be_true.GivesFailureWhenExpessionIsNull.sql -@@lib/RunTest.sql ut_expectations/ut.expect.to_be_true.GivesSuccessWhenExpessionIsTrue.sql -@@ut_expectations/ut.expect.not_to_equal.GivesFailureForEqualValues.sql -@@ut_expectations/ut.expect.not_to_equal.GivesSuccessForDifferentValues.sql -@@lib/RunTest.sql ut_expectations/ut.expect.to_match.FailsForUnsupportedDatatype.sql -@@lib/RunTest.sql ut_expectations/ut_data_value_object.compare.Gives0WhenComparingIdenticalObjects.sql @@lib/RunTest.sql ut_expectations/ut_expectation_processor.nulls_are_equal.raisesExceptionWhenTryingToSetNullValue.sql @@lib/RunTest.sql ut_expectations/ut_expectation_processor.stackOnFailedTest.sql @@lib/RunTest.sql ut_expectations/ut_expectation_processor.stackOnUtFail.sql -@@ut_matchers/be_between.sql -@@ut_matchers/be_like.sql -@@ut_matchers/match.sql - -@@lib/RunTest.sql ut_matchers/timestamp_between.sql -@@lib/RunTest.sql ut_matchers/timestamp_ltz_between.sql -@@lib/RunTest.sql ut_matchers/timestamp_ltz_not_between.sql -@@lib/RunTest.sql ut_matchers/timestamp_not_between.sql -@@lib/RunTest.sql ut_matchers/timestamp_tz_between.sql -@@lib/RunTest.sql ut_matchers/timestamp_tz_not_between.sql - @@lib/RunTest.sql ut_metadata/ut_metadata.form_name.TrimStandaloneProgramName.sql -@@lib/RunTest.sql ut_output_buffer/get_lines.RecievesALineFromBufferTableAndDeletes.sql -@@lib/RunTest.sql ut_output_buffer/get_lines.WaitsForMoreDataToAppearForSpecifiedTime.sql -@@lib/RunTest.sql ut_output_buffer/get_lines.WaitsForTheDataToAppearForSpecifiedTime.sql -@@lib/RunTest.sql ut_output_buffer/send_line.DoesNotSendLineIfNullTextGiven.sql -@@lib/RunTest.sql ut_output_buffer/send_line.SendsALineIntoBufferTable.sql - @@lib/RunTest.sql ut_reporters/ut_documentation_reporter.providesCorrectLineFromStacktrace.sql @@lib/RunTest.sql ut_reporters/ut_documentation_reporter.reportMultipleWarnings.sql @@lib/RunTest.sql ut_reporters/ut_documentation_reporter.reportTestTiming.sql @@lib/RunTest.sql ut_reporters/ut_html_reporter.DefaultSchemaCoverage.sql @@lib/RunTest.sql ut_reporters/ut_html_reporter.UserOverrideSchemaCoverage.sql -@@lib/RunTest.sql ut_reporters/ut_teamcity_reporter.ProducesExpectedOutputs.sql - -@@lib/RunTest.sql ut/ut.run.AcceptsCoverageFileList.sql -@@lib/RunTest.sql ut/ut.run.AcceptsCoverageFileListWithSutePaths.sql -@@lib/RunTest.sql ut/ut.run.AcceptsSutePaths.sql -@@lib/RunTest.sql ut/ut.run.ExecutesSuccesfullyAnEmptySuite.sql -@@lib/RunTest.sql ut/ut.run.FailsToExecuteAnInvalidPackageBody.sql -@@lib/RunTest.sql ut/ut.run.function.AcceptsCoverageFileList.sql -@@lib/RunTest.sql ut/ut.run.function.AcceptsCoverageFileListWithSutePaths.sql -@@lib/RunTest.sql ut/ut.run.function.AcceptsSutePaths.sql -@@lib/RunTest.sql ut/ut.run.function.WithGivenReporter.ExectutesAllInCurrentSchemaUsingReporter.sql -@@lib/RunTest.sql ut/ut.run.function.WithNoParams.ExecutesAllFromCurrentSchema.sql -@@lib/RunTest.sql ut/ut.run.function.WithPackageName.ExecutesAllFromGivenPackage.sql ---@@lib/RunTest.sql ut.run/ut.run.function.WithPackageName.ExecutesAllFromGivenPackageOnly.sql --TODO this one doesn't work at the moment -@@lib/RunTest.sql ut/ut.run.function.WithSchemaName.ExecutesAllFromGivenSchema.sql -@@lib/RunTest.sql ut/ut.run.function.WithSuitePath.ExecutesAllFromGivenPath.sql -@@lib/RunTest.sql ut/ut.run.WithGivenReporter.ExectutesAllInCurrentSchemaUsingReporter.sql -@@lib/RunTest.sql ut/ut.run.WithNoParams.ExecutesAllFromCurrentSchema.sql -@@lib/RunTest.sql ut/ut.run.WithPackageName.ExecutesAllFromGivenPackage.sql ---@@lib/RunTest.sql ut.run/ut.run.WithPackageName.ExecutesAllFromGivenPackageOnly.sql --TODO this one doesn't work at the moment -@@lib/RunTest.sql ut/ut.run.WithSchemaName.ExecutesAllFromGivenSchema.sql -@@lib/RunTest.sql ut/ut.run.WithSuitePath.ExecutesAllFromGivenPath.sql -@@lib/RunTest.sql ut/ut.version.sql @@lib/RunTest.sql ut_suite_manager/ut_suite_manager.AllowsDescriptionsWithComma.sql -@@lib/RunTest.sql ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheSchema.sql -@@lib/RunTest.sql ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageByPath.sql -@@lib/RunTest.sql ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageByPathCurUser.sql -@@lib/RunTest.sql ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTop2PackageByPath.sql -@@lib/RunTest.sql ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTop2PackageByPathCurUser.sql -@@lib/RunTest.sql ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageWithoutSubsuitesByPath.sql -@@lib/RunTest.sql ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageWithoutSubsuitesByPathCurUser.sql -@@lib/RunTest.sql ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageByName.sql -@@lib/RunTest.sql ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageByNameCurUser.sql -@@lib/RunTest.sql ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTop2PackageByName.sql -@@lib/RunTest.sql ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTop2PackageByNameCurUser.sql -@@lib/RunTest.sql ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageWithoutSubsuitesByName.sql -@@lib/RunTest.sql ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageWithoutSubsuitesByNameCurUser.sql -@@lib/RunTest.sql ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageProcedureByPath.sql -@@lib/RunTest.sql ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageProcedureByPathCurUser.sql -@@lib/RunTest.sql ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTop2PackageProcedureByPath.sql -@@lib/RunTest.sql ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTop2PackageProcedureByPathCurUser.sql @@lib/RunTest.sql ut_suite_manager/ut_suite_manager.emptySuitePath.sql @@lib/RunTest.sql ut_suite_manager/ut_suite_manager.get_schema_ut_packages.IncludesPackagesWithSutePath.sql @@lib/RunTest.sql ut_suite_manager/ut_suite_manager.IncludesInvalidPackageBodiesInTheRun.sql diff --git a/old_tests/ut/ut.run.AcceptsCoverageFileList.sql b/old_tests/ut/ut.run.AcceptsCoverageFileList.sql deleted file mode 100644 index 0dea02727..000000000 --- a/old_tests/ut/ut.run.AcceptsCoverageFileList.sql +++ /dev/null @@ -1,30 +0,0 @@ -declare - l_output_data dbms_output.chararr; - l_num_lines integer := 100000; - l_packages_reported integer := 0; -begin - --act - ut.run( - ut_sonar_test_reporter(), a_source_files => ut_varchar2_list(), - a_test_files => ut_varchar2_list('tests/test_package_1.pkb','tests/test_package_2.pkb','tests/test_package_3.pkb') - ); - dbms_output.get_lines( l_output_data, l_num_lines); - - for i in 1 .. l_num_lines loop - if l_output_data(i) like '%tests/test_package_1.pkb%' escape '\' - or l_output_data(i) like '%tests/test_package_2.pkb%' - or l_output_data(i) like '%tests/test_package_3.pkb%' then - l_packages_reported := l_packages_reported + 1; - end if; - end loop; - - if l_packages_reported = 3 then - :test_result := ut_utils.gc_success; - else - for i in 1 .. l_output_data.count loop - dbms_output.put_line(l_output_data(i)); - end loop; - dbms_output.put_line('Failed: not all package paths were found in the outputs. Expected 3, got '||l_packages_reported); - end if; -end; -/ diff --git a/old_tests/ut/ut.run.AcceptsCoverageFileListWithSutePaths.sql b/old_tests/ut/ut.run.AcceptsCoverageFileListWithSutePaths.sql deleted file mode 100644 index 73046daf9..000000000 --- a/old_tests/ut/ut.run.AcceptsCoverageFileListWithSutePaths.sql +++ /dev/null @@ -1,30 +0,0 @@ -declare - l_output_data dbms_output.chararr; - l_num_lines integer := 100000; - l_packages_reported integer := 0; -begin - --act - ut.run( - ut_varchar2_list('test_package_1','test_package_3'), ut_sonar_test_reporter(), - a_source_files => ut_varchar2_list(), a_test_files => ut_varchar2_list('tests/test_package_1.pkb','tests/test_package_2.pkb','tests/test_package_3.pkb') - ); - dbms_output.get_lines( l_output_data, l_num_lines); - - for i in 1 .. l_num_lines loop - if l_output_data(i) like '%tests/test_package_1.pkb%' escape '\' - or l_output_data(i) like '%tests/test_package_2.pkb%' - or l_output_data(i) like '%tests/test_package_3.pkb%' then - l_packages_reported := l_packages_reported + 1; - end if; - end loop; - - if l_packages_reported = 3 then - :test_result := ut_utils.gc_success; - else - for i in 1 .. l_output_data.count loop - dbms_output.put_line(l_output_data(i)); - end loop; - dbms_output.put_line('Failed: not all package paths were found in the outputs. Expected 3, got '||l_packages_reported); - end if; -end; -/ diff --git a/old_tests/ut/ut.run.AcceptsSutePaths.sql b/old_tests/ut/ut.run.AcceptsSutePaths.sql deleted file mode 100644 index 1ed2b001b..000000000 --- a/old_tests/ut/ut.run.AcceptsSutePaths.sql +++ /dev/null @@ -1,27 +0,0 @@ -declare - l_output_data dbms_output.chararr; - l_num_lines integer := 100000; - l_packages_executed integer := 0; -begin - --act - ut.run(ut_varchar2_list('test_package_1','test_package_3'),ut_teamcity_reporter()); - dbms_output.get_lines( l_output_data, l_num_lines); - - for i in 1 .. l_num_lines loop - if l_output_data(i) like '%Finished %''%test\_package\_1''%' escape '\' - or l_output_data(i) like '%Finished %''%test_package_2''%' - or l_output_data(i) like '%Finished %''%test_package_3''%' then - l_packages_executed := l_packages_executed + 1; - end if; - end loop; - - if l_packages_executed = 3 then - :test_result := ut_utils.gc_success; - else - for i in 1 .. l_output_data.count loop - dbms_output.put_line(l_output_data(i)); - end loop; - dbms_output.put_line('Failed: not all packages were found in the outputs. Expected 3, got '||l_packages_executed); - end if; -end; -/ diff --git a/old_tests/ut/ut.run.ExecutesSuccesfullyAnEmptySuite.sql b/old_tests/ut/ut.run.ExecutesSuccesfullyAnEmptySuite.sql deleted file mode 100644 index 35a752acd..000000000 --- a/old_tests/ut/ut.run.ExecutesSuccesfullyAnEmptySuite.sql +++ /dev/null @@ -1,30 +0,0 @@ -set termout off -create or replace package empty_suite as - -- %suite - - procedure not_a_test; -end; -/ -create or replace package body empty_suite as - procedure not_a_test is begin null; end; -end; -/ -set termout on -declare - l_result integer; -begin - select * - into l_result - from table(ut.run('empty_suite',utplsql_test_reporter())); ---Assert - if l_result = ut_utils.gc_error then - :test_result := ut_utils.gc_success; - else - dbms_output.put_line('expected failure of ''empty_suite'' got: '''||ut_utils.test_result_to_char(l_result)||'''' ); - end if; -end; -/ - -set termout off -drop package empty_suite; -set termout on diff --git a/old_tests/ut/ut.run.FailsToExecuteAnInvalidPackageBody.sql b/old_tests/ut/ut.run.FailsToExecuteAnInvalidPackageBody.sql deleted file mode 100644 index b37fe1529..000000000 --- a/old_tests/ut/ut.run.FailsToExecuteAnInvalidPackageBody.sql +++ /dev/null @@ -1,35 +0,0 @@ -set termout off -create table test_dependency_table (id integer); -create or replace package test_dependencies as - -- %suite - - -- %test - procedure dependant; -end; -/ -create or replace package body test_dependencies as - gc_dependant_variable test_dependency_table.id%type; - procedure dependant is begin null; end; -end; -/ -drop table test_dependency_table; -set termout on - -declare - l_result integer; -begin - select * - into l_result - from table(ut.run('test_dependencies',utplsql_test_reporter())); ---Assert - if l_result = ut_utils.gc_error then - :test_result := ut_utils.gc_success; - else - dbms_output.put_line('expected failure of ''test_dependencies'' got: '''||ut_utils.test_result_to_char(l_result)||'''' ); - end if; -end; -/ - -set termout off -drop package test_dependencies; -set termout on diff --git a/old_tests/ut/ut.run.WithGivenReporter.ExectutesAllInCurrentSchemaUsingReporter.sql b/old_tests/ut/ut.run.WithGivenReporter.ExectutesAllInCurrentSchemaUsingReporter.sql deleted file mode 100644 index 88aa01d1e..000000000 --- a/old_tests/ut/ut.run.WithGivenReporter.ExectutesAllInCurrentSchemaUsingReporter.sql +++ /dev/null @@ -1,27 +0,0 @@ -declare - l_output_data dbms_output.chararr; - l_num_lines integer := 100000; - l_packages_executed integer := 0; -begin - --act - ut.run(ut_teamcity_reporter()); - dbms_output.get_lines( l_output_data, l_num_lines); - - for i in 1 .. l_num_lines loop - if l_output_data(i) like '%Finished %''%test\_package\_1''%' escape '\' - or l_output_data(i) like '%Finished %''%test_package_2''%' - or l_output_data(i) like '%Finished %''%test_package_3''%' then - l_packages_executed := l_packages_executed + 1; - end if; - end loop; - - if l_packages_executed = 3 then - :test_result := ut_utils.gc_success; - else - for i in 1 .. l_num_lines loop - dbms_output.put_line(l_output_data(i)); - end loop; - dbms_output.put_line('Failed: not all packages were found in the outputs. Expected 3, got '||l_packages_executed); - end if; -end; -/ diff --git a/old_tests/ut/ut.run.WithNoParams.ExecutesAllFromCurrentSchema.sql b/old_tests/ut/ut.run.WithNoParams.ExecutesAllFromCurrentSchema.sql deleted file mode 100644 index f50403dcd..000000000 --- a/old_tests/ut/ut.run.WithNoParams.ExecutesAllFromCurrentSchema.sql +++ /dev/null @@ -1,27 +0,0 @@ -declare - l_output_data dbms_output.chararr; - l_num_lines integer := 100000; - l_packages_executed integer := 0; -begin - --act - ut.run(); - dbms_output.get_lines( l_output_data, l_num_lines); - - for i in 1 .. l_num_lines loop - if l_output_data(i) like '%test\_package\_1%' escape '\' - or l_output_data(i) like '%test_package_2%' - or l_output_data(i) like '%test_package_3%' then - l_packages_executed := l_packages_executed + 1; - end if; - end loop; - - if l_packages_executed = 3 then - :test_result := ut_utils.gc_success; - else - for i in 1 .. l_num_lines loop - dbms_output.put_line(l_output_data(i)); - end loop; - dbms_output.put_line('Failed: not all packages were found in the outputs. Expected 3, got '||l_packages_executed); - end if; -end; -/ diff --git a/old_tests/ut/ut.run.WithPackageName.ExecutesAllFromGivenPackage.sql b/old_tests/ut/ut.run.WithPackageName.ExecutesAllFromGivenPackage.sql deleted file mode 100644 index cd6371e64..000000000 --- a/old_tests/ut/ut.run.WithPackageName.ExecutesAllFromGivenPackage.sql +++ /dev/null @@ -1,27 +0,0 @@ -declare - l_output_data dbms_output.chararr; - l_num_lines integer := 100000; - l_packages_executed integer := 0; -begin - --act - ut.run(user||'.test_package_3'); - dbms_output.get_lines( l_output_data, l_num_lines); - - for i in 1 .. l_num_lines loop - if l_output_data(i) like '%test\_package\_1%' escape '\' - or l_output_data(i) like '%test_package_2%' - or l_output_data(i) like '%test_package_3%' then - l_packages_executed := l_packages_executed + 1; - end if; - end loop; - - if l_packages_executed = 1 then - :test_result := ut_utils.gc_success; - else - for i in 1 .. l_num_lines loop - dbms_output.put_line(l_output_data(i)); - end loop; - dbms_output.put_line('Failed: not all packages were found in the outputs. Expected 1, got '||l_packages_executed); - end if; -end; -/ diff --git a/old_tests/ut/ut.run.WithPackageName.ExecutesAllFromGivenPackageOnly.sql b/old_tests/ut/ut.run.WithPackageName.ExecutesAllFromGivenPackageOnly.sql deleted file mode 100644 index 09f5fcdea..000000000 --- a/old_tests/ut/ut.run.WithPackageName.ExecutesAllFromGivenPackageOnly.sql +++ /dev/null @@ -1,27 +0,0 @@ -declare - l_output_data dbms_output.chararr; - l_num_lines integer := 100000; - l_packages_executed integer := 0; -begin - --act - ut.run(user||'.test_package_1'); - dbms_output.get_lines( l_output_data, l_num_lines); - - for i in 1 .. l_num_lines loop - if l_output_data(i) like '%test\_package\_1%' escape '\' - or l_output_data(i) like '%test_package_2%' - or l_output_data(i) like '%test_package_3%' then - l_packages_executed := l_packages_executed + 1; - end if; - end loop; - - if l_packages_executed = 1 then - :test_result := ut_utils.gc_success; - else - for i in 1 .. l_num_lines loop - dbms_output.put_line(l_output_data(i)); - end loop; - dbms_output.put_line('Failed: more than just package test_package_1 was executed. Expected 1, got '||l_packages_executed); - end if; -end; -/ diff --git a/old_tests/ut/ut.run.WithSchemaName.ExecutesAllFromGivenSchema.sql b/old_tests/ut/ut.run.WithSchemaName.ExecutesAllFromGivenSchema.sql deleted file mode 100644 index ce568ecea..000000000 --- a/old_tests/ut/ut.run.WithSchemaName.ExecutesAllFromGivenSchema.sql +++ /dev/null @@ -1,27 +0,0 @@ -declare - l_output_data dbms_output.chararr; - l_num_lines integer := 100000; - l_packages_executed integer := 0; -begin - --act - ut.run(user); - dbms_output.get_lines( l_output_data, l_num_lines); - - for i in 1 .. l_num_lines loop - if l_output_data(i) like '%test\_package\_1%' escape '\' - or l_output_data(i) like '%test_package_2%' - or l_output_data(i) like '%test_package_3%' then - l_packages_executed := l_packages_executed + 1; - end if; - end loop; - - if l_packages_executed = 3 then - :test_result := ut_utils.gc_success; - else - for i in 1 .. l_num_lines loop - dbms_output.put_line(l_output_data(i)); - end loop; - dbms_output.put_line('Failed: not all packages were found in the outputs. Expected 3, got '||l_packages_executed); - end if; -end; -/ diff --git a/old_tests/ut/ut.run.WithSuitePath.ExecutesAllFromGivenPath.sql b/old_tests/ut/ut.run.WithSuitePath.ExecutesAllFromGivenPath.sql deleted file mode 100644 index d31099e9f..000000000 --- a/old_tests/ut/ut.run.WithSuitePath.ExecutesAllFromGivenPath.sql +++ /dev/null @@ -1,27 +0,0 @@ -declare - l_output_data dbms_output.chararr; - l_num_lines integer := 100000; - l_packages_executed integer := 0; -begin - --act - ut.run(user||':tests.test_package_1'); - dbms_output.get_lines( l_output_data, l_num_lines); - - for i in 1 .. l_num_lines loop - if l_output_data(i) like '%test\_package\_1%' escape '\' - or l_output_data(i) like '%test_package_2%' - or l_output_data(i) like '%test_package_3%' then - l_packages_executed := l_packages_executed + 1; - end if; - end loop; - - if l_packages_executed = 2 then - :test_result := ut_utils.gc_success; - else - for i in 1 .. l_num_lines loop - dbms_output.put_line(l_output_data(i)); - end loop; - dbms_output.put_line('Failed: not all packages were found in the outputs. Expected 2, got '||l_packages_executed); - end if; -end; -/ diff --git a/old_tests/ut/ut.run.function.AcceptsCoverageFileList.sql b/old_tests/ut/ut.run.function.AcceptsCoverageFileList.sql deleted file mode 100644 index c5b7af70c..000000000 --- a/old_tests/ut/ut.run.function.AcceptsCoverageFileList.sql +++ /dev/null @@ -1,29 +0,0 @@ -declare - l_output_data ut_varchar2_list; - l_packages_reported integer := 0; -begin - --act - select * bulk collect into l_output_data - from table(ut.run( - ut_sonar_test_reporter(), a_source_files => ut_varchar2_list(), - a_test_files => ut_varchar2_list('tests/test_package_1.pkb','tests/test_package_2.pkb','tests/test_package_3.pkb') - )); - - for i in 1 .. l_output_data.count loop - if l_output_data(i) like '%tests/test_package_1.pkb%' escape '\' - or l_output_data(i) like '%tests/test_package_2.pkb%' - or l_output_data(i) like '%tests/test_package_3.pkb%' then - l_packages_reported := l_packages_reported + 1; - end if; - end loop; - - if l_packages_reported = 3 then - :test_result := ut_utils.gc_success; - else - for i in 1 .. l_output_data.count loop - dbms_output.put_line(l_output_data(i)); - end loop; - dbms_output.put_line('Failed: not all package paths were found in the outputs. Expected 3, got '||l_packages_reported); - end if; -end; -/ diff --git a/old_tests/ut/ut.run.function.AcceptsCoverageFileListWithSutePaths.sql b/old_tests/ut/ut.run.function.AcceptsCoverageFileListWithSutePaths.sql deleted file mode 100644 index e3f0055c1..000000000 --- a/old_tests/ut/ut.run.function.AcceptsCoverageFileListWithSutePaths.sql +++ /dev/null @@ -1,29 +0,0 @@ -declare - l_output_data ut_varchar2_list; - l_packages_reported integer := 0; -begin - --act - select * bulk collect into l_output_data - from table(ut.run( - ut_varchar2_list('test_package_1','test_package_3'), ut_sonar_test_reporter(), - a_source_files => ut_varchar2_list(), a_test_files => ut_varchar2_list('tests/test_package_1.pkb','tests/test_package_2.pkb','tests/test_package_3.pkb') - )); - - for i in 1 .. l_output_data.count loop - if l_output_data(i) like '%tests/test_package_1.pkb%' escape '\' - or l_output_data(i) like '%tests/test_package_2.pkb%' - or l_output_data(i) like '%tests/test_package_3.pkb%' then - l_packages_reported := l_packages_reported + 1; - end if; - end loop; - - if l_packages_reported = 3 then - :test_result := ut_utils.gc_success; - else - for i in 1 .. l_output_data.count loop - dbms_output.put_line(l_output_data(i)); - end loop; - dbms_output.put_line('Failed: not all package paths were found in the outputs. Expected 3, got '||l_packages_reported); - end if; -end; -/ diff --git a/old_tests/ut/ut.run.function.AcceptsSutePaths.sql b/old_tests/ut/ut.run.function.AcceptsSutePaths.sql deleted file mode 100644 index 98abbae39..000000000 --- a/old_tests/ut/ut.run.function.AcceptsSutePaths.sql +++ /dev/null @@ -1,26 +0,0 @@ -declare - l_output_data ut_varchar2_list; - l_packages_executed integer := 0; -begin - --act - select * bulk collect into l_output_data - from table(ut.run(ut_varchar2_list('test_package_1','test_package_3'),ut_teamcity_reporter())); - - for i in 1 .. l_output_data.count loop - if l_output_data(i) like '%Finished %''%test\_package\_1''%' escape '\' - or l_output_data(i) like '%Finished %''%test_package_2''%' - or l_output_data(i) like '%Finished %''%test_package_3''%' then - l_packages_executed := l_packages_executed + 1; - end if; - end loop; - - if l_packages_executed = 3 then - :test_result := ut_utils.gc_success; - else - for i in 1 .. l_output_data.count loop - dbms_output.put_line(l_output_data(i)); - end loop; - dbms_output.put_line('Failed: not all packages were found in the outputs. Expected 3, got '||l_packages_executed); - end if; -end; -/ diff --git a/old_tests/ut/ut.run.function.WithGivenReporter.ExectutesAllInCurrentSchemaUsingReporter.sql b/old_tests/ut/ut.run.function.WithGivenReporter.ExectutesAllInCurrentSchemaUsingReporter.sql deleted file mode 100644 index a4d779f93..000000000 --- a/old_tests/ut/ut.run.function.WithGivenReporter.ExectutesAllInCurrentSchemaUsingReporter.sql +++ /dev/null @@ -1,26 +0,0 @@ -declare - l_output_data ut_varchar2_list; - l_packages_executed integer := 0; -begin - --act - select * bulk collect into l_output_data - from table(ut.run(ut_teamcity_reporter())); - - for i in 1 .. l_output_data.count loop - if l_output_data(i) like '%Finished %''%test\_package\_1''%' escape '\' - or l_output_data(i) like '%Finished %''%test_package_2''%' - or l_output_data(i) like '%Finished %''%test_package_3''%' then - l_packages_executed := l_packages_executed + 1; - end if; - end loop; - - if l_packages_executed = 3 then - :test_result := ut_utils.gc_success; - else - for i in 1 .. l_output_data.count loop - dbms_output.put_line(l_output_data(i)); - end loop; - dbms_output.put_line('Failed: not all packages were found in the outputs. Expected 3, got '||l_packages_executed); - end if; -end; -/ diff --git a/old_tests/ut/ut.run.function.WithNoParams.ExecutesAllFromCurrentSchema.sql b/old_tests/ut/ut.run.function.WithNoParams.ExecutesAllFromCurrentSchema.sql deleted file mode 100644 index c9e80068e..000000000 --- a/old_tests/ut/ut.run.function.WithNoParams.ExecutesAllFromCurrentSchema.sql +++ /dev/null @@ -1,26 +0,0 @@ -declare - l_output_data ut_varchar2_list; - l_packages_executed integer := 0; -begin - --act - select * bulk collect into l_output_data - from table(ut.run()); - - for i in 1 .. l_output_data.count loop - if l_output_data(i) like '%test\_package\_1%' escape '\' - or l_output_data(i) like '%test_package_2%' - or l_output_data(i) like '%test_package_3%' then - l_packages_executed := l_packages_executed + 1; - end if; - end loop; - - if l_packages_executed = 3 then - :test_result := ut_utils.gc_success; - else - for i in 1 .. l_output_data.count loop - dbms_output.put_line(l_output_data(i)); - end loop; - dbms_output.put_line('Failed: not all packages were found in the outputs. Expected 3, got '||l_packages_executed); - end if; -end; -/ diff --git a/old_tests/ut/ut.run.function.WithPackageName.ExecutesAllFromGivenPackage.sql b/old_tests/ut/ut.run.function.WithPackageName.ExecutesAllFromGivenPackage.sql deleted file mode 100644 index f630baeb6..000000000 --- a/old_tests/ut/ut.run.function.WithPackageName.ExecutesAllFromGivenPackage.sql +++ /dev/null @@ -1,26 +0,0 @@ -declare - l_output_data ut_varchar2_list; - l_packages_executed integer := 0; -begin - --act - select * bulk collect into l_output_data - from table(ut.run(user||'.test_package_3')); - - for i in 1 .. l_output_data.count loop - if l_output_data(i) like '%test\_package\_1%' escape '\' - or l_output_data(i) like '%test_package_2%' - or l_output_data(i) like '%test_package_3%' then - l_packages_executed := l_packages_executed + 1; - end if; - end loop; - - if l_packages_executed = 1 then - :test_result := ut_utils.gc_success; - else - for i in 1 .. l_output_data.count loop - dbms_output.put_line(l_output_data(i)); - end loop; - dbms_output.put_line('Failed: not all packages were found in the outputs. Expected 1, got '||l_packages_executed); - end if; -end; -/ diff --git a/old_tests/ut/ut.run.function.WithPackageName.ExecutesAllFromGivenPackageOnly.sql b/old_tests/ut/ut.run.function.WithPackageName.ExecutesAllFromGivenPackageOnly.sql deleted file mode 100644 index 2cdc8e717..000000000 --- a/old_tests/ut/ut.run.function.WithPackageName.ExecutesAllFromGivenPackageOnly.sql +++ /dev/null @@ -1,26 +0,0 @@ -declare - l_output_data ut_varchar2_list; - l_packages_executed integer := 0; -begin - --act - select * bulk collect into l_output_data - from table(ut.run(user||'.test_package_1')); - - for i in 1 .. l_output_data.count loop - if l_output_data(i) like '%test\_package\_1%' escape '\' - or l_output_data(i) like '%test_package_2%' - or l_output_data(i) like '%test_package_3%' then - l_packages_executed := l_packages_executed + 1; - end if; - end loop; - - if l_packages_executed = 1 then - :test_result := ut_utils.gc_success; - else - for i in 1 .. l_output_data.count loop - dbms_output.put_line(l_output_data(i)); - end loop; - dbms_output.put_line('Failed: more than just package test_package_1 was executed. Expected 1, got '||l_packages_executed); - end if; -end; -/ diff --git a/old_tests/ut/ut.run.function.WithSchemaName.ExecutesAllFromGivenSchema.sql b/old_tests/ut/ut.run.function.WithSchemaName.ExecutesAllFromGivenSchema.sql deleted file mode 100644 index bccf6583a..000000000 --- a/old_tests/ut/ut.run.function.WithSchemaName.ExecutesAllFromGivenSchema.sql +++ /dev/null @@ -1,26 +0,0 @@ -declare - l_output_data ut_varchar2_list; - l_packages_executed integer := 0; -begin - --act - select * bulk collect into l_output_data - from table(ut.run(user)); - - for i in 1 .. l_output_data.count loop - if l_output_data(i) like '%test\_package\_1%' escape '\' - or l_output_data(i) like '%test_package_2%' - or l_output_data(i) like '%test_package_3%' then - l_packages_executed := l_packages_executed + 1; - end if; - end loop; - - if l_packages_executed = 3 then - :test_result := ut_utils.gc_success; - else - for i in 1 .. l_output_data.count loop - dbms_output.put_line(l_output_data(i)); - end loop; - dbms_output.put_line('Failed: not all packages were found in the outputs. Expected 3, got '||l_packages_executed); - end if; -end; -/ diff --git a/old_tests/ut/ut.run.function.WithSuitePath.ExecutesAllFromGivenPath.sql b/old_tests/ut/ut.run.function.WithSuitePath.ExecutesAllFromGivenPath.sql deleted file mode 100644 index f44c13e79..000000000 --- a/old_tests/ut/ut.run.function.WithSuitePath.ExecutesAllFromGivenPath.sql +++ /dev/null @@ -1,26 +0,0 @@ -declare - l_output_data ut_varchar2_list; - l_packages_executed integer := 0; -begin - --act - select * bulk collect into l_output_data - from table(ut.run(user||':tests.test_package_1')); - - for i in 1 .. l_output_data.count loop - if l_output_data(i) like '%test\_package\_1%' escape '\' - or l_output_data(i) like '%test_package_2%' - or l_output_data(i) like '%test_package_3%' then - l_packages_executed := l_packages_executed + 1; - end if; - end loop; - - if l_packages_executed = 2 then - :test_result := ut_utils.gc_success; - else - for i in 1 .. l_output_data.count loop - dbms_output.put_line(l_output_data(i)); - end loop; - dbms_output.put_line('Failed: not all packages were found in the outputs. Expected 2, got '||l_packages_executed); - end if; -end; -/ diff --git a/old_tests/ut/ut.version.sql b/old_tests/ut/ut.version.sql deleted file mode 100644 index 22d04056e..000000000 --- a/old_tests/ut/ut.version.sql +++ /dev/null @@ -1,11 +0,0 @@ -declare - l_expected varchar2(100) := '%.%.%.%'; -begin ---Assert - if ut.version() like l_expected then - :test_result := ut_utils.gc_success; - else - dbms_output.put_line('expected version like '''||l_expected ||''' got: '''||ut.version()||'''' ); - end if; -end; -/ diff --git a/old_tests/ut_expectation_processor/who_called_expectation.parseStackTrace.sql b/old_tests/ut_expectation_processor/who_called_expectation.parseStackTrace.sql deleted file mode 100644 index 9333a9b6a..000000000 --- a/old_tests/ut_expectation_processor/who_called_expectation.parseStackTrace.sql +++ /dev/null @@ -1,34 +0,0 @@ -declare - l_stack_trace varchar2(4000); - l_source_line varchar2(4000); -begin -l_stack_trace := q'[----- PL/SQL Call Stack ----- - object line object - handle number name -34f88e4420 124 package body SCH_TEST.UT_EXPECTATION_PROCESSOR -353dfeb2f8 26 SCH_TEST.UT_EXPECTATION_RESULT -cba249ce0 112 SCH_TEST.UT_EXPECTATION -3539881cf0 21 SCH_TEST.UT_EXPECTATION_NUMBER -351a608008 28 package body SCH_TEST.TPKG_PRIOR_YEAR_GENERATION -351a6862b8 6 anonymous block -351fe31010 1825 package body SYS.DBMS_SQL -20befbe4d8 129 SCH_TEST.UT_EXECUTABLE -20befbe4d8 65 SCH_TEST.UT_EXECUTABLE -34f8ab7cd8 80 SCH_TEST.UT_TEST -34f8ab98f0 48 SCH_TEST.UT_SUITE_ITEM -34f8ab9b10 74 SCH_TEST.UT_SUITE -34f8ab98f0 48 SCH_TEST.UT_SUITE_ITEM -cba24bfd0 75 SCH_TEST.UT_LOGICAL_SUITE -353dfecf30 59 SCH_TEST.UT_RUN -34f8ab98f0 48 SCH_TEST.UT_SUITE_ITEM -357f5421e8 77 package body SCH_TEST.UT_RUNNER -357f5421e8 111 package body SCH_TEST.UT_RUNNER -20be951ab0 292 package body SCH_TEST.UT -20be951ab0 320 package body SCH_TEST.UT -]'; - l_source_line := ut_expectation_processor.WHO_CALLED_EXPECTATION(l_stack_trace); - if l_source_line like 'at "SCH_TEST.TPKG_PRIOR_YEAR_GENERATION", line 28 %' then - :test_result := ut_utils.gc_success; - end if; -end; -/ diff --git a/old_tests/ut_expectation_processor/who_called_expectation.parseStackTraceWith0x.sql b/old_tests/ut_expectation_processor/who_called_expectation.parseStackTraceWith0x.sql deleted file mode 100644 index 1b9996a80..000000000 --- a/old_tests/ut_expectation_processor/who_called_expectation.parseStackTraceWith0x.sql +++ /dev/null @@ -1,28 +0,0 @@ -declare - l_stack_trace varchar2(4000); - l_source_line varchar2(4000); -begin -l_stack_trace := q'[----- PL/SQL Call Stack ----- - object line object - handle number name -0x80e701d8 26 UT3.UT_EXPECTATION_RESULT -0x85e10150 112 UT3.UT_EXPECTATION -0x8b54bad8 21 UT3.UT_EXPECTATION_NUMBER -0x85cfd238 20 package body UT3.UT_EXAMPLETEST -0x85def380 6 anonymous block -0x85e93750 1825 package body SYS.DBMS_SQL -0x80f4f608 129 UT3.UT_EXECUTABLE -0x80f4f608 65 UT3.UT_EXECUTABLE -0x8a116010 76 UT3.UT_TEST -0x8a3348a0 48 UT3.UT_SUITE_ITEM -0x887e9948 67 UT3.UT_LOGICAL_SUITE -0x8a26de20 59 UT3.UT_RUN -0x8a3348a0 48 UT3.UT_SUITE_ITEM -0x838d17c0 28 anonymous block -]'; - l_source_line := ut_expectation_processor.WHO_CALLED_EXPECTATION(l_stack_trace); - if l_source_line like 'at "UT3.UT_EXAMPLETEST", line 20 %' then - :test_result := ut_utils.gc_success; - end if; -end; -/ diff --git a/old_tests/ut_expectations/common/ut.expect.not_to_equal.scalar.common.sql b/old_tests/ut_expectations/common/ut.expect.not_to_equal.scalar.common.sql deleted file mode 100644 index 2921d9745..000000000 --- a/old_tests/ut_expectations/common/ut.expect.not_to_equal.scalar.common.sql +++ /dev/null @@ -1,17 +0,0 @@ ---Arrange -declare - l_actual &&1 := &&2; - l_expected &&1 := &&3; - l_result integer; -begin ---Act - ut.expect(l_actual).not_to_equal(l_expected); - l_result := ut_expectation_processor.get_status(); ---Assert - if nvl(:test_result, ut_utils.gc_success) = ut_utils.gc_success and l_result = &&4 then - :test_result := ut_utils.gc_success; - else - dbms_output.put_line('expected: '''||&&4||''', got: '''||l_result||'''' ); - end if; -end; -/ diff --git a/old_tests/ut_expectations/common/ut.expect.to_equal.different_scalars.common.sql b/old_tests/ut_expectations/common/ut.expect.to_equal.different_scalars.common.sql deleted file mode 100644 index da139a647..000000000 --- a/old_tests/ut_expectations/common/ut.expect.to_equal.different_scalars.common.sql +++ /dev/null @@ -1,20 +0,0 @@ ---Arrange -declare - l_actual &&1 := &&3; - l_expected &&2 := &&4; - l_result integer; - l_message varchar2(32767); -begin ---Act - ut.expect(l_actual).&&5.to_equal(l_expected); - l_result := ut_expectation_processor.get_status(); - l_message := ut_expectation_processor.get_failed_expectations()(1).get_result_clob; ---Assert - if nvl(:test_result, ut_utils.gc_success) = ut_utils.gc_success and l_result = ut_utils.gc_failure - and l_message like 'Actual (%) cannot be compared to Expected (%) using matcher%' then - :test_result := ut_utils.gc_success; - else - dbms_output.put_line('expected: '''||ut_utils.gc_failure||''', got: '''||l_result||'''' ); - end if; -end; -/ diff --git a/old_tests/ut_expectations/common/ut.expect.to_equal.scalar.common.sql b/old_tests/ut_expectations/common/ut.expect.to_equal.scalar.common.sql deleted file mode 100644 index 0632246f9..000000000 --- a/old_tests/ut_expectations/common/ut.expect.to_equal.scalar.common.sql +++ /dev/null @@ -1,17 +0,0 @@ ---Arrange -declare - l_actual &&1 := &&2; - l_expected &&1 := &&3; - l_result integer; -begin ---Act - ut.expect(l_actual).to_equal(l_expected); - l_result := ut_expectation_processor.get_status(); ---Assert - if nvl(:test_result, ut_utils.gc_success) = ut_utils.gc_success and l_result = &&4 then - :test_result := ut_utils.gc_success; - else - dbms_output.put_line('expected: '''||&&4||''', got: '''||l_result||'''' ); - end if; -end; -/ diff --git a/old_tests/ut_expectations/common/ut.expect.to_equal.scalar.null_value_text.common.sql b/old_tests/ut_expectations/common/ut.expect.to_equal.scalar.null_value_text.common.sql deleted file mode 100644 index bfac42e68..000000000 --- a/old_tests/ut_expectations/common/ut.expect.to_equal.scalar.null_value_text.common.sql +++ /dev/null @@ -1,17 +0,0 @@ ---Arrange -declare - l_actual &&1 := &&2; - l_expected &&1 := &&3; - l_result ut_expectation_result; -begin ---Act - ut.expect(l_actual).to_equal(l_expected); - l_result := ut_expectation_processor.get_failed_expectations()(1); ---Assert - if nvl(:test_result, ut_utils.gc_success) = ut_utils.gc_success and l_result.get_result_clob like '&&4' then - :test_result := ut_utils.gc_success; - else - dbms_output.put_line('expected text like ''&&4'', but got '''||l_result.get_result_clob||'''' ); - end if; -end; -/ diff --git a/old_tests/ut_expectations/common/ut.expect.to_equal.scalar.with_message.common.sql b/old_tests/ut_expectations/common/ut.expect.to_equal.scalar.with_message.common.sql deleted file mode 100644 index 9b172bc8c..000000000 --- a/old_tests/ut_expectations/common/ut.expect.to_equal.scalar.with_message.common.sql +++ /dev/null @@ -1,19 +0,0 @@ ---Arrange -declare - l_expected &&1 := &&2; - l_actual &&1 := &&3; - l_results ut_expectation_results; - l_test_description varchar2(30) := 'A test message'; -begin ---Act - ut.expect(l_actual, l_test_description ).to_equal( l_expected); - l_results := ut_expectation_processor.get_failed_expectations(); ---Assert - if nvl(:test_result, ut_utils.gc_success) = ut_utils.gc_success - and treat(l_results(1) as ut_expectation_result).description like '' || l_test_description || '' then - :test_result := ut_utils.gc_success; - else - dbms_output.put_line('expected: '''||treat(l_results(1) as ut_expectation_result).description||''' to match ''%' || l_test_description || '%''' ); - end if; -end; -/ diff --git a/old_tests/ut_expectations/common/ut.expect.to_equal.scalar.with_nulls_equal.common.sql b/old_tests/ut_expectations/common/ut.expect.to_equal.scalar.with_nulls_equal.common.sql deleted file mode 100644 index 352ceaf05..000000000 --- a/old_tests/ut_expectations/common/ut.expect.to_equal.scalar.with_nulls_equal.common.sql +++ /dev/null @@ -1,19 +0,0 @@ ---Arrange -declare - l_expected &&1 := &&2; - l_actual &&1 := &&3; - l_result integer; - l_expected_result integer := &&4; - l_nulls_are_equal boolean := &&5; -begin ---Act - ut.expect(l_actual).to_equal(l_expected, l_nulls_are_equal); - l_result := ut_expectation_processor.get_status(); ---Assert - if nvl(:test_result, ut_utils.gc_success) = ut_utils.gc_success and l_result = l_expected_result then - :test_result := ut_utils.gc_success; - else - dbms_output.put_line('expected: '''||&&4||''', got: '''||l_result||'''' ); - end if; -end; -/ diff --git a/old_tests/ut_expectations/ut.expect.not_to_equal.GivesFailureForEqualValues.sql b/old_tests/ut_expectations/ut.expect.not_to_equal.GivesFailureForEqualValues.sql deleted file mode 100644 index d32655480..000000000 --- a/old_tests/ut_expectations/ut.expect.not_to_equal.GivesFailureForEqualValues.sql +++ /dev/null @@ -1,15 +0,0 @@ -@@lib/RunTest.sql "ut_expectations/common/ut.expect.not_to_equal.scalar.common.sql 'blob' 'to_blob(''Abc'')' 'to_blob(''abc'')' 'ut_utils.gc_failure'" -@@lib/RunTest.sql "ut_expectations/common/ut.expect.not_to_equal.scalar.common.sql 'boolean' 'false' 'false' 'ut_utils.gc_failure'" -@@lib/RunTest.sql "ut_expectations/common/ut.expect.not_to_equal.scalar.common.sql 'clob' '''Abc''' '''Abc''' 'ut_utils.gc_failure'" -@@lib/RunTest.sql "ut_expectations/common/ut.expect.not_to_equal.scalar.common.sql 'date' 'sysdate' 'sysdate' 'ut_utils.gc_failure'" -@@lib/RunTest.sql "ut_expectations/common/ut.expect.not_to_equal.scalar.common.sql 'number' '12345' '12345' 'ut_utils.gc_failure'" -@@lib/RunTest.sql "ut_expectations/common/ut.expect.not_to_equal.scalar.common.sql 'timestamp(9)' 'to_Timestamp(''2016 123456789'',''yyyy ff'')' 'to_Timestamp(''2016 123456789'',''yyyy ff'')' 'ut_utils.gc_failure'" -@@lib/RunTest.sql "ut_expectations/common/ut.expect.not_to_equal.scalar.common.sql 'timestamp(9) with local time zone' 'to_Timestamp(''2016 123456789'',''yyyy ff'')' 'to_Timestamp(''2016 123456789'',''yyyy ff'')' 'ut_utils.gc_failure'" -@@lib/RunTest.sql "ut_expectations/common/ut.expect.not_to_equal.scalar.common.sql 'timestamp(9) with time zone' 'to_Timestamp(''2016 123456789'',''yyyy ff'')' 'to_Timestamp(''2016 123456789'',''yyyy ff'')' 'ut_utils.gc_failure'" -@@lib/RunTest.sql "ut_expectations/common/ut.expect.not_to_equal.scalar.common.sql 'varchar2(4000)' '''Abc''' '''Abc''' 'ut_utils.gc_failure'" -@@lib/RunTest.sql "ut_expectations/common/ut.expect.not_to_equal.scalar.common.sql 'interval day to second' '''2 01:00:00''' '''2 01:00:00''' 'ut_utils.gc_failure'" -@@lib/RunTest.sql "ut_expectations/common/ut.expect.not_to_equal.scalar.common.sql 'interval year to month' '''1-1''' '''1-1''' 'ut_utils.gc_failure'" - - - - diff --git a/old_tests/ut_expectations/ut.expect.not_to_equal.GivesSuccessForDifferentValues.sql b/old_tests/ut_expectations/ut.expect.not_to_equal.GivesSuccessForDifferentValues.sql deleted file mode 100644 index e30b2c5e5..000000000 --- a/old_tests/ut_expectations/ut.expect.not_to_equal.GivesSuccessForDifferentValues.sql +++ /dev/null @@ -1,11 +0,0 @@ -@@lib/RunTest.sql "ut_expectations/common/ut.expect.not_to_equal.scalar.common.sql 'blob' 'to_blob(''abc'')' 'to_blob(''abd'')' 'ut_utils.gc_success'" -@@lib/RunTest.sql "ut_expectations/common/ut.expect.not_to_equal.scalar.common.sql 'boolean' 'true' 'false' 'ut_utils.gc_success'" -@@lib/RunTest.sql "ut_expectations/common/ut.expect.not_to_equal.scalar.common.sql 'clob' '''Abc''' '''abc''' 'ut_utils.gc_success'" -@@lib/RunTest.sql "ut_expectations/common/ut.expect.not_to_equal.scalar.common.sql 'date' 'sysdate' 'sysdate-1' 'ut_utils.gc_success'" -@@lib/RunTest.sql "ut_expectations/common/ut.expect.not_to_equal.scalar.common.sql 'number' '0.1' '0.3' 'ut_utils.gc_success'" -@@lib/RunTest.sql "ut_expectations/common/ut.expect.not_to_equal.scalar.common.sql 'timestamp' 'systimestamp' 'systimestamp' 'ut_utils.gc_success'" -@@lib/RunTest.sql "ut_expectations/common/ut.expect.not_to_equal.scalar.common.sql 'timestamp with local time zone' 'systimestamp' 'systimestamp' 'ut_utils.gc_success'" -@@lib/RunTest.sql "ut_expectations/common/ut.expect.not_to_equal.scalar.common.sql 'timestamp with time zone' 'systimestamp' 'systimestamp' 'ut_utils.gc_success'" -@@lib/RunTest.sql "ut_expectations/common/ut.expect.not_to_equal.scalar.common.sql 'varchar2(4000)' '''Abc''' '''abc''' 'ut_utils.gc_success'" -@@lib/RunTest.sql "ut_expectations/common/ut.expect.not_to_equal.scalar.common.sql 'interval day to second' '''2 01:00:00''' '''2 01:00:01''' 'ut_utils.gc_success'" -@@lib/RunTest.sql "ut_expectations/common/ut.expect.not_to_equal.scalar.common.sql 'interval year to month' '''1-1''' '''1-2''' 'ut_utils.gc_success'" diff --git a/old_tests/ut_expectations/ut.expect.not_to_equal.anydata.GivesFailureWhenComparingTheSameData.sql b/old_tests/ut_expectations/ut.expect.not_to_equal.anydata.GivesFailureWhenComparingTheSameData.sql deleted file mode 100644 index 9af3ed06d..000000000 --- a/old_tests/ut_expectations/ut.expect.not_to_equal.anydata.GivesFailureWhenComparingTheSameData.sql +++ /dev/null @@ -1,17 +0,0 @@ ---Arrange -declare - l_expected department$ := department$('hr'); - l_actual department$ := department$('hr'); - l_result integer; -begin ---Act - ut.expect( anydata.convertObject(l_actual) ).not_to_equal( anydata.convertObject(l_expected) ); - l_result := ut_expectation_processor.get_status(); ---Assert - if l_result = ut_utils.gc_failure then - :test_result := ut_utils.gc_success; - else - dbms_output.put_line('expected: '''||ut_utils.gc_success||''', got: '''||l_result||'''' ); - end if; -end; -/ diff --git a/old_tests/ut_expectations/ut.expect.to_be_false.GivesFailureWhenExpessionIsNotBoolean.sql b/old_tests/ut_expectations/ut.expect.to_be_false.GivesFailureWhenExpessionIsNotBoolean.sql deleted file mode 100644 index 58c15bffb..000000000 --- a/old_tests/ut_expectations/ut.expect.to_be_false.GivesFailureWhenExpessionIsNotBoolean.sql +++ /dev/null @@ -1,21 +0,0 @@ -PROMPT Gives a failre when expression evaluates to a boolean true ---Arrange -declare - l_result integer; -begin ---Act - ut.expect( 1 ).to_( be_false() ); - ut.expect( 1 ).not_to( be_true() ); - l_result := ut_expectation_processor.get_status(); ---Assert - if nvl(:test_result, ut_utils.gc_success) = ut_utils.gc_success and l_result = ut_utils.gc_failure then - :test_result := ut_utils.gc_success; - else - dbms_output.put_line('expected: '''||ut_utils.gc_failure||''', got: '''||l_result||'''' ); - end if; -end; -/ - - - - diff --git a/old_tests/ut_expectations/ut.expect.to_be_false.GivesFailureWhenExpessionIsNull.sql b/old_tests/ut_expectations/ut.expect.to_be_false.GivesFailureWhenExpessionIsNull.sql deleted file mode 100644 index 4b3cbbab2..000000000 --- a/old_tests/ut_expectations/ut.expect.to_be_false.GivesFailureWhenExpessionIsNull.sql +++ /dev/null @@ -1,21 +0,0 @@ -PROMPT Gives a failre when expression evaluates to a boolean null ---Arrange -declare - l_result integer; -begin ---Act - ut.expect( 1 = null ).to_be_false(); - ut.expect( 1 = null ).not_to_be_true(); - l_result := ut_expectation_processor.get_status(); ---Assert - if nvl(:test_result, ut_utils.gc_success) = ut_utils.gc_success and l_result = ut_utils.gc_failure then - :test_result := ut_utils.gc_success; - else - dbms_output.put_line('expected: '''||ut_utils.gc_failure||''', got: '''||l_result||'''' ); - end if; -end; -/ - - - - diff --git a/old_tests/ut_expectations/ut.expect.to_be_false.GivesFailureWhenExpessionIsTrue.sql b/old_tests/ut_expectations/ut.expect.to_be_false.GivesFailureWhenExpessionIsTrue.sql deleted file mode 100644 index 6b2357c20..000000000 --- a/old_tests/ut_expectations/ut.expect.to_be_false.GivesFailureWhenExpessionIsTrue.sql +++ /dev/null @@ -1,21 +0,0 @@ -PROMPT Gives a failre when expression evaluates to a boolean true ---Arrange -declare - l_result integer; -begin ---Act - ut.expect( 1 = 1 ).to_be_false(); - ut.expect( 1 = 1 ).not_to_be_true(); - l_result := ut_expectation_processor.get_status(); ---Assert - if nvl(:test_result, ut_utils.gc_success) = ut_utils.gc_success and l_result = ut_utils.gc_failure then - :test_result := ut_utils.gc_success; - else - dbms_output.put_line('expected: '''||ut_utils.gc_failure||''', got: '''||l_result||'''' ); - end if; -end; -/ - - - - diff --git a/old_tests/ut_expectations/ut.expect.to_be_false.GivesSuccessWhenExpessionIsFalse.sql b/old_tests/ut_expectations/ut.expect.to_be_false.GivesSuccessWhenExpessionIsFalse.sql deleted file mode 100644 index cdee68133..000000000 --- a/old_tests/ut_expectations/ut.expect.to_be_false.GivesSuccessWhenExpessionIsFalse.sql +++ /dev/null @@ -1,21 +0,0 @@ -PROMPT Gives a success when expression evaluates to a boolean false ---Arrange -declare - l_result integer; -begin ---Act - ut.expect( 1 = 0 ).to_be_false(); - ut.expect( 1 = 0 ).not_to_be_true(); - l_result := ut_expectation_processor.get_status(); ---Assert - if nvl(:test_result, ut_utils.gc_success) = ut_utils.gc_success and l_result = ut_utils.gc_success then - :test_result := ut_utils.gc_success; - else - dbms_output.put_line('expected: '''||ut_utils.gc_success||''', got: '''||l_result||'''' ); - end if; -end; -/ - - - - diff --git a/old_tests/ut_expectations/ut.expect.to_be_like.FailsForUnsupportedDatatype.sql b/old_tests/ut_expectations/ut.expect.to_be_like.FailsForUnsupportedDatatype.sql deleted file mode 100644 index 68aa1cc3a..000000000 --- a/old_tests/ut_expectations/ut.expect.to_be_like.FailsForUnsupportedDatatype.sql +++ /dev/null @@ -1,17 +0,0 @@ -declare - l_actual number := 1234; - l_pattern varchar2(32767) := '1234'; - l_escape_char varchar2(32767) := ''; - l_result integer; -begin ---Act - ut.expect( l_actual ).to_( be_like(l_pattern, l_escape_char) ); - l_result := ut_expectation_processor.get_status(); ---Assert - if l_result = ut_utils.gc_failure then - :test_result := ut_utils.gc_success; - else - dbms_output.put_line('expected: '''||l_actual||''', to be like '''||l_pattern||''' escape'''||l_escape_char||'''' ); - end if; -end; -/ diff --git a/old_tests/ut_expectations/ut.expect.to_be_null.anydata.GivesSuccessWhenAnydataIsNull.sql b/old_tests/ut_expectations/ut.expect.to_be_null.anydata.GivesSuccessWhenAnydataIsNull.sql deleted file mode 100644 index a338ee2ad..000000000 --- a/old_tests/ut_expectations/ut.expect.to_be_null.anydata.GivesSuccessWhenAnydataIsNull.sql +++ /dev/null @@ -1,16 +0,0 @@ -PROMPT Gives a success when the Anydata argument is null ---Arrange -declare - l_result integer; -begin ---Act - ut.expect( cast(null as anydata) ).to_be_null(); - l_result := ut_expectation_processor.get_status(); ---Assert - if l_result = ut_utils.gc_success then - :test_result := ut_utils.gc_success; - else - dbms_output.put_line('expected: '''||ut_utils.gc_success||''', got: '''||l_result||'''' ); - end if; -end; -/ diff --git a/old_tests/ut_expectations/ut.expect.to_be_null.anydata.GivesSuccessWhenCollectionPassedIsNull.sql b/old_tests/ut_expectations/ut.expect.to_be_null.anydata.GivesSuccessWhenCollectionPassedIsNull.sql deleted file mode 100644 index 29ef147fa..000000000 --- a/old_tests/ut_expectations/ut.expect.to_be_null.anydata.GivesSuccessWhenCollectionPassedIsNull.sql +++ /dev/null @@ -1,16 +0,0 @@ ---Arrange -declare - l_expected ut_varchar2_list; - l_result integer; -begin ---Act - ut.expect( anydata.convertCollection(l_expected) ).to_be_null(); - l_result := ut_expectation_processor.get_status(); ---Assert - if l_result = ut_utils.gc_success then - :test_result := ut_utils.gc_success; - else - dbms_output.put_line('expected: '''||ut_utils.gc_success||''', got: '''||l_result||'''' ); - end if; -end; -/ diff --git a/old_tests/ut_expectations/ut.expect.to_be_null.anydata.GivesSuccessWhenObjectPassedIsNull.sql b/old_tests/ut_expectations/ut.expect.to_be_null.anydata.GivesSuccessWhenObjectPassedIsNull.sql deleted file mode 100644 index 970216166..000000000 --- a/old_tests/ut_expectations/ut.expect.to_be_null.anydata.GivesSuccessWhenObjectPassedIsNull.sql +++ /dev/null @@ -1,16 +0,0 @@ ---Arrange -declare - l_expected department$; - l_result integer; -begin ---Act - ut.expect( anydata.convertObject(l_expected) ).to_be_null(); - l_result := ut_expectation_processor.get_status(); ---Assert - if l_result = ut_utils.gc_success then - :test_result := ut_utils.gc_success; - else - dbms_output.put_line('expected: '''||ut_utils.gc_success||''', got: '''||l_result||'''' ); - end if; -end; -/ diff --git a/old_tests/ut_expectations/ut.expect.to_be_null.refcursor.GivesSuccessWhenCursorIsNull.sql b/old_tests/ut_expectations/ut.expect.to_be_null.refcursor.GivesSuccessWhenCursorIsNull.sql deleted file mode 100644 index e5952b871..000000000 --- a/old_tests/ut_expectations/ut.expect.to_be_null.refcursor.GivesSuccessWhenCursorIsNull.sql +++ /dev/null @@ -1,17 +0,0 @@ -PROMPT Gives a success when the Cursor is null ---Arrange -declare - l_cursor sys_refcursor; - l_result integer; -begin ---Act - ut.expect( l_cursor ).to_be_null(); - l_result := ut_expectation_processor.get_status(); ---Assert - if l_result = ut_utils.gc_success then - :test_result := ut_utils.gc_success; - else - dbms_output.put_line('expected: '''||ut_utils.gc_success||''', got: '''||l_result||'''' ); - end if; -end; -/ diff --git a/old_tests/ut_expectations/ut.expect.to_be_true.GivesFailureWhenExpessionIsFalse.sql b/old_tests/ut_expectations/ut.expect.to_be_true.GivesFailureWhenExpessionIsFalse.sql deleted file mode 100644 index 9b7459868..000000000 --- a/old_tests/ut_expectations/ut.expect.to_be_true.GivesFailureWhenExpessionIsFalse.sql +++ /dev/null @@ -1,21 +0,0 @@ -PROMPT Gives a failre when expression evaluates to a boolean false ---Arrange -declare - l_result integer; -begin ---Act - ut.expect( 1 = 0 ).to_be_true(); - ut.expect( 1 = 0 ).not_to_be_false(); - l_result := ut_expectation_processor.get_status(); ---Assert - if nvl(:test_result, ut_utils.gc_success) = ut_utils.gc_success and l_result = ut_utils.gc_failure then - :test_result := ut_utils.gc_success; - else - dbms_output.put_line('expected: '''||ut_utils.gc_failure||''', got: '''||l_result||'''' ); - end if; -end; -/ - - - - diff --git a/old_tests/ut_expectations/ut.expect.to_be_true.GivesFailureWhenExpessionIsNotBoolean.sql b/old_tests/ut_expectations/ut.expect.to_be_true.GivesFailureWhenExpessionIsNotBoolean.sql deleted file mode 100644 index d099e7316..000000000 --- a/old_tests/ut_expectations/ut.expect.to_be_true.GivesFailureWhenExpessionIsNotBoolean.sql +++ /dev/null @@ -1,21 +0,0 @@ -PROMPT Gives a failre when expression evaluates to a boolean false ---Arrange -declare - l_result integer; -begin ---Act - ut.expect( 1 ).to_( be_true() ); - ut.expect( 1 ).not_to( be_false() ); - l_result := ut_expectation_processor.get_status(); ---Assert - if nvl(:test_result, ut_utils.gc_success) = ut_utils.gc_success and l_result = ut_utils.gc_failure then - :test_result := ut_utils.gc_success; - else - dbms_output.put_line('expected: '''||ut_utils.gc_failure||''', got: '''||l_result||'''' ); - end if; -end; -/ - - - - diff --git a/old_tests/ut_expectations/ut.expect.to_be_true.GivesFailureWhenExpessionIsNull.sql b/old_tests/ut_expectations/ut.expect.to_be_true.GivesFailureWhenExpessionIsNull.sql deleted file mode 100644 index 4ea53dff5..000000000 --- a/old_tests/ut_expectations/ut.expect.to_be_true.GivesFailureWhenExpessionIsNull.sql +++ /dev/null @@ -1,21 +0,0 @@ -PROMPT Gives a failre when expression evaluates to a boolean null ---Arrange -declare - l_result integer; -begin ---Act - ut.expect( 1 = null ).to_be_true(); - ut.expect( 1 = null ).not_to_be_false(); - l_result := ut_expectation_processor.get_status(); ---Assert - if nvl(:test_result, ut_utils.gc_success) = ut_utils.gc_success and l_result = ut_utils.gc_failure then - :test_result := ut_utils.gc_success; - else - dbms_output.put_line('expected: '''||ut_utils.gc_failure||''', got: '''||l_result||'''' ); - end if; -end; -/ - - - - diff --git a/old_tests/ut_expectations/ut.expect.to_be_true.GivesSuccessWhenExpessionIsTrue.sql b/old_tests/ut_expectations/ut.expect.to_be_true.GivesSuccessWhenExpessionIsTrue.sql deleted file mode 100644 index b4dc25197..000000000 --- a/old_tests/ut_expectations/ut.expect.to_be_true.GivesSuccessWhenExpessionIsTrue.sql +++ /dev/null @@ -1,21 +0,0 @@ -PROMPT Gives a success when expression evaluates to a boolean true ---Arrange -declare - l_result integer; -begin ---Act - ut.expect( 1 = 1 ).to_be_true(); - ut.expect( 1 = 1 ).not_to_be_false(); - l_result := ut_expectation_processor.get_status(); ---Assert - if nvl(:test_result, ut_utils.gc_success) = ut_utils.gc_success and l_result = ut_utils.gc_success then - :test_result := ut_utils.gc_success; - else - dbms_output.put_line('expected: '''||ut_utils.gc_success||''', got: '''||l_result||'''' ); - end if; -end; -/ - - - - diff --git a/old_tests/ut_expectations/ut.expect.to_equal.cursor.UsesDefaultNLSSettingsForDatesFormatting.sql b/old_tests/ut_expectations/ut.expect.to_equal.cursor.UsesDefaultNLSSettingsForDatesFormatting.sql deleted file mode 100644 index 09e58bcf8..000000000 --- a/old_tests/ut_expectations/ut.expect.to_equal.cursor.UsesDefaultNLSSettingsForDatesFormatting.sql +++ /dev/null @@ -1,19 +0,0 @@ ---Arrange -declare - l_actual SYS_REFCURSOR; - l_expected SYS_REFCURSOR; - l_result integer; -begin ---Act - open l_actual for select sysdate as some_date from dual; - open l_expected for select to_char(sysdate) some_date from dual; - ut.expect(l_actual).to_equal(l_expected); - l_result := ut_expectation_processor.get_status(); ---Assert - if nvl(:test_result, ut_utils.gc_success) = ut_utils.gc_success and l_result = ut_utils.gc_success then - :test_result := ut_utils.gc_success; - else - dbms_output.put_line('expected: '''||ut_utils.gc_success||''', got: '''||l_result||'''' ); - end if; -end; -/ diff --git a/old_tests/ut_expectations/ut.expect.to_equal.cursor.worksOnLargeDatasets.sql b/old_tests/ut_expectations/ut.expect.to_equal.cursor.worksOnLargeDatasets.sql deleted file mode 100644 index f4ad730d3..000000000 --- a/old_tests/ut_expectations/ut.expect.to_equal.cursor.worksOnLargeDatasets.sql +++ /dev/null @@ -1,21 +0,0 @@ ---Arrange -declare - l_actual sys_refcursor; - l_expected sys_refcursor; - l_result integer; -begin ---Act - open l_actual for select object_name from all_objects where rownum <=1100; - open l_expected for select object_name from all_objects where rownum <=1100; - ut.expect(l_actual).to_equal(l_expected); - ---Assert - l_result := ut_expectation_processor.get_status(); ---Assert - if l_result = ut_utils.gc_success then - :test_result := ut_utils.gc_success; - else - dbms_output.put_line('expected 1 data and got: '||l_result ); - end if; -end; -/ diff --git a/old_tests/ut_expectations/ut.expect.to_match.FailsForUnsupportedDatatype.sql b/old_tests/ut_expectations/ut.expect.to_match.FailsForUnsupportedDatatype.sql deleted file mode 100644 index 0d8a93ac2..000000000 --- a/old_tests/ut_expectations/ut.expect.to_match.FailsForUnsupportedDatatype.sql +++ /dev/null @@ -1,17 +0,0 @@ -declare - l_actual number := 1234; - l_pattern varchar2(32767) := '^1234'; - l_modifiers varchar2(32767) := 'i'; - l_result integer; -begin ---Act - ut.expect( l_actual ).to_( match(l_pattern, l_modifiers) ); - l_result := ut_expectation_processor.get_status(); ---Assert - if l_result = ut_utils.gc_failure then - :test_result := ut_utils.gc_success; - else - dbms_output.put_line('expected: '''||l_actual||''', to match: '''||l_pattern||''' using modifiers:'''||l_modifiers||'''' ); - end if; -end; -/ diff --git a/old_tests/ut_expectations/ut_data_value_object.compare.Gives0WhenComparingIdenticalObjects.sql b/old_tests/ut_expectations/ut_data_value_object.compare.Gives0WhenComparingIdenticalObjects.sql deleted file mode 100644 index d6b70de79..000000000 --- a/old_tests/ut_expectations/ut_data_value_object.compare.Gives0WhenComparingIdenticalObjects.sql +++ /dev/null @@ -1,22 +0,0 @@ ---Arrange -declare - l_expected department$ := department$('HR'); - l_actual department$ := department$('HR'); - l_result integer; -begin ---Act - l_result := - ut_data_value_object( - anydata.convertObject(l_actual) - ).compare_implementation( - ut_data_value_object( - anydata.convertObject(l_expected)) - ); ---Assert - if l_result = 0 then - :test_result := ut_utils.gc_success; - else - dbms_output.put_line( 'Expected comparison to give 0, got '||l_result ); - end if; -end; -/ diff --git a/old_tests/ut_matchers/be_between.sql b/old_tests/ut_matchers/be_between.sql deleted file mode 100644 index 0ec54cf27..000000000 --- a/old_tests/ut_matchers/be_between.sql +++ /dev/null @@ -1,72 +0,0 @@ ---failure when value out of range -@@lib/RunTest.sql "ut_matchers/common/ut.expect.common.be_between.sql 'date' 'sysdate' 'sysdate-2' 'sysdate-1' 'ut_utils.gc_failure' ''" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.common.be_between.sql 'number' '2.0' '1.99' '1.999' 'ut_utils.gc_failure' ''" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.common.be_between.sql 'varchar2(1)' '''c''' '''a''' '''b''' 'ut_utils.gc_failure' ''" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.common.be_between.sql 'timestamp' 'systimestamp+1' 'systimestamp-1' 'systimestamp' 'ut_utils.gc_failure' ''" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.common.be_between.sql 'timestamp with local time zone' 'systimestamp+1' 'systimestamp-1' 'systimestamp' 'ut_utils.gc_failure' ''" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.common.be_between.sql 'timestamp with time zone' 'systimestamp+1' 'systimestamp-1' 'systimestamp' 'ut_utils.gc_failure' ''" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.common.be_between.sql 'interval year to month' '''2-2''' '''2-0''' '''2-1''' 'ut_utils.gc_failure' ''" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.common.be_between.sql 'interval day to second' '''2 01:00:00''' '''2 00:59:58''' '''2 00:59:59''' 'ut_utils.gc_failure' ''" ---success when value in range -@@lib/RunTest.sql "ut_matchers/common/ut.expect.common.be_between.sql 'date' 'sysdate' 'sysdate-1' 'sysdate+1' 'ut_utils.gc_success' ''" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.common.be_between.sql 'number' '2.0' '1.99' '2.01' 'ut_utils.gc_success' ''" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.common.be_between.sql 'varchar2(1)' '''b''' '''a''' '''c''' 'ut_utils.gc_success' ''" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.common.be_between.sql 'timestamp' 'systimestamp' 'systimestamp-1' 'systimestamp+1' 'ut_utils.gc_success' ''" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.common.be_between.sql 'timestamp with local time zone' 'systimestamp' 'systimestamp-1' 'systimestamp+1' 'ut_utils.gc_success' ''" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.common.be_between.sql 'timestamp with time zone' 'systimestamp' 'systimestamp-1' 'systimestamp+1' 'ut_utils.gc_success' ''" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.common.be_between.sql 'interval year to month' '''2-1''' '''2-0''' '''2-2''' 'ut_utils.gc_success' ''" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.common.be_between.sql 'interval day to second' '''2 01:00:00''' '''2 00:59:58''' '''2 01:00:01''' 'ut_utils.gc_success' ''" ---success when value not in range -@@lib/RunTest.sql "ut_matchers/common/ut.expect.common.be_between.sql 'date' 'sysdate' 'sysdate-2' 'sysdate-1' 'ut_utils.gc_success' 'not_'" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.common.be_between.sql 'number' '2.0' '1.99' '1.999' 'ut_utils.gc_success' 'not_'" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.common.be_between.sql 'varchar2(1)' '''c''' '''a''' '''b''' 'ut_utils.gc_success' 'not_'" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.common.be_between.sql 'timestamp' 'systimestamp+1' 'systimestamp-1' 'systimestamp' 'ut_utils.gc_success' 'not_'" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.common.be_between.sql 'timestamp with local time zone' 'systimestamp+1' 'systimestamp-1' 'systimestamp' 'ut_utils.gc_success' 'not_'" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.common.be_between.sql 'timestamp with time zone' 'systimestamp+1' 'systimestamp-1' 'systimestamp' 'ut_utils.gc_success' 'not_'" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.common.be_between.sql 'interval year to month' '''2-2''' '''2-0''' '''2-1''' 'ut_utils.gc_success' 'not_'" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.common.be_between.sql 'interval day to second' '''2 01:00:00''' '''2 00:59:58''' '''2 00:59:59''' 'ut_utils.gc_success' 'not_'" ---failure when value not out of range -@@lib/RunTest.sql "ut_matchers/common/ut.expect.common.be_between.sql 'date' 'sysdate' 'sysdate-1' 'sysdate+1' 'ut_utils.gc_failure' 'not_'" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.common.be_between.sql 'number' '2.0' '1.99' '2.01' 'ut_utils.gc_failure' 'not_'" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.common.be_between.sql 'varchar2(1)' '''b''' '''a''' '''c''' 'ut_utils.gc_failure' 'not_'" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.common.be_between.sql 'timestamp' 'systimestamp' 'systimestamp-1' 'systimestamp+1' 'ut_utils.gc_failure' 'not_'" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.common.be_between.sql 'timestamp with local time zone' 'systimestamp' 'systimestamp-1' 'systimestamp+1' 'ut_utils.gc_failure' 'not_'" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.common.be_between.sql 'timestamp with time zone' 'systimestamp' 'systimestamp-1' 'systimestamp+1' 'ut_utils.gc_failure' 'not_'" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.common.be_between.sql 'interval year to month' '''2-1''' '''2-0''' '''2-2''' 'ut_utils.gc_failure' 'not_'" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.common.be_between.sql 'interval day to second' '''2 01:00:00''' '''2 00:59:58''' '''2 01:00:01''' 'ut_utils.gc_failure' 'not_'" - ---failure when value is null -@@lib/RunTest.sql "ut_matchers/common/ut.expect.common.be_between.sql 'date' 'null' 'sysdate-1' 'sysdate+1' 'ut_utils.gc_failure' ''" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.common.be_between.sql 'number' 'null' '1.99' '2.01' 'ut_utils.gc_failure' ''" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.common.be_between.sql 'varchar2(1)' 'null' '''a''' '''c''' 'ut_utils.gc_failure' ''" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.common.be_between.sql 'timestamp' 'null' 'systimestamp-1' 'systimestamp+1' 'ut_utils.gc_failure' ''" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.common.be_between.sql 'timestamp with local time zone' 'null' 'systimestamp-1' 'systimestamp+1' 'ut_utils.gc_failure' ''" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.common.be_between.sql 'timestamp with time zone' 'null' 'systimestamp-1' 'systimestamp+1' 'ut_utils.gc_failure' ''" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.common.be_between.sql 'interval year to month' 'null' '''2-0''' '''2-2''' 'ut_utils.gc_failure' ''" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.common.be_between.sql 'interval day to second' 'null' '''2 00:59:58''' '''2 01:00:01''' 'ut_utils.gc_failure' ''" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.common.be_between.sql 'date' 'null' 'sysdate-2' 'sysdate-1' 'ut_utils.gc_failure' 'not_'" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.common.be_between.sql 'number' 'null' '1.99' '1.999' 'ut_utils.gc_failure' 'not_'" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.common.be_between.sql 'varchar2(1)' 'null' '''a''' '''b''' 'ut_utils.gc_failure' 'not_'" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.common.be_between.sql 'timestamp' 'null' 'systimestamp-1' 'systimestamp' 'ut_utils.gc_failure' 'not_'" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.common.be_between.sql 'timestamp with local time zone' 'null' 'systimestamp-1' 'systimestamp' 'ut_utils.gc_failure' 'not_'" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.common.be_between.sql 'timestamp with time zone' 'null' 'systimestamp-1' 'systimestamp' 'ut_utils.gc_failure' 'not_'" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.common.be_between.sql 'interval year to month' 'null' '''2-0''' '''2-1''' 'ut_utils.gc_failure' 'not_'" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.common.be_between.sql 'interval day to second' 'null' '''2 00:59:58''' '''2 00:59:59''' 'ut_utils.gc_failure' 'not_'" - ---failure when lower bound is null -@@lib/RunTest.sql "ut_matchers/common/ut.expect.common.be_between.sql 'date' 'sysdate' 'null' 'sysdate+1' 'ut_utils.gc_failure' ''" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.common.be_between.sql 'number' '2.0' 'null' '2.01' 'ut_utils.gc_failure' ''" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.common.be_between.sql 'varchar2(1)' '''b''' 'null' '''c''' 'ut_utils.gc_failure' ''" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.common.be_between.sql 'timestamp' 'systimestamp' 'null' 'systimestamp+1' 'ut_utils.gc_failure' ''" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.common.be_between.sql 'timestamp with local time zone' 'systimestamp' 'null' 'systimestamp+1' 'ut_utils.gc_failure' ''" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.common.be_between.sql 'timestamp with time zone' 'systimestamp' 'null' 'systimestamp+1' 'ut_utils.gc_failure' ''" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.common.be_between.sql 'interval year to month' '''2-1''' 'null' '''2-2''' 'ut_utils.gc_failure' ''" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.common.be_between.sql 'interval day to second' '''2 01:00:00''' 'null' '''2 01:00:01''' 'ut_utils.gc_failure' ''" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.common.be_between.sql 'date' 'sysdate' 'null' 'sysdate-1' 'ut_utils.gc_failure' 'not_'" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.common.be_between.sql 'number' '2.0' 'null' '1.999' 'ut_utils.gc_failure' 'not_'" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.common.be_between.sql 'varchar2(1)' '''b''' 'null' '''b''' 'ut_utils.gc_failure' 'not_'" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.common.be_between.sql 'timestamp' 'systimestamp+1' 'null' 'systimestamp' 'ut_utils.gc_failure' 'not_'" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.common.be_between.sql 'timestamp with local time zone' 'systimestamp+1' 'null' 'systimestamp' 'ut_utils.gc_failure' 'not_'" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.common.be_between.sql 'timestamp with time zone' 'systimestamp+1' 'null' 'systimestamp' 'ut_utils.gc_failure' 'not_'" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.common.be_between.sql 'interval year to month' '''2-2''' 'null' '''2-1''' 'ut_utils.gc_failure' 'not_'" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.common.be_between.sql 'interval day to second' '''2 01:00:00''' 'null' '''2 00:59:59''' 'ut_utils.gc_failure' 'not_'" diff --git a/old_tests/ut_matchers/be_like.sql b/old_tests/ut_matchers/be_like.sql deleted file mode 100644 index 186e3e24a..000000000 --- a/old_tests/ut_matchers/be_like.sql +++ /dev/null @@ -1,19 +0,0 @@ -@@lib/RunTest.sql "ut_matchers/common/ut.expect.to_be_like.common.sql 'varchar2(100)' '''Stephen_King''' 'Ste__en%' '' 'ut_utils.gc_success' ''" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.to_be_like.common.sql 'varchar2(100)' '''Stephen_King''' 'Ste__en\_K%' '\' 'ut_utils.gc_success' ''" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.to_be_like.common.sql 'clob' 'rpad(''a'',32767,''a'')||''Stephen_King''' 'a%Ste__en%' '' 'ut_utils.gc_success' ''" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.to_be_like.common.sql 'clob' 'rpad(''a'',32767,''a'')||''Stephen_King''' 'a%Ste__en\_K%' '\' 'ut_utils.gc_success' ''" - -@@lib/RunTest.sql "ut_matchers/common/ut.expect.to_be_like.common.sql 'varchar2(100)' '''Stephen_King''' 'Ste_en%' '' 'ut_utils.gc_failure' ''" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.to_be_like.common.sql 'varchar2(100)' '''Stephen_King''' 'Stephe\__%' '\' 'ut_utils.gc_failure' ''" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.to_be_like.common.sql 'clob' 'rpad(''a'',32767,''a'')||''Stephen_King''' 'a%Ste_en%' '' 'ut_utils.gc_failure' ''" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.to_be_like.common.sql 'clob' 'rpad(''a'',32767,''a'')||''Stephen_King''' 'a%Stephe\__%' '\' 'ut_utils.gc_failure' ''" - -@@lib/RunTest.sql "ut_matchers/common/ut.expect.to_be_like.common.sql 'varchar2(100)' '''Stephen_King''' 'Ste__en%' '' 'ut_utils.gc_failure' 'not_'" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.to_be_like.common.sql 'varchar2(100)' '''Stephen_King''' 'Ste__en\_K%' '\' 'ut_utils.gc_failure' 'not_'" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.to_be_like.common.sql 'clob' 'rpad(''a'',32767,''a'')||''Stephen_King''' 'a%Ste__en%' '' 'ut_utils.gc_failure' 'not_'" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.to_be_like.common.sql 'clob' 'rpad(''a'',32767,''a'')||''Stephen_King''' 'a%Ste__en\_K%' '\' 'ut_utils.gc_failure' 'not_'" - -@@lib/RunTest.sql "ut_matchers/common/ut.expect.to_be_like.common.sql 'varchar2(100)' '''Stephen_King''' 'Ste_en%' '' 'ut_utils.gc_success' 'not_'" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.to_be_like.common.sql 'varchar2(100)' '''Stephen_King''' 'Stephe\__%' '\' 'ut_utils.gc_success' 'not_'" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.to_be_like.common.sql 'clob' 'rpad(''a'',32767,''a'')||''Stephen_King''' 'a%Ste_en%' '' 'ut_utils.gc_success' 'not_'" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.to_be_like.common.sql 'clob' 'rpad(''a'',32767,''a'')||''Stephen_King''' 'a%Stephe\__%' '\' 'ut_utils.gc_success' 'not_'" diff --git a/old_tests/ut_matchers/common/ut.expect.common.be_between.sql b/old_tests/ut_matchers/common/ut.expect.common.be_between.sql deleted file mode 100644 index 9a2b33ab4..000000000 --- a/old_tests/ut_matchers/common/ut.expect.common.be_between.sql +++ /dev/null @@ -1,17 +0,0 @@ ---Arrange -declare - l_value1 &&1 := &&2; - l_value_lower &&1 := &&3; - l_value_upper &&1 := &&4; -begin ---Act - ut.expect(l_value1).&&6.to_be_between(l_value_lower,l_value_upper); ---Assert - if ut_expectation_processor.get_status = &&5 then - :test_result := ut_utils.gc_success; - else - :test_result := ut_utils.gc_failure; - dbms_output.put_line('expected: '''||&&5||''', got: '''||ut_expectation_processor.get_status||'''' ); - end if; -end; -/ diff --git a/old_tests/ut_matchers/common/ut.expect.to_be_like.common.sql b/old_tests/ut_matchers/common/ut.expect.to_be_like.common.sql deleted file mode 100644 index d76e9a530..000000000 --- a/old_tests/ut_matchers/common/ut.expect.to_be_like.common.sql +++ /dev/null @@ -1,17 +0,0 @@ -declare - l_actual &1 := &2; - l_pattern varchar2(32767) := '&3'; - l_escape_char varchar2(32767) := '&4'; - l_result integer; -begin ---Act - ut.expect( l_actual ).&&6.to_be_like(l_pattern, l_escape_char); - l_result := ut_expectation_processor.get_status(); ---Assert - if l_result = &5 then - :test_result := ut_utils.gc_success; - else - dbms_output.put_line('expected: '''||l_actual||''', to be like '''||l_pattern||''' escape'''||l_escape_char||'''' ); - end if; -end; -/ diff --git a/old_tests/ut_matchers/common/ut.expect.to_match.common.sql b/old_tests/ut_matchers/common/ut.expect.to_match.common.sql deleted file mode 100644 index 441d0205f..000000000 --- a/old_tests/ut_matchers/common/ut.expect.to_match.common.sql +++ /dev/null @@ -1,17 +0,0 @@ -declare - l_actual &1 := &2; - l_pattern varchar2(32767) := '&3'; - l_modifiers varchar2(32767) := '&4'; - l_result integer; -begin ---Act - ut.expect( l_actual ).&&6.to_match(l_pattern, l_modifiers); - l_result := ut_expectation_processor.get_status(); ---Assert - if l_result = &5 then - :test_result := ut_utils.gc_success; - else - dbms_output.put_line('expected: '''||l_actual||''', to match: '''||l_pattern||''' using modifiers:'''||l_modifiers||'''' ); - end if; -end; -/ diff --git a/old_tests/ut_matchers/match.sql b/old_tests/ut_matchers/match.sql deleted file mode 100644 index 29028762e..000000000 --- a/old_tests/ut_matchers/match.sql +++ /dev/null @@ -1,19 +0,0 @@ -@@lib/RunTest.sql "ut_matchers/common/ut.expect.to_match.common.sql 'varchar2(100)' '''Stephen''' '^Ste(v|ph)en$' '' 'ut_utils.gc_success' ''" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.to_match.common.sql 'varchar2(100)' '''sTEPHEN''' '^Ste(v|ph)en$' 'i' 'ut_utils.gc_success' ''" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.to_match.common.sql 'clob' 'rpad('' '',32767)||''Stephen''' 'Ste(v|ph)en$' '' 'ut_utils.gc_success' ''" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.to_match.common.sql 'clob' 'rpad('' '',32767)||''sTEPHEN''' 'Ste(v|ph)en$' 'i' 'ut_utils.gc_success' ''" - -@@lib/RunTest.sql "ut_matchers/common/ut.expect.to_match.common.sql 'varchar2(100)' '''Stephen''' '^Steven$' '' 'ut_utils.gc_failure' ''" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.to_match.common.sql 'varchar2(100)' '''sTEPHEN''' '^Steven$' 'i' 'ut_utils.gc_failure' ''" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.to_match.common.sql 'clob' 'to_clob(rpad('' '',32767)||''Stephen'')' '^Stephen' '' 'ut_utils.gc_failure' ''" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.to_match.common.sql 'clob' 'to_clob(rpad('' '',32767)||''sTEPHEN'')' '^Stephen' 'i' 'ut_utils.gc_failure' ''" - -@@lib/RunTest.sql "ut_matchers/common/ut.expect.to_match.common.sql 'varchar2(100)' '''Stephen''' '^Ste(v|ph)en$' '' 'ut_utils.gc_failure' 'not_'" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.to_match.common.sql 'varchar2(100)' '''sTEPHEN''' '^Ste(v|ph)en$' 'i' 'ut_utils.gc_failure' 'not_'" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.to_match.common.sql 'clob' 'rpad('' '',32767)||''Stephen''' 'Ste(v|ph)en$' '' 'ut_utils.gc_failure' 'not_'" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.to_match.common.sql 'clob' 'rpad('' '',32767)||''sTEPHEN''' 'Ste(v|ph)en$' 'i' 'ut_utils.gc_failure' 'not_'" - -@@lib/RunTest.sql "ut_matchers/common/ut.expect.to_match.common.sql 'varchar2(100)' '''Stephen''' '^Steven$' '' 'ut_utils.gc_success' 'not_'" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.to_match.common.sql 'varchar2(100)' '''sTEPHEN''' '^Steven$' 'i' 'ut_utils.gc_success' 'not_'" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.to_match.common.sql 'clob' 'to_clob(rpad('' '',32767)||''Stephen'')' '^Stephen' '' 'ut_utils.gc_success' 'not_'" -@@lib/RunTest.sql "ut_matchers/common/ut.expect.to_match.common.sql 'clob' 'to_clob(rpad('' '',32767)||''sTEPHEN'')' '^Stephen' 'i' 'ut_utils.gc_success' 'not_'" diff --git a/old_tests/ut_matchers/timestamp_between.sql b/old_tests/ut_matchers/timestamp_between.sql deleted file mode 100644 index 622b8092d..000000000 --- a/old_tests/ut_matchers/timestamp_between.sql +++ /dev/null @@ -1,17 +0,0 @@ ---Arrange -declare - l_value timestamp := to_timestamp('1997-01-31 09:26:50.13','YYYY-MM-DD HH24.MI.SS.FF'); - l_value_lower timestamp := to_timestamp('1997-01-31 09:26:50.11','YYYY-MM-DD HH24.MI.SS.FF'); - l_value_upper timestamp := to_timestamp('1997-01-31 09:26:50.14','YYYY-MM-DD HH24.MI.SS.FF'); -begin - --Act - ut.expect(l_value).to_be_between(l_value_lower,l_value_upper); - --Assert - if ut_expectation_processor.get_status = ut_utils.gc_success then - :test_result := ut_utils.gc_success; - else - dbms_output.put_line('expected: '''||ut_utils.gc_success||''', got: '''||ut_expectation_processor.get_status||'''' ); - end if; -end; -/ - diff --git a/old_tests/ut_matchers/timestamp_ltz_between.sql b/old_tests/ut_matchers/timestamp_ltz_between.sql deleted file mode 100644 index e4ab6b566..000000000 --- a/old_tests/ut_matchers/timestamp_ltz_between.sql +++ /dev/null @@ -1,16 +0,0 @@ ---Arrange -declare - l_value timestamp with local time zone := to_timestamp_tz('1997-01-31 09:26:50.12 +02:00','YYYY-MM-DD HH24.MI.SS.FF TZR'); - l_value_lower timestamp with local time zone := to_timestamp_tz('1997-01-31 09:26:50.12 +03:00','YYYY-MM-DD HH24.MI.SS.FF TZR'); - l_value_upper timestamp with local time zone := to_timestamp_tz('1997-01-31 09:26:50.12 +01:00','YYYY-MM-DD HH24.MI.SS.FF TZR'); -begin - --Act - ut.expect(l_value).to_be_between(l_value_lower,l_value_upper); - --Assert - if ut_expectation_processor.get_status = ut_utils.gc_success then - :test_result := ut_utils.gc_success; - else - dbms_output.put_line('expected: '''||ut_utils.gc_success||''', got: '''||ut_expectation_processor.get_status||'''' ); - end if; -end; -/ diff --git a/old_tests/ut_matchers/timestamp_ltz_not_between.sql b/old_tests/ut_matchers/timestamp_ltz_not_between.sql deleted file mode 100644 index 6d7f71a62..000000000 --- a/old_tests/ut_matchers/timestamp_ltz_not_between.sql +++ /dev/null @@ -1,17 +0,0 @@ ---Arrange -declare - l_value_tlz timestamp with local time zone := to_timestamp_tz('1997-01-31 09:26:50.12 +01:00','YYYY-MM-DD HH24.MI.SS.FF TZR'); - l_value_lower_tlz timestamp with local time zone := to_timestamp_tz('1997-01-31 09:26:50.12 +02:00','YYYY-MM-DD HH24.MI.SS.FF TZR'); - l_value_upper_tlz timestamp with local time zone := to_timestamp_tz('1997-01-31 09:26:50.12 +03:00','YYYY-MM-DD HH24.MI.SS.FF TZR'); -begin - --Act - ut.expect(l_value_tlz).to_be_between(l_value_lower_tlz,l_value_upper_tlz); - --Assert - if ut_expectation_processor.get_status = ut_utils.gc_failure then - :test_result := ut_utils.gc_success; - else - dbms_output.put_line('expected: '''||ut_utils.gc_failure||''', got: '''||ut_expectation_processor.get_status||'''' ); - end if; -end; -/ - diff --git a/old_tests/ut_matchers/timestamp_not_between.sql b/old_tests/ut_matchers/timestamp_not_between.sql deleted file mode 100644 index 7365e63ce..000000000 --- a/old_tests/ut_matchers/timestamp_not_between.sql +++ /dev/null @@ -1,17 +0,0 @@ ---Arrange -declare - l_value timestamp := to_timestamp('1997-01-31 09:26:50.13','YYYY-MM-DD HH24.MI.SS.FF'); - l_value_lower timestamp := to_timestamp('1997-01-31 09:26:50.11','YYYY-MM-DD HH24.MI.SS.FF'); - l_value_upper timestamp := to_timestamp('1997-01-31 09:26:50.12','YYYY-MM-DD HH24.MI.SS.FF'); -begin - --Act - ut.expect(l_value).to_be_between(l_value_lower,l_value_upper); - --Assert - if ut_expectation_processor.get_status = ut_utils.gc_failure then - :test_result := ut_utils.gc_success; - else - dbms_output.put_line('expected: '''||ut_utils.gc_failure||''', got: '''||ut_expectation_processor.get_status||'''' ); - end if; -end; -/ - diff --git a/old_tests/ut_matchers/timestamp_tz_between.sql b/old_tests/ut_matchers/timestamp_tz_between.sql deleted file mode 100644 index 0c178dace..000000000 --- a/old_tests/ut_matchers/timestamp_tz_between.sql +++ /dev/null @@ -1,17 +0,0 @@ ---Arrange -declare - l_value timestamp with time zone := to_timestamp_tz('1997-01-31 09:26:50.12 +02:00','YYYY-MM-DD HH24.MI.SS.FF TZR'); - l_value_lower timestamp with time zone := to_timestamp_tz('1997-01-31 09:26:50.12 +03:00','YYYY-MM-DD HH24.MI.SS.FF TZR'); - l_value_upper timestamp with time zone := to_timestamp_tz('1997-01-31 09:26:50.12 +01:00','YYYY-MM-DD HH24.MI.SS.FF TZR'); -begin - --Act - ut.expect(l_value).to_be_between(l_value_lower,l_value_upper); - --Assert - if ut_expectation_processor.get_status = ut_utils.gc_success then - :test_result := ut_utils.gc_success; - else - dbms_output.put_line('expected: '''||ut_utils.gc_success||''', got: '''||ut_expectation_processor.get_status||'''' ); - end if; -end; -/ - diff --git a/old_tests/ut_matchers/timestamp_tz_not_between.sql b/old_tests/ut_matchers/timestamp_tz_not_between.sql deleted file mode 100644 index 8ac3fac6d..000000000 --- a/old_tests/ut_matchers/timestamp_tz_not_between.sql +++ /dev/null @@ -1,18 +0,0 @@ ---Arrange -declare - l_value_tz timestamp with time zone := to_timestamp_tz('1997-01-31 09:26:50.12 +01:00','YYYY-MM-DD HH24.MI.SS.FF TZR'); - l_value_lower_tz timestamp with time zone := to_timestamp_tz('1997-01-31 09:26:50.12 +02:00','YYYY-MM-DD HH24.MI.SS.FF TZR'); - l_value_upper_tz timestamp with time zone := to_timestamp_tz('1997-01-31 09:26:50.12 +03:00','YYYY-MM-DD HH24.MI.SS.FF TZR'); -begin - --Act - ut.expect(l_value_tz).to_be_between(l_value_lower_tz,l_value_upper_tz); - --Assert - if ut_expectation_processor.get_status = ut_utils.gc_failure then - :test_result := ut_utils.gc_success; - else - :test_result := ut_utils.gc_failure; - dbms_output.put_line('expected: '''||ut_utils.gc_failure||''', got: '''||ut_expectation_processor.get_status||'''' ); - end if; -end; -/ - diff --git a/old_tests/ut_output_buffer/get_lines.RecievesALineFromBufferTableAndDeletes.sql b/old_tests/ut_output_buffer/get_lines.RecievesALineFromBufferTableAndDeletes.sql deleted file mode 100644 index 81aac7d7d..000000000 --- a/old_tests/ut_output_buffer/get_lines.RecievesALineFromBufferTableAndDeletes.sql +++ /dev/null @@ -1,33 +0,0 @@ ---Arrange -declare - l_result varchar2(4000); - l_remaining integer; - l_expected varchar2(4000); - l_output ut_output_buffer_base := ut_output_table_buffer(); -begin - --Act - l_expected := lpad('a text',4000,',a text'); - l_output.send_line(l_expected); - - select * into l_result from table(l_output.get_lines(a_timeout_sec => 0)); - select count(1) into l_remaining from ut_output_buffer_tmp where output_id = l_output.output_id; - - --Assert - ut.expect(l_result).to_equal(l_expected); - ut.expect(l_remaining).to_equal(0); - - if ut_expectation_processor.get_status = ut_utils.gc_success then - :test_result := ut_utils.gc_success; - else - dbms_output.put_line(ut_expectation_processor.get_failed_expectations()(1).get_result_clob); - end if; - - delete from ut_output_buffer_tmp where output_id = l_output.output_id; - commit; -exception - when others then - delete from ut_output_buffer_tmp where output_id = l_output.output_id; - commit; - raise; -end; -/ diff --git a/old_tests/ut_output_buffer/get_lines.WaitsForMoreDataToAppearForSpecifiedTime.sql b/old_tests/ut_output_buffer/get_lines.WaitsForMoreDataToAppearForSpecifiedTime.sql deleted file mode 100644 index 24284f38b..000000000 --- a/old_tests/ut_output_buffer/get_lines.WaitsForMoreDataToAppearForSpecifiedTime.sql +++ /dev/null @@ -1,24 +0,0 @@ ---Arrange -declare - l_result integer; - l_dummy integer; - l_output ut_output_buffer_base := ut_output_table_buffer(); - l_start_time timestamp := localtimestamp; - l_wait_seconds integer := 1; -begin - --Act - l_output.send_line(lpad('a text',4000,',a text')); - - select count(*) into l_dummy from table( l_output.get_lines( a_initial_timeout => 0, a_timeout_sec => l_wait_seconds )); - l_result := round(extract(second from (localtimestamp - l_start_time))); - - --Assert - ut.expect(l_result).to_equal(l_wait_seconds); - - if ut_expectation_processor.get_status = ut_utils.gc_success then - :test_result := ut_utils.gc_success; - else - dbms_output.put_line(ut_expectation_processor.get_failed_expectations()(1).get_result_clob); - end if; -end; -/ diff --git a/old_tests/ut_output_buffer/get_lines.WaitsForTheDataToAppearForSpecifiedTime.sql b/old_tests/ut_output_buffer/get_lines.WaitsForTheDataToAppearForSpecifiedTime.sql deleted file mode 100644 index 20bf4ca6c..000000000 --- a/old_tests/ut_output_buffer/get_lines.WaitsForTheDataToAppearForSpecifiedTime.sql +++ /dev/null @@ -1,22 +0,0 @@ ---Arrange -declare - l_result integer; - l_dummy integer; - l_output ut_output_buffer_base := ut_output_table_buffer(); - l_start_time timestamp := localtimestamp; - l_wait_seconds integer := 1; -begin - --Act - select count(1) into l_dummy from table( l_output.get_lines( a_initial_timeout => l_wait_seconds, a_timeout_sec => 0 )); - l_result := round(extract(second from (localtimestamp - l_start_time))); - - --Assert - ut.expect(l_result).to_equal(l_wait_seconds); - - if ut_expectation_processor.get_status = ut_utils.gc_success then - :test_result := ut_utils.gc_success; - else - dbms_output.put_line(ut_expectation_processor.get_failed_expectations()(1).get_result_clob); - end if; -end; -/ diff --git a/old_tests/ut_output_buffer/send_line.DoesNotSendLineIfNullTextGiven.sql b/old_tests/ut_output_buffer/send_line.DoesNotSendLineIfNullTextGiven.sql deleted file mode 100644 index 5bdbba31a..000000000 --- a/old_tests/ut_output_buffer/send_line.DoesNotSendLineIfNullTextGiven.sql +++ /dev/null @@ -1,21 +0,0 @@ ---Arrange -declare - l_result integer; - l_output ut_output_buffer_base := ut_output_table_buffer(); -begin - delete from ut_output_buffer_tmp; - --Act - l_output.send_line(null); - - select count(1) into l_result from ut_output_buffer_tmp; - - --Assert - ut.expect(l_result).to_equal(0); - if ut_expectation_processor.get_status = ut_utils.gc_success then - :test_result := ut_utils.gc_success; - else - dbms_output.put_line(ut_expectation_processor.get_failed_expectations()(1).get_result_clob); - end if; - -end; -/ diff --git a/old_tests/ut_output_buffer/send_line.SendsALineIntoBufferTable.sql b/old_tests/ut_output_buffer/send_line.SendsALineIntoBufferTable.sql deleted file mode 100644 index 8c2348143..000000000 --- a/old_tests/ut_output_buffer/send_line.SendsALineIntoBufferTable.sql +++ /dev/null @@ -1,24 +0,0 @@ ---Arrange -declare - l_result varchar2(4000); - l_expected varchar2(4000); - l_output ut_output_buffer_base := ut_output_table_buffer(); -begin - --Act - l_expected := lpad('a text',4000,',a text'); - l_output.send_line(l_expected); - - select text into l_result from ut_output_buffer_tmp where output_id = l_output.output_id; - - --Assert - ut.expect(l_result).to_equal(l_expected); - if ut_expectation_processor.get_status = ut_utils.gc_success then - :test_result := ut_utils.gc_success; - else - dbms_output.put_line(ut_expectation_processor.get_failed_expectations()(1).get_result_clob); - end if; - - delete from ut_output_buffer_tmp where output_id = l_output.output_id; - commit; -end; -/ diff --git a/old_tests/ut_reporters/ut_teamcity_reporter.ProducesExpectedOutputs.sql b/old_tests/ut_reporters/ut_teamcity_reporter.ProducesExpectedOutputs.sql deleted file mode 100644 index 4a3b682ba..000000000 --- a/old_tests/ut_reporters/ut_teamcity_reporter.ProducesExpectedOutputs.sql +++ /dev/null @@ -1,52 +0,0 @@ -declare - l_output_data ut_varchar2_list; - l_output clob; - l_expected varchar2(32767); -begin - l_expected := q'{%##teamcity[testSuiteStarted timestamp='%' name='org'] -%##teamcity[testSuiteStarted timestamp='%' name='org.utplsql'] -%##teamcity[testSuiteStarted timestamp='%' name='org.utplsql.utplsql'] -%##teamcity[testSuiteStarted timestamp='%' name='org.utplsql.utplsql.test'] -%##teamcity[testSuiteStarted timestamp='%' name='A suite for testing different outcomes from reporters'] -%##teamcity[testStarted timestamp='%' captureStandardOutput='true' name='ut3.test_reporters.passing_test'] - - - - - -%##teamcity[testFinished timestamp='%' duration='%' name='ut3.test_reporters.passing_test'] -%##teamcity[testStarted timestamp='%' captureStandardOutput='true' name='ut3.test_reporters.failing_test'] - - - -%##teamcity[testFailed timestamp='%' message='Fails as values are different' name='ut3.test_reporters.failing_test'] -%##teamcity[testFinished timestamp='%' duration='%' name='ut3.test_reporters.failing_test'] -%##teamcity[testStarted timestamp='%' captureStandardOutput='true' name='ut3.test_reporters.erroring_test'] - - - -%##teamcity[testStdErr timestamp='%' name='ut3.test_reporters.erroring_test' out='Test exception:|rORA-06512: at |"UT3.TEST_REPORTERS|", line %|rORA-06512: at %|r|r'] -%##teamcity[testFailed timestamp='%' details='Test exception:|rORA-06512: at |"UT3.TEST_REPORTERS|", line %|rORA-06512: at %|r|r' message='Error occured' name='ut3.test_reporters.erroring_test'] -%##teamcity[testFinished timestamp='%' duration='%' name='ut3.test_reporters.erroring_test'] -%##teamcity[testStarted timestamp='%' captureStandardOutput='true' name='ut3.test_reporters.disabled_test'] -%##teamcity[testIgnored timestamp='%' name='ut3.test_reporters.disabled_test'] -%##teamcity[testSuiteFinished timestamp='%' name='A suite for testing different outcomes from reporters'] -%##teamcity[testSuiteFinished timestamp='%' name='org.utplsql.utplsql.test'] -%##teamcity[testSuiteFinished timestamp='%' name='org.utplsql.utplsql'] -%##teamcity[testSuiteFinished timestamp='%' name='org.utplsql'] -%##teamcity[testSuiteFinished timestamp='%' name='org']}'; - --act - select * - bulk collect into l_output_data - from table(ut.run('test_reporters',ut_teamcity_reporter())); - - l_output := ut_utils.table_to_clob(l_output_data); - --assert - if l_output like l_expected then - :test_result := ut_utils.gc_success; - else - dbms_output.put_line(l_output); - end if; - -end; -/ diff --git a/old_tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheSchema.sql b/old_tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheSchema.sql deleted file mode 100644 index 8afb6b622..000000000 --- a/old_tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheSchema.sql +++ /dev/null @@ -1,44 +0,0 @@ -PROMPT Prepare runner for the schema - ---Arrange -declare - c_path varchar2(100) := USER; - l_objects_to_run ut_suite_items; - - l_test0_suite ut_logical_suite; - l_test1_suite ut_logical_suite; - l_test2_suite ut_logical_suite; -begin - --Act - l_objects_to_run := ut_suite_manager.configure_execution_by_path(ut_varchar2_list(c_path)); - - --Assert - for i in 1 .. l_objects_to_run.count loop - if l_test0_suite is of (ut_logical_suite) then - l_test0_suite := treat(l_objects_to_run(i) as ut_logical_suite); - --assume there are only two logical suites in the test - ut.expect(l_test0_suite.name in ('tests', 'tests2')).to_be_true; - - l_test1_suite := treat(l_test0_suite.items(1) as ut_logical_suite); - - case l_test0_suite.name - when 'tests' then - ut.expect(l_test1_suite.name).to_equal('test_package_1'); - ut.expect(l_test1_suite.items.count).to_equal(3); - l_test2_suite := treat(l_test1_suite.items(3) as ut_logical_suite); - - ut.expect(l_test2_suite.name).to_equal('test_package_2'); - ut.expect(l_test2_suite.items.count).to_equal(2); - when 'tests2' then - ut.expect(l_test1_suite.name).to_equal('test_package_3'); - ut.expect(l_test1_suite.items.count).to_equal(3); - end case; - end if; - end loop; - - if ut_expectation_processor.get_status = ut_utils.gc_success then - :test_result := ut_utils.gc_success; - end if; - -end; -/ diff --git a/old_tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTop2PackageByName.sql b/old_tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTop2PackageByName.sql deleted file mode 100644 index 61d46b201..000000000 --- a/old_tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTop2PackageByName.sql +++ /dev/null @@ -1,36 +0,0 @@ -PROMPT Prepare runner for the top 2 package by package name - ---Arrange -declare - c_path varchar2(100) := USER||'.test_package_2'; - l_objects_to_run ut_suite_items; - - l_test0_suite ut_logical_suite; - l_test1_suite ut_logical_suite; - l_test2_suite ut_logical_suite; -begin ---Act - l_objects_to_run := ut_suite_manager.configure_execution_by_path(ut_varchar2_list(c_path)); - ---Assert - ut.expect(l_objects_to_run.count).to_equal(1); - l_test0_suite := treat(l_objects_to_run(1) as ut_logical_suite); - - ut.expect(l_test0_suite.name).to_equal('tests'); - ut.expect(l_test0_suite.items.count).to_equal(1); - l_test1_suite := treat(l_test0_suite.items(1) as ut_logical_suite); - - ut.expect(l_test1_suite.name).to_equal('test_package_1'); - ut.expect(l_test1_suite.items.count).to_equal(1); - l_test2_suite := treat(l_test1_suite.items(1) as ut_logical_suite); - - ut.expect(l_test2_suite.name).to_equal('test_package_2'); - ut.expect(l_test2_suite.items.count).to_equal(2); - - - if ut_expectation_processor.get_status = ut_utils.gc_success then - :test_result := ut_utils.gc_success; - end if; - -end; -/ diff --git a/old_tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTop2PackageByNameCurUser.sql b/old_tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTop2PackageByNameCurUser.sql deleted file mode 100644 index 9762a3397..000000000 --- a/old_tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTop2PackageByNameCurUser.sql +++ /dev/null @@ -1,36 +0,0 @@ -PROMPT Prepare runner for the top 2 package by package name for current user - ---Arrange -declare - c_path varchar2(100) := 'test_package_2'; - l_objects_to_run ut_suite_items; - - l_test0_suite ut_logical_suite; - l_test1_suite ut_logical_suite; - l_test2_suite ut_logical_suite; -begin ---Act - l_objects_to_run := ut_suite_manager.configure_execution_by_path(ut_varchar2_list(c_path)); - ---Assert - ut.expect(l_objects_to_run.count).to_equal(1); - l_test0_suite := treat(l_objects_to_run(1) as ut_logical_suite); - - ut.expect(l_test0_suite.name).to_equal('tests'); - ut.expect(l_test0_suite.items.count).to_equal(1); - l_test1_suite := treat(l_test0_suite.items(1) as ut_logical_suite); - - ut.expect(l_test1_suite.name).to_equal('test_package_1'); - ut.expect(l_test1_suite.items.count).to_equal(1); - l_test2_suite := treat(l_test1_suite.items(1) as ut_logical_suite); - - ut.expect(l_test2_suite.name).to_equal('test_package_2'); - ut.expect(l_test2_suite.items.count).to_equal(2); - - - if ut_expectation_processor.get_status = ut_utils.gc_success then - :test_result := ut_utils.gc_success; - end if; - -end; -/ diff --git a/old_tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTop2PackageByPath.sql b/old_tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTop2PackageByPath.sql deleted file mode 100644 index dbc6c3486..000000000 --- a/old_tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTop2PackageByPath.sql +++ /dev/null @@ -1,36 +0,0 @@ -PROMPT Prepare runner for the top 2 package by path - ---Arrange -declare - c_path varchar2(100) := USER||':tests.test_package_1.test_package_2'; - l_objects_to_run ut_suite_items; - - l_test0_suite ut_logical_suite; - l_test1_suite ut_logical_suite; - l_test2_suite ut_logical_suite; -begin ---Act - l_objects_to_run := ut_suite_manager.configure_execution_by_path(ut_varchar2_list(c_path)); - ---Assert - ut.expect(l_objects_to_run.count).to_equal(1); - l_test0_suite := treat(l_objects_to_run(1) as ut_logical_suite); - - ut.expect(l_test0_suite.name).to_equal('tests'); - ut.expect(l_test0_suite.items.count).to_equal(1); - l_test1_suite := treat(l_test0_suite.items(1) as ut_logical_suite); - - ut.expect(l_test1_suite.name).to_equal('test_package_1'); - ut.expect(l_test1_suite.items.count).to_equal(1); - l_test2_suite := treat(l_test1_suite.items(1) as ut_logical_suite); - - ut.expect(l_test2_suite.name).to_equal('test_package_2'); - ut.expect(l_test2_suite.items.count).to_equal(2); - - - if ut_expectation_processor.get_status = ut_utils.gc_success then - :test_result := ut_utils.gc_success; - end if; - -end; -/ diff --git a/old_tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTop2PackageByPathCurUser.sql b/old_tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTop2PackageByPathCurUser.sql deleted file mode 100644 index 68a0443dd..000000000 --- a/old_tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTop2PackageByPathCurUser.sql +++ /dev/null @@ -1,36 +0,0 @@ -PROMPT Prepare runner for the top 2 package by path for current user - ---Arrange -declare - c_path varchar2(100) := ':tests.test_package_1.test_package_2'; - l_objects_to_run ut_suite_items; - - l_test0_suite ut_logical_suite; - l_test1_suite ut_logical_suite; - l_test2_suite ut_logical_suite; -begin ---Act - l_objects_to_run := ut_suite_manager.configure_execution_by_path(ut_varchar2_list(c_path)); - ---Assert - ut.expect(l_objects_to_run.count).to_equal(1); - l_test0_suite := treat(l_objects_to_run(1) as ut_logical_suite); - - ut.expect(l_test0_suite.name).to_equal('tests'); - ut.expect(l_test0_suite.items.count).to_equal(1); - l_test1_suite := treat(l_test0_suite.items(1) as ut_logical_suite); - - ut.expect(l_test1_suite.name).to_equal('test_package_1'); - ut.expect(l_test1_suite.items.count).to_equal(1); - l_test2_suite := treat(l_test1_suite.items(1) as ut_logical_suite); - - ut.expect(l_test2_suite.name).to_equal('test_package_2'); - ut.expect(l_test2_suite.items.count).to_equal(2); - - - if ut_expectation_processor.get_status = ut_utils.gc_success then - :test_result := ut_utils.gc_success; - end if; - -end; -/ diff --git a/old_tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTop2PackageProcedureByPath.sql b/old_tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTop2PackageProcedureByPath.sql deleted file mode 100644 index 7de3aab68..000000000 --- a/old_tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTop2PackageProcedureByPath.sql +++ /dev/null @@ -1,52 +0,0 @@ -PROMPT Prepare runner for the top 2 package procedure by path - ---Arrange -declare - c_path varchar2(100) := USER||':tests.test_package_1.test_package_2.test2'; - l_objects_to_run ut_suite_items; - - l_test0_suite ut_logical_suite; - l_test1_suite ut_logical_suite; - l_test2_suite ut_logical_suite; - l_test_proc ut_test; -begin ---Act - l_objects_to_run := ut_suite_manager.configure_execution_by_path(ut_varchar2_list(c_path)); - ---Assert - ut.expect(l_objects_to_run.count).to_equal(1); - l_test0_suite := treat(l_objects_to_run(1) as ut_logical_suite); - - ut.expect(l_test0_suite.name).to_equal('tests'); - ut.expect(l_test0_suite.items.count).to_equal(1); - l_test1_suite := treat(l_test0_suite.items(1) as ut_logical_suite); - - ut.expect(l_test1_suite.name).to_equal('test_package_1'); - ut.expect(l_test1_suite.items.count).to_equal(1); - l_test2_suite := treat(l_test1_suite.items(1) as ut_logical_suite); - - ut.expect(l_test2_suite.name).to_equal('test_package_2'); - ut.expect(l_test2_suite.items.count).to_equal(1); - - l_test_proc := treat(l_test2_suite.items(1) as ut_test); - ut.expect(l_test_proc.name).to_equal('test2'); - ut.expect(l_test_proc.before_test_list.count).to_equal(1); - ut.expect(l_test_proc.after_test_list.count).to_equal(1); - - if ut_expectation_processor.get_status = ut_utils.gc_success then - :test_result := ut_utils.gc_success; - else - dbms_output.put_line(q'[ut.expect(l_objects_to_run.count).to_equal(1);=]'||l_objects_to_run.count); - dbms_output.put_line(q'[ut.expect(l_test0_suite.name).to_equal('tests');=]'||l_test0_suite.name); - dbms_output.put_line(q'[ut.expect(l_test0_suite.items.count).to_equal(1);=]'||l_test0_suite.items.count); - dbms_output.put_line(q'[ut.expect(l_test1_suite.name).to_equal('test_package_1');=]'||l_test1_suite.name); - dbms_output.put_line(q'[ut.expect(l_test1_suite.items.count).to_equal(1);=]'||l_test1_suite.items.count); - dbms_output.put_line(q'[ut.expect(l_test2_suite.name).to_equal('test_package_2');=]'||l_test2_suite.name); - dbms_output.put_line(q'[ut.expect(l_test2_suite.items.count).to_equal(1);=]'||l_test2_suite.items.count); - dbms_output.put_line(q'[ut.expect(l_test_proc.name).to_equal('test2');=]'||l_test_proc.name); - dbms_output.put_line(q'[ut.expect(l_test_proc.before_test is not null).to_be_true;=]'||ut_utils.to_string(l_test_proc.before_test_list.count())); - dbms_output.put_line(q'[ut.expect(l_test_proc.after_test is not null).to_be_true;=]'||ut_utils.to_string(l_test_proc.after_test_list.count())); - end if; - -end; -/ diff --git a/old_tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTop2PackageProcedureByPathCurUser.sql b/old_tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTop2PackageProcedureByPathCurUser.sql deleted file mode 100644 index d476c064d..000000000 --- a/old_tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTop2PackageProcedureByPathCurUser.sql +++ /dev/null @@ -1,52 +0,0 @@ -PROMPT Prepare runner for the top 2 package procedure by path for current user - ---Arrange -declare - c_path varchar2(100) := ':tests.test_package_1.test_package_2.test2'; - l_objects_to_run ut_suite_items; - - l_test0_suite ut_logical_suite; - l_test1_suite ut_logical_suite; - l_test2_suite ut_logical_suite; - l_test_proc ut_test; -begin ---Act - l_objects_to_run := ut_suite_manager.configure_execution_by_path(ut_varchar2_list(c_path)); - ---Assert - ut.expect(l_objects_to_run.count).to_equal(1); - l_test0_suite := treat(l_objects_to_run(1) as ut_logical_suite); - - ut.expect(l_test0_suite.name).to_equal('tests'); - ut.expect(l_test0_suite.items.count).to_equal(1); - l_test1_suite := treat(l_test0_suite.items(1) as ut_logical_suite); - - ut.expect(l_test1_suite.name).to_equal('test_package_1'); - ut.expect(l_test1_suite.items.count).to_equal(1); - l_test2_suite := treat(l_test1_suite.items(1) as ut_logical_suite); - - ut.expect(l_test2_suite.name).to_equal('test_package_2'); - ut.expect(l_test2_suite.items.count).to_equal(1); - - l_test_proc := treat(l_test2_suite.items(1) as ut_test); - ut.expect(l_test_proc.name).to_equal('test2'); - ut.expect(l_test_proc.before_test_list.count).to_equal(1); - ut.expect(l_test_proc.after_test_list.count).to_equal(1); - - if ut_expectation_processor.get_status = ut_utils.gc_success then - :test_result := ut_utils.gc_success; - else - dbms_output.put_line(q'[ut.expect(l_objects_to_run.count).to_equal(1);=]'||l_objects_to_run.count); - dbms_output.put_line(q'[ut.expect(l_test0_suite.name).to_equal('tests');=]'||l_test0_suite.name); - dbms_output.put_line(q'[ut.expect(l_test0_suite.items.count).to_equal(1);=]'||l_test0_suite.items.count); - dbms_output.put_line(q'[ut.expect(l_test1_suite.name).to_equal('test_package_1');=]'||l_test1_suite.name); - dbms_output.put_line(q'[ut.expect(l_test1_suite.items.count).to_equal(1);=]'||l_test1_suite.items.count); - dbms_output.put_line(q'[ut.expect(l_test2_suite.name).to_equal('test_package_2');=]'||l_test2_suite.name); - dbms_output.put_line(q'[ut.expect(l_test2_suite.items.count).to_equal(1);=]'||l_test2_suite.items.count); - dbms_output.put_line(q'[ut.expect(l_test_proc.name).to_equal('test2');=]'||l_test_proc.name); - dbms_output.put_line(q'[ut.expect(l_test_proc.before_test is not null).to_be_true;=]'||ut_utils.to_string(l_test_proc.before_test_list.count())); - dbms_output.put_line(q'[ut.expect(l_test_proc.after_test is not null).to_be_true;=]'||ut_utils.to_string(l_test_proc.after_test_list.count())); - end if; - -end; -/ diff --git a/old_tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageByName.sql b/old_tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageByName.sql deleted file mode 100644 index 969524f5e..000000000 --- a/old_tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageByName.sql +++ /dev/null @@ -1,65 +0,0 @@ -PROMPT Prepare runner for the top package by package name - ---Arrange -declare - c_path varchar2(100) := USER||'.test_package_1'; - l_objects_to_run ut_suite_items; - - l_test0_suite ut_logical_suite; - l_test1_suite ut_suite; - l_test2_suite ut_suite; -begin ---Act - l_objects_to_run := ut_suite_manager.configure_execution_by_path(ut_varchar2_list(c_path)); - ---Assert - ut.expect(l_objects_to_run.count).to_equal(1); - l_test0_suite := treat(l_objects_to_run(1) as ut_logical_suite); - - ut.expect(l_test0_suite.name).to_equal('tests'); - ut.expect(l_test0_suite.items.count).to_equal(1); - l_test1_suite := treat(l_test0_suite.items(1) as ut_suite); - - ut.expect(l_test1_suite.name).to_equal('test_package_1'); - ut.expect(l_test1_suite.items.count).to_equal(3); - - ut.expect(l_test1_suite.items(1).name).to_equal('test1'); - ut.expect(l_test1_suite.items(1).description).to_equal('Test1 from test package 1'); - ut.expect(treat(l_test1_suite.items(1) as ut_test).before_test_list.count()).to_equal(0); - ut.expect(treat(l_test1_suite.items(1) as ut_test).after_test_list.count()).to_equal(0); - ut.expect(treat(l_test1_suite.items(1) as ut_test).before_each_list.count()).to_equal(1); - ut.expect(treat(l_test1_suite.items(1) as ut_test).disabled_flag).to_equal(0); - - ut.expect(l_test1_suite.items(2).name).to_equal('test2'); - ut.expect(l_test1_suite.items(2).description).to_equal('Test2 from test package 1'); - ut.expect(treat(l_test1_suite.items(2) as ut_test).before_test_list.count()).to_equal(1); - ut.expect(treat(l_test1_suite.items(2) as ut_test).after_test_list.count()).to_equal(1); - ut.expect(treat(l_test1_suite.items(2) as ut_test).before_each_list.count()).to_equal(1); - ut.expect(treat(l_test1_suite.items(2) as ut_test).disabled_flag).to_equal(0); - - -- temporary behavior. - -- decided that when executed by package, not path, only that package has to execute - l_test2_suite := treat(l_test1_suite.items(3) as ut_suite); - - ut.expect(l_test2_suite.name).to_equal('test_package_2'); - ut.expect(l_test2_suite.items.count).to_equal(2); - - - if ut_expectation_processor.get_status = ut_utils.gc_success then - :test_result := ut_utils.gc_success; - else - declare - l_results ut_expectation_results; - begin - l_results := ut_expectation_processor.get_failed_expectations; - for i in 1..l_results.count loop - if l_results(i).result > ut_utils.gc_success then - dbms_output.put_line(l_results(i).get_result_clob); - end if; - end loop; - end; - - end if; - -end; -/ diff --git a/old_tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageByNameCurUser.sql b/old_tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageByNameCurUser.sql deleted file mode 100644 index c918529b5..000000000 --- a/old_tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageByNameCurUser.sql +++ /dev/null @@ -1,65 +0,0 @@ -PROMPT Prepare runner for the top package by package name for current user - ---Arrange -declare - c_path varchar2(100) := 'test_package_1'; - l_objects_to_run ut_suite_items; - - l_test0_suite ut_logical_suite; - l_test1_suite ut_suite; - l_test2_suite ut_suite; -begin ---Act - l_objects_to_run := ut_suite_manager.configure_execution_by_path(ut_varchar2_list(c_path)); - ---Assert - ut.expect(l_objects_to_run.count).to_equal(1); - l_test0_suite := treat(l_objects_to_run(1) as ut_logical_suite); - - ut.expect(l_test0_suite.name).to_equal('tests'); - ut.expect(l_test0_suite.items.count).to_equal(1); - l_test1_suite := treat(l_test0_suite.items(1) as ut_suite); - - ut.expect(l_test1_suite.name).to_equal('test_package_1'); - ut.expect(l_test1_suite.items.count).to_equal(3); - - ut.expect(l_test1_suite.items(1).name).to_equal('test1'); - ut.expect(l_test1_suite.items(1).description).to_equal('Test1 from test package 1'); - ut.expect(treat(l_test1_suite.items(1) as ut_test).before_test_list.count()).to_equal(0); - ut.expect(treat(l_test1_suite.items(1) as ut_test).after_test_list.count()).to_equal(0); - ut.expect(treat(l_test1_suite.items(1) as ut_test).before_each_list.count()).to_equal(1); - ut.expect(treat(l_test1_suite.items(1) as ut_test).disabled_flag).to_equal(0); - - ut.expect(l_test1_suite.items(2).name).to_equal('test2'); - ut.expect(l_test1_suite.items(2).description).to_equal('Test2 from test package 1'); - ut.expect(treat(l_test1_suite.items(2) as ut_test).before_test_list.count()).to_equal(1); - ut.expect(treat(l_test1_suite.items(2) as ut_test).after_test_list.count()).to_equal(1); - ut.expect(treat(l_test1_suite.items(2) as ut_test).before_each_list.count()).to_equal(1); - ut.expect(treat(l_test1_suite.items(2) as ut_test).disabled_flag).to_equal(0); - - -- temporary behavior. - -- decided that when executed by package, not path, only that package has to execute - l_test2_suite := treat(l_test1_suite.items(3) as ut_suite); - - ut.expect(l_test2_suite.name).to_equal('test_package_2'); - ut.expect(l_test2_suite.items.count).to_equal(2); - - - if ut_expectation_processor.get_status = ut_utils.gc_success then - :test_result := ut_utils.gc_success; - else - declare - l_results ut_expectation_results; - begin - l_results := ut_expectation_processor.get_failed_expectations; - for i in 1..l_results.count loop - if l_results(i).result > ut_utils.gc_success then - dbms_output.put_line(l_results(i).get_result_clob); - end if; - end loop; - end; - - end if; - -end; -/ diff --git a/old_tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageByPath.sql b/old_tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageByPath.sql deleted file mode 100644 index 3f035c932..000000000 --- a/old_tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageByPath.sql +++ /dev/null @@ -1,36 +0,0 @@ -PROMPT Prepare runner for the top package by path - ---Arrange -declare - c_path varchar2(100) := USER||':tests'; - l_objects_to_run ut_suite_items; - - l_test0_suite ut_logical_suite; - l_test1_suite ut_logical_suite; - l_test2_suite ut_logical_suite; -begin ---Act - l_objects_to_run := ut_suite_manager.configure_execution_by_path(ut_varchar2_list(c_path)); - ---Assert - ut.expect(l_objects_to_run.count).to_equal(1); - l_test0_suite := treat(l_objects_to_run(1) as ut_logical_suite); - - ut.expect(l_test0_suite.name).to_equal('tests'); - ut.expect(l_test0_suite.items.count).to_equal(1); - l_test1_suite := treat(l_test0_suite.items(1) as ut_logical_suite); - - ut.expect(l_test1_suite.name).to_equal('test_package_1'); - ut.expect(l_test1_suite.items.count).to_equal(3); - l_test2_suite := treat(l_test1_suite.items(3) as ut_logical_suite); - - ut.expect(l_test2_suite.name).to_equal('test_package_2'); - ut.expect(l_test2_suite.items.count).to_equal(2); - - - if ut_expectation_processor.get_status = ut_utils.gc_success then - :test_result := ut_utils.gc_success; - end if; - -end; -/ diff --git a/old_tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageByPathCurUser.sql b/old_tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageByPathCurUser.sql deleted file mode 100644 index 28dc17442..000000000 --- a/old_tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageByPathCurUser.sql +++ /dev/null @@ -1,36 +0,0 @@ -PROMPT Prepare runner for the top package by path for current user - ---Arrange -declare - c_path varchar2(100) := ':tests'; - l_objects_to_run ut_suite_items; - - l_test0_suite ut_logical_suite; - l_test1_suite ut_logical_suite; - l_test2_suite ut_logical_suite; -begin ---Act - l_objects_to_run := ut_suite_manager.configure_execution_by_path(ut_varchar2_list(c_path)); - ---Assert - ut.expect(l_objects_to_run.count).to_equal(1); - l_test0_suite := treat(l_objects_to_run(1) as ut_logical_suite); - - ut.expect(l_test0_suite.name).to_equal('tests'); - ut.expect(l_test0_suite.items.count).to_equal(1); - l_test1_suite := treat(l_test0_suite.items(1) as ut_logical_suite); - - ut.expect(l_test1_suite.name).to_equal('test_package_1'); - ut.expect(l_test1_suite.items.count).to_equal(3); - l_test2_suite := treat(l_test1_suite.items(3) as ut_logical_suite); - - ut.expect(l_test2_suite.name).to_equal('test_package_2'); - ut.expect(l_test2_suite.items.count).to_equal(2); - - - if ut_expectation_processor.get_status = ut_utils.gc_success then - :test_result := ut_utils.gc_success; - end if; - -end; -/ diff --git a/old_tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageProcedureByPath.sql b/old_tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageProcedureByPath.sql deleted file mode 100644 index 58958881f..000000000 --- a/old_tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageProcedureByPath.sql +++ /dev/null @@ -1,38 +0,0 @@ -PROMPT Prepare runner for the top package procedure by path - ---Arrange -declare - c_path varchar2(100) := USER||':tests.test_package_1.test2'; - l_objects_to_run ut_suite_items; - - l_test0_suite ut_logical_suite; - l_test1_suite ut_logical_suite; - l_test2_suite ut_logical_suite; - l_test_proc ut_test; -begin ---Act - l_objects_to_run := ut_suite_manager.configure_execution_by_path(ut_varchar2_list(c_path)); - ---Assert - ut.expect(l_objects_to_run.count).to_equal(1); - l_test0_suite := treat(l_objects_to_run(1) as ut_logical_suite); - - ut.expect(l_test0_suite.name).to_equal('tests'); - ut.expect(l_test0_suite.items.count).to_equal(1); - l_test1_suite := treat(l_test0_suite.items(1) as ut_logical_suite); - - ut.expect(l_test1_suite.name).to_equal('test_package_1'); - ut.expect(l_test1_suite.items.count).to_equal(1); - l_test_proc := treat(l_test1_suite.items(1) as ut_test); - - ut.expect(l_test_proc.name).to_equal('test2'); - ut.expect(l_test_proc.description).to_equal('Test2 from test package 1'); - ut.expect(l_test_proc.before_test_list.count).to_equal(1); - ut.expect(l_test_proc.after_test_list.count).to_equal(1); - - if ut_expectation_processor.get_status = ut_utils.gc_success then - :test_result := ut_utils.gc_success; - end if; - -end; -/ diff --git a/old_tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageProcedureByPathCurUser.sql b/old_tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageProcedureByPathCurUser.sql deleted file mode 100644 index 009078767..000000000 --- a/old_tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageProcedureByPathCurUser.sql +++ /dev/null @@ -1,38 +0,0 @@ -PROMPT Prepare runner for the top package procedure by path for current user - ---Arrange -declare - c_path varchar2(100) := ':tests.test_package_1.test2'; - l_objects_to_run ut_suite_items; - - l_test0_suite ut_logical_suite; - l_test1_suite ut_logical_suite; - l_test2_suite ut_logical_suite; - l_test_proc ut_test; -begin ---Act - l_objects_to_run := ut_suite_manager.configure_execution_by_path(ut_varchar2_list(c_path)); - ---Assert - ut.expect(l_objects_to_run.count).to_equal(1); - l_test0_suite := treat(l_objects_to_run(1) as ut_logical_suite); - - ut.expect(l_test0_suite.name).to_equal('tests'); - ut.expect(l_test0_suite.items.count).to_equal(1); - l_test1_suite := treat(l_test0_suite.items(1) as ut_logical_suite); - - ut.expect(l_test1_suite.name).to_equal('test_package_1'); - ut.expect(l_test1_suite.items.count).to_equal(1); - l_test_proc := treat(l_test1_suite.items(1) as ut_test); - - ut.expect(l_test_proc.name).to_equal('test2'); - ut.expect(l_test_proc.description).to_equal('Test2 from test package 1'); - ut.expect(l_test_proc.before_test_list.count).to_equal(1); - ut.expect(l_test_proc.after_test_list.count).to_equal(1); - - if ut_expectation_processor.get_status = ut_utils.gc_success then - :test_result := ut_utils.gc_success; - end if; - -end; -/ diff --git a/old_tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageProcedureWithoutSubsuitesByName.sql b/old_tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageProcedureWithoutSubsuitesByName.sql deleted file mode 100644 index 986b497a0..000000000 --- a/old_tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageProcedureWithoutSubsuitesByName.sql +++ /dev/null @@ -1,36 +0,0 @@ -PROMPT Prepare runner for the top package procedure without sub-suites by package name - ---Arrange -declare - c_path varchar2(100) := USER||'.test_package_2.test2'; - l_objects_to_run ut_suite_items; - - l_test0_suite ut_logical_suite; - l_test1_suite ut_logical_suite; - l_test_proc ut_test; -begin ---Act - l_objects_to_run := ut_suite_manager.configure_execution_by_path(ut_varchar2_list(c_path)); - ---Assert - ut.expect(l_objects_to_run.count).to_equal(1); - l_test0_suite := treat(l_objects_to_run(1) as ut_logical_suite); - - ut.expect(l_test0_suite.name).to_equal('tests'); - ut.expect(l_test0_suite.items.count).to_equal(1); - l_test1_suite := treat(l_test0_suite.items(1) as ut_logical_suite); - - ut.expect(l_test1_suite.name).to_equal('test_package_3'); - ut.expect(l_test1_suite.items.count).to_equal(1); - - l_test_proc := treat(l_test1_suite.items(1) as ut_test); - ut.expect(l_test_proc.name).to_equal('test2'); - ut.expect(l_test_proc.before_test_list.count).to_equal(1); - ut.expect(l_test_proc.after_test_list.count).to_equal(1); - - if ut_expectation_processor.get_status = ut_utils.gc_success then - :test_result := ut_utils.gc_success; - end if; - -end; -/ diff --git a/old_tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageProcedureWithoutSubsuitesByNameCurUser.sql b/old_tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageProcedureWithoutSubsuitesByNameCurUser.sql deleted file mode 100644 index f1b536e21..000000000 --- a/old_tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageProcedureWithoutSubsuitesByNameCurUser.sql +++ /dev/null @@ -1,36 +0,0 @@ -PROMPT Prepare runner for the top package procedure without sub-suites by package name for current user - ---Arrange -declare - c_path varchar2(100) := 'test_package_2.test2'; - l_objects_to_run ut_suite_items; - - l_test0_suite ut_logical_suite; - l_test1_suite ut_logical_suite; - l_test_proc ut_test; -begin ---Act - l_objects_to_run := ut_suite_manager.configure_execution_by_path(ut_varchar2_list(c_path)); - ---Assert - ut.expect(l_objects_to_run.count).to_equal(1); - l_test0_suite := treat(l_objects_to_run(1) as ut_logical_suite); - - ut.expect(l_test0_suite.name).to_equal('tests'); - ut.expect(l_test0_suite.items.count).to_equal(1); - l_test1_suite := treat(l_test0_suite.items(1) as ut_logical_suite); - - ut.expect(l_test1_suite.name).to_equal('test_package_3'); - ut.expect(l_test1_suite.items.count).to_equal(1); - - l_test_proc := treat(l_test1_suite.items(1) as ut_test); - ut.expect(l_test_proc.name).to_equal('test2'); - ut.expect(l_test_proc.before_test_list.count).to_equal(1); - ut.expect(l_test_proc.after_test_list.count).to_equal(1); - - if ut_expectation_processor.get_status = ut_utils.gc_success then - :test_result := ut_utils.gc_success; - end if; - -end; -/ diff --git a/old_tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageWithoutSubsuitesByName.sql b/old_tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageWithoutSubsuitesByName.sql deleted file mode 100644 index 4f95592fe..000000000 --- a/old_tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageWithoutSubsuitesByName.sql +++ /dev/null @@ -1,40 +0,0 @@ -PROMPT Prepare runner for the top package without sub-suites by package name - ---Arrange -declare - c_path varchar2(100) := USER||'.test_package_3'; - l_objects_to_run ut_suite_items; - - l_test0_suite ut_logical_suite; - l_test1_suite ut_logical_suite; - l_test1 ut_test; - l_test3 ut_test; -begin ---Act - l_objects_to_run := ut_suite_manager.configure_execution_by_path(ut_varchar2_list(c_path)); - ---Assert - ut.expect(l_objects_to_run.count).to_equal(1); - l_test0_suite := treat(l_objects_to_run(1) as ut_logical_suite); - - ut.expect(l_test0_suite.name).to_equal('tests2'); - ut.expect(l_test0_suite.items.count).to_equal(1); - l_test1_suite := treat(l_test0_suite.items(1) as ut_logical_suite); - - ut.expect(l_test1_suite.name).to_equal('test_package_3'); - ut.expect(l_test1_suite.items.count).to_equal(3); - - l_test1 := treat(l_test1_suite.items(1) as ut_test); - ut.expect(l_test1.name).to_equal('test1'); - ut.expect(l_test1.disabled_flag).to_equal(0); - - l_test3 := treat(l_test1_suite.items(3) as ut_test); - ut.expect(l_test3.name).to_equal('disabled_test'); - ut.expect(l_test3.disabled_flag).to_equal(1); - - if ut_expectation_processor.get_status = ut_utils.gc_success then - :test_result := ut_utils.gc_success; - end if; - -end; -/ diff --git a/old_tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageWithoutSubsuitesByNameCurUser.sql b/old_tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageWithoutSubsuitesByNameCurUser.sql deleted file mode 100644 index 48da40bad..000000000 --- a/old_tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageWithoutSubsuitesByNameCurUser.sql +++ /dev/null @@ -1,40 +0,0 @@ -PROMPT Prepare runner for the top package without sub-suites by package name for current user - ---Arrange -declare - c_path varchar2(100) := 'test_package_3'; - l_objects_to_run ut_suite_items; - - l_test0_suite ut_logical_suite; - l_test1_suite ut_logical_suite; - l_test1 ut_test; - l_test3 ut_test; -begin ---Act - l_objects_to_run := ut_suite_manager.configure_execution_by_path(ut_varchar2_list(c_path)); - ---Assert - ut.expect(l_objects_to_run.count).to_equal(1); - l_test0_suite := treat(l_objects_to_run(1) as ut_logical_suite); - - ut.expect(l_test0_suite.name).to_equal('tests2'); - ut.expect(l_test0_suite.items.count).to_equal(1); - l_test1_suite := treat(l_test0_suite.items(1) as ut_logical_suite); - - ut.expect(l_test1_suite.name).to_equal('test_package_3'); - ut.expect(l_test1_suite.items.count).to_equal(3); - - l_test1 := treat(l_test1_suite.items(1) as ut_test); - ut.expect(l_test1.name).to_equal('test1'); - ut.expect(l_test1.disabled_flag).to_equal(0); - - l_test3 := treat(l_test1_suite.items(3) as ut_test); - ut.expect(l_test3.name).to_equal('disabled_test'); - ut.expect(l_test3.disabled_flag).to_equal(1); - - if ut_expectation_processor.get_status = ut_utils.gc_success then - :test_result := ut_utils.gc_success; - end if; - -end; -/ diff --git a/old_tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageWithoutSubsuitesByPath.sql b/old_tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageWithoutSubsuitesByPath.sql deleted file mode 100644 index c5e8a3c0a..000000000 --- a/old_tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageWithoutSubsuitesByPath.sql +++ /dev/null @@ -1,40 +0,0 @@ -PROMPT Prepare runner for the top package without subsuites by path - ---Arrange -declare - c_path varchar2(100) := USER||':tests2.test_package_3'; - l_objects_to_run ut_suite_items; - - l_test0_suite ut_logical_suite; - l_test1_suite ut_logical_suite; - l_test1 ut_test; - l_test3 ut_test; -begin ---Act - l_objects_to_run := ut_suite_manager.configure_execution_by_path(ut_varchar2_list(c_path)); - ---Assert - ut.expect(l_objects_to_run.count).to_equal(1); - l_test0_suite := treat(l_objects_to_run(1) as ut_logical_suite); - - ut.expect(l_test0_suite.name).to_equal('tests2'); - ut.expect(l_test0_suite.items.count).to_equal(1); - l_test1_suite := treat(l_test0_suite.items(1) as ut_logical_suite); - - ut.expect(l_test1_suite.name).to_equal('test_package_3'); - ut.expect(l_test1_suite.items.count).to_equal(3); - - l_test1 := treat(l_test1_suite.items(1) as ut_test); - ut.expect(l_test1.name).to_equal('test1'); - ut.expect(l_test1.disabled_flag).to_equal(0); - - l_test3 := treat(l_test1_suite.items(3) as ut_test); - ut.expect(l_test3.name).to_equal('disabled_test'); - ut.expect(l_test3.disabled_flag).to_equal(1); - - if ut_expectation_processor.get_status = ut_utils.gc_success then - :test_result := ut_utils.gc_success; - end if; - -end; -/ diff --git a/old_tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageWithoutSubsuitesByPathCurUser.sql b/old_tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageWithoutSubsuitesByPathCurUser.sql deleted file mode 100644 index ff8cd6f75..000000000 --- a/old_tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageWithoutSubsuitesByPathCurUser.sql +++ /dev/null @@ -1,40 +0,0 @@ -PROMPT Prepare runner for the top package without subsuites by path for current user - ---Arrange -declare - c_path varchar2(100) := ':tests2.test_package_3'; - l_objects_to_run ut_suite_items; - - l_test0_suite ut_logical_suite; - l_test1_suite ut_logical_suite; - l_test1 ut_test; - l_test3 ut_test; -begin ---Act - l_objects_to_run := ut_suite_manager.configure_execution_by_path(ut_varchar2_list(c_path)); - ---Assert - ut.expect(l_objects_to_run.count).to_equal(1); - l_test0_suite := treat(l_objects_to_run(1) as ut_logical_suite); - - ut.expect(l_test0_suite.name).to_equal('tests2'); - ut.expect(l_test0_suite.items.count).to_equal(1); - l_test1_suite := treat(l_test0_suite.items(1) as ut_logical_suite); - - ut.expect(l_test1_suite.name).to_equal('test_package_3'); - ut.expect(l_test1_suite.items.count).to_equal(3); - - l_test1 := treat(l_test1_suite.items(1) as ut_test); - ut.expect(l_test1.name).to_equal('test1'); - ut.expect(l_test1.disabled_flag).to_equal(0); - - l_test3 := treat(l_test1_suite.items(3) as ut_test); - ut.expect(l_test3.name).to_equal('disabled_test'); - ut.expect(l_test3.disabled_flag).to_equal(1); - - if ut_expectation_processor.get_status = ut_utils.gc_success then - :test_result := ut_utils.gc_success; - end if; - -end; -/ diff --git a/source/api/ut.pkb b/source/api/ut.pkb index 1159182fa..6fd4eab08 100644 --- a/source/api/ut.pkb +++ b/source/api/ut.pkb @@ -107,7 +107,7 @@ create or replace package body ut is procedure run_autonomous( a_paths ut_varchar2_list, - a_reporter ut_reporter_base, + a_reporter in out nocopy ut_reporter_base, a_color_console integer, a_coverage_schemes ut_varchar2_list := null, a_source_file_mappings ut_file_mappings, @@ -119,9 +119,10 @@ create or replace package body ut is pragma autonomous_transaction; c_fail_on_errors constant boolean := false; begin + a_reporter := coalesce(a_reporter,ut_documentation_reporter()); ut_runner.run( a_paths, - ut_reporters(coalesce(a_reporter,ut_documentation_reporter())), + ut_reporters(a_reporter), ut_utils.int_to_boolean(a_color_console), a_coverage_schemes, a_source_file_mappings, @@ -136,7 +137,7 @@ create or replace package body ut is procedure run_autonomous( a_paths ut_varchar2_list, - a_reporter ut_reporter_base, + a_reporter in out nocopy ut_reporter_base, a_color_console integer, a_coverage_schemes ut_varchar2_list := null, a_source_files ut_varchar2_list, @@ -148,9 +149,10 @@ create or replace package body ut is pragma autonomous_transaction; c_fail_on_errors constant boolean := false; begin + a_reporter := coalesce(a_reporter,ut_documentation_reporter()); ut_runner.run( a_paths, - ut_reporters(coalesce(a_reporter,ut_documentation_reporter())), + ut_reporters(a_reporter), ut_utils.int_to_boolean(a_color_console), a_coverage_schemes, ut_file_mapper.build_file_mappings(a_source_files), @@ -173,14 +175,12 @@ create or replace package body ut is a_exclude_objects ut_varchar2_list := null, a_client_character_set varchar2 := null ) return ut_varchar2_rows pipelined is - l_reporter ut_reporter_base := coalesce(a_reporter, - ut_documentation_reporter()); - l_paths ut_varchar2_list := ut_varchar2_list(sys_context('userenv', 'current_schema')); + l_reporter ut_reporter_base := a_reporter; l_lines sys_refcursor; l_line varchar2(4000); begin run_autonomous( - l_paths, + ut_varchar2_list(), l_reporter, a_color_console, a_coverage_schemes, @@ -213,13 +213,12 @@ create or replace package body ut is a_exclude_objects ut_varchar2_list := null, a_client_character_set varchar2 := null ) return ut_varchar2_rows pipelined is - l_reporter ut_reporter_base := coalesce(a_reporter, ut_documentation_reporter()); - l_paths ut_varchar2_list := ut_varchar2_list(sys_context('userenv', 'current_schema')); + l_reporter ut_reporter_base := a_reporter; l_lines sys_refcursor; l_line varchar2(4000); begin run_autonomous( - l_paths, + ut_varchar2_list(), l_reporter, a_color_console, a_coverage_schemes, @@ -253,7 +252,7 @@ create or replace package body ut is a_exclude_objects ut_varchar2_list := null, a_client_character_set varchar2 := null ) return ut_varchar2_rows pipelined is - l_reporter ut_reporter_base := coalesce(a_reporter, ut_documentation_reporter()); + l_reporter ut_reporter_base := a_reporter; l_lines sys_refcursor; l_line varchar2(4000); begin @@ -292,7 +291,7 @@ create or replace package body ut is a_exclude_objects ut_varchar2_list := null, a_client_character_set varchar2 := null ) return ut_varchar2_rows pipelined is - l_reporter ut_reporter_base := coalesce(a_reporter, ut_documentation_reporter()); + l_reporter ut_reporter_base := a_reporter; l_lines sys_refcursor; l_line varchar2(4000); begin @@ -331,14 +330,12 @@ create or replace package body ut is a_exclude_objects ut_varchar2_list := null, a_client_character_set varchar2 := null ) return ut_varchar2_rows pipelined is - l_reporter ut_reporter_base := coalesce(a_reporter, - ut_documentation_reporter()); - l_paths ut_varchar2_list := ut_varchar2_list(coalesce(a_path, sys_context('userenv', 'current_schema'))); + l_reporter ut_reporter_base := a_reporter; l_lines sys_refcursor; l_line varchar2(4000); begin run_autonomous( - l_paths, + ut_varchar2_list(a_path), l_reporter, a_color_console, a_coverage_schemes, @@ -372,13 +369,12 @@ create or replace package body ut is a_exclude_objects ut_varchar2_list := null, a_client_character_set varchar2 := null ) return ut_varchar2_rows pipelined is - l_reporter ut_reporter_base := coalesce(a_reporter, ut_documentation_reporter()); - l_paths ut_varchar2_list := ut_varchar2_list(coalesce(a_path, sys_context('userenv', 'current_schema'))); + l_reporter ut_reporter_base := a_reporter; l_lines sys_refcursor; l_line varchar2(4000); begin run_autonomous( - l_paths, + ut_varchar2_list(a_path), l_reporter, a_color_console, a_coverage_schemes, @@ -412,7 +408,7 @@ create or replace package body ut is a_exclude_objects ut_varchar2_list := null, a_client_character_set varchar2 := null ) is - l_reporter ut_reporter_base := coalesce(a_reporter, ut_documentation_reporter()); + l_reporter ut_reporter_base := a_reporter; begin run_autonomous( a_paths, @@ -442,7 +438,7 @@ create or replace package body ut is a_exclude_objects ut_varchar2_list := null, a_client_character_set varchar2 := null ) is - l_reporter ut_reporter_base := coalesce(a_reporter, ut_documentation_reporter()); + l_reporter ut_reporter_base := a_reporter; begin run_autonomous( a_paths, @@ -473,7 +469,7 @@ create or replace package body ut is ) is begin ut.run( - ut_varchar2_list(sys_context('userenv', 'current_schema')), + ut_varchar2_list(), a_reporter, a_color_console, a_coverage_schemes, @@ -497,7 +493,7 @@ create or replace package body ut is ) is begin ut.run( - ut_varchar2_list(sys_context('userenv', 'current_schema')), + ut_varchar2_list(), a_reporter, a_color_console, a_coverage_schemes, @@ -520,10 +516,9 @@ create or replace package body ut is a_exclude_objects ut_varchar2_list := null, a_client_character_set varchar2 := null ) is - l_paths ut_varchar2_list := ut_varchar2_list(coalesce(a_path, sys_context('userenv', 'current_schema'))); begin ut.run( - l_paths, + ut_varchar2_list(a_path), a_reporter, a_color_console, a_coverage_schemes, @@ -546,10 +541,9 @@ create or replace package body ut is a_exclude_objects ut_varchar2_list := null, a_client_character_set varchar2 := null ) is - l_paths ut_varchar2_list := ut_varchar2_list(coalesce(a_path, sys_context('userenv', 'current_schema'))); begin ut.run( - l_paths, + ut_varchar2_list(a_path), a_reporter, a_color_console, a_coverage_schemes, diff --git a/source/api/ut_runner.pkb b/source/api/ut_runner.pkb index eb3bc8e68..0e01557b5 100644 --- a/source/api/ut_runner.pkb +++ b/source/api/ut_runner.pkb @@ -89,8 +89,14 @@ create or replace package body ut_runner is l_coverage_schema_names ut_varchar2_rows; l_exclude_object_names ut_object_names := ut_object_names(); l_include_object_names ut_object_names; + l_paths ut_varchar2_list; begin ut_event_manager.initialize(); + if a_paths is null or a_paths is empty or a_paths.count = 1 and a_paths(1) is null then + l_paths := ut_varchar2_list(sys_context('userenv', 'current_schema')); + else + l_paths := a_paths; + end if; begin ut_expectation_processor.reset_invalidation_exception(); ut_utils.save_dbms_output_to_cache(); @@ -107,7 +113,7 @@ create or replace package body ut_runner is if a_coverage_schemes is not empty then l_coverage_schema_names := ut_utils.convert_collection(a_coverage_schemes); else - l_coverage_schema_names := ut_suite_manager.get_schema_names(a_paths); + l_coverage_schema_names := ut_suite_manager.get_schema_names(l_paths); end if; if a_exclude_objects is not empty then @@ -119,8 +125,8 @@ create or replace package body ut_runner is l_include_object_names := to_ut_object_list(a_include_objects, l_coverage_schema_names); l_run := ut_run( - ut_suite_manager.configure_execution_by_path(a_paths), - a_paths, + ut_suite_manager.configure_execution_by_path(l_paths), + l_paths, l_coverage_schema_names, l_exclude_object_names, l_include_object_names, diff --git a/source/core/ut_file_mapper.pks b/source/core/ut_file_mapper.pks index 573b0528f..f16913e98 100644 --- a/source/core/ut_file_mapper.pks +++ b/source/core/ut_file_mapper.pks @@ -16,10 +16,10 @@ create or replace package ut_file_mapper authid current_user is limitations under the License. */ - gc_file_mapping_regex constant varchar2(100) := '/((\w+)\.)?(\w+)\.(\w{3})$'; + gc_file_mapping_regex constant varchar2(100) := '/(((\w|[$#])+)\.)?((\w|[$#])+)\.(\w{3})$'; gc_regex_owner_subexpression constant positive := 2; - gc_regex_name_subexpression constant positive := 3; - gc_regex_type_subexpression constant positive := 4; + gc_regex_name_subexpression constant positive := 4; + gc_regex_type_subexpression constant positive := 6; function default_file_to_obj_type_map return ut_key_value_pairs; diff --git a/source/expectations/data_values/ut_compound_data_helper.pkb b/source/expectations/data_values/ut_compound_data_helper.pkb index 0e8eba809..bde359738 100644 --- a/source/expectations/data_values/ut_compound_data_helper.pkb +++ b/source/expectations/data_values/ut_compound_data_helper.pkb @@ -162,9 +162,7 @@ create or replace package body ut_compound_data_helper is begin select replace((extract(a_item_data,a_join_by_xpath).getclobval()),chr(10)) into l_pk_value from dual; return l_pk_value; - exception when no_data_found then - return 'null'; - end; + end; function get_rows_diff( a_expected_dataset_guid raw, a_actual_dataset_guid raw, a_diff_id raw, diff --git a/test/api/test_ut_run.pkb b/test/api/test_ut_run.pkb index cee41c085..6db85cc05 100644 --- a/test/api/test_ut_run.pkb +++ b/test/api/test_ut_run.pkb @@ -1,5 +1,518 @@ create or replace package body test_ut_run is + --%test(ut.version() returns version of the framework) + procedure ut_version is + begin + ut.expect(ut3.ut.version()).to_match('^v\d+\.\d+\.\d+\.\d+(-\w+)?$'); + end; + + --%test(ut.fail() marks test as failed) + procedure ut_fail is + begin + --Act + ut3.ut.fail('Testing failure message'); + --Assert + ut.expect( + xmltype(anydata.convertCollection(ut3.ut_expectation_processor.get_failed_expectations())).getClobVal() + ).to_be_like('%2%Testing failure message%'); + --Cleanup + ut3.ut_expectation_processor.clear_expectations(); + end; + + + function get_dbms_output_as_clob return clob is + l_status number; + l_line varchar2(32767); + l_result clob; + begin + + dbms_output.get_line(line => l_line, status => l_status); + if l_status != 1 then + dbms_lob.createtemporary(l_result, true, dur => dbms_lob.session); + end if; + while l_status != 1 loop + if l_line is not null then + ut3.ut_utils.append_to_clob(l_result, l_line||chr(10)); + end if; + dbms_output.get_line(line => l_line, status => l_status); + end loop; + return l_result; + end; + + procedure create_ut3$user#_tests is + pragma autonomous_transaction; + begin + execute immediate q'[create or replace package ut3$user#.test_package_1 is + --%suite + --%suitepath(tests) + + --%test(Test1 from test package 1) + procedure test1; + + --%test(Test2 from test package 1) + procedure test2; + + procedure run(a_reporter ut3.ut_reporter_base := null); + procedure run(a_test_files ut3.ut_varchar2_list, a_reporter ut3.ut_reporter_base); + procedure run(a_path varchar2, a_reporter ut3.ut_reporter_base := null); + procedure run(a_path varchar2, a_test_files ut3.ut_varchar2_list, a_reporter ut3.ut_reporter_base); + procedure run(a_paths ut3.ut_varchar2_list, a_reporter ut3.ut_reporter_base := null); + procedure run(a_paths ut3.ut_varchar2_list, a_test_files ut3.ut_varchar2_list, a_reporter ut3.ut_reporter_base); + function run(a_reporter ut3.ut_reporter_base := null) return ut3.ut_varchar2_list; + function run(a_test_files ut3.ut_varchar2_list, a_reporter ut3.ut_reporter_base) return ut3.ut_varchar2_list; + function run(a_path varchar2, a_reporter ut3.ut_reporter_base := null) return ut3.ut_varchar2_list; + function run(a_path varchar2, a_test_files ut3.ut_varchar2_list, a_reporter ut3.ut_reporter_base) return ut3.ut_varchar2_list; + function run(a_paths ut3.ut_varchar2_list, a_reporter ut3.ut_reporter_base := null) return ut3.ut_varchar2_list; + function run(a_paths ut3.ut_varchar2_list, a_test_files ut3.ut_varchar2_list, a_reporter ut3.ut_reporter_base) return ut3.ut_varchar2_list; + + end test_package_1; + ]'; + execute immediate q'[create or replace package body ut3$user#.test_package_1 is + procedure test1 is + begin + dbms_output.put_line('test_package_1.test1 executed'); + end; + procedure test2 is + begin + dbms_output.put_line('test_package_1.test2 executed'); + end; + + procedure run(a_reporter ut3.ut_reporter_base := null) is + begin + ut3.ut.run(a_reporter); + end; + procedure run(a_test_files ut3.ut_varchar2_list, a_reporter ut3.ut_reporter_base) is + begin + ut3.ut.run( + a_reporter, a_source_files => ut3.ut_varchar2_list(), + a_test_files => a_test_files + ); + end; + procedure run(a_path varchar2, a_reporter ut3.ut_reporter_base := null) is + begin + ut3.ut.run(a_path, a_reporter); + end; + procedure run(a_path varchar2, a_test_files ut3.ut_varchar2_list, a_reporter ut3.ut_reporter_base) is + begin + ut3.ut.run( + a_path, + a_reporter, a_source_files => ut3.ut_varchar2_list(), + a_test_files => a_test_files + ); + end; + procedure run(a_paths ut3.ut_varchar2_list, a_reporter ut3.ut_reporter_base := null) is + begin + ut3.ut.run(a_paths, a_reporter); + end; + procedure run(a_paths ut3.ut_varchar2_list, a_test_files ut3.ut_varchar2_list, a_reporter ut3.ut_reporter_base) is + begin + ut3.ut.run( + a_paths, + a_reporter, a_source_files => ut3.ut_varchar2_list(), + a_test_files => a_test_files + ); + end; + + function run(a_reporter ut3.ut_reporter_base := null) return ut3.ut_varchar2_list is + l_results ut3.ut_varchar2_list; + begin + select * bulk collect into l_results from table (ut3.ut.run(a_reporter)); + return l_results; + end; + function run(a_test_files ut3.ut_varchar2_list, a_reporter ut3.ut_reporter_base) return ut3.ut_varchar2_list is + l_results ut3.ut_varchar2_list; + begin + select * bulk collect into l_results from table ( + ut3.ut.run( + a_reporter, a_source_files => ut3.ut_varchar2_list(), + a_test_files => a_test_files + )); + return l_results; + end; + function run(a_path varchar2, a_reporter ut3.ut_reporter_base := null) return ut3.ut_varchar2_list is + l_results ut3.ut_varchar2_list; + begin + select * bulk collect into l_results from table (ut3.ut.run(a_path, a_reporter)); + return l_results; + end; + function run(a_path varchar2, a_test_files ut3.ut_varchar2_list, a_reporter ut3.ut_reporter_base) return ut3.ut_varchar2_list is + l_results ut3.ut_varchar2_list; + begin + select * bulk collect into l_results from table ( + ut3.ut.run( + a_path, + a_reporter, a_source_files => ut3.ut_varchar2_list(), + a_test_files => a_test_files + )); + return l_results; + end; + function run(a_paths ut3.ut_varchar2_list, a_reporter ut3.ut_reporter_base := null) return ut3.ut_varchar2_list is + l_results ut3.ut_varchar2_list; + begin + select * bulk collect into l_results from table (ut3.ut.run(a_paths, a_reporter)); + return l_results; + end; + function run(a_paths ut3.ut_varchar2_list, a_test_files ut3.ut_varchar2_list, a_reporter ut3.ut_reporter_base) return ut3.ut_varchar2_list is + l_results ut3.ut_varchar2_list; + begin + select * bulk collect into l_results from table ( + ut3.ut.run( + a_paths, + a_reporter, a_source_files => ut3.ut_varchar2_list(), + a_test_files => a_test_files + )); + return l_results; + end; + end test_package_1; + ]'; + + execute immediate q'[create or replace package ut3$user#.test_package_2 is + --%suite + --%suitepath(tests.test_package_1) + + --%test + procedure test1; + + --%test + procedure test2; + + end test_package_2; + ]'; + execute immediate q'[create or replace package body ut3$user#.test_package_2 is + procedure test1 is + begin + dbms_output.put_line('test_package_2.test1 executed'); + end; + procedure test2 is + begin + dbms_output.put_line('test_package_2.test2 executed'); + end; + end test_package_2; + ]'; + + execute immediate q'[create or replace package ut3$user#.test_package_3 is + --%suite + --%suitepath(tests2) + + --%test + procedure test1; + + --%test + procedure test2; + + end test_package_3; + ]'; + execute immediate q'[create or replace package body ut3$user#.test_package_3 is + procedure test1 is + begin + dbms_output.put_line('test_package_3.test1 executed'); + end; + procedure test2 is + begin + dbms_output.put_line('test_package_3.test2 executed'); + end; + end test_package_3; + ]'; + end; + + procedure drop_ut3$user#_tests is + pragma autonomous_transaction; + begin + execute immediate q'[drop package ut3$user#.test_package_1]'; + execute immediate q'[drop package ut3$user#.test_package_2]'; + execute immediate q'[drop package ut3$user#.test_package_3]'; + end; + + procedure run_proc_no_params is + l_results clob; + begin + execute immediate 'begin ut3$user#.test_package_1.run(); end;'; + l_results := get_dbms_output_as_clob(); + --Assert + ut.expect( l_results ).to_be_like( '%test_package_1%test_package_2%test_package_3%' ); + end; + + procedure run_proc_specific_reporter is + l_results clob; + begin + --Act + execute immediate 'begin ut3$user#.test_package_1.run(:a_reporter); end;' + using in ut3.ut_documentation_reporter(); + l_results := get_dbms_output_as_clob(); + --Assert + ut.expect( l_results ).to_be_like( '%test_package_1%test_package_2%test_package_3%' ); + end; + + procedure run_proc_cov_file_list is + l_results clob; + begin + --Act + execute immediate 'begin ut3$user#.test_package_1.run(a_test_files=>:a_test_files, a_reporter=>:a_reporter); end;' + using + in ut3.ut_varchar2_list('tests/ut3$user#.test_package_1.pkb','tests/ut3$user#.test_package_2.pkb','tests/ut3$user#.test_package_3.pkb'), + in ut3.ut_sonar_test_reporter(); + l_results := get_dbms_output_as_clob(); + --Assert + ut.expect( l_results ).to_be_like( '%tests/ut3$user#.test_package_2.pkb%tests/ut3$user#.test_package_1.pkb%tests/ut3$user#.test_package_3.pkb%' ); + end; + + procedure run_proc_pkg_name is + l_results clob; + begin + execute immediate 'begin ut3$user#.test_package_1.run(:a_path); end;' + using in 'test_package_1'; + l_results := get_dbms_output_as_clob(); + --Assert + ut.expect( l_results ).to_be_like( '%test_package_1%' ); + ut.expect( l_results ).not_to_be_like( '%test_package_2%' ); + ut.expect( l_results ).not_to_be_like( '%test_package_3%' ); + end; + + procedure run_proc_pkg_name_file_list is + l_results clob; + begin + execute immediate 'begin ut3$user#.test_package_1.run(:a_path, :a_test_files, :a_reporter); end;' + using + in 'test_package_3', + in ut3.ut_varchar2_list('tests/ut3$user#.test_package_1.pkb','tests/ut3$user#.test_package_2.pkb','tests/ut3$user#.test_package_3.pkb'), + in ut3.ut_sonar_test_reporter(); + l_results := get_dbms_output_as_clob(); + --Assert + ut.expect( l_results ).to_be_like( '%tests/ut3$user#.test_package_3.pkb%' ); + ut.expect( l_results ).not_to_be_like( '%tests/ut3$user#.test_package_1.pkb%' ); + ut.expect( l_results ).not_to_be_like( '%tests/ut3$user#.test_package_2.pkb%' ); + end; + + procedure run_proc_path_list is + l_results clob; + begin + execute immediate 'begin ut3$user#.test_package_1.run(:a_paths); end;' + using in ut3.ut_varchar2_list(':tests.test_package_1',':tests'); + l_results := get_dbms_output_as_clob(); + --Assert + ut.expect( l_results ).to_be_like( '%test_package_1%' ); + ut.expect( l_results ).to_be_like( '%test_package_2%' ); + ut.expect( l_results ).not_to_be_like( '%test_package_3%' ); + end; + + procedure run_proc_path_list_file_list is + l_results clob; + begin + execute immediate 'begin ut3$user#.test_package_1.run(:a_paths, :a_test_files, :a_reporter); end;' + using + in ut3.ut_varchar2_list(':tests.test_package_1',':tests'), + in ut3.ut_varchar2_list('tests/ut3$user#.test_package_1.pkb','tests/ut3$user#.test_package_2.pkb','tests/ut3$user#.test_package_3.pkb'), + in ut3.ut_sonar_test_reporter(); + l_results := get_dbms_output_as_clob(); + --Assert + ut.expect( l_results ).to_be_like( '%tests/ut3$user#.test_package_1.pkb%' ); + ut.expect( l_results ).to_be_like( '%tests/ut3$user#.test_package_2.pkb%' ); + ut.expect( l_results ).not_to_be_like( '%tests/ut3$user#.test_package_3.pkb%' ); + end; + + procedure run_proc_null_reporter is + l_results clob; + begin + --Act + execute immediate 'begin ut3$user#.test_package_1.run(:a_reporter); end;' + using in cast(null as ut3.ut_reporter_base); + l_results := get_dbms_output_as_clob(); + --Assert + ut.expect( l_results ).to_be_like( '%tests%test_package_1%test_package_2%tests2%test_package_3%' ); + end; + + procedure run_proc_null_path is + l_results clob; + begin + --Act + execute immediate 'begin ut3$user#.test_package_1.run(:a_path); end;' + using in cast(null as varchar2); + l_results := get_dbms_output_as_clob(); + --Assert + ut.expect( l_results ).to_be_like( '%test_package_1%test_package_2%test_package_3%' ); + end; + + procedure run_proc_null_path_list is + l_results clob; + l_paths ut3.ut_varchar2_list; + begin + --Act + execute immediate 'begin ut3$user#.test_package_1.run(:a_paths); end;' + using in l_paths; + l_results := get_dbms_output_as_clob(); + --Assert + ut.expect( l_results ).to_be_like( '%test_package_1%test_package_2%test_package_3%' ); + end; + + procedure run_proc_empty_path_list is + l_results clob; + begin + --Act + execute immediate 'begin ut3$user#.test_package_1.run(:a_paths); end;' + using in ut3.ut_varchar2_list(); + l_results := get_dbms_output_as_clob(); + --Assert + ut.expect( l_results ).to_be_like( '%test_package_1%test_package_2%test_package_3%' ); + end; + + procedure run_func_no_params is + l_results ut3.ut_varchar2_list; + begin + execute immediate 'begin :l_results := ut3$user#.test_package_1.run(); end;' using out l_results; + --Assert + ut.expect( ut3.ut_utils.table_to_clob(l_results) ).to_be_like( '%test_package_1%test_package_2%test_package_3%' ); + end; + + procedure run_func_specific_reporter is + l_results ut3.ut_varchar2_list; + begin + --Act + execute immediate 'begin :l_results := ut3$user#.test_package_1.run(:a_reporter); end;' + using out l_results, in ut3.ut_documentation_reporter(); + --Assert + ut.expect( ut3.ut_utils.table_to_clob(l_results) ).to_be_like( '%test_package_1%test_package_2%test_package_3%' ); + end; + + procedure run_func_cov_file_list is + l_results ut3.ut_varchar2_list; + begin + --Act + execute immediate 'begin :l_results := ut3$user#.test_package_1.run(a_test_files=>:a_test_files, a_reporter=>:a_reporter); end;' + using out l_results, + in ut3.ut_varchar2_list('tests/ut3$user#.test_package_1.pkb','tests/ut3$user#.test_package_2.pkb','tests/ut3$user#.test_package_3.pkb'), + in ut3.ut_sonar_test_reporter(); + --Assert + ut.expect( ut3.ut_utils.table_to_clob(l_results) ).to_be_like( '%tests/ut3$user#.test_package_2.pkb%tests/ut3$user#.test_package_1.pkb%tests/ut3$user#.test_package_3.pkb%' ); + end; + + procedure run_func_pkg_name is + l_results ut3.ut_varchar2_list; + begin + execute immediate 'begin :l_results := ut3$user#.test_package_1.run(:a_path); end;' + using out l_results, in 'test_package_1'; + --Assert + ut.expect( ut3.ut_utils.table_to_clob(l_results) ).to_be_like( '%test_package_bal%' ); + ut.expect( ut3.ut_utils.table_to_clob(l_results) ).not_to_be_like( '%test_package_2%' ); + ut.expect( ut3.ut_utils.table_to_clob(l_results) ).not_to_be_like( '%test_package_3%' ); + end; + + procedure run_func_pkg_name_file_list is + l_results ut3.ut_varchar2_list; + begin + execute immediate 'begin :l_results := ut3$user#.test_package_1.run(:a_path, :a_test_files, :a_reporter); end;' + using out l_results, + in 'test_package_3', + in ut3.ut_varchar2_list('tests/ut3$user#.test_package_1.pkb','tests/ut3$user#.test_package_2.pkb','tests/ut3$user#.test_package_3.pkb'), + in ut3.ut_sonar_test_reporter(); + --Assert + ut.expect( ut3.ut_utils.table_to_clob(l_results) ).to_be_like( '%tests/ut3$user#.test_package_3.pkb%' ); + ut.expect( ut3.ut_utils.table_to_clob(l_results) ).not_to_be_like( '%tests/ut3$user#.test_package_1.pkb%' ); + ut.expect( ut3.ut_utils.table_to_clob(l_results) ).not_to_be_like( '%tests/ut3$user#.test_package_2.pkb%' ); + end; + + procedure run_func_path_list is + l_results ut3.ut_varchar2_list; + begin + execute immediate 'begin :l_results := ut3$user#.test_package_1.run(:a_paths); end;' + using out l_results, in ut3.ut_varchar2_list(':tests.test_package_1',':tests'); + --Assert + ut.expect( ut3.ut_utils.table_to_clob(l_results) ).to_be_like( '%test_package_1%' ); + ut.expect( ut3.ut_utils.table_to_clob(l_results) ).to_be_like( '%test_package_2%' ); + ut.expect( ut3.ut_utils.table_to_clob(l_results) ).not_to_be_like( '%test_package_3%' ); + end; + + procedure run_func_path_list_file_list is + l_results ut3.ut_varchar2_list; + begin + execute immediate 'begin :l_results := ut3$user#.test_package_1.run(:a_paths, :a_test_files, :a_reporter); end;' + using out l_results, + in ut3.ut_varchar2_list(':tests.test_package_1',':tests'), + in ut3.ut_varchar2_list('tests/ut3$user#.test_package_1.pkb','tests/ut3$user#.test_package_2.pkb','tests/ut3$user#.test_package_3.pkb'), + in ut3.ut_sonar_test_reporter(); + --Assert + ut.expect( ut3.ut_utils.table_to_clob(l_results) ).to_be_like( '%tests/ut3$user#.test_package_1.pkb%' ); + ut.expect( ut3.ut_utils.table_to_clob(l_results) ).to_be_like( '%tests/ut3$user#.test_package_2.pkb%' ); + ut.expect( ut3.ut_utils.table_to_clob(l_results) ).not_to_be_like( '%tests/ut3$user#.test_package_3.pkb%' ); + end; + + procedure run_func_null_reporter is + l_results ut3.ut_varchar2_list; + begin + --Act + execute immediate 'begin :l_results := ut3$user#.test_package_1.run(:a_reporter); end;' + using out l_results, in cast(null as ut3.ut_reporter_base); + --Assert + ut.expect( ut3.ut_utils.table_to_clob(l_results) ).to_be_like( '%tests%test_package_1%test_package_2%tests2%test_package_3%' ); + end; + + procedure run_func_null_path is + l_results ut3.ut_varchar2_list; + begin + --Act + execute immediate 'begin :l_results := ut3$user#.test_package_1.run(:a_path); end;' + using out l_results, in cast(null as varchar2); + --Assert + ut.expect( ut3.ut_utils.table_to_clob(l_results) ).to_be_like( '%test_package_1%test_package_2%test_package_3%' ); + end; + + procedure run_func_null_path_list is + l_results ut3.ut_varchar2_list; + l_paths ut3.ut_varchar2_list; + begin + --Act + execute immediate 'begin :l_results := ut3$user#.test_package_1.run(:a_paths); end;' + using out l_results, in l_paths; + --Assert + ut.expect( ut3.ut_utils.table_to_clob(l_results) ).to_be_like( '%test_package_1%test_package_2%test_package_3%' ); + end; + + procedure run_func_empty_path_list is + l_results ut3.ut_varchar2_list; + begin + --Act + execute immediate 'begin :l_results := ut3$user#.test_package_1.run(:a_paths); end;' + using out l_results, in ut3.ut_varchar2_list(); + --Assert + ut.expect( ut3.ut_utils.table_to_clob(l_results) ).to_be_like( '%test_package_1%test_package_2%test_package_3%' ); + end; + + procedure run_func_cov_file_lst_null_rep is + l_results ut3.ut_varchar2_list; + begin + --Act + execute immediate 'begin :l_results := ut3$user#.test_package_1.run(a_test_files=>:a_test_files, a_reporter=>:a_reporter); end;' + using out l_results, + in ut3.ut_varchar2_list('tests/ut3$user#.test_package_1.pkb','tests/ut3$user#.test_package_2.pkb','tests/ut3$user#.test_package_3.pkb'), + in cast(null as ut3.ut_reporter_base); + --Assert + ut.expect( ut3.ut_utils.table_to_clob(l_results) ).to_be_like( '%test_package_1%test_package_2%test_package_3%' ); + end; + + procedure run_func_empty_suite is + l_results ut3.ut_varchar2_list; + l_expected varchar2(32767); + pragma autonomous_transaction; + begin + --Arrange + execute immediate q'[create or replace package empty_suite as + -- %suite + + procedure not_a_test; + end;]'; + execute immediate q'[create or replace package body empty_suite as + procedure not_a_test is begin null; end; + end;]'; + l_expected := '%empty_suite%0 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)%'; + --Act + select * bulk collect into l_results from table(ut3.ut.run('empty_suite')); + + --Assert + ut.expect( ut3.ut_utils.table_to_clob(l_results) ).to_be_like( l_expected ); + + --Cleanup + execute immediate q'[drop package empty_suite]'; + end; + procedure create_test_suite is pragma autonomous_transaction; begin @@ -107,9 +620,7 @@ Failures:% l_actual clob; l_expected varchar2(32767); begin - select * - bulk collect into l_results - from table(ut3.ut.run('failing_invalid_spec')); + select * bulk collect into l_results from table(ut3.ut.run('failing_invalid_spec')); l_actual := ut3.ut_utils.table_to_clob(l_results); ut.expect(l_actual).to_be_like('%Call params for % are not valid: package does not exist or is invalid: %FAILING_INVALID_SPEC%'); @@ -122,19 +633,21 @@ Failures:% pragma autonomous_transaction; begin begin - execute immediate q'[create or replace package failing_invalid_spec as - --%suite - gv_glob_val non_existing_table.id%type := 0; + execute immediate q'[ + create or replace package failing_invalid_spec as + --%suite + gv_glob_val non_existing_table.id%type := 0; - --%test - procedure test1; -end;]'; + --%test + procedure test1; + end;]'; exception when ex_compilation_error then null; end; begin - execute immediate q'[create or replace package body failing_invalid_spec as - procedure test1 is begin ut.expect(1).to_equal(1); end; -end;]'; + execute immediate q'[ + create or replace package body failing_invalid_spec as + procedure test1 is begin ut.expect(1).to_equal(1); end; + end;]'; exception when ex_compilation_error then null; end; end; @@ -153,9 +666,7 @@ end;]'; and o.status = 'INVALID' and o.object_name= :object_name]' into l_is_invalid using user,'INVALID_PCKAG_THAT_REVALIDATES'; - select * - bulk collect into l_results - from table(ut3.ut.run('invalid_pckag_that_revalidates')); + select * bulk collect into l_results from table(ut3.ut.run('invalid_pckag_that_revalidates')); l_actual := ut3.ut_utils.table_to_clob(l_results); ut.expect(1).to_equal(l_is_invalid); @@ -171,33 +682,38 @@ end;]'; pragma autonomous_transaction; begin - execute immediate q'[create or replace package parent_specs as - c_test constant varchar2(1) := 'Y'; -end;]'; + execute immediate q'[ + create or replace package parent_specs as + c_test constant varchar2(1) := 'Y'; + end;]'; - execute immediate q'[create or replace package invalid_pckag_that_revalidates as - --%suite - g_var varchar2(1) := parent_specs.c_test; + execute immediate q'[ + create or replace package invalid_pckag_that_revalidates as + --%suite + g_var varchar2(1) := parent_specs.c_test; - --%test(invalidspecs) - procedure test1; -end;]'; + --%test(invalidspecs) + procedure test1; + end;]'; - execute immediate q'[create or replace package body invalid_pckag_that_revalidates as - procedure test1 is begin ut.expect('Y').to_equal(g_var); end; -end;]'; + execute immediate q'[ + create or replace package body invalid_pckag_that_revalidates as + procedure test1 is begin ut.expect('Y').to_equal(g_var); end; + end;]'; -- That should invalidate test package and we can then revers - execute immediate q'[create or replace package parent_specs as - c_test_error constant varchar2(1) := 'Y'; -end;]'; + execute immediate q'[ + create or replace package parent_specs as + c_test_error constant varchar2(1) := 'Y'; + end;]'; - execute immediate q'[create or replace package parent_specs as - c_test constant varchar2(1) := 'Y'; -end;]'; + execute immediate q'[ + create or replace package parent_specs as + c_test constant varchar2(1) := 'Y'; + end;]'; end; - procedure drop_test_package is + procedure drop_invalid_spec is pragma autonomous_transaction; begin execute immediate 'drop package invalid_pckag_that_revalidates'; diff --git a/test/api/test_ut_run.pks b/test/api/test_ut_run.pks index 5dc6991e5..cd4a78ff3 100644 --- a/test/api/test_ut_run.pks +++ b/test/api/test_ut_run.pks @@ -1,27 +1,106 @@ create or replace package test_ut_run is - --%suite(ut_run) + --%suite(ut.run) + --%suitepath(utplsql.api) + + + --%test(ut.version() returns version of the framework) + procedure ut_version; + + --%test(ut.fail() marks test as failed) + procedure ut_fail; + + procedure create_ut3$user#_tests; + procedure drop_ut3$user#_tests; + + --%context(ut_run_procedure) + --%displayname(ut.run() procedure options) + --%beforeall(create_ut3$user#_tests) + --%afterall(drop_ut3$user#_tests) + + --%test(Runs all tests in current schema with default reporter when no parameters given) + procedure run_proc_no_params; + --%test(Runs all tests in current schema with specified reporter) + procedure run_proc_specific_reporter; + --%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) + procedure run_proc_pkg_name_file_list; + --%test(Runs tests from given paths only with paths list) + procedure run_proc_path_list; + --%test(Runs tests from given paths only with paths list and coverage file list) + procedure run_proc_path_list_file_list; + --%test(Runs all tests in current schema using default reporter when null reporter given) + procedure run_proc_null_reporter; + --%test(Runs all tests in current schema with null path provided) + procedure run_proc_null_path; + --%test(Runs all tests in current schema with null path list given) + procedure run_proc_null_path_list; + --%test(Runs all tests in current schema with empty path list given) + procedure run_proc_empty_path_list; + + --%endcontext - procedure create_test_suite; - procedure drop_test_suite; + + --%context(ut_run_function) + --%displayname(ut.run() function options) + --%beforeall(create_ut3$user#_tests) + --%afterall(drop_ut3$user#_tests) + + --%test(Runs all tests in current schema with default reporter when no parameters given) + procedure run_func_no_params; + --%test(Runs all tests in current schema with specified reporter) + procedure run_func_specific_reporter; + --%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) + procedure run_func_pkg_name_file_list; + --%test(Runs tests from given paths with paths list) + procedure run_func_path_list; + --%test(Runs tests from given paths with paths list and coverage file list) + procedure run_func_path_list_file_list; + --%test(Runs all tests in current schema using default reporter when null reporter given) + procedure run_func_null_reporter; + --%test(Runs all tests in current schema with null path provided) + procedure run_func_null_path; + --%test(Runs all tests in current schema with null path list given) + procedure run_func_null_path_list; + --%test(Runs all tests in current schema with empty path list given) + procedure run_func_empty_path_list; + --%test(Runs all tests in current schema with coverage file list and default reporter) + procedure run_func_cov_file_lst_null_rep; + --%test(Executes successfully an empty suite) + procedure run_func_empty_suite; --%test(ut.run - raises after completing all tests if a test fails with ORA-04068 or ORA-04061) --%beforetest(create_test_suite) --%aftertest(drop_test_suite) procedure raise_in_invalid_state; - + procedure create_test_suite; + procedure drop_test_suite; + --%test(ut.run - Does not execute suite when specified package is not valid) --%beforetest(compile_invalid_package) --%aftertest(drop_invalid_package) procedure run_in_invalid_state; procedure compile_invalid_package; procedure drop_invalid_package; - + --%test(Invalidate package specs via rebuild but still execute package) --%beforetest(generate_invalid_spec) - --%aftertest(drop_test_package) + --%aftertest(drop_invalid_spec) procedure run_and_revalidate_specs; procedure generate_invalid_spec; - procedure drop_test_package; - + procedure drop_invalid_spec; + + --%endcontext + end; / diff --git a/test/core/expectations/binary/test_be_greater_or_equal.pkb b/test/core/expectations/binary/test_be_greater_or_equal.pkb index 7e82adde7..f41878643 100644 --- a/test/core/expectations/binary/test_be_greater_or_equal.pkb +++ b/test/core/expectations/binary/test_be_greater_or_equal.pkb @@ -251,5 +251,13 @@ create or replace package body test_be_greater_or_equal is ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); end; + procedure actual_clob is + begin + --Act + ut3.ut.expect(to_clob('3')).to_( ut3.be_greater_or_equal(3) ); + --Assert + ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); + end; + end; / diff --git a/test/core/expectations/binary/test_be_greater_or_equal.pks b/test/core/expectations/binary/test_be_greater_or_equal.pks index 3aa21b486..077dff59c 100644 --- a/test/core/expectations/binary/test_be_greater_or_equal.pks +++ b/test/core/expectations/binary/test_be_greater_or_equal.pks @@ -90,5 +90,8 @@ create or replace package test_be_greater_or_equal is --%test(Negated - Gives failure when actual timestamp with local time zone is greater than expected) procedure not_actual_timestamp_ltz_gretr; + --%test(Gives failure when running against CLOB) + procedure actual_clob; + end; / diff --git a/test/core/expectations/binary/test_be_greater_than.pkb b/test/core/expectations/binary/test_be_greater_than.pkb index 688200707..5863b11b1 100644 --- a/test/core/expectations/binary/test_be_greater_than.pkb +++ b/test/core/expectations/binary/test_be_greater_than.pkb @@ -251,5 +251,13 @@ create or replace package body test_be_greater_than is ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); end; + procedure actual_clob is + begin + --Act + ut3.ut.expect(to_clob('3')).to_( ut3.be_greater_than(2) ); + --Assert + ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); + end; + end; / diff --git a/test/core/expectations/binary/test_be_greater_than.pks b/test/core/expectations/binary/test_be_greater_than.pks index cb3f666d5..6a1dfcc3e 100644 --- a/test/core/expectations/binary/test_be_greater_than.pks +++ b/test/core/expectations/binary/test_be_greater_than.pks @@ -90,5 +90,8 @@ create or replace package test_be_greater_than is --%test(Negated - Gives failure when actual timestamp with local time zone is greater than expected) procedure not_actual_timestamp_ltz_gretr; + --%test(Gives failure when running against CLOB) + procedure actual_clob; + end; / diff --git a/test/core/expectations/binary/test_be_less_or_equal.pkb b/test/core/expectations/binary/test_be_less_or_equal.pkb index f3ee4bc47..c72e0039b 100644 --- a/test/core/expectations/binary/test_be_less_or_equal.pkb +++ b/test/core/expectations/binary/test_be_less_or_equal.pkb @@ -251,5 +251,13 @@ create or replace package body test_be_less_or_equal is ut.expect( expectations.failed_expectations_data( ) ).to_be_empty(); end; + procedure actual_clob is + begin + --Act + ut3.ut.expect(to_clob('3')).to_( ut3.be_less_or_equal(3) ); + --Assert + ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); + end; + end; / diff --git a/test/core/expectations/binary/test_be_less_or_equal.pks b/test/core/expectations/binary/test_be_less_or_equal.pks index 74f98a412..a6ab01664 100644 --- a/test/core/expectations/binary/test_be_less_or_equal.pks +++ b/test/core/expectations/binary/test_be_less_or_equal.pks @@ -90,5 +90,8 @@ create or replace package test_be_less_or_equal is --%test(Negated - Gives success when actual timestamp with local time zone is greater than expected) procedure not_actual_timestamp_ltz_gretr; + --%test(Gives failure when running against CLOB) + procedure actual_clob; + end; / diff --git a/test/core/expectations/binary/test_equal.pkb b/test/core/expectations/binary/test_equal.pkb index 0e5ab2fdf..dd7dd7a82 100644 --- a/test/core/expectations/binary/test_equal.pkb +++ b/test/core/expectations/binary/test_equal.pkb @@ -95,6 +95,8 @@ create or replace package body test_equal is procedure equal_fail_on_type_diff is begin + test_to_equal_fail('boolean', 'integer', 'true', '1'); + test_to_equal_fail('integer', 'boolean', '1', 'true'); test_to_equal_fail('blob', 'clob', 'to_blob(''ABC'')', '''ABC'''); test_to_equal_fail('clob', 'blob', '''ABC''', 'to_blob(''ABC'')'); test_to_equal_fail('clob', 'anydata', '''ABC''', 'null'); @@ -115,6 +117,8 @@ create or replace package body test_equal is procedure not_equal_fail_on_type_diff is begin + test_not_to_equal_fail('boolean', 'integer', 'true', '1'); + test_not_to_equal_fail('integer', 'boolean', '1', 'true'); test_not_to_equal_fail('blob', 'clob', 'to_blob(''ABC'')', '''ABC'''); test_not_to_equal_fail('clob', 'blob', '''ABC''', 'to_blob(''ABC'')'); test_not_to_equal_fail('clob', 'anydata', '''ABC''', 'null'); @@ -136,6 +140,7 @@ create or replace package body test_equal is procedure failure_on_data_diff is begin test_to_equal_fail('blob', 'to_blob(''abc'')', 'to_blob(''abd'')'); + test_to_equal_fail('boolean', 'false', 'true'); test_to_equal_fail('boolean', 'true', 'false'); test_to_equal_fail('clob', '''Abc''', '''abc'''); test_to_equal_fail('date', 'sysdate', 'sysdate-1'); diff --git a/test/core/expectations/binary/test_expect_to_be_less_than.pkb b/test/core/expectations/binary/test_expect_to_be_less_than.pkb index 987cbf9cd..8f1278db4 100644 --- a/test/core/expectations/binary/test_expect_to_be_less_than.pkb +++ b/test/core/expectations/binary/test_expect_to_be_less_than.pkb @@ -251,5 +251,13 @@ create or replace package body test_expect_to_be_less_than is ut.expect( expectations.failed_expectations_data( ) ).to_be_empty( ); end; + procedure actual_clob is + begin + --Act + ut3.ut.expect(to_clob('3')).to_( ut3.be_less_than(4) ); + --Assert + ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); + end; + end; / diff --git a/test/core/expectations/binary/test_expect_to_be_less_than.pks b/test/core/expectations/binary/test_expect_to_be_less_than.pks index 785c5c122..67e6b8776 100644 --- a/test/core/expectations/binary/test_expect_to_be_less_than.pks +++ b/test/core/expectations/binary/test_expect_to_be_less_than.pks @@ -90,5 +90,8 @@ create or replace package test_expect_to_be_less_than is --%test(Negated - Gives success when actual timestamp with local time zone is greater than expected) procedure not_actual_timestamp_ltz_gretr; + --%test(Gives failure when running against CLOB) + procedure actual_clob; + end; / diff --git a/test/core/expectations/test_expectation_processor.pkb b/test/core/expectations/test_expectation_processor.pkb new file mode 100644 index 000000000..17ffbec3c --- /dev/null +++ b/test/core/expectations/test_expectation_processor.pkb @@ -0,0 +1,71 @@ +create or replace package body test_expectation_processor is + + procedure who_called_expectation is + l_stack_trace varchar2(4000); + l_source_line varchar2(4000); + begin + l_stack_trace := q'[----- PL/SQL Call Stack ----- + object line object + handle number name +34f88e4420 124 package body SCH_TEST.UT_EXPECTATION_PROCESSOR +353dfeb2f8 26 SCH_TEST.UT_EXPECTATION_RESULT +cba249ce0 112 SCH_TEST.UT_EXPECTATION +3539881cf0 21 SCH_TEST.UT_EXPECTATION_NUMBER +351a608008 28 package body SCH_TEST.TPKG_PRIOR_YEAR_GENERATION +351a6862b8 6 anonymous block +351fe31010 1825 package body SYS.DBMS_SQL +20befbe4d8 129 SCH_TEST.UT_EXECUTABLE +20befbe4d8 65 SCH_TEST.UT_EXECUTABLE +34f8ab7cd8 80 SCH_TEST.UT_TEST +34f8ab98f0 48 SCH_TEST.UT_SUITE_ITEM +34f8ab9b10 74 SCH_TEST.UT_SUITE +34f8ab98f0 48 SCH_TEST.UT_SUITE_ITEM +cba24bfd0 75 SCH_TEST.UT_LOGICAL_SUITE +353dfecf30 59 SCH_TEST.UT_RUN +34f8ab98f0 48 SCH_TEST.UT_SUITE_ITEM +357f5421e8 77 package body SCH_TEST.UT_RUNNER +357f5421e8 111 package body SCH_TEST.UT_RUNNER +20be951ab0 292 package body SCH_TEST.UT +20be951ab0 320 package body SCH_TEST.UT +]'; + ut.expect( + ut3.ut_expectation_processor.who_called_expectation(l_stack_trace) + ).to_be_like('at "SCH_TEST.TPKG_PRIOR_YEAR_GENERATION", line 28 %'); + end; + + + procedure who_called_expectation_0x is + l_stack_trace varchar2(4000); + l_source_line varchar2(4000); + begin + l_stack_trace := q'[----- PL/SQL Call Stack ----- + object line object + handle number name +34f88e4420 124 package body SCH_TEST.UT_EXPECTATION_PROCESSOR +353dfeb2f8 26 SCH_TEST.UT_EXPECTATION_RESULT +cba249ce0 112 SCH_TEST.UT_EXPECTATION +3539881cf0 21 SCH_TEST.UT_EXPECTATION_NUMBER +351a608008 28 package body SCH_TEST.TPKG_PRIOR_YEAR_GENERATION +351a6862b8 6 anonymous block +351fe31010 1825 package body SYS.DBMS_SQL +20befbe4d8 129 SCH_TEST.UT_EXECUTABLE +20befbe4d8 65 SCH_TEST.UT_EXECUTABLE +34f8ab7cd8 80 SCH_TEST.UT_TEST +34f8ab98f0 48 SCH_TEST.UT_SUITE_ITEM +34f8ab9b10 74 SCH_TEST.UT_SUITE +34f8ab98f0 48 SCH_TEST.UT_SUITE_ITEM +cba24bfd0 75 SCH_TEST.UT_LOGICAL_SUITE +353dfecf30 59 SCH_TEST.UT_RUN +34f8ab98f0 48 SCH_TEST.UT_SUITE_ITEM +357f5421e8 77 package body SCH_TEST.UT_RUNNER +357f5421e8 111 package body SCH_TEST.UT_RUNNER +20be951ab0 292 package body SCH_TEST.UT +20be951ab0 320 package body SCH_TEST.UT +]'; + ut.expect( + ut3.ut_expectation_processor.who_called_expectation(l_stack_trace) + ).to_be_like('at "SCH_TEST.TPKG_PRIOR_YEAR_GENERATION", line 28 %'); + end; + +end; +/ diff --git a/test/core/expectations/test_expectation_processor.pks b/test/core/expectations/test_expectation_processor.pks new file mode 100644 index 000000000..ecde48153 --- /dev/null +++ b/test/core/expectations/test_expectation_processor.pks @@ -0,0 +1,17 @@ +create or replace package test_expectation_processor is + + --%suite(expectation_processor) + --%suitepath(utplsql.core.expectations) + + --%context(who_called_expectation) + + --%test(parses stack trace and returns object and line that called expectation) + procedure who_called_expectation; + + --%test(parses stack trace containing 0x and returns object and line that called expectation) + procedure who_called_expectation_0x; + + --%endcontext + +end; +/ diff --git a/test/core/expectations/test_expectations_cursor.pkb b/test/core/expectations/test_expectations_cursor.pkb index aa0615e4a..d18cef5fb 100644 --- a/test/core/expectations/test_expectations_cursor.pkb +++ b/test/core/expectations/test_expectations_cursor.pkb @@ -325,10 +325,10 @@ create or replace package body test_expectations_cursor is l_second number := 1/24/60/60; begin --Arrange - ut.set_nls; + ut3.ut.set_nls; open l_actual for select l_date as some_date from dual; open l_expected for select l_date-l_second some_date from dual; - ut.reset_nls; + ut3.ut.reset_nls; --Act ut3.ut.expect( l_actual ).to_equal( l_expected ); --Assert diff --git a/test/core/expectations/test_matchers.pkb b/test/core/expectations/test_matchers.pkb index cbc265319..e66f7c750 100644 --- a/test/core/expectations/test_matchers.pkb +++ b/test/core/expectations/test_matchers.pkb @@ -64,7 +64,7 @@ create or replace package body test_matchers is cleanup_expectations(); end exec_be_between2; - procedure exec_be_like(a_type varchar2, a_value varchar2, a_pattern varchar2, a_escape varchar2, a_result integer, a_prefix varchar2) is + procedure exec_be_like(a_type varchar2, a_value varchar2, a_pattern varchar2, a_escape varchar2, a_result integer, a_prefix varchar2 default null) is begin execute immediate 'declare @@ -156,6 +156,7 @@ create or replace package body test_matchers is exec_be_between2('timestamp with time zone', 'null', 'systimestamp-1', 'systimestamp+1', ut3.ut_utils.gc_failure, ''); exec_be_between2('interval year to month', 'null', '''2-0''', '''2-2''', ut3.ut_utils.gc_failure, ''); exec_be_between2('interval day to second', 'null', '''2 00:59:58''', '''2 01:00:01''', ut3.ut_utils.gc_failure, ''); + exec_be_between2('date', 'null', 'sysdate-2', 'sysdate-1', ut3.ut_utils.gc_failure, 'not_'); exec_be_between2('number', 'null', '1.99', '1.999', ut3.ut_utils.gc_failure, 'not_'); exec_be_between2('varchar2(1)', 'null', '''a''', '''b''', ut3.ut_utils.gc_failure, 'not_'); @@ -174,6 +175,7 @@ create or replace package body test_matchers is exec_be_between2('timestamp with time zone', 'systimestamp', 'null', 'systimestamp+1', ut3.ut_utils.gc_failure, ''); exec_be_between2('interval year to month', '''2-1''', 'null', '''2-2''', ut3.ut_utils.gc_failure, ''); exec_be_between2('interval day to second', '''2 01:00:00''', 'null', '''2 01:00:01''', ut3.ut_utils.gc_failure, ''); + exec_be_between2('date', 'sysdate', 'null', 'sysdate-1', ut3.ut_utils.gc_failure, 'not_'); exec_be_between2('number', '2.0', 'null', '1.999', ut3.ut_utils.gc_failure, 'not_'); exec_be_between2('varchar2(1)', '''b''', 'null', '''b''', ut3.ut_utils.gc_failure, 'not_'); @@ -182,19 +184,21 @@ create or replace package body test_matchers is exec_be_between2('timestamp with time zone', 'systimestamp+1', 'null', 'systimestamp', ut3.ut_utils.gc_failure, 'not_'); exec_be_between2('interval year to month', '''2-2''', 'null', '''2-1''', ut3.ut_utils.gc_failure, 'not_'); exec_be_between2('interval day to second', '''2 01:00:00''', 'null', '''2 00:59:59''', ut3.ut_utils.gc_failure, 'not_'); + --Fails for unsupported data-type + exec_be_between2('clob', '''b''', '''a''', '''c''', ut3.ut_utils.gc_failure, ''); end; procedure test_match is begin - exec_match('varchar2(100)', '''Stephen''', '^Ste(v|ph)en$', '', ut3.ut_utils.gc_success, ''); - exec_match('varchar2(100)', '''sTEPHEN''', '^Ste(v|ph)en$', 'i', ut3.ut_utils.gc_success, ''); - exec_match('clob', 'rpad('', '',32767)||''Stephen''', 'Ste(v|ph)en$', '', ut3.ut_utils.gc_success, ''); - exec_match('clob', 'rpad('', '',32767)||''sTEPHEN''', 'Ste(v|ph)en$', 'i', ut3.ut_utils.gc_success, ''); + exec_match('varchar2(100)', '''Stephen''', '^Ste(v|ph)en$', '', ut3.ut_utils.gc_success); + exec_match('varchar2(100)', '''sTEPHEN''', '^Ste(v|ph)en$', 'i', ut3.ut_utils.gc_success); + exec_match('clob', 'rpad('', '',32767)||''Stephen''', 'Ste(v|ph)en$', '', ut3.ut_utils.gc_success); + exec_match('clob', 'rpad('', '',32767)||''sTEPHEN''', 'Ste(v|ph)en$', 'i', ut3.ut_utils.gc_success); - exec_match('varchar2(100)', '''Stephen''', '^Steven$', '', ut3.ut_utils.gc_failure, ''); - exec_match('varchar2(100)', '''sTEPHEN''', '^Steven$', 'i', ut3.ut_utils.gc_failure, ''); - exec_match('clob', 'to_clob(rpad('', '',32767)||''Stephen'')', '^Stephen', '', ut3.ut_utils.gc_failure, ''); - exec_match('clob', 'to_clob(rpad('', '',32767)||''sTEPHEN'')', '^Stephen', 'i', ut3.ut_utils.gc_failure, ''); + exec_match('varchar2(100)', '''Stephen''', '^Steven$', '', ut3.ut_utils.gc_failure); + exec_match('varchar2(100)', '''sTEPHEN''', '^Steven$', 'i', ut3.ut_utils.gc_failure); + exec_match('clob', 'to_clob(rpad('', '',32767)||''Stephen'')', '^Stephen', '', ut3.ut_utils.gc_failure); + exec_match('clob', 'to_clob(rpad('', '',32767)||''sTEPHEN'')', '^Stephen', 'i', ut3.ut_utils.gc_failure); exec_match('varchar2(100)', '''Stephen''', '^Ste(v|ph)en$', '', ut3.ut_utils.gc_failure, 'not_'); exec_match('varchar2(100)', '''sTEPHEN''', '^Ste(v|ph)en$', 'i', ut3.ut_utils.gc_failure, 'not_'); @@ -205,19 +209,21 @@ create or replace package body test_matchers is exec_match('varchar2(100)', '''sTEPHEN''', '^Steven$', 'i', ut3.ut_utils.gc_success, 'not_'); exec_match('clob', 'to_clob(rpad('', '',32767)||''Stephen'')', '^Stephen', '', ut3.ut_utils.gc_success, 'not_'); exec_match('clob', 'to_clob(rpad('', '',32767)||''sTEPHEN'')', '^Stephen', 'i', ut3.ut_utils.gc_success, 'not_'); + --Fails for unsupported data-type + exec_match('number', '12345', '^123.*', 'i', ut3.ut_utils.gc_failure); end; procedure test_be_like is begin - exec_be_like('varchar2(100)', '''Stephen_King''', 'Ste__en%', '', ut3.ut_utils.gc_success, ''); - exec_be_like('varchar2(100)', '''Stephen_King''', 'Ste__en\_K%', '\', ut3.ut_utils.gc_success, ''); - exec_be_like('clob', 'rpad(''a'',32767,''a'')||''Stephen_King''', 'a%Ste__en%', '', ut3.ut_utils.gc_success, ''); - exec_be_like('clob', 'rpad(''a'',32767,''a'')||''Stephen_King''', 'a%Ste__en\_K%', '\', ut3.ut_utils.gc_success, ''); + exec_be_like('varchar2(100)', '''Stephen_King''', 'Ste__en%', '', ut3.ut_utils.gc_success); + exec_be_like('varchar2(100)', '''Stephen_King''', 'Ste__en\_K%', '\', ut3.ut_utils.gc_success); + exec_be_like('clob', 'rpad(''a'',32767,''a'')||''Stephen_King''', 'a%Ste__en%', '', ut3.ut_utils.gc_success); + exec_be_like('clob', 'rpad(''a'',32767,''a'')||''Stephen_King''', 'a%Ste__en\_K%', '\', ut3.ut_utils.gc_success); - exec_be_like('varchar2(100)', '''Stephen_King''', 'Ste_en%', '', ut3.ut_utils.gc_failure, ''); - exec_be_like('varchar2(100)', '''Stephen_King''', 'Stephe\__%', '\', ut3.ut_utils.gc_failure, ''); - exec_be_like('clob', 'rpad(''a'',32767,''a'')||''Stephen_King''', 'a%Ste_en%', '', ut3.ut_utils.gc_failure, ''); - exec_be_like('clob', 'rpad(''a'',32767,''a'')||''Stephen_King''', 'a%Stephe\__%', '\', ut3.ut_utils.gc_failure, ''); + exec_be_like('varchar2(100)', '''Stephen_King''', 'Ste_en%', '', ut3.ut_utils.gc_failure); + exec_be_like('varchar2(100)', '''Stephen_King''', 'Stephe\__%', '\', ut3.ut_utils.gc_failure); + exec_be_like('clob', 'rpad(''a'',32767,''a'')||''Stephen_King''', 'a%Ste_en%', '', ut3.ut_utils.gc_failure); + exec_be_like('clob', 'rpad(''a'',32767,''a'')||''Stephen_King''', 'a%Stephe\__%', '\', ut3.ut_utils.gc_failure); exec_be_like('varchar2(100)', '''Stephen_King''', 'Ste__en%', '', ut3.ut_utils.gc_failure, 'not_'); exec_be_like('varchar2(100)', '''Stephen_King''', 'Ste__en\_K%', '\', ut3.ut_utils.gc_failure, 'not_'); @@ -228,6 +234,9 @@ create or replace package body test_matchers is exec_be_like('varchar2(100)', '''Stephen_King''', 'Stephe\__%', '\', ut3.ut_utils.gc_success, 'not_'); exec_be_like('clob', 'rpad(''a'',32767,''a'')||''Stephen_King''', 'a%Ste_en%', '', ut3.ut_utils.gc_success, 'not_'); exec_be_like('clob', 'rpad(''a'',32767,''a'')||''Stephen_King''', 'a%Stephe\__%', '\', ut3.ut_utils.gc_success, 'not_'); + + --Fails for unsupported data-type + exec_be_like('number', '12345', '123%', '', ut3.ut_utils.gc_failure); end; procedure test_timestamp_between is diff --git a/test/core/reporters/test_teamcity_reporter.pkb b/test/core/reporters/test_teamcity_reporter.pkb new file mode 100644 index 000000000..e3c05003f --- /dev/null +++ b/test/core/reporters/test_teamcity_reporter.pkb @@ -0,0 +1,52 @@ +create or replace package body test_teamcity_reporter as + + procedure report_produces_expected_out is + l_output_data ut3.ut_varchar2_list; + l_output clob; + l_expected varchar2(32767); + begin + l_expected := q'{%##teamcity[testSuiteStarted timestamp='%' name='utplsqlorg'] +%##teamcity[testSuiteStarted timestamp='%' name='utplsqlorg.helpers'] +%##teamcity[testSuiteStarted timestamp='%' name='utplsqlorg.helpers.tests'] +%##teamcity[testSuiteStarted timestamp='%' name='utplsqlorg.helpers.tests.test'] +%##teamcity[testSuiteStarted timestamp='%' name='utplsqlorg.helpers.tests.test.test_reporters'] +%##teamcity[testSuiteStarted timestamp='%' name='A suite for testing different outcomes from reporters'] +%##teamcity[testStarted timestamp='%' captureStandardOutput='true' name='ut3_tester.test_reporters.passing_test'] + + + + + +%##teamcity[testFinished timestamp='%' duration='%' name='ut3_tester.test_reporters.passing_test'] +%##teamcity[testStarted timestamp='%' captureStandardOutput='true' name='ut3_tester.test_reporters.failing_test'] + + + +%##teamcity[testFailed timestamp='%' message='Fails as values are different' name='ut3_tester.test_reporters.failing_test'] +%##teamcity[testFinished timestamp='%' duration='%' name='ut3_tester.test_reporters.failing_test'] +%##teamcity[testStarted timestamp='%' captureStandardOutput='true' name='ut3_tester.test_reporters.erroring_test'] + + + +%##teamcity[testStdErr timestamp='%' name='ut3_tester.test_reporters.erroring_test' out='Test exception:|rORA-06512: at |"UT3_TESTER.TEST_REPORTERS|", line %|rORA-06512: at %|r|r'] +%##teamcity[testFailed timestamp='%' details='Test exception:|rORA-06512: at |"UT3_TESTER.TEST_REPORTERS|", line %|rORA-06512: at %|r|r' message='Error occured' name='ut3_tester.test_reporters.erroring_test'] +%##teamcity[testFinished timestamp='%' duration='%' name='ut3_tester.test_reporters.erroring_test'] +%##teamcity[testStarted timestamp='%' captureStandardOutput='true' name='ut3_tester.test_reporters.disabled_test'] +%##teamcity[testIgnored timestamp='%' name='ut3_tester.test_reporters.disabled_test'] +%##teamcity[testSuiteFinished timestamp='%' name='A suite for testing different outcomes from reporters'] +%##teamcity[testSuiteFinished timestamp='%' name='utplsqlorg.helpers.tests.test.test_reporters'] +%##teamcity[testSuiteFinished timestamp='%' name='utplsqlorg.helpers.tests.test'] +%##teamcity[testSuiteFinished timestamp='%' name='utplsqlorg.helpers.tests'] +%##teamcity[testSuiteFinished timestamp='%' name='utplsqlorg.helpers'] +%##teamcity[testSuiteFinished timestamp='%' name='utplsqlorg']}'; + --act + select * + bulk collect into l_output_data + from table(ut3.ut.run('test_reporters',ut3.ut_teamcity_reporter())); + + --assert + ut.expect(ut3.ut_utils.table_to_clob(l_output_data)).to_be_like(l_expected); + end; + +end; +/ diff --git a/test/core/reporters/test_teamcity_reporter.pks b/test/core/reporters/test_teamcity_reporter.pks new file mode 100644 index 000000000..277044417 --- /dev/null +++ b/test/core/reporters/test_teamcity_reporter.pks @@ -0,0 +1,10 @@ +create or replace package test_teamcity_reporter as + + --%suite(ut_teamcity_reporter) + --%suitepath(utplsql.core.reporters) + + --%test(Report produces expected output) + procedure report_produces_expected_out; + +end; +/ diff --git a/test/core/test_output_buffer.pks b/test/core/test_output_buffer.pks index 6311d2275..1392b39ad 100644 --- a/test/core/test_output_buffer.pks +++ b/test/core/test_output_buffer.pks @@ -3,7 +3,7 @@ create or replace package test_output_buffer is --%suite(output_buffer) --%suitepath(utplsql.core) - --%test(Recieves a line from buffer table and deletes) + --%test(Receives a line from buffer table and deletes) procedure test_recieve; --%test(Does not send line if null text given) diff --git a/test/core/test_suite_builder.pkb b/test/core/test_suite_builder.pkb index 90c6c166f..df5e4e7c9 100644 --- a/test/core/test_suite_builder.pkb +++ b/test/core/test_suite_builder.pkb @@ -664,15 +664,15 @@ create or replace package body test_suite_builder is begin --Arrange l_annotations := ut3.ut_annotations( - ut3.ut_annotation(1, 'suite','Cool', null), - ut3.ut_annotation(2, 'test','In suite', 'suite_level_test'), - ut3.ut_annotation(3, 'context','a_context', null), - ut3.ut_annotation(4, 'beforeall',null, 'context_beforeall'), - ut3.ut_annotation(5, 'beforeeach',null, 'context_beforeeach'), + ut3.ut_annotation(1, 'suite', 'Cool', null), + ut3.ut_annotation(2, 'test', 'In suite', 'suite_level_test'), + ut3.ut_annotation(3, 'context', 'a_context', null), + ut3.ut_annotation(4, 'beforeall', 'context_beforeall', null), + ut3.ut_annotation(5, 'beforeeach', null, 'context_beforeeach'), ut3.ut_annotation(6, 'test', 'In context', 'test_in_a_context'), - ut3.ut_annotation(7, 'aftereach',null, 'context_aftereach'), - ut3.ut_annotation(8, 'afterall',null, 'context_afterall'), - ut3.ut_annotation(9, 'endcontext',null, null) + ut3.ut_annotation(7, 'aftereach', 'context_aftereach' ,null), + ut3.ut_annotation(8, 'afterall', null, 'context_afterall'), + ut3.ut_annotation(9, 'endcontext', null, null) ); --Act l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); diff --git a/test/install_tests.sql b/test/install_tests.sql index e7c9e1f62..e0a5d6d9f 100644 --- a/test/install_tests.sql +++ b/test/install_tests.sql @@ -23,6 +23,7 @@ whenever oserror exit failure rollback @@core/annotations/test_annotation_parser.pks @@core/annotations/test_annotation_manager.pks @@core/annotations/test_before_after_test_annotation.pks +@@core/expectations/test_expectation_processor.pks @@core/expectations/test_matchers.pks @@core/test_output_buffer.pks @@core/test_file_mapper.pks @@ -44,6 +45,7 @@ set define on set define off @@core/reporters/test_tfs_junit_reporter.pks @@core/reporters/test_sonar_test_reporter.pks +@@core/reporters/test_teamcity_reporter.pks @@core/expectations.pks @@core/expectations/binary/test_be_greater_or_equal.pks @@core/expectations/binary/test_be_greater_than.pks @@ -68,6 +70,7 @@ set define off @@core/test_ut_test.pkb @@core/annotations/test_annotation_parser.pkb @@core/annotations/test_annotation_manager.pkb +@@core/expectations/test_expectation_processor.pkb @@core/expectations/test_matchers.pkb @@core/annotations/test_before_after_test_annotation.pkb @@core/test_output_buffer.pkb @@ -90,6 +93,7 @@ set define on set define off @@core/reporters/test_tfs_junit_reporter.pkb @@core/reporters/test_sonar_test_reporter.pkb +@@core/reporters/test_teamcity_reporter.pkb @@core/expectations.pkb @@core/expectations/binary/test_be_greater_or_equal.pkb @@core/expectations/binary/test_be_greater_than.pkb From f0b2ddf4a6e1bae6a222c3dfd363ed16d5724c57 Mon Sep 17 00:00:00 2001 From: Jacek Gebal Date: Mon, 16 Jul 2018 00:36:19 +0100 Subject: [PATCH 161/184] Fixed issue with case statement. --- source/check_object_grants.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/check_object_grants.sql b/source/check_object_grants.sql index 729bdceda..705882bd2 100644 --- a/source/check_object_grants.sql +++ b/source/check_object_grants.sql @@ -19,7 +19,7 @@ declare begin l_target_table := get_view('dba_tab_privs'); - l_owner_column := case when l_target_table like 'DBA%' then 'owner' else 'table_schema' end; + l_owner_column := case when l_target_table like 'dba%' then 'owner' else 'table_schema' end; execute immediate q'[ select listagg(' - '||object_name,CHR(10)) within group(order by object_name) from ( From 50204ce7abec711c13e022f39c849e86f21058b6 Mon Sep 17 00:00:00 2001 From: Travis CI Date: Mon, 16 Jul 2018 11:58:15 +0000 Subject: [PATCH 162/184] Updated project version after build [skip ci] --- source/core/ut_utils.pks | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/core/ut_utils.pks b/source/core/ut_utils.pks index e137b5e9d..e1c761d84 100644 --- a/source/core/ut_utils.pks +++ b/source/core/ut_utils.pks @@ -21,7 +21,7 @@ create or replace package ut_utils authid definer is * */ - gc_version constant varchar2(50) := 'v3.1.2.2081-develop'; + gc_version constant varchar2(50) := 'v3.1.2.2093-develop'; /* Constants: Event names */ subtype t_event_name is varchar2(30); From a1007e4f712a5251a0868aedba43205d414431e8 Mon Sep 17 00:00:00 2001 From: Jacek Gebal Date: Mon, 16 Jul 2018 23:50:46 +0100 Subject: [PATCH 163/184] Updated documentation. Resolves #717 --- docs/userguide/annotations.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/userguide/annotations.md b/docs/userguide/annotations.md index 9bcb7907f..a6e8ea71b 100644 --- a/docs/userguide/annotations.md +++ b/docs/userguide/annotations.md @@ -21,7 +21,7 @@ We strongly recommend putting package level annotations at the very top of packa | `--%suitepath()` | Package | Similar to java package. The annotation allows logical grouping of suites into hierarchies. | | `--%displayname()` | Package/procedure | Human-readable and meaningful description of a suite/test. `%displayname(Name of the suite/test)`. The annotation is provided for flexibility and convenience only. It has exactly the same meaning as `` in `test` and `suite` annotations. If description is provided using both `suite`/`test` and `displayname`, then the one defined as last takes precedence. | | `--%test()` | Procedure | Denotes that the annotated procedure is a unit test procedure. Optional test description can by provided (see `displayname`). | -| `--%throws([,[,...]])`| Procedure | Denotes that the annotated procedure must throw one of the exception numbers provided. If no valid numbers were provided as annotation parameters the annotation is ignored. Applicable to test procedures only. | +| `--%throws([,...])`| Procedure | Denotes that the annotated test procedure must throw one of the exceptions provided. Supported forms of exceptions are: numeric literals, numeric contant names, exception constant names, predefined Oracle exception names. | | `--%beforeall` | Procedure | Denotes that the annotated procedure should be executed once before all elements of the suite. | | `--%beforeall([[.].][,...])` | Package | Denotes that the mentioned procedure(s) should be executed once before all elements of the suite. | | `--%afterall` | Procedure | Denotes that the annotated procedure should be executed once after all elements of the suite. | @@ -1081,6 +1081,7 @@ Below test suite defines: ```sql create or replace package test_rooms_management is + gc_null_value_exception constant integer := -1400; --%suite(Rooms management) --%beforeall @@ -1104,11 +1105,11 @@ create or replace package test_rooms_management is --%description(Add content to a room) --%test(Fails when room name is not valid) - --%throws(-1403) + --%throws(no_data_found) procedure fails_on_room_name_invalid; --%test(Fails when content name is null) - --%throws(-1400) + --%throws(gc_null_value_exception) procedure fails_on_content_null; --%test(Adds a content to existing room) @@ -1170,7 +1171,7 @@ create or replace package body test_rooms_management is begin --Act add_rooms_content('Dining Room',null); - --Assert by --%throws annotation + --Assert done by --%throws annotation end; procedure add_content_success is From fbd45148b33863b9731b5f000dc23b8e39ad6582 Mon Sep 17 00:00:00 2001 From: Jacek Gebal Date: Tue, 17 Jul 2018 00:27:25 +0100 Subject: [PATCH 164/184] Added reporting of warnings for unknown annotations. Resolves #624 --- source/core/ut_suite_builder.pkb | 44 +++++++++++++++++++++++++++++++- test/core/test_suite_builder.pkb | 34 +++++++++++++++++++++++- test/core/test_suite_builder.pks | 13 +++++++++- 3 files changed, 88 insertions(+), 3 deletions(-) diff --git a/source/core/ut_suite_builder.pkb b/source/core/ut_suite_builder.pkb index bc2d20b36..5baf7d349 100644 --- a/source/core/ut_suite_builder.pkb +++ b/source/core/ut_suite_builder.pkb @@ -37,6 +37,27 @@ create or replace package body ut_suite_builder is gc_context constant t_annotation_name := 'context'; gc_endcontext constant t_annotation_name := 'endcontext'; + type tt_annotations is table of t_annotation_name; + + gc_supported_annotations constant tt_annotations + := tt_annotations( + gc_suite, + gc_suitepath, + gc_test, + gc_disabled, + gc_displayname, + gc_beforeall, + gc_beforeeach, + gc_beforetest, + gc_afterall, + gc_aftereach, + gc_aftertest, + gc_throws, + gc_rollback, + gc_context, + gc_endcontext + ); + gc_placeholder constant varchar2(3) := '\\%'; gc_integer_exception constant varchar2(1) := 'I'; @@ -757,7 +778,27 @@ create or replace package body ut_suite_builder is end loop; end if; end; - + + procedure warning_on_unknown_annotations( + a_suite in out nocopy ut_suite_item, + a_annotations tt_annotations_by_line + ) is + l_line_no t_annotation_position := a_annotations.first; + begin + while l_line_no is not null loop + if a_annotations(l_line_no).name not member of (gc_supported_annotations) then + add_annotation_ignored_warning( + a_suite, + a_annotations(l_line_no).name, + 'Unsupported annotation %%%.', + l_line_no, + a_annotations(l_line_no).procedure_name + ); + end if; + l_line_no := a_annotations.next(l_line_no); + end loop; + end; + function create_suite( a_annotations t_annotations_info ) return ut_logical_suite is @@ -771,6 +812,7 @@ create or replace package body ut_suite_builder is l_suite := ut_suite(l_annotations.owner, l_annotations.name); l_annotation_pos := l_annotations.by_name( gc_suite).first; l_suite.description := l_annotations.by_name( gc_suite)( l_annotation_pos); + warning_on_unknown_annotations(l_suite, l_annotations.by_line); warning_on_duplicate_annot( l_suite, l_annotations.by_name, gc_suite ); diff --git a/test/core/test_suite_builder.pkb b/test/core/test_suite_builder.pkb index 90c6c166f..4b9630194 100644 --- a/test/core/test_suite_builder.pkb +++ b/test/core/test_suite_builder.pkb @@ -1020,5 +1020,37 @@ create or replace package body test_suite_builder is ); end; -end; + procedure test_bad_procedure_annotation is + l_actual clob; + l_annotations ut3.ut_annotations; + begin + --Arrange + l_annotations := ut3.ut_annotations( + ut3.ut_annotation(1, 'suite','Cool', null), + ut3.ut_annotation(2, 'bad_procedure_annotation',null, 'some_procedure'), + ut3.ut_annotation(6, 'test','A test', 'do_stuff') + ); + --Act + l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); + --Assert + ut.expect(l_actual).to_be_like('%Unsupported annotation "--\%bad_procedure_annotation". Annotation ignored.% line 2%', '\'); + end; + + procedure test_bad_package_annotation is + l_actual clob; + l_annotations ut3.ut_annotations; + begin + --Arrange + l_annotations := ut3.ut_annotations( + ut3.ut_annotation(1, 'suite','Cool', null), + ut3.ut_annotation(17, 'bad_package_annotation',null, null), + ut3.ut_annotation(24, 'test','A test', 'do_stuff') + ); + --Act + l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); + --Assert + ut.expect(l_actual).to_be_like('%Unsupported annotation "--\%bad_package_annotation". Annotation ignored.% line 17%', '\'); + end; + +end test_suite_builder; / diff --git a/test/core/test_suite_builder.pks b/test/core/test_suite_builder.pks index f9548afd3..36517432b 100644 --- a/test/core/test_suite_builder.pks +++ b/test/core/test_suite_builder.pks @@ -163,5 +163,16 @@ create or replace package test_suite_builder is --%endcontext -end; + --%context(unknown_annotation) + --%displayname(--%bad_annotation) + + --%test(Gives warning when unknown procedure level annotation passed) + procedure test_bad_procedure_annotation; + + --%test(Gives warning when unknown package level annotation passed) + procedure test_bad_package_annotation; + + --%endcontext + +end test_suite_builder; / From 26faed22ce2650a172f978ea25339398a39559a4 Mon Sep 17 00:00:00 2001 From: Travis CI Date: Mon, 16 Jul 2018 23:31:37 +0000 Subject: [PATCH 165/184] Updated project version after build [skip ci] --- source/core/ut_utils.pks | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/core/ut_utils.pks b/source/core/ut_utils.pks index e1c761d84..905be31f7 100644 --- a/source/core/ut_utils.pks +++ b/source/core/ut_utils.pks @@ -21,7 +21,7 @@ create or replace package ut_utils authid definer is * */ - gc_version constant varchar2(50) := 'v3.1.2.2093-develop'; + gc_version constant varchar2(50) := 'v3.1.2.2096-develop'; /* Constants: Event names */ subtype t_event_name is varchar2(30); From dc49e49bd6a3c04a11a2dc87126ba1fde2d0f121 Mon Sep 17 00:00:00 2001 From: Jacek Gebal Date: Tue, 17 Jul 2018 00:57:42 +0100 Subject: [PATCH 166/184] Fixed issue with sonar scanner failing on PRs from other repositories. --- .travis/run_sonar_scanner.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis/run_sonar_scanner.sh b/.travis/run_sonar_scanner.sh index d05b5806e..b3a051df8 100755 --- a/.travis/run_sonar_scanner.sh +++ b/.travis/run_sonar_scanner.sh @@ -30,9 +30,10 @@ else fi -#Are we running on develop branch ? +#Are we running on utPLSQL repo and not an external PR? echo "Check if we running from develop or on branch" -if [ "${TRAVIS_REPO_SLUG}" = "${UTPLSQL_REPO}" ] && [[ ! "${BRANCH}" =~ ^(release/v[0-9]+\.[0-9]+\.[0-9]+.*|"${MAIN_DEV_BRANCH}")$ ]]; then +if [ "${TRAVIS_REPO_SLUG}" = "${UTPLSQL_REPO}" ] && [ "${TRAVIS_PULL_REQUEST_SLUG}" = "${TRAVIS_REPO_SLUG}" ] && \ + [[ ! "${BRANCH}" =~ ^(release/v[0-9]+\.[0-9]+\.[0-9]+.*|"${MAIN_DEV_BRANCH}")$ ]]; then echo "" >> sonar-project.properties if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then From 48ea16afe2506db0fa28c8024d4751aaee21852b Mon Sep 17 00:00:00 2001 From: Travis CI Date: Tue, 17 Jul 2018 07:23:49 +0000 Subject: [PATCH 167/184] Updated project version after build [skip ci] --- source/core/ut_utils.pks | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/core/ut_utils.pks b/source/core/ut_utils.pks index 905be31f7..bd28fb7bf 100644 --- a/source/core/ut_utils.pks +++ b/source/core/ut_utils.pks @@ -21,7 +21,7 @@ create or replace package ut_utils authid definer is * */ - gc_version constant varchar2(50) := 'v3.1.2.2096-develop'; + gc_version constant varchar2(50) := 'v3.1.2.2101-develop'; /* Constants: Event names */ subtype t_event_name is varchar2(30); From 2470ee26d041295f5f332cfce2cc2d7391ab57c3 Mon Sep 17 00:00:00 2001 From: lwasylow Date: Tue, 17 Jul 2018 22:29:54 +0100 Subject: [PATCH 168/184] Update sonar PR external --- .travis/run_sonar_scanner.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.travis/run_sonar_scanner.sh b/.travis/run_sonar_scanner.sh index b3a051df8..09038bd5f 100755 --- a/.travis/run_sonar_scanner.sh +++ b/.travis/run_sonar_scanner.sh @@ -32,20 +32,21 @@ fi #Are we running on utPLSQL repo and not an external PR? echo "Check if we running from develop or on branch" -if [ "${TRAVIS_REPO_SLUG}" = "${UTPLSQL_REPO}" ] && [ "${TRAVIS_PULL_REQUEST_SLUG}" = "${TRAVIS_REPO_SLUG}" ] && \ - [[ ! "${BRANCH}" =~ ^(release/v[0-9]+\.[0-9]+\.[0-9]+.*|"${MAIN_DEV_BRANCH}")$ ]]; then +if [ "${TRAVIS_REPO_SLUG}" = "${UTPLSQL_REPO}" ] && [[ ! "${BRANCH}" =~ ^(release/v[0-9]+\.[0-9]+\.[0-9]+.*|"${MAIN_DEV_BRANCH}")$ ]]; then echo "" >> sonar-project.properties if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then echo "Updating sonar properties to include branch ${BRANCH}" add_sonar_property "${BRANCH_SONAR_PROPERTY}" "${BRANCH}" add_sonar_property "${BRANCH_SONAR_TARGET_PROPERTY}" "${MAIN_DEV_BRANCH}" - else + elif [ "${TRAVIS_PULL_REQUEST_SLUG}" = "${TRAVIS_REPO_SLUG}" ] echo "Updating sonar properties to include pull request ${BRANCH}" add_sonar_property "${PR_SONAR_TOKEN_PROPERTY}" "${GITHUB_TRAVISCI_TOKEN}" add_sonar_property "${PR_SONAR_BRANCH_PROPERTY}" "${BRANCH}" add_sonar_property "${PR_KEY_PROPERTY}" "${PR}" add_sonar_property "${PR_SONAR_BASE_PROPERTY}" "${PR_BRANCH}" + else + echo "PR from external source no changes to properties." fi else echo "No need to update sonar we building on release or develop" From 49ae4275a2b9b25f2c4211ded92ed3caf407d641 Mon Sep 17 00:00:00 2001 From: lwasylow Date: Tue, 17 Jul 2018 23:08:36 +0100 Subject: [PATCH 169/184] Updates to code, move the Coma separated list into ut_runner. --- docs/userguide/running-unit-tests.md | 10 +- source/api/ut.pkb | 8 +- source/api/ut_runner.pkb | 11 +- test/api/test_ut_run.pkb | 230 --------------------------- test/api/test_ut_run.pks | 41 +---- test/api/test_ut_runner.pkb | 170 ++++++++++++++++++++ test/api/test_ut_runner.pks | 30 ++++ 7 files changed, 222 insertions(+), 278 deletions(-) diff --git a/docs/userguide/running-unit-tests.md b/docs/userguide/running-unit-tests.md index eda27cedf..54116cf65 100644 --- a/docs/userguide/running-unit-tests.md +++ b/docs/userguide/running-unit-tests.md @@ -93,6 +93,14 @@ end; ``` Executes all tests from package _hr.test_apply_bonus_ and all tests from schema _cust_. +```sql +begin + ut.run(ut_varchar2_list('hr.test_apply_bonus,cust)'); +end; +``` + +Executes all tests from package _hr.test_apply_bonus_ and all tests from schema _cust_. + ```sql begin ut.run('hr.test_apply_bonus,cust'); @@ -103,7 +111,7 @@ Executes all tests from package _hr.test_apply_bonus_ and all tests from schema Using a list of items to execute allows you to execute a fine-grained set of tests. -List can be passed as a comma separated list or a list of *ut_varchar2_list objects*. +List can be passed as a comma separated list or a list of *ut_varchar2_list objects* or as a list within ut_varchar2_list. **Note:** diff --git a/source/api/ut.pkb b/source/api/ut.pkb index 2b53bdd78..1159182fa 100644 --- a/source/api/ut.pkb +++ b/source/api/ut.pkb @@ -333,7 +333,7 @@ create or replace package body ut is ) return ut_varchar2_rows pipelined is l_reporter ut_reporter_base := coalesce(a_reporter, ut_documentation_reporter()); - l_paths ut_varchar2_list := coalesce(ut_utils.string_to_table(a_string => a_path,a_delimiter => ','),ut_varchar2_list(sys_context('userenv', 'current_schema'))); + l_paths ut_varchar2_list := ut_varchar2_list(coalesce(a_path, sys_context('userenv', 'current_schema'))); l_lines sys_refcursor; l_line varchar2(4000); begin @@ -373,7 +373,7 @@ create or replace package body ut is a_client_character_set varchar2 := null ) return ut_varchar2_rows pipelined is l_reporter ut_reporter_base := coalesce(a_reporter, ut_documentation_reporter()); - l_paths ut_varchar2_list := coalesce(ut_utils.string_to_table(a_string => a_path,a_delimiter => ','),ut_varchar2_list(sys_context('userenv', 'current_schema'))); + l_paths ut_varchar2_list := ut_varchar2_list(coalesce(a_path, sys_context('userenv', 'current_schema'))); l_lines sys_refcursor; l_line varchar2(4000); begin @@ -520,7 +520,7 @@ create or replace package body ut is a_exclude_objects ut_varchar2_list := null, a_client_character_set varchar2 := null ) is - l_paths ut_varchar2_list := coalesce(ut_utils.string_to_table(a_string => a_path,a_delimiter => ','),ut_varchar2_list(sys_context('userenv', 'current_schema'))); + l_paths ut_varchar2_list := ut_varchar2_list(coalesce(a_path, sys_context('userenv', 'current_schema'))); begin ut.run( l_paths, @@ -546,7 +546,7 @@ create or replace package body ut is a_exclude_objects ut_varchar2_list := null, a_client_character_set varchar2 := null ) is - l_paths ut_varchar2_list := coalesce(ut_utils.string_to_table(a_string => a_path,a_delimiter => ','),ut_varchar2_list(sys_context('userenv', 'current_schema'))); + l_paths ut_varchar2_list := ut_varchar2_list(coalesce(a_path, sys_context('userenv', 'current_schema'))); begin ut.run( l_paths, diff --git a/source/api/ut_runner.pkb b/source/api/ut_runner.pkb index eb3bc8e68..ca0d6dccf 100644 --- a/source/api/ut_runner.pkb +++ b/source/api/ut_runner.pkb @@ -89,12 +89,17 @@ create or replace package body ut_runner is l_coverage_schema_names ut_varchar2_rows; l_exclude_object_names ut_object_names := ut_object_names(); l_include_object_names ut_object_names; + l_paths ut_varchar2_list := ut_varchar2_list(); begin ut_event_manager.initialize(); begin ut_expectation_processor.reset_invalidation_exception(); ut_utils.save_dbms_output_to_cache(); + for i in 1..a_paths.COUNT loop + l_paths := l_paths multiset union ut_utils.string_to_table(a_string => a_paths(i),a_delimiter => ','); + end loop; + ut_console_reporter_base.set_color_enabled(a_color_console); if a_reporters is null or a_reporters.count = 0 then ut_event_manager.add_listener(ut_documentation_reporter()); @@ -107,7 +112,7 @@ create or replace package body ut_runner is if a_coverage_schemes is not empty then l_coverage_schema_names := ut_utils.convert_collection(a_coverage_schemes); else - l_coverage_schema_names := ut_suite_manager.get_schema_names(a_paths); + l_coverage_schema_names := ut_suite_manager.get_schema_names(l_paths); end if; if a_exclude_objects is not empty then @@ -119,8 +124,8 @@ create or replace package body ut_runner is l_include_object_names := to_ut_object_list(a_include_objects, l_coverage_schema_names); l_run := ut_run( - ut_suite_manager.configure_execution_by_path(a_paths), - a_paths, + ut_suite_manager.configure_execution_by_path(l_paths), + l_paths, l_coverage_schema_names, l_exclude_object_names, l_include_object_names, diff --git a/test/api/test_ut_run.pkb b/test/api/test_ut_run.pkb index 2333c6e18..57d41b004 100644 --- a/test/api/test_ut_run.pkb +++ b/test/api/test_ut_run.pkb @@ -203,236 +203,6 @@ end;]'; execute immediate 'drop package invalid_pckag_that_revalidates'; execute immediate 'drop package parent_specs'; end; - - procedure create_test_csl_packages is - pragma autonomous_transaction; - begin - execute immediate q'[ - create or replace package test_csl_names1 as - --%suite - --%suitepath(test_csl_names) - - --%test - procedure one_is_one; - - --%test - procedure two_is_two; - - end; - ]'; - - execute immediate q'{ - create or replace package body test_csl_names1 as - - procedure one_is_one is - begin - ut3.ut.expect(1).to_equal(1); - end; - - procedure two_is_two is - begin - ut3.ut.expect(2).to_equal(2); - end; - - end; - }'; - - execute immediate q'[ - create or replace package test_csl_names2 as - --%suite - --%suitepath(test_csl_names) - - --%test - procedure one_is_one; - - --%test - procedure two_is_two; - - end; - ]'; - - execute immediate q'{ - create or replace package body test_csl_names2 as - - procedure one_is_one is - begin - ut3.ut.expect(1).to_equal(1); - end; - - procedure two_is_two is - begin - ut3.ut.expect(2).to_equal(2); - end; - - end; - }'; - - end; - - procedure drop_test_csl_packages is - pragma autonomous_transaction; - begin - execute immediate 'drop package test_csl_names1'; - execute immediate 'drop package test_csl_names2'; - end; - - procedure pass_varchar2_name_list is - l_results ut3.ut_varchar2_list; - l_actual clob; - begin - select * - bulk collect into l_results - from table(ut3.ut.run(ut3.ut_varchar2_list('test_csl_names1','test_csl_names2'))); - - l_actual := ut3.ut_utils.table_to_clob(l_results); - ut.expect(l_actual).to_be_like('%Finished in % seconds -%4 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)%'); - end; - - procedure pass_varchar2_name is - l_results ut3.ut_varchar2_list; - l_actual clob; - begin - select * - bulk collect into l_results - from table(ut3.ut.run('test_csl_names1')); - - l_actual := ut3.ut_utils.table_to_clob(l_results); - ut.expect(l_actual).to_be_like('%Finished in % seconds -%2 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)%'); - end; - - procedure pass_varchar2_suite_csl is - l_results ut3.ut_varchar2_list; - l_actual clob; - begin - select * - bulk collect into l_results - from table(ut3.ut.run('test_csl_names1,test_csl_names2')); - - l_actual := ut3.ut_utils.table_to_clob(l_results); - ut.expect(l_actual).to_be_like('%Finished in % seconds -%4 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)%'); - end; - - procedure pass_varchar2_test_csl is - l_results ut3.ut_varchar2_list; - l_actual clob; - begin - select * - bulk collect into l_results - from table(ut3.ut.run('test_csl_names1.one_is_one,test_csl_names2.one_is_one')); - - l_actual := ut3.ut_utils.table_to_clob(l_results); - ut.expect(l_actual).to_be_like('%Finished in % seconds -%2 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)%'); - end; - - procedure pass_varch_test_csl_spc is - l_results ut3.ut_varchar2_list; - l_actual clob; - begin - select * - bulk collect into l_results - from table(ut3.ut.run('test_csl_names1.one_is_one, test_csl_names2.one_is_one')); - - l_actual := ut3.ut_utils.table_to_clob(l_results); - ut.expect(l_actual).to_be_like('%Finished in % seconds -%2 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)%'); - end; - - procedure pass_csl_with_srcfile is - l_results ut3.ut_varchar2_list; - l_actual clob; - begin - - select * - bulk collect into l_results - from table( - ut3.ut.run( - a_path => 'test_csl_names1.one_is_one,test_csl_names2.one_is_one', - a_source_files => ut3.ut_varchar2_list('ut3.ut'), - a_test_files => ut3.ut_varchar2_list('ut3_tester.test_csl_names2') - ) - ); - - l_actual := ut3.ut_utils.table_to_clob(l_results); - ut.expect(l_actual).to_be_like('%Finished in % seconds -%2 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)%'); - end; - - procedure pass_singlevar_with_proc is - l_output_data dbms_output.chararr; - l_num_lines integer := 100000; - l_packages_executed integer := 0; - begin - --act - ut3.ut.run('test_csl_names1'); - dbms_output.get_lines( l_output_data, l_num_lines); - - for i in 1 .. l_num_lines loop - if l_output_data(i) like '%test_csl_names1%' then - l_packages_executed := l_packages_executed + 1; - end if; - end loop; - ut.expect(l_packages_executed ).to_equal(1); - end; - - procedure pass_vlist_with_proc is - l_output_data dbms_output.chararr; - l_num_lines integer := 100000; - l_packages_executed integer := 0; - begin - --act - ut3.ut.run(ut3.ut_varchar2_list('test_csl_names1','test_csl_names2')); - dbms_output.get_lines( l_output_data, l_num_lines); - - for i in 1 .. l_num_lines loop - if l_output_data(i) like '%test_csl_names1%' - or l_output_data(i) like '%test_csl_names2%' then - l_packages_executed := l_packages_executed + 1; - end if; - end loop; - ut.expect(l_packages_executed ).to_equal(2); - end; - - procedure pass_csl_with_proc is - l_output_data dbms_output.chararr; - l_num_lines integer := 100000; - l_packages_executed integer := 0; - begin - --act - ut3.ut.run('test_csl_names1,test_csl_names2'); - dbms_output.get_lines( l_output_data, l_num_lines); - - for i in 1 .. l_num_lines loop - if l_output_data(i) like '%test_csl_names1%' - or l_output_data(i) like '%test_csl_names2%' then - l_packages_executed := l_packages_executed + 1; - end if; - end loop; - ut.expect(l_packages_executed ).to_equal(2); - end; - - procedure pass_csl_src_proc is - l_output_data dbms_output.chararr; - l_num_lines integer := 100000; - l_packages_executed integer := 0; - begin - --act - ut3.ut.run(a_path => 'test_csl_names1,test_csl_names2', - a_source_files => ut3.ut_varchar2_list('ut3.ut'), - a_test_files => ut3.ut_varchar2_list('ut3_tester.test_csl_names2')); - dbms_output.get_lines( l_output_data, l_num_lines); - - for i in 1 .. l_num_lines loop - if l_output_data(i) like '%test_csl_names1%' - or l_output_data(i) like '%test_csl_names2%' then - l_packages_executed := l_packages_executed + 1; - end if; - end loop; - ut.expect(l_packages_executed ).to_equal(2); - end; end; / diff --git a/test/api/test_ut_run.pks b/test/api/test_ut_run.pks index 4e2a9b261..f4758ff3a 100644 --- a/test/api/test_ut_run.pks +++ b/test/api/test_ut_run.pks @@ -22,45 +22,6 @@ create or replace package test_ut_run is procedure run_and_revalidate_specs; procedure generate_invalid_spec; procedure drop_test_package; - - procedure create_test_csl_packages; - procedure drop_test_csl_packages; - - --%context(ut_run_coma_sep_list) - --%beforeall(create_test_csl_packages) - --%afterall(drop_test_csl_packages) - - --%test( Pass name of tests as varchar2_list ) - procedure pass_varchar2_name_list; - - --%test( Pass single test name as varchar2 ) - procedure pass_varchar2_name; - - --%test( Pass coma separated list of suite names ) - procedure pass_varchar2_suite_csl; - - --%test( Pass coma separated list of test names ) - procedure pass_varchar2_test_csl; - - --%test( Pass coma separated list of test names with spaces ) - procedure pass_varch_test_csl_spc; - - --%test( Pass coma separated list and source and test files ) - procedure pass_csl_with_srcfile; - - --%test( Pass single varchar2 into procedure ) - procedure pass_singlevar_with_proc; - - --%test( Pass varchar2_list into procedure ) - procedure pass_vlist_with_proc; - - --%test( Pass coma separated list varchar2 into procedure ) - procedure pass_csl_with_proc; - - --%test( Pass coma separated list varchar2 into procedure with src file) - procedure pass_csl_src_proc; - - --%endcontext - + end; / diff --git a/test/api/test_ut_runner.pkb b/test/api/test_ut_runner.pkb index fa3121bfa..3a8f6f670 100644 --- a/test/api/test_ut_runner.pkb +++ b/test/api/test_ut_runner.pkb @@ -361,5 +361,175 @@ end;'; ut.expect(dbms_utility.format_error_stack||dbms_utility.format_error_backtrace).not_to_be_like('%ORA-02055%'); end; + procedure create_test_csl_packages is + pragma autonomous_transaction; + begin + execute immediate q'[ + create or replace package test_csl_names1 as + --%suite + --%suitepath(test_csl_names) + + --%test + procedure one_is_one; + + --%test + procedure two_is_two; + + end; + ]'; + + execute immediate q'{ + create or replace package body test_csl_names1 as + + procedure one_is_one is + begin + ut3.ut.expect(1).to_equal(1); + end; + + procedure two_is_two is + begin + ut3.ut.expect(2).to_equal(2); + end; + + end; + }'; + + execute immediate q'[ + create or replace package test_csl_names2 as + --%suite + --%suitepath(test_csl_names) + + --%test + procedure one_is_one; + + --%test + procedure two_is_two; + + end; + ]'; + + execute immediate q'{ + create or replace package body test_csl_names2 as + + procedure one_is_one is + begin + ut3.ut.expect(1).to_equal(1); + end; + + procedure two_is_two is + begin + ut3.ut.expect(2).to_equal(2); + end; + + end; + }'; + + end; + + procedure drop_test_csl_packages is + pragma autonomous_transaction; + begin + execute immediate 'drop package test_csl_names1'; + execute immediate 'drop package test_csl_names2'; + end; + + procedure pass_varchar2_name_list is + l_results ut3.ut_varchar2_list; + l_actual clob; + begin + select * + bulk collect into l_results + from table(ut3.ut.run(ut3.ut_varchar2_list('test_csl_names1','test_csl_names2'))); + + l_actual := ut3.ut_utils.table_to_clob(l_results); + ut.expect(l_actual).to_be_like('%Finished in % seconds +%4 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)%'); + end; + + procedure pass_varchar2_name is + l_results ut3.ut_varchar2_list; + l_actual clob; + begin + select * + bulk collect into l_results + from table(ut3.ut.run('test_csl_names1')); + + l_actual := ut3.ut_utils.table_to_clob(l_results); + ut.expect(l_actual).to_be_like('%Finished in % seconds +%2 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)%'); + end; + + procedure pass_varchar2_suite_csl is + l_results ut3.ut_varchar2_list; + l_actual clob; + begin + select * + bulk collect into l_results + from table(ut3.ut.run('test_csl_names1,test_csl_names2')); + + l_actual := ut3.ut_utils.table_to_clob(l_results); + ut.expect(l_actual).to_be_like('%Finished in % seconds +%4 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)%'); + end; + + procedure pass_varchar2_test_csl is + l_results ut3.ut_varchar2_list; + l_actual clob; + begin + select * + bulk collect into l_results + from table(ut3.ut.run('test_csl_names1.one_is_one,test_csl_names2.one_is_one')); + + l_actual := ut3.ut_utils.table_to_clob(l_results); + ut.expect(l_actual).to_be_like('%Finished in % seconds +%2 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)%'); + end; + + procedure pass_varch_test_csl_spc is + l_results ut3.ut_varchar2_list; + l_actual clob; + begin + select * + bulk collect into l_results + from table(ut3.ut.run('test_csl_names1.one_is_one, test_csl_names2.one_is_one')); + + l_actual := ut3.ut_utils.table_to_clob(l_results); + ut.expect(l_actual).to_be_like('%Finished in % seconds +%2 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)%'); + end; + + procedure pass_csl_with_srcfile is + l_results ut3.ut_varchar2_list; + l_actual clob; + begin + + select * + bulk collect into l_results + from table( + ut3.ut.run( + a_path => 'test_csl_names1.one_is_one,test_csl_names2.one_is_one', + a_source_files => ut3.ut_varchar2_list('ut3.ut'), + a_test_files => ut3.ut_varchar2_list('ut3_tester.test_csl_names2') + ) + ); + + l_actual := ut3.ut_utils.table_to_clob(l_results); + ut.expect(l_actual).to_be_like('%Finished in % seconds +%2 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)%'); + end; + + procedure pass_csl_within_var2list is + l_results ut3.ut_varchar2_list; + l_actual clob; + begin + select * + bulk collect into l_results + from table(ut3.ut.run(ut3.ut_varchar2_list('test_csl_names1.one_is_one,test_csl_names2.one_is_one'))); + + l_actual := ut3.ut_utils.table_to_clob(l_results); + ut.expect(l_actual).to_be_like('%Finished in % seconds +%2 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)%'); + end; + end; / diff --git a/test/api/test_ut_runner.pks b/test/api/test_ut_runner.pks index 7b22fd4f1..74c93dbae 100644 --- a/test/api/test_ut_runner.pks +++ b/test/api/test_ut_runner.pks @@ -61,5 +61,35 @@ create or replace package test_ut_runner is --%aftertest(db_link_cleanup) procedure raises_20213_on_fail_link; + procedure create_test_csl_packages; + procedure drop_test_csl_packages; + + --%context(ut_run_coma_sep_list) + --%beforeall(create_test_csl_packages) + --%afterall(drop_test_csl_packages) + + --%test( Pass name of tests as varchar2_list ) + procedure pass_varchar2_name_list; + + --%test( Pass single test name as varchar2 ) + procedure pass_varchar2_name; + + --%test( Pass coma separated list of suite names ) + procedure pass_varchar2_suite_csl; + + --%test( Pass coma separated list of test names ) + procedure pass_varchar2_test_csl; + + --%test( Pass coma separated list of test names with spaces ) + procedure pass_varch_test_csl_spc; + + --%test( Pass coma separated list and source and test files ) + procedure pass_csl_with_srcfile; + + --%test( Pass coma separated list in varchar2list ) + procedure pass_csl_within_var2list; + + --%endcontext + end; / From d7c53a6cbe20b6019667440630b86bbb318b6a66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacek=20G=C4=99bal?= Date: Tue, 17 Jul 2018 23:47:14 +0100 Subject: [PATCH 170/184] Update .travis.yml --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4d455ea5e..7fa054ded 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,9 +5,9 @@ addons: apt: packages: - unzip - # Java8 Required for Sonar and SQLCL - - oracle-java8-installer - - oracle-java8-set-default + # Java9 Required for Sonar and SQLCL + - oracle-java9-installer + - oracle-java9-set-default sonarcloud: organization: utplsql token: From 0e7f137d9f18112907de7a8a8f984e61b5a45299 Mon Sep 17 00:00:00 2001 From: Travis CI Date: Tue, 17 Jul 2018 23:37:23 +0000 Subject: [PATCH 171/184] Updated project version after build [skip ci] --- source/core/ut_utils.pks | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/core/ut_utils.pks b/source/core/ut_utils.pks index bd28fb7bf..967ac19f0 100644 --- a/source/core/ut_utils.pks +++ b/source/core/ut_utils.pks @@ -21,7 +21,7 @@ create or replace package ut_utils authid definer is * */ - gc_version constant varchar2(50) := 'v3.1.2.2101-develop'; + gc_version constant varchar2(50) := 'v3.1.2.2112-develop'; /* Constants: Event names */ subtype t_event_name is varchar2(30); From bf686c2a4da6143c987db7ca6ab16d738ada9291 Mon Sep 17 00:00:00 2001 From: Travis CI Date: Wed, 18 Jul 2018 00:45:32 +0000 Subject: [PATCH 172/184] Updated project version after build [skip ci] --- source/core/ut_utils.pks | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/core/ut_utils.pks b/source/core/ut_utils.pks index 967ac19f0..a297e760a 100644 --- a/source/core/ut_utils.pks +++ b/source/core/ut_utils.pks @@ -21,7 +21,7 @@ create or replace package ut_utils authid definer is * */ - gc_version constant varchar2(50) := 'v3.1.2.2112-develop'; + gc_version constant varchar2(50) := 'v3.1.2.2117-develop'; /* Constants: Event names */ subtype t_event_name is varchar2(30); From d6aeef8e00dc5f471391b5d78cb5987d1bd532ff Mon Sep 17 00:00:00 2001 From: lwasylow Date: Wed, 18 Jul 2018 06:46:41 +0100 Subject: [PATCH 173/184] Update if statment --- .travis/run_sonar_scanner.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis/run_sonar_scanner.sh b/.travis/run_sonar_scanner.sh index 09038bd5f..5cad42e29 100755 --- a/.travis/run_sonar_scanner.sh +++ b/.travis/run_sonar_scanner.sh @@ -39,7 +39,7 @@ if [ "${TRAVIS_REPO_SLUG}" = "${UTPLSQL_REPO}" ] && [[ ! "${BRANCH}" =~ ^(releas echo "Updating sonar properties to include branch ${BRANCH}" add_sonar_property "${BRANCH_SONAR_PROPERTY}" "${BRANCH}" add_sonar_property "${BRANCH_SONAR_TARGET_PROPERTY}" "${MAIN_DEV_BRANCH}" - elif [ "${TRAVIS_PULL_REQUEST_SLUG}" = "${TRAVIS_REPO_SLUG}" ] + elif [ "${TRAVIS_PULL_REQUEST_SLUG}" = "${TRAVIS_REPO_SLUG}" ]; then echo "Updating sonar properties to include pull request ${BRANCH}" add_sonar_property "${PR_SONAR_TOKEN_PROPERTY}" "${GITHUB_TRAVISCI_TOKEN}" add_sonar_property "${PR_SONAR_BRANCH_PROPERTY}" "${BRANCH}" From e84ce734015c6637d9792b74dcfb10c2d6c0c1cc Mon Sep 17 00:00:00 2001 From: Travis CI Date: Wed, 18 Jul 2018 07:10:54 +0000 Subject: [PATCH 174/184] Updated project version after build [skip ci] --- source/core/ut_utils.pks | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/core/ut_utils.pks b/source/core/ut_utils.pks index a297e760a..26e861c2e 100644 --- a/source/core/ut_utils.pks +++ b/source/core/ut_utils.pks @@ -21,7 +21,7 @@ create or replace package ut_utils authid definer is * */ - gc_version constant varchar2(50) := 'v3.1.2.2117-develop'; + gc_version constant varchar2(50) := 'v3.1.2.2122-develop'; /* Constants: Event names */ subtype t_event_name is varchar2(30); From 34fdc579cad19ddbde8f7e5935b1a152b954304f Mon Sep 17 00:00:00 2001 From: Travis CI Date: Wed, 18 Jul 2018 12:03:09 +0000 Subject: [PATCH 175/184] Updated project version after build [skip ci] --- source/core/ut_utils.pks | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/core/ut_utils.pks b/source/core/ut_utils.pks index 26e861c2e..c672b1576 100644 --- a/source/core/ut_utils.pks +++ b/source/core/ut_utils.pks @@ -21,7 +21,7 @@ create or replace package ut_utils authid definer is * */ - gc_version constant varchar2(50) := 'v3.1.2.2122-develop'; + gc_version constant varchar2(50) := 'v3.1.2.2125-develop'; /* Constants: Event names */ subtype t_event_name is varchar2(30); From e7fba34d34c2093ad024cd4cec60145f8d785f81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacek=20G=C4=99bal?= Date: Thu, 19 Jul 2018 01:01:03 +0100 Subject: [PATCH 176/184] Update VERSION --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 82228f380..d95827c3d 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v3.1.2-develop +v3.1.2 From fa9de566d52f15e1b09268002bfd9572ed70c72f Mon Sep 17 00:00:00 2001 From: Jacek Gebal Date: Thu, 19 Jul 2018 01:29:50 +0100 Subject: [PATCH 177/184] Fixed flaky test. --- test/core/test_output_buffer.pkb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/core/test_output_buffer.pkb b/test/core/test_output_buffer.pkb index 051293c60..a22f3772d 100644 --- a/test/core/test_output_buffer.pkb +++ b/test/core/test_output_buffer.pkb @@ -60,7 +60,7 @@ create or replace package body test_output_buffer is l_duration := localtimestamp - l_start; ut.expect(l_result).to_equal(l_expected); - ut.expect(l_duration).to_be_greater_than(interval '1' second); + ut.expect(l_duration).to_be_greater_than(interval '0.99' second); select count(1) into l_remaining from ut3.ut_output_buffer_tmp where output_id = l_buffer.output_id; ut.expect(l_remaining).to_equal(0); From 5bac98e0c87ffc01db6f646a04346b70eea5bf93 Mon Sep 17 00:00:00 2001 From: Travis CI Date: Thu, 19 Jul 2018 00:50:52 +0000 Subject: [PATCH 178/184] Updated project version after build [skip ci] --- sonar-project.properties | 2 +- source/core/ut_utils.pks | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sonar-project.properties b/sonar-project.properties index 48e6fee2a..a2139b3fe 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -2,7 +2,7 @@ sonar.projectKey=utPLSQL # this is the name and version displayed in the SonarQube UI. Was mandatory prior to SonarQube 6.1. sonar.projectName=utPLSQL -sonar.projectVersion=v3.1.2-develop +sonar.projectVersion=v3.1.2 # Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. # Since SonarQube 4.2, this property is optional if sonar.modules is set. diff --git a/source/core/ut_utils.pks b/source/core/ut_utils.pks index c672b1576..026448a94 100644 --- a/source/core/ut_utils.pks +++ b/source/core/ut_utils.pks @@ -21,7 +21,7 @@ create or replace package ut_utils authid definer is * */ - gc_version constant varchar2(50) := 'v3.1.2.2125-develop'; + gc_version constant varchar2(50) := 'v3.1.2.2127'; /* Constants: Event names */ subtype t_event_name is varchar2(30); From b69c89b37ff9842703c1110e17cbc34515004ec9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacek=20G=C4=99bal?= Date: Thu, 19 Jul 2018 21:53:18 +0100 Subject: [PATCH 179/184] Update annotations.md --- docs/userguide/annotations.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/userguide/annotations.md b/docs/userguide/annotations.md index a6e8ea71b..3b8f0a9dd 100644 --- a/docs/userguide/annotations.md +++ b/docs/userguide/annotations.md @@ -21,7 +21,7 @@ We strongly recommend putting package level annotations at the very top of packa | `--%suitepath()` | Package | Similar to java package. The annotation allows logical grouping of suites into hierarchies. | | `--%displayname()` | Package/procedure | Human-readable and meaningful description of a suite/test. `%displayname(Name of the suite/test)`. The annotation is provided for flexibility and convenience only. It has exactly the same meaning as `` in `test` and `suite` annotations. If description is provided using both `suite`/`test` and `displayname`, then the one defined as last takes precedence. | | `--%test()` | Procedure | Denotes that the annotated procedure is a unit test procedure. Optional test description can by provided (see `displayname`). | -| `--%throws([,...])`| Procedure | Denotes that the annotated test procedure must throw one of the exceptions provided. Supported forms of exceptions are: numeric literals, numeric contant names, exception constant names, predefined Oracle exception names. | +| `--%throws([,...])`| Procedure | Denotes that the annotated test procedure must throw one of the exceptions provided. Supported forms of exceptions are: numeric literals, numeric contant names, exception constant names, predefined Oracle exception names. | | `--%beforeall` | Procedure | Denotes that the annotated procedure should be executed once before all elements of the suite. | | `--%beforeall([[.].][,...])` | Package | Denotes that the mentioned procedure(s) should be executed once before all elements of the suite. | | `--%afterall` | Procedure | Denotes that the annotated procedure should be executed once after all elements of the suite. | From f09ad29d3d7c611af48c7b35012b6da4549ee62c Mon Sep 17 00:00:00 2001 From: Travis CI Date: Thu, 19 Jul 2018 21:15:58 +0000 Subject: [PATCH 180/184] Updated project version after build [skip ci] --- source/core/ut_utils.pks | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/core/ut_utils.pks b/source/core/ut_utils.pks index 026448a94..3bd5cf40e 100644 --- a/source/core/ut_utils.pks +++ b/source/core/ut_utils.pks @@ -21,7 +21,7 @@ create or replace package ut_utils authid definer is * */ - gc_version constant varchar2(50) := 'v3.1.2.2127'; + gc_version constant varchar2(50) := 'v3.1.2.2128'; /* Constants: Event names */ subtype t_event_name is varchar2(30); From 5c02105ec31aa15f6621fdabbbe51f481a5553d8 Mon Sep 17 00:00:00 2001 From: Jacek Gebal Date: Fri, 20 Jul 2018 21:14:28 +0100 Subject: [PATCH 181/184] Updated lints to cheat-sheets. --- docs/index.md | 2 +- readme.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/index.md b/docs/index.md index 781048235..693c8076b 100644 --- a/docs/index.md +++ b/docs/index.md @@ -16,7 +16,7 @@ The framework follows industry standards and best patterns of modern Unit Testin - [Using reporters](userguide/reporters.md) - [Reporting errors](userguide/exception-reporting.md) - [Code coverage](userguide/coverage.md) - - [Cheat-sheet](https://www.cheatography.com/jgebal/cheat-sheets/utplsql-v3/#downloads) + - [Cheat-sheet](https://www.cheatography.com/jgebal/cheat-sheets/utplsql-v3-1-2/#downloads) - About - [Project Details](about/project-details.md) - [License](about/license.md) diff --git a/readme.md b/readme.md index 18cc50f3b..16e68d5a0 100644 --- a/readme.md +++ b/readme.md @@ -45,7 +45,7 @@ Published releases are available for download on the [utPLSQL GitHub Releases Pa Full documentation of the project is automatically published on [utPLSQL github pages](https://utplsql.github.io/utPLSQL/) -[Cheat-sheet](https://www.cheatography.com/jgebal/cheat-sheets/utplsql-v3/#downloads) +[Cheat-sheets](https://www.cheatography.com/jgebal/lists/utplsql-v3-cheat-sheets/) # Installation From fb4821324c512949e528f12c55d6c157cf909843 Mon Sep 17 00:00:00 2001 From: Travis CI Date: Fri, 20 Jul 2018 20:36:59 +0000 Subject: [PATCH 182/184] Updated project version after build [skip ci] --- source/core/ut_utils.pks | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/core/ut_utils.pks b/source/core/ut_utils.pks index 3bd5cf40e..ac101044c 100644 --- a/source/core/ut_utils.pks +++ b/source/core/ut_utils.pks @@ -21,7 +21,7 @@ create or replace package ut_utils authid definer is * */ - gc_version constant varchar2(50) := 'v3.1.2.2128'; + gc_version constant varchar2(50) := 'v3.1.2.2129'; /* Constants: Event names */ subtype t_event_name is varchar2(30); From 05ea7d453ad28416587e09d386f8fbb995bc71ad Mon Sep 17 00:00:00 2001 From: Jacek Gebal Date: Sun, 22 Jul 2018 10:16:08 +0100 Subject: [PATCH 183/184] Updated `releasing.md` --- development/releasing.md | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/development/releasing.md b/development/releasing.md index 44fe4914c..added5a92 100644 --- a/development/releasing.md +++ b/development/releasing.md @@ -4,17 +4,19 @@ With every build, the build process on Travis updates files with an appropriate This step is performed, to confirm that the update of versions works properly. To create a release: - - create release branch and wait for release build to complete successfully - - merge release branch to master and wait for master build to complete successfully - - create a release from the master branch using github web page and populate release description using information found on the issues and pull requests for release + - create release branch from development branch and make sure to name the release branch: `release/vX.Y.Z` + - update, commit and push at least one file change in the release branch, to kickoff a Travis build + - wait for th build to complete successfully + - merge the release branch to master and wait for master build to complete successfully + - create a release from the master branch using [github releases page](https://github.com/utPLSQL/utPLSQL/releases) and populate release description using information found on the issues and pull requests since previous release. + To find issues closed after certain date use [advanced filters](https://help.github.com/articles/searching-issues-and-pull-requests/#search-by-open-or-closed-state) The following will happen: - - build executed on branch `release/v1.2.3-[something]` updates files `sonar-project.properties`, `VERSION` with project version derived from the release branch name + - build executed on branch `release/vX.Y.Z-[something]` updates files `sonar-project.properties`, `VERSION` with project version derived from the release branch name - changes to those two files are committed and pushed back to release branch by Travis - when a release is created, a new tag is added in on the repository and a tag build is executed - the documentation for new release is published on `utplsql.github.io` and installation archives are added to the tag. Note: -The released version does not provide access to un-versioned source files (the default zip file from GitHub is empty). The sources for release are provided in separate zip files delivered from the Travis build process. -This is because we do not keep version in our source files in develop branch. +The built zip files include HTML documentation generated from MD files. From 1bdb86c65400fd63a3a0d0d34a0b3e265fee58b6 Mon Sep 17 00:00:00 2001 From: Travis CI Date: Sun, 22 Jul 2018 09:37:23 +0000 Subject: [PATCH 184/184] Updated project version after build [skip ci] --- source/core/ut_utils.pks | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/core/ut_utils.pks b/source/core/ut_utils.pks index ac101044c..847c57fd8 100644 --- a/source/core/ut_utils.pks +++ b/source/core/ut_utils.pks @@ -21,7 +21,7 @@ create or replace package ut_utils authid definer is * */ - gc_version constant varchar2(50) := 'v3.1.2.2129'; + gc_version constant varchar2(50) := 'v3.1.2.2130'; /* Constants: Event names */ subtype t_event_name is varchar2(30);