Skip to content

Support removing tags set globally by using -tag syntax with [Tags] setting #4374

Closed

Description

@pekkaklarck

Currently it is possible to use the Default Tags setting to specify tags that tests have by default but that can be overridden by individual tests by using the [Tags] setting. The whole system to set tags for tests with Force Tags, Default Tags and [Tags] is somewhat complicated and issue #4365 proposes simplifying it so that Force Tags is renamed to Test Tags and Default Tags is removed altogether. I believe simplifying the syntax is a good idea, but I understand there are still sometimes cases where specifying tags that most tests have but some don't would be convenient.

My proposal is that we'd make it possible to use -tag syntax with tests that want to opt out from tags set globally. Basically that would change current

*** Settings ***
Force Tags      all
Default Tags    most

*** Test Cases ***
T1
    No Operation
T2
    [Tags]    one
    No Operation
T3
    No Operation

to

*** Settings ***
Test Tags      all    most

*** Test Cases ***
T1
    No Operation
T2
    [Tags]    one    -most
    No Operation
T3
    No Operation

I actually consider the above easier to understand the original with strange Force Tags and Default Tags settings.

The major benefit of this syntax would be that it would work also with the proposed Keyword Tags setting (#4373). Regardless do we remove Default Tags or not, I don't think it makes sense to add something like Default Keyword Tags in addition to Keyword Tags, but this would work just fine:

*** Settings ***
Keywords Tags      all    most

*** Keywords ***
K1
    No Operation
K2
    [Tags]    one    -most
    No Operation
K3
    No Operation

Activity

  1. pekkaklarck commented on Jun 20, 2022

    @pekkaklarck
    MemberAuthor

    A problem with the -tag syntax is that someone may be using tags that start with a hyphen. This is how I think we can mitigate that problem:

    1. Only make the -tag syntax special with the [Tags] setting. With Test Tags just add all all tags regardless do they start with - or not.
    2. Allow escaping the syntax like \-tag. That would mean adding tag -tag, not removing tag tag.
    3. Deprecate using -tag with [Tags] as a literal tag name in RF 6.0.
    4. Change -tag with [Tags] to mean removing tag in RF 6.1.
  2. pekkaklarck commented on Jun 20, 2022

    @pekkaklarck
    MemberAuthor

    Another small problem is handling variables. I believe we should handle the -tag syntax when building the executable model and we don't have variables available at that point. It means we cannot know tag to actually remove if someone uses -${tag} or that does the value actually start with - if the value is just ${tag}. I believe this is how we should handle these issues:

    1. When someone uses -${tag}, remove possible tags that have been set like ${tag}.
    2. If someone uses ${tag} and the value starts with -, just use the value as-is when it is actually resolved. As discussed in the above comment, we'd keep supporting tags starting with - anyway.
  3. added this to the v5.2 milestone on Jun 22, 2022
  4. pekkaklarck commented on Oct 31, 2022

    @pekkaklarck
    MemberAuthor

    Another design decision to make is how to handle possible patterns when using the -tag syntax. For example, should -t* remove literal tag t* or all tags starting with t. The latter would make the feature more powerful, but requires escaping like -t[*] if tags actually contain meta characters used in glob patterns. I believe such meta characters are so rare that making the feature more powerful makes sense.

  5. modified the milestones: v6.1, on Jan 3, 2023
  6. modified the milestones: , v7.0 on Jun 2, 2023
  7. self-assigned this
    on Sep 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions