Skip to content

Conversation

@grynspan
Copy link
Contributor

This PR is a follow-on to #77. It adds the ability to filter tests to just the ones that contain a given tag using an environment variable. As before, swift test --filter is unaware of swift-testing, so we need a temporary solution until such time as swift test is taught about us.

To try it out:

SWT_SELECTED_TAGS='trait' swift test

Will run only those tests with the "trait" tag.

If both "SWT_SELECTED_TAGS"" and "SWT_SELECTED_TEST_IDS" are specified, a test must have (at least one of) the given tags and be selected by ID. Whether or not this is the right way to combine these environment variables is, to be polite, probably uninteresting since this is not meant to be a permanent solution.

This change also implements == and hash(into:) on Tag as they were previously synthesized which would cause them to consider the internal sourceCode property, which was not intentional.

This PR is a follow-on to #77. It adds the ability to filter tests to just the ones that contain a given tag using an environment variable. As before, `swift test --filter` is unaware of swift-testing, so we need a temporary solution until such time as `swift test` is taught about us.

To try it out:

```
SWT_SELECTED_TAGS='trait' swift test
```

Will run only those tests with the `"trait"` tag.

If both `"SWT_SELECTED_TAGS""` and `"SWT_SELECTED_TEST_IDS"` are specified, a test must have (at least one of) the given tags _and_ be selected by ID. Whether or not this is the right way to combine these environment variables is, to be polite, probably uninteresting since this is not meant to be a permanent solution.

This change also implements `==` and `hash(into:)` on `Tag` as they were previously synthesized which would cause them to consider the internal `sourceCode` property, which was not intentional.
@grynspan
Copy link
Contributor Author

@swift-ci please test

for test in tests {
let idComponents = test.id.keyPathRepresentation
testGraph.insertValue(test, at: idComponents)
actionGraph.insertValue(.run, at: idComponents, intermediateValue: .run)
Copy link
Contributor

Choose a reason for hiding this comment

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

Moving the where ... clause here will cause the actionGraph to always be updated, even if some of those tests are later filtered out. Does something else later on cause the corresponding nodes in that graph to be pruned?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, immediately below we prune them out (after applying traits recursively) on line 173.

@grynspan grynspan requested a review from stmontgomery October 24, 2023 15:19
@grynspan grynspan merged commit 6cb4869 into main Oct 25, 2023
@grynspan grynspan deleted the jgrynspan/filter-by-tag branch October 25, 2023 18:05
@grynspan grynspan added the enhancement New feature or request label Oct 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants