-
Notifications
You must be signed in to change notification settings - Fork 186
Invalid parameter value [constant_name] for "--%throws" annotation #1033
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hey @alshib , create or replace package pkg_errors is
function get_exception_code(i_identifier varchar2)
return integer;
end;
/
create or replace package body pkg_errors is
function get_exception_code(i_identifier varchar2)
return integer
as
begin
return
case i_identifier
when 'err_1_name' then -20001
when 'err_2_name' then -20002
when 'err_3_name' then -20003
end;
end;
end;
/
create or replace package test_balablabla is
c_1 number := pkg_errors.get_exception_code('err_1_name');
c_2 number := pkg_errors.get_exception_code('err_2_name');
c_n number := pkg_errors.get_exception_code('err_n_name');
-- %suite(blabla)
-- %test
-- %throws(test_balablabla.c_1)
procedure precheck_something;
end;
/
create or replace package body test_balablabla is
procedure precheck_something
as
begin
raise_application_error(-20001, 'OMG! The rebels are attacking!');
end;
end;
/
call ut.run('test_balablabla'); Output:
Is it possible that something is broken in |
Unfortunately i cannot reproduce too when i want to do it. right now i cannot describe the algorithm for reproducing this bug. This one arises when i modify package specification but not each time. Sometime ago we were able to fix it by doing these staps 1 - delete constants 2 -recompile package 3 - run tests 4- restore constants but today it does not work(( Code:
|
Hey, |
hi, create or replace package body pkg_errors is create or replace package test_balablabla is -- %test end; create or replace package body test_balablabla is --!!!initialize suite cache --add new test and constant in another session: -- %test create or replace package body test_balablabla is --!!!reinitialize suite cache --!!!Call tests again |
Second way for reproduce bug(thoday`s variant): create or replace package body pkg_errors is
end; create or replace package test_balablabla is -- %test end; create or replace package body test_balablabla is --!!!initialize suite cash with bug in the pkg_errors --fix bug in the pkg_errors
end; --call tests again |
If you replace function with constant does it break? If you initialize variable as part of begin block on package level will that break? E. G. -- %test |
hi, No. it does not give a good result. This bug can be fixed after force rebuild the suite(for refresh suite cache) |
This is related to: #721 The throws annotation is validated at suite parse time, not at suite-run time. Also. You're not using package constants but package variables. Please give it a try with:
This looks like an ORACLE bug though. Are you using v3.1.9 installation with DDL trigger or without? Maybe the parsing at package compile time is the cause of issues in that case. So what I would suggest trying is:
From our side, we should consider moving the interpretation of the throws annotation content into suite runtime engine. |
Hi! constant: DDL trigger: "Maybe the parsing at package compile time is the cause of issues in that case." - you are right. In the general case this error coming up when teat package(or pkg_errors) is broken or has invalid state at moment of parse the suite As second way to fix this error i can suggest to raise an exception when you are parsing the suite like this: 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
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;
exception
when others then
raise;
--invalid exception number (positive)
--TODO add warning for this value
null;
end;
end if;
end;
return l_exception_type;
end; |
@alshib - you can use code block syntax of markdown to make the examples more readable to get this result select * from dual I've updated your last comment |
@alshib In general this would violate the principles of running all run-able tests even if other test suites are in invalid state. I think the best we can do is to move the exception name/constants validation into suite runtime. |
@alshib |
Now the validation is executed at runtime, when the tests is executed. This resolves issues related to the fact that some package constants may not exist or be valid at suite parse time. In such scenario, the annotations continued to be ignored despite the fact that package constants were valid at test runtime. With this change, tests can now have `--throws` annotations referencing constants that are undefined at compile time. Resolves #1033
Hi, |
Hi!
When we modify and recompile test package sometimes we get warnings like this:
"Invalid parameter value "test_blablabla.c_1" for "--%throws" annotation. Parameter ignored."
Provide version info
Information about utPLSQL and Database version,
11.2.0.4.0
11.2.0.4.0
UT_VERSION
v3.1.9.3270
1 row selected.
BANNER
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
PL/SQL Release 11.2.0.4.0 - Production
CORE 11.2.0.4.0 Production
TNS for Linux: Version 11.2.0.4.0 - Production
NLSRTL Version 11.2.0.4.0 - Production
5 rows selected.
PARAMETER
VALUE
NLS_LANGUAGE
AMERICAN
NLS_TERRITORY
CIS
NLS_CURRENCY
р.
NLS_ISO_CURRENCY
CIS
NLS_NUMERIC_CHARACTERS
,
NLS_CALENDAR
GREGORIAN
NLS_DATE_FORMAT
PARAMETER
VALUE
DD.MM.RR
NLS_DATE_LANGUAGE
AMERICAN
NLS_SORT
BINARY
NLS_TIME_FORMAT
HH24:MI:SSXFF
NLS_TIMESTAMP_FORMAT
DD.MM.RR HH24:MI:SSXFF
NLS_TIME_TZ_FORMAT
HH24:MI:SSXFF TZR
NLS_TIMESTAMP_TZ_FORMAT
DD.MM.RR HH24:MI:SSXFF TZR
PARAMETER
VALUE
NLS_DUAL_CURRENCY
р.
NLS_COMP
BINARY
NLS_LENGTH_SEMANTICS
BYTE
NLS_NCHAR_CONV_EXCP
FALSE
17 rows selected.
PORT_STRING
x86_64/Linux 2.4.xx
1 row selected.
Information about client software
TOAD
To Reproduce
add new test in the package (an error does not always occur )
Expected behavior
Tests are working without warnings
Example code
example of package specification:
"create or replace package test_balablabla is
c_1 number := pkg_errors.get_exception_code('err_1_name');
c_2 number := pkg_errors.get_exception_code('err_2_name');
c_n number := pkg_errors.get_exception_code('err_n_name');
end;"
The text was updated successfully, but these errors were encountered: