-
Notifications
You must be signed in to change notification settings - Fork 103
Add the current configuration to Event.Context
.
#677
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Merged
Merged
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
This PR adds a `var configuration: Configuration` property to `Event.Context` and adds a `verbosity` property to `Configuration`. We solve two problems: 1. An event handler cannot see the current configuration (without querying `Configuration.current`) which limits its ability to customize its behaviour; and 2. The verbosity of human-readable output is tracked by individual event handlers when it is intended to be part of a test run's configuration. Since the configuration contains the event handler to which we pass the event context, the `eventHandler` property of the context is cleared before the event handler is called (thus breaking any reference cycles.) Callers of the internal `Event.post()` function are now required to either pass _both_ the test and test case for the event, or to pass neither (in which case we now gather both from the runtime state in a single call rather than hitting the task-local twice.) This is effected with a tuple as an argument to `Event.post()` which is admittedly a bit wonky but does force our call sites to explicitly pass values for both the test and test case, where previously we could accidentally pass a specific test and then go look up the task-local current test case (which should have been `nil` in all the cases where we were doing this anyway.) A couple of interfaces on the event recorder types have changed in this PR in source-breaking ways. The old interfaces remain present but deprecated; they will be removed later in the Swift 6.1 development cycle after tools authors have had time to migrate.
@swift-ci test |
2 tasks
stmontgomery
approved these changes
Sep 11, 2024
grynspan
added a commit
that referenced
this pull request
Sep 17, 2024
This PR restores/undeprecates the `verbosity` argument to `HumanReadableOutputRecorder.record()` that was deprecated in #677. We still need to be able to override the command-line-specified value in the event stream.
2 tasks
grynspan
added a commit
that referenced
this pull request
Sep 17, 2024
…)`. (#707) This PR restores/undeprecates the `verbosity` argument to `HumanReadableOutputRecorder.record()` that was deprecated in #677. We still need to be able to override the command-line-specified value in the event stream. ### 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.
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
Labels
enhancement
New feature or request
performance
Performance issues
tools integration
Integration of swift-testing into tools/IDEs
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.
This PR adds a
var configuration: Configuration
property toEvent.Context
and adds averbosity
property toConfiguration
. We solve two problems:Configuration.current
) which limits its ability to customize its behaviour; andSince the configuration contains the event handler to which we pass the event context, the
eventHandler
property of the context is cleared before the event handler is called (thus breaking any reference cycles.)Callers of the internal
Event.post()
function are now required to either pass both the test and test case for the event, or to pass neither (in which case we now gather both from the runtime state in a single call rather than hitting the task-local twice.) This is effected with a tuple as an argument toEvent.post()
which is admittedly a bit wonky but does force our call sites to explicitly pass values for both the test and test case, where previously we could accidentally pass a specific test and then go look up the task-local current test case (which should have beennil
in all the cases where we were doing this anyway.)A couple of interfaces on the event recorder types have changed in this PR in source-breaking ways. The old interfaces remain present but deprecated; they will be removed later in the Swift 6.1 development cycle after tools authors have had time to migrate.
Checklist: