GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Exclude Objects from code coverage by wildcard · Issue #1053 · utPLSQL/utPLSQL

Exclude Objects from code coverage by wildcard #1053

New issue
Copy link
New issue
Copy link
Closed
#1186
Closed
Exclude Objects from code coverage by wildcard#1053
#1186
Copy link
Assignees
lwasylow
Labels
enhancement
Milestone
v3.1.13

Description

@wolframhaussig
wolframhaussig
opened on Mar 11, 2020
Issue body actions

Is your feature request related to a problem? Please describe.
We have a database schema which includes temporary objects - this means objects which are required only for a short time like procedure for upgrades or objects which are still work in progress - and legacy test code. Temporary objects are always prefixed with the username of the author like:
windowsusr_my_table
Test Procedures are prefixed with test_ and cannot be moved to utPLSQL because they do an integration test rather than a unit test as they access and read data from remote systems and therefore need manual checks of the data.

Describe the solution you'd like
We would like to exclude objects using a wildcard like:
windowsusr_*
test_*

Describe alternatives you've considered
I tried to list every object which currently exists and which should be excluded but gave up after about 15 names.

Additional context
We use Oracle 12.1 with Sqldeveloper and installed the utPLSQL plugin.

Activity

  1. jgebal
    added
    enhancement
    on Mar 12, 2020
  2. jgebal commented on Mar 12, 2020

    @jgebal
    jgebal
    on Mar 12, 2020
    Member
    More actions

    We would need to make few decisions here:

    1. should we use % or * as wildcard aka Oracle vs. OS style
    2. should it be passed using the same parameters or should we create new ones
    3. should we use simple wildcard or REGEXP?

    For No. 1 - I don't have an strong opinion, but whatever we choose should be taken as standard. No other input parameters accept wildcards so far so this would lay foundations for future enhancements in other areas.

    For No. 2 - I would lean towards reuse of existing parameters. They would simply become more flexible.

    I didn't check the code yet but as far as I remember it shouldn't be too hard to implement.

  3. jgebal
    added
    good first issue
    on Mar 12, 2020
  4. wolframhaussig commented on Mar 12, 2020

    @wolframhaussig
    wolframhaussig
    on Mar 12, 2020
    Author
    More actions

    Here are my 2 cents:

    1. I think we should use % as this is a framework for Oracle users so we should use the Oracle style
    2. I think reusing the parameters would be fine
    3. I think regular expressions are overpowered in this case although this would be helpful for us as the Windows-Usernames have a predefined structure and we could catch all usernames with a single RegEx instead of one wildcard entry for each developer.
  5. jgebal commented on Mar 13, 2020

    @jgebal
    jgebal
    on Mar 13, 2020
    Member
    More actions

    I was thinking a bit.
    The currently accepted syntax makes it impossible to convert to regex support without breaking backward compatibility.
    This is because you can pass schema.object or object and both are valid.
    The . in current parameter syntax is the problem.

    Given the above and the fact that filtering objects by using regexp_like can bring extra penalty on performance I think we would need to stick with regular wildcard filtering.

    Wildcard filtering using like expression has also one pitfall. The underscore character ( _ ) is the default and most commonly used separator in object names. It is also a single character substitution in the like operator.

    With that, the only way to introduce full wildcards in a non-breaking way would be to use OS-style substitution characters:

    • * - match zero or more characters
    • ? - match exactly one character

    Another option would be to use Oracle wildcard matching but only to support % and not _ (match exactly one character). This however seems like a big limitation of functionality.

    A mixed option would be to allow for use of * and % interchangeably but only allow for ? as a single-char match.

    The more I think about it the more I lean towards using OS-style substitution characters.

    Examples:

    begin
      ut.run(
        'unit_test_schema', ut_coverage_html_reporter(), 
        a_include_objects => ut_varchar2_list(
          'user_???.bonus*',
          '???_user.*_process_*'
        ),
        a_exclude_objects => ut_varchar2_list(
          'user_???.*award*',
          '???_user.*calc*'
        )
      );
    end;

    @pesse @lwasylow @PhilippSalvisberg - any inputs from your side?

    Reacted by Philipp Salvisberg
  6. jgebal commented on Mar 13, 2020

    @jgebal
    jgebal
    on Mar 13, 2020
    Member
    More actions

    Current documentation can be found here for reference

  7. jgebal commented on Mar 13, 2020

    @jgebal
    jgebal
    on Mar 13, 2020
    Member
    More actions

    Relates to: #470

  8. PhilippSalvisberg commented on Mar 13, 2020

    @PhilippSalvisberg
    PhilippSalvisberg
    on Mar 13, 2020
    Member
    More actions

    @jgebal I agree with your proposal since it simplifies the handling of unquoted identifiers. However, it will make it more difficult in the future to support quoted identifiers (e.g. "My _strange% ., *Package? Name"). Quoted identifiers are probably not relevant for test code. But code under test is another story (might be not in control of the developer). So I wonder if it wouldn't be easier or cleaner to separate schema and object and provide dedicated parameters for include and exclude that accept a case-insensitive regular expression (I do not think that case-sensitive handling is ever needed, even if quoted names are case sensitive). Something like this

    begin
      ut.run(
        a_path => 'unit_test_schema', 
        a_reporter => ut_coverage_html_reporter(), 
        a_include_schema_expr => '(user_...)|(..._user)',
        a_include_object_expr => '(bonus.*)|(.*_process_.*)',
        a_exclude_schema_expr => '(user_t..)|(t.._user)',
        a_exclude_object_expr => '(.*award.*)|(.*calc.*)'
      );
    end;
    
    Reacted by Lukasz Wasylow and Satya Padala
  9. lwasylow commented on Mar 13, 2020

    @lwasylow
    lwasylow
    on Mar 13, 2020
    Member
    More actions

    Like idea of @PhilippSalvisberg. Nice granularity level enough to cover most requirements. I think simple like of oracle will be sufficient. Unfortunately any new input parameters will explode into load number of ut run overloads so maybe its time to introduce a new subtype that will go into include objects exclude objects that is a tab of varchar2 etc.? That way we keep old functionality not break and reduce new specs

  10. jgebal
    pinned this issue on Mar 14, 2020
  11. jgebal commented on Jun 28, 2020

    @jgebal
    jgebal
    on Jun 28, 2020
    Member
    More actions

    @lwasylow
    I think we could go along with suggestion from @PhilippSalvisberg without exploding the parameters.
    We would add those parameters to all currently supported parameter combinations.

    We would need to enforce precedence of parameters when both a_include_objects and a_include_object_expr are provided by
    user.

    This can be done in few ways:

    • document that a_include_object_expr overrides the a_include_objects
    • raise exception when both are provided. note that the current pattern is not to raise exceptions on bad parameters but rather ignore them.
    • accept both lists and use both for inclusion with an OR operator. For exclusions we would assume that we accept both as exclusion filters

    That way it should be relatively easy to implement

  12. jgebal
    unpinned this issue on Nov 11, 2021
  13. lwasylow
    self-assigned this
    on Feb 8, 2022
  14. lwasylow commented on Feb 9, 2022

    @lwasylow
    lwasylow
    on Feb 9, 2022
    Member
    More actions

    I have drafted a first checking of approach to the problem I as initial start decided to use logic as follow:
    a_include_object_expr and a_include_schema_expr silently overwrites a_include_object_expr

    I don't like the idea of raising exception as currently a_include_object_expr silently overwrites a_coverage_schemas anyway.
    The approach of OR operator is tempting however I feel like a_include_object_expr is more specialized to extract info regarding one or two packages where a_include_object/schema_expr is more to filter results.

    @PhilippSalvisberg @jgebal
    What are your thoughts on this ?

  15. PhilippSalvisberg commented on Feb 9, 2022

    @PhilippSalvisberg
    PhilippSalvisberg
    on Feb 9, 2022
    Member
    More actions

    The approach of OR operator is tempting however I feel like a_include_object_expr is more specialized to extract info regarding one or two packages where a_include_object/schema_expr is more to filter results.

    What do you mean with the OR operator? The example I've drafted in this comment is using a single regular expression.

  16. lwasylow commented on Feb 9, 2022

    @lwasylow
    lwasylow
    on Feb 9, 2022
    Member
    More actions

    @PhilippSalvisberg I was referring to proposal that @jgebal said an earlier

    This can be done in few ways:

    document that a_include_object_expr overrides the a_include_objects
    raise exception when both are provided. note that the current pattern is not to raise exceptions on bad parameters but rather ignore them.
    accept both lists and use both for inclusion with an OR operator. For exclusions we would assume that we accept both as exclusion filters

    As for implementation I think your idea is good and implemented this that way. Only question remains about existing attributes / filters how they would behave with a new ones.

  17. PhilippSalvisberg commented on Feb 10, 2022

    @PhilippSalvisberg
    PhilippSalvisberg
    on Feb 10, 2022
    Member
    More actions

    As for implementation I think your idea is good and implemented this that way. Only question remains about existing attributes / filters how they would behave with a new ones.

    Personally I like errors better. It happens when someone uses the new feature. It's a precise feedback. It tells you that want you defined does not work. As a result you simply change the call. Done. Otherwise it "works" but maybe does not produce the result the expected result. I have to dig deeper to find out that something has has been ignored. Furthermore I think the implementation will become simpler when you clearly state what is allowed and want not.

  18. lwasylow commented on Feb 26, 2022

    @lwasylow
    lwasylow
    on Feb 26, 2022
    Member
    More actions

    @jgebal, so currently I follow the principles as follows

    • include regex silently overwrite include objects but dont interfere with exclude objects
    • exclude regex silently overwrite exclude objects but wont interfere with include objects.

    I prefer silent approach to be consistent with others, l but if you think its best to warn users abiut ignoring we could maybe see if we can push warning? Dont think error is good.
    Second matter is precedence, do we want to fully overwrite include exclude when regex is supplied?
    To clarify what I mean is when supply include regex will not interfere with exclude objects and similar for exclude version as per above.But we can make it so that regex fully take control of filter and include regex will ignore including and excluding objects ans use only regex.

    Personally i think that is excessive and limit flexibility?

  19. jgebal commented on Feb 26, 2022

    @jgebal
    jgebal
    on Feb 26, 2022
    Member
    More actions

    I understand where Philipp is coming from with the exceptions.
    It is making it harder to understand what is going on when you don't get expected results (something doesn't work) and you don't know why.
    Change of the appear from silently ignoring incompatible parameters to raising exceptions would however mean one of two things:

    • we are inconsistent, if we only do this for those parameters
    • we introduce a breaking change
      Both are not acceptable for me at this time.
      With that I suggest silent override.
      We could provide warning on ignored parameters as a separate feature/enhancement.
    Reacted by Philipp Salvisberg
  20. jgebal commented on Feb 26, 2022

    @jgebal
    jgebal
    on Feb 26, 2022
    Member
    More actions

    Also, I need to read the entire coverage documentation to see if it is still consistent and clear.

  21. jgebal
    closed this as completedin #1186on Mar 2, 2022
  22. malugrz commented on Mar 7, 2023

    @malugrz
    malugrz
    on Mar 7, 2023
    More actions

    I'm using utPLSQL-cli to run the tests on a build server. I found the parameter "-exclude" to exclude objects. It works with full names. However, I want to use patterns to exclude several objects with similar names. What would be the correct syntax for wildcards? I cannot find it in the documentation.

  23. lwasylow commented on Mar 7, 2023

    @lwasylow
    lwasylow
    on Mar 7, 2023
    Member
    More actions

    Which version of utplsql your are using? We have introduced a new feature in latest release. Have you checked this?

  24. malugrz commented on Mar 8, 2023

    @malugrz
    malugrz
    on Mar 8, 2023
    More actions

    I'm using v3.1.12.3589.
    In the release notes there's only one feature mentioned: Add ability to run tests by part of a name.
    Not sure if this is related to excluding objects for the coverage report.

    • Do I need to upgrade?
    • What would be the correct syntax for wildcards to exclude objects for the coverage report?
  25. lwasylow commented on Mar 8, 2023

    @lwasylow
    lwasylow
    on Mar 8, 2023
    Member
    More actions

    Ok I understand now your question.
    So there is section in documentation
    https://www.utplsql.org/utPLSQL/latest/userguide/coverage.html#filtering-objects-in-coverage-reports
    I think what you looking for is

    • a_exclude_schema_expr ( varchar(4000) ) - string of regex expression of schemas to be excluded from the coverage report. Case-insensitive.
    • a_exclude_object_expr ( varchar(4000) ) - string of regex expression of objects ( without schema name ) to be excluded from the coverage report. Case-insensitive._
  26. malugrz commented on Mar 9, 2023

    @malugrz
    malugrz
    on Mar 9, 2023
    More actions

    Thank you for the link. However, it referes to the manual execution of tests with coverage. For the automatic execution I can only use the utPLSQL-cli. If you look at the code of the class RunPicocliCommand (https://github.com/utPLSQL/utPLSQL-cli/blob/develop/src/main/java/org/utplsql/cli/RunPicocliCommand.java) you can see there is no such parameter "a_exclude_schema_expr" or "a_exclude_object_expr".

    However, there's the parameter "-exclude" wich works fine, if you pass the full name of the object. So far I've been not successful to pass regexp in this parameter nor do I know the correct format of an accepted regular expression.

    Maybe utPLSQL-cli is not adapted yet to support exclusions à la a_exclude_object_expr?

  27. jgebal commented on Mar 9, 2023

    @jgebal
    jgebal
    on Mar 9, 2023
    Member
    More actions

    utplsql-cli is not supporting the new parameters yet.

    We need to extend cli as well as maven plugin to be up to date with utplsql api enchancements.

    When it can be done is a question probably more for @pesse

  28. jgebal commented on Mar 9, 2023

    @jgebal
    jgebal
    on Mar 9, 2023
    Member
    More actions

    @malugrz
    Could you open a new issue on utplsql-cli for that? This issue can be linked for reference

  29. jgebal
    removed
    good first issue
    on May 28, 2023
  30. jgebal
    added this to the v3.1.13 milestone on May 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @lwasylow
    lwasylow

Labels

enhancement

Type

No type

Projects

No projects

    Milestone

    • v3.1.13

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.