-
Notifications
You must be signed in to change notification settings - Fork 120
Create a separate library containing a fallback event handler. #1280
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
base: main
Are you sure you want to change the base?
Conversation
This PR adds an experimental helper library that contains a hook function called the "fallback event handler". When Swift Testing posts an event such as "issue recorded", but Swift Testing itself isn't the running testing library (i.e. XCTest is actually running), it calls the fallback event handler and passes the event (JSON-encoded) to it. Because the hook function is exported from a separate library, XCTest can (in theory, anyway) set the fallback event handler to a function that decodes the JSON-encoded event and translates it into the corresponding XCTest event. Swift Testing sets the fallback event handler itself when it starts running so that, conversely, if a testing library such as XCTest were to generate an event and determine it isn't running, it could post that event to the same event handler and have Swift Testing pick it up and translate it into a Swift Testing event. So that if you have code that calls `#expect()` from within XCTest, or if you have code that calls `XCTAssert()`` from within Swift Testing, it'll "just work™".
@swift-ci test |
@@ -203,7 +203,8 @@ sufficient information to display the event in a human-readable format. | |||
} | |||
|
|||
<attachment> ::= { | |||
"path": <string>, ; the absolute path to the attachment on disk | |||
["path": <string>,] ; the absolute path to the attachment on disk if it has |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This value is not set if an attachment wasn't saved to disk already, so it should be optional in the schema.
// MARK: - Converting back to an Issue | ||
|
||
extension Issue { | ||
/// Attempt to reconstruct an instance of ``Issue`` from the given encoded |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved this code from ExitTest.swift so we can reuse it.
@swift-ci test |
1 similar comment
@swift-ci test |
@swift-ci test |
@swift-ci test |
@swift-ci test |
This PR adds an experimental helper library that contains a hook function called the "fallback event handler". When Swift Testing posts an event such as "issue recorded", but Swift Testing itself isn't the running testing library (i.e. XCTest is actually running), it calls the fallback event handler and passes the event (JSON-encoded) to it.
Because the hook function is exported from a separate library, XCTest can (in theory, anyway) set the fallback event handler to a function that decodes the JSON-encoded event and translates it into the corresponding XCTest event.
Swift Testing sets the fallback event handler itself when it starts running so that, conversely, if a testing library such as XCTest were to generate an event and determine it isn't running, it could post that event to the same event handler and have Swift Testing pick it up and translate it into a Swift Testing event.
So that if you have code that calls
#expect()
from within XCTest, or if you have code that callsXCTAssert()
from within Swift Testing, it'll "just work™".Checklist: