@@ -114,5 +114,107 @@ Failures:%
114114 execute immediate 'drop package test_stateful';
115115 end;
116116
117+ procedure run_in_invalid_state is
118+ l_results ut3.ut_varchar2_list;
119+ l_actual clob;
120+ l_expected varchar2(32767);
121+ begin
122+ select *
123+ bulk collect into l_results
124+ from table(ut3.ut.run('failing_invalid_spec'));
125+
126+ l_actual := ut3.ut_utils.table_to_clob(l_results);
127+ ut.expect(l_actual).to_be_like('%Call params for % are not valid: package does not exist or is invalid: %FAILING_INVALID_SPEC%');
128+
129+ end;
130+
131+ procedure compile_invalid_package is
132+ ex_compilation_error exception;
133+ pragma exception_init(ex_compilation_error,-24344);
134+ pragma autonomous_transaction;
135+ begin
136+ begin
137+ execute immediate q'[create or replace package failing_invalid_spec as
138+ --%suite
139+ gv_glob_val non_existing_table.id%type := 0;
140+
141+ --%test
142+ procedure test1;
143+ end;]';
144+ exception when ex_compilation_error then null;
145+ end;
146+ begin
147+ execute immediate q'[create or replace package body failing_invalid_spec as
148+ procedure test1 is begin ut.expect(1).to_equal(1); end;
149+ end;]';
150+ exception when ex_compilation_error then null;
151+ end;
152+ end;
153+ procedure drop_invalid_package is
154+ pragma autonomous_transaction;
155+ begin
156+ execute immediate 'drop package failing_invalid_spec';
157+ end;
158+
159+ procedure run_and_revalidate_specs is
160+ l_results ut3.ut_varchar2_list;
161+ l_actual clob;
162+ l_is_invalid number;
163+ begin
164+ execute immediate q'[select count(1) from all_objects o where o.owner = :object_owner and o.object_type = 'PACKAGE'
165+ and o.status = 'INVALID' and o.object_name= :object_name]' into l_is_invalid
166+ using user,'FAILING_INVALID_SPEC';
167+
168+ select *
169+ bulk collect into l_results
170+ from table(ut3.ut.run('failing_invalid_spec'));
171+
172+ l_actual := ut3.ut_utils.table_to_clob(l_results);
173+ ut.expect(1).to_equal(l_is_invalid);
174+ ut.expect(l_actual).to_be_like('%failing_invalid_spec%invalidspecs [% sec]%
175+ %Finished in % seconds%
176+ %1 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)%');
177+
178+ end;
179+
180+ procedure generate_invalid_spec is
181+ ex_compilation_error exception;
182+ pragma exception_init(ex_compilation_error,-24344);
183+ pragma autonomous_transaction;
184+ begin
185+
186+ execute immediate q'[create or replace package parent_specs as
187+ c_test constant varchar2(1) := 'Y';
188+ end;]';
189+
190+ execute immediate q'[create or replace package failing_invalid_spec as
191+ --%suite
192+ g_var varchar2(1) := parent_specs.c_test;
193+
194+ --%test(invalidspecs)
195+ procedure test1;
196+ end;]';
197+
198+ execute immediate q'[create or replace package body failing_invalid_spec as
199+ procedure test1 is begin ut.expect('Y').to_equal(g_var); end;
200+ end;]';
201+
202+ -- That should invalidate test package and we can then revers
203+ execute immediate q'[create or replace package parent_specs as
204+ c_test_error constant varchar2(1) := 'Y';
205+ end;]';
206+
207+ execute immediate q'[create or replace package parent_specs as
208+ c_test constant varchar2(1) := 'Y';
209+ end;]';
210+
211+ end;
212+ procedure drop_test_package is
213+ pragma autonomous_transaction;
214+ begin
215+ execute immediate 'drop package failing_invalid_spec';
216+ execute immediate 'drop package parent_specs';
217+ end;
218+
117219end;
118220/
0 commit comments