test_runner: add tags option and tag-name filter#63221
Conversation
|
Review requested:
|
4f4407b to
3d18efb
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #63221 +/- ##
==========================================
+ Coverage 90.02% 90.04% +0.02%
==========================================
Files 713 714 +1
Lines 224950 225192 +242
Branches 42530 42570 +40
==========================================
+ Hits 202513 202777 +264
+ Misses 14220 14186 -34
- Partials 8217 8229 +12
🚀 New features to boost your workflow:
|
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
| For each test that is executed, any corresponding test hooks, such as | ||
| `beforeEach()`, are also run. | ||
| **Default:** `undefined`. | ||
| * `testTagFilters` {string|string\[]} A tag name, or an array of tag names, |
There was a problem hiding this comment.
should we accept a function as well?
There was a problem hiding this comment.
I don't think so.
That should be discussed in a follow up, as part of the DSL addition, IMHO
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
Adds a `tags` option to test(), it(), suite(), and describe() that accepts an array of string labels. Tags are canonicalized to lowercase and inherited from suites to nested tests by union. Reporter events expose the tag set on every test, and TestContext exposes the test's tags via `context.tags`. Filtering is done by literal tag name through the new `--experimental-test-tag-filter=<tag>` flag (or `testTagFilters` on run()). The flag may be specified more than once; tests must contain every filter to run. Untagged tests are excluded under any positive filter. The tagging mechanism is gated behind a one-shot ExperimentalWarning. Signed-off-by: atlowChemi <chemi@atlow.co.il>
3d18efb to
28beec8
Compare
|
@MoLow @pmarchini I rebased to include a CI fix for the windows Jenkins job. Could you re-approve? |
This comment was marked as outdated.
This comment was marked as outdated.
| if (testTagFilters.length === 0) { | ||
| testTagFilters = null; | ||
| } else { | ||
| emitExperimentalWarning('Test tags'); |
There was a problem hiding this comment.
| emitExperimentalWarning('Test tags'); | |
| emitExperimentalWarning('Test tag filtering'); |
There was a problem hiding this comment.
@avivkeller I don't agree with this, since this is not only the filtering which is experimental, but also the inheritance between suites/tests, the property on the test's context etc.
|
|
||
| const tagFilterFlag = getOptionValue('--experimental-test-tag-filter'); | ||
| if (tagFilterFlag?.length > 0) { | ||
| emitExperimentalWarning('Test tags'); |
There was a problem hiding this comment.
| emitExperimentalWarning('Test tags'); | |
| emitExperimentalWarning('Test tag filtering'); |
Summary
tagsarray option totest(),it(),suite(),describe()with case-insensitive canonicalization and union inheritance from suites.
test:start,test:pass, etc.) andvia
context.tags.--experimental-test-tag-filter=<tag>andtestTagFiltersforliteral tag-name filtering. Multi-occurrence composes by AND.
Extracts the tagging mechanism from #63054 so the boolean expression
DSL can be discussed separately. The filter syntax here is a single
literal tag name.
One known caveat: tag values currently accept any non-empty string.
Adding the DSL later will require reserving operator characters
(
& | ! ( ) *) and the wordsand/or/not, which would be abreaking change. Acceptable since this ships at Stability 1.0
(Early development).