Skip to content

Running single test from package body fails with string literals containing "create package" #1

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

Closed
jgebal opened this issue Jan 27, 2018 · 1 comment
Assignees
Milestone

Comments

@jgebal
Copy link
Member

jgebal commented Jan 27, 2018

When trying to execute test: test_expect_not_to_be_null.blob_not_null from utPLSQL test suites, the extension generates the following call:

SET SERVEROUTPUT ON SIZE 1000000
EXECUTE ut.run(''||gc_varray_name||'.drop_types');

The body of package can be seen here

It has constants at the top of the package body.

create or replace package body test_expect_not_to_be_null
is
    gc_object_name constant varchar2(30) := 't_not_to_be_null_test';
    gc_nested_table_name constant varchar2(30) := 'tt_not_to_be_null_test';
    gc_varray_name constant varchar2(30) := 'tv_not_to_be_null_test';

    procedure cleanup_expectations
    is
    begin
        ut3.ut_expectation_processor.clear_expectations();
    end;

    procedure create_types
    is
        pragma autonomous_transaction;
    begin
        execute immediate 'create type '||gc_object_name||' is object (dummy number)';
        execute immediate 'create type '||gc_nested_table_name||' is table of number';
        execute immediate 'create type '||gc_varray_name||' is varray(1) of number';
    end;

    procedure drop_types
    is
        pragma autonomous_transaction;
    begin
        execute immediate 'drop type '||gc_object_name;
        execute immediate 'drop type '||gc_nested_table_name;
        execute immediate 'drop type '||gc_varray_name;
    end;

    procedure blob_not_null
    is
    begin
        --Act
        execute immediate expectations_helpers.unary_expectation_block('not_to_be_null', 'blob', 'to_blob(''abc'')');
        --Assert
        ut.expect(anydata.convertCollection(ut3.ut_expectation_processor.get_failed_expectations())).to_be_empty();
    end;

--and so on...

end;
@jgebal jgebal added the bug label Jan 27, 2018
@PhilippSalvisberg
Copy link
Member

Yes it is a bug in the parser. The parser identifies a drop type statements within a string literal. That leads to the wrong behaviour.

It should not be to difficult to fix that.

I will rename the bug title.

@PhilippSalvisberg PhilippSalvisberg self-assigned this Jan 27, 2018
@PhilippSalvisberg PhilippSalvisberg changed the title Running single test from packqge body fails when body has constants Running single test from package body fails when contains string literals with "create package" or "create type" statements Jan 27, 2018
@PhilippSalvisberg PhilippSalvisberg added this to the v0.2.0 milestone Jan 28, 2018
@PhilippSalvisberg PhilippSalvisberg changed the title Running single test from package body fails when contains string literals with "create package" or "create type" statements Running single test from package body fails with string literals create package or create type Feb 1, 2018
@PhilippSalvisberg PhilippSalvisberg changed the title Running single test from package body fails with string literals create package or create type Running single test from package body fails with string literals containing "create package" Feb 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants