Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Feature/1042 add and to tags #1250

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

Merged
merged 35 commits into from
Apr 28, 2023
Merged

Feature/1042 add and to tags #1250

merged 35 commits into from
Apr 28, 2023

Conversation

lwasylow
Copy link
Member

@lwasylow lwasylow commented Mar 31, 2023

Fixes #1042

Introduction of expressions for running tests with tags

Tag Expressions

Tag expressions are boolean expressions created by combining tags with the !, &, | operators. Tag expressions can be grouped using ( and ) braces. Grouping tag expressions affects operator precedence.

Two reserved keywords, any and none, can be used when creating a tag expression to run tests.

  • any keyword represents tests and suites with any tags
  • none keyword represents tests and suites without tags

These keywords may be combined with other expressions just like normal tags.

Note: When specifying none, be aware that it will exclude any tests/suites/contexts contained within a tagged suite.

Operator Meaning
! not
& and
| or

If you are tagging your tests across multiple dimensions, tag expressions help you to select which tests to execute. When tagging by test type (e.g., micro, integration, end-to-end) and feature (e.g., product, catalog, shipping), the following tag expressions can be useful.

Tag Expression Selection
product all tests for product
catalog | shipping all tests for catalog plus all tests for shipping
catalog & shipping all tests that are tagged with both catalog and shipping tags
product & !end-to-end all tests tagged product, except the tests tagged end-to-end
(micro | integration) & (product | shipping) all micro or integration tests for product or shipping

Taking the last expression above (micro | integration) & (product | shipping)

--%tags included in run
micro no
integration no
micro no
product no
shipping no
micro no
micro, integration no
product, shipping no
micro, product yes
micro, shipping yes
integration, product yes
integration, shipping yes
integration, micro, shipping yes
integration, micro, product yes
integration, shipping ,product yes
micro, shipping ,product yes
integration, micro, shipping ,product yes

Excluding tests/suites by tags

It is possible to exclude parts of test suites with tags.
In order to do so, prefix the tag name to exclude with a ! (exclamation) sign when invoking the test run which is equivalent of - (dash) in legacy notation.
Examples:

select * from table(ut.run(a_tags => '(api|fast)&!complex'));
select * from table(ut.run(a_tags => '(api|fast)&!complex&!test1'));

@codecov
Copy link

codecov bot commented Mar 31, 2023

Codecov Report

Patch coverage: 99.24% and project coverage change: +0.11 🎉

Comparison is base (8b01a39) 94.78% compared to head (46ffe73) 94.89%.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1250      +/-   ##
===========================================
+ Coverage    94.78%   94.89%   +0.11%     
===========================================
  Files          109      111       +2     
  Lines         5173     5286     +113     
  Branches        24       24              
===========================================
+ Hits          4903     5016     +113     
- Misses         262      263       +1     
+ Partials         8        7       -1     
Flag Coverage Δ
11XE 94.27% <99.24%> (+0.15%) ⬆️
12.1EE 94.27% <98.48%> (+0.13%) ⬆️
18XE 94.48% <99.24%> (+0.10%) ⬆️
21XE 94.65% <99.24%> (+0.09%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
source/core/types/ut_run.tpb 93.93% <ø> (ø)
source/core/ut_utils.pkb 94.69% <ø> (+0.24%) ⬆️
source/core/ut_suite_tag_filter.pkb 99.09% <99.09%> (ø)
source/api/ut_runner.pkb 95.91% <100.00%> (-0.13%) ⬇️
source/core/types/ut_stack.tpb 100.00% <100.00%> (ø)
source/core/ut_suite_cache_manager.pkb 97.01% <100.00%> (-0.43%) ⬇️
source/core/ut_suite_manager.pkb 96.72% <100.00%> (+0.01%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 31, 2023

Unit Test Results

       1 files         2 suites   5m 24s ⏱️
1 047 tests 1 043 ✔️ 4 💤 0
1 050 runs  1 042 ✔️ 8 💤 0

Results for commit 46ffe73.

♻️ This comment has been updated with latest results.

@lwasylow
Copy link
Member Author

lwasylow commented Apr 1, 2023

So seems like there is no hit in perf:
New code:
Finished in 9.393748 seconds
2000 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)

First run took+000000000 00:01:26.587663000

Finished in 16.495174 seconds
2000 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)

Second run took+000000000 00:01:17.189142000

Finished in 13.658072 seconds
2000 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)

third run took+000000000 00:01:20.499584000

old

Finished in 16.167675 seconds
2000 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)

First run took+000000000 00:03:37.830094000

Finished in 13.127262 seconds
2000 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)

Second run took+000000000 00:03:29.262099000

Finished in 10.98218 seconds
2000 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)

Third run took+000000000 00:03:01.665203000

@lwasylow lwasylow requested a review from jgebal April 7, 2023 05:29
@lwasylow
Copy link
Member Author

lwasylow commented Apr 7, 2023

@jgebal I'm also considering to add keywords none() and any(). What you think? It will take an extra time to implement.
Also not sure if that would have any usage so maybe keep it simple :)

@jgebal
Copy link
Member

jgebal commented Apr 7, 2023

I can review this PR after Wednesday.
Sorry for delay.

What is the idea behind any() and none()?
Can you explain how it would work?

@lwasylow
Copy link
Member Author

lwasylow commented Apr 7, 2023

Aye, no rush. As for keyword as per junit5
Two special expressions are supported, any() and none(), which select all tests with any tags at all, and all tests without any tags, respectively. These special expressions may be combined with other expressions just like normal tags. docs

@lwasylow
Copy link
Member Author

lwasylow commented Apr 7, 2023

Got some small changes to do still.
Want to validate using a shunting algorithm and polish reverse notation.
That should allow me to put a back later on to SQL filter of tag members string in infix notation.
The initial idea of using regex was flaky and unreliable.
The RPN supports all complex expressions.

Copy link
Member

@jgebal jgebal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like the code you wrote. It's realitvely easy to digest. The except rnp and infix/postfix logic is of course quite complex and hard to grasp without some reading.

I added quite few comments but they are mostly cosmetic/readability and maintainability oriented.

Copy link
Member

@jgebal jgebal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a complete review yet, but few comments.
I'll need a bit more time to look through it all.

@jgebal
Copy link
Member

jgebal commented Apr 18, 2023

Aye, no rush. As for keyword as per junit5 Two special expressions are supported, any() and none(), which select all tests with any tags at all, and all tests without any tags, respectively. These special expressions may be combined with other expressions just like normal tags. docs

Sounds like a great idea.
You want to do it as part of this PR or separate after this one is done?

@lwasylow
Copy link
Member Author

Aye, no rush. As for keyword as per junit5 Two special expressions are supported, any() and none(), which select all tests with any tags at all, and all tests without any tags, respectively. These special expressions may be combined with other expressions just like normal tags. docs

Sounds like a great idea. You want to do it as part of this PR or separate after this one is done?

Let's get that in new PR.
It will be cleaner to review and write tests as well as update documentation.
I started already working on change and seems like it small one but need to write more complex tests and scenarios.

@lwasylow
Copy link
Member Author

Aye, no rush. As for keyword as per junit5 Two special expressions are supported, any() and none(), which select all tests with any tags at all, and all tests without any tags, respectively. These special expressions may be combined with other expressions just like normal tags. docs

Sounds like a great idea. You want to do it as part of this PR or separate after this one is done?

Let's get that in new PR. It will be cleaner to review and write tests as well as update documentation. I started already working on change and seems like it small one but need to write more complex tests and scenarios.

I have added into existing PR as the change was minimal.

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

99.3% 99.3% Coverage
0.0% 0.0% Duplication

@jgebal jgebal merged commit 46e0a8e into develop Apr 28, 2023
@jgebal jgebal deleted the feature/1042_add_and_to_tags branch April 28, 2023 09:09
@alexeyhimself
Copy link

👏👏👏

@jgebal jgebal changed the title Feature/1042 add and to tags Feature/1042 add and to tags May 21, 2023
@jgebal jgebal added this to the v3.1.14 milestone May 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support "AND" logic to tags for the tests runner
3 participants