-
Notifications
You must be signed in to change notification settings - Fork 128
Generalize the selectedTests facility to be closure-based, to allow filtering tests via other criteria than ID #48
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
suzannaratcliff
merged 6 commits into
swiftlang:main
from
stmontgomery:selected-tests-filter
Oct 20, 2023
Merged
Generalize the selectedTests facility to be closure-based, to allow filtering tests via other criteria than ID #48
suzannaratcliff
merged 6 commits into
swiftlang:main
from
stmontgomery:selected-tests-filter
Oct 20, 2023
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…iltering tests via other criteria than ID
Contributor
Author
|
@swift-ci please test |
grynspan
reviewed
Oct 3, 2023
grynspan
reviewed
Oct 3, 2023
grynspan
reviewed
Oct 3, 2023
grynspan
reviewed
Oct 3, 2023
grynspan
reviewed
Oct 3, 2023
…iltering tests via other criteria than ID Add documentation and update the selection to be outside the loop
stmontgomery
commented
Oct 5, 2023
stmontgomery
commented
Oct 5, 2023
stmontgomery
commented
Oct 5, 2023
stmontgomery
commented
Oct 5, 2023
…iltering tests via other criteria than ID swiftlang#48 - Remove comment
…iltering tests via other criteria than ID Remove more TODO's
briancroom
approved these changes
Oct 10, 2023
dennisweissmann
approved these changes
Oct 17, 2023
stmontgomery
commented
Oct 17, 2023
stmontgomery
commented
Oct 17, 2023
grynspan
reviewed
Oct 17, 2023
grynspan
reviewed
Oct 17, 2023
grynspan
reviewed
Oct 17, 2023
grynspan
reviewed
Oct 17, 2023
Contributor
|
@swift-ci please test |
Contributor
Author
|
Looks good, pending CI! |
suzannaratcliff
approved these changes
Oct 20, 2023
stmontgomery
added a commit
that referenced
this pull request
Nov 14, 2023
This removes the `Test.ID.Selection.testIDs` property whose type is `Set<Test.ID>`, since it's no longer used as of #48
2 tasks
stmontgomery
added a commit
that referenced
this pull request
Nov 14, 2023
This removes the `Test.ID.Selection.testIDs` property whose type is `Set<Test.ID>`, since it's no longer used as of #48
grynspan
added a commit
that referenced
this pull request
Jun 11, 2025
This PR adds a wrapper around `__builtin_unreachable()` (`Builtin.unreachable()` when building the Swift standard library) that we can use in place of `fatalError()`. The benefit is that the generated code size for unreachable paths is significantly reduced. For example, given the following function compiled with `-O`: ```swift @available(*, unavailable) func f() { fatalError("Unreachable") } ``` The compiler currently produces: ```asm sub sp, sp, #0x20 stp x29, x30, [sp, #0x10] add x29, sp, #0x10 mov w8, #0x1 ; =1 str w8, [sp, #0x8] mov w8, #0xc ; =12 str x8, [sp] adrp x0, 0 add x0, x0, #0x6a8 ; "Fatal error" adrp x5, 0 add x5, x5, #0x690 ; "UnreachableTest/S.swift" mov x3, #0x6e55 ; =28245 movk x3, #0x6572, lsl #16 movk x3, #0x6361, lsl #32 movk x3, #0x6168, lsl #48 mov x4, #0x6c62 ; =27746 movk x4, #0x65, lsl #16 movk x4, #0xeb00, lsl #48 mov w1, #0xb ; =11 mov w2, #0x2 ; =2 mov w6, #0x17 ; =23 mov w7, #0x2 ; =2 bl 0x100000680 ; symbol stub for: Swift._assertionFailure(_: Swift.StaticString, _: Swift.String, file: Swift.StaticString, line: Swift.UInt, flags: Swift.UInt32) -> Swift.Never brk #0x1 ``` But with this change: ```swift @available(*, unavailable) func f() { swt_unreachable() } ``` It instead compiles to simply: ```asm brk #0x1 ```
grynspan
added a commit
that referenced
this pull request
Jun 11, 2025
This PR adds a wrapper around `__builtin_unreachable()` (`Builtin.unreachable()` when building the Swift standard library) that we can use in place of `fatalError()`. The benefit is that the generated code size for unreachable paths is significantly reduced. For example, given the following function compiled with `-O`: ```swift @available(*, unavailable) func f() { fatalError("Unreachable") } ``` The compiler currently produces: ```asm sub sp, sp, #0x20 stp x29, x30, [sp, #0x10] add x29, sp, #0x10 mov w8, #0x1 ; =1 str w8, [sp, #0x8] mov w8, #0xc ; =12 str x8, [sp] adrp x0, 0 add x0, x0, #0x6a8 ; "Fatal error" adrp x5, 0 add x5, x5, #0x690 ; "UnreachableTest/S.swift" mov x3, #0x6e55 ; =28245 movk x3, #0x6572, lsl #16 movk x3, #0x6361, lsl #32 movk x3, #0x6168, lsl #48 mov x4, #0x6c62 ; =27746 movk x4, #0x65, lsl #16 movk x4, #0xeb00, lsl #48 mov w1, #0xb ; =11 mov w2, #0x2 ; =2 mov w6, #0x17 ; =23 mov w7, #0x2 ; =2 bl 0x100000680 ; symbol stub for: Swift._assertionFailure(_: Swift.StaticString, _: Swift.String, file: Swift.StaticString, line: Swift.UInt, flags: Swift.UInt32) -> Swift.Never brk #0x1 ``` But with this change: ```swift @available(*, unavailable) func f() { swt_unreachable() } ``` It instead compiles to simply: ```asm brk #0x1 ```
grynspan
added a commit
that referenced
this pull request
Jun 12, 2025
This PR adds a wrapper around `__builtin_unreachable()` (`Builtin.unreachable()` when building the Swift standard library) that we can use in place of `fatalError()`. The benefit is that the generated code size for unreachable paths is significantly reduced. For example, given the following function compiled with `-O`: ```swift @available(*, unavailable) func f() { fatalError("Unreachable") } ``` The compiler currently produces: ```asm sub sp, sp, #0x20 stp x29, x30, [sp, #0x10] add x29, sp, #0x10 mov w8, #0x1 ; =1 str w8, [sp, #0x8] mov w8, #0xc ; =12 str x8, [sp] adrp x0, 0 add x0, x0, #0x6a8 ; "Fatal error" adrp x5, 0 add x5, x5, #0x690 ; "UnreachableTest/S.swift" mov x3, #0x6e55 ; =28245 movk x3, #0x6572, lsl #16 movk x3, #0x6361, lsl #32 movk x3, #0x6168, lsl #48 mov x4, #0x6c62 ; =27746 movk x4, #0x65, lsl #16 movk x4, #0xeb00, lsl #48 mov w1, #0xb ; =11 mov w2, #0x2 ; =2 mov w6, #0x17 ; =23 mov w7, #0x2 ; =2 bl 0x100000680 ; symbol stub for: Swift._assertionFailure(_: Swift.StaticString, _: Swift.String, file: Swift.StaticString, line: Swift.UInt, flags: Swift.UInt32) -> Swift.Never brk #0x1 ``` But with this change: ```swift @available(*, unavailable) func f() { swt_unreachable() } ``` It instead compiles to simply: ```asm brk #0x1 ``` ### Checklist: - [x] Code and documentation should follow the style of the [Style Guide](https://github.com/apple/swift-testing/blob/main/Documentation/StyleGuide.md). - [x] If public symbols are renamed or modified, DocC references should be updated.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Replace
Configuration.selectedTestswith an optional closure property which acts as a predicate for choosing which tests should be selected.Motivation:
Currently, the testing library supports selecting specific test(s) to run based on their
Test.ID, but we would like it to be possible to select tests based on other criteria, such as specific tag(s), or even based on arbitrary logic. Offering a closure-based predicate to filter tests would help accomplish this.Modifications:
Configuration.selectedTestIDsand associated storage property.Configuration.testSelectionFilterwhich accepts aTestand returnsBoolwhether to include it in the selected tests.Runner.Planbased on the above changes.Result:
There is now a more flexible closure-based facility for selecting/filtering tests.