-
Notifications
You must be signed in to change notification settings - Fork 47
[refactor]: improve diagnostics for escaped context instances #380
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -61,21 +61,26 @@ let package = Package( | |
| .package(url: "https://github.com/pointfreeco/swift-macro-testing", from: "0.4.0"), | ||
| .package(url: "https://github.com/pointfreeco/swift-perception", "1.5.0" ..< "3.0.0"), | ||
| .package(url: "https://github.com/pointfreeco/swift-custom-dump", from: "1.3.3"), | ||
| .package(url: "https://github.com/pointfreeco/xctest-dynamic-overlay", from: "1.0.0"), | ||
| // 'xctest-dynamic-overlay' is actually for "IssueReporting" | ||
| .package(url: "https://github.com/pointfreeco/xctest-dynamic-overlay", from: "1.2.2"), | ||
| ], | ||
| targets: [ | ||
| // MARK: Workflow | ||
|
|
||
| .target( | ||
| name: "Workflow", | ||
| dependencies: ["ReactiveSwift"], | ||
| dependencies: [ | ||
| .product(name: "IssueReporting", package: "xctest-dynamic-overlay"), | ||
| .product(name: "ReactiveSwift", package: "ReactiveSwift"), | ||
| ], | ||
| path: "Workflow/Sources" | ||
| ), | ||
| .target( | ||
| name: "WorkflowTesting", | ||
| dependencies: [ | ||
| "Workflow", | ||
| .product(name: "CustomDump", package: "swift-custom-dump"), | ||
| .product(name: "IssueReporting", package: "xctest-dynamic-overlay"), | ||
| ], | ||
| path: "WorkflowTesting/Sources", | ||
| linkerSettings: [.linkedFramework("XCTest")] | ||
|
|
@@ -125,7 +130,10 @@ let package = Package( | |
|
|
||
| .target( | ||
| name: "WorkflowReactiveSwift", | ||
| dependencies: ["ReactiveSwift", "Workflow"], | ||
| dependencies: [ | ||
| "Workflow", | ||
| .product(name: "ReactiveSwift", package: "ReactiveSwift"), | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. standardized some of these so now all the 'package-level' dependencies are just strings, and the external ones are |
||
| ], | ||
| path: "WorkflowReactiveSwift/Sources" | ||
| ), | ||
| .target( | ||
|
|
@@ -139,7 +147,10 @@ let package = Package( | |
|
|
||
| .target( | ||
| name: "WorkflowRxSwift", | ||
| dependencies: ["RxSwift", "Workflow"], | ||
| dependencies: [ | ||
| "Workflow", | ||
| .product(name: "RxSwift", package: "RxSwift"), | ||
| ], | ||
| path: "WorkflowRxSwift/Sources" | ||
| ), | ||
| .target( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,18 +14,18 @@ | |
| * limitations under the License. | ||
| */ | ||
|
|
||
| import Testing | ||
| import IssueReporting | ||
| import XCTest | ||
|
|
||
| @testable import Workflow | ||
|
|
||
| @MainActor | ||
| struct ApplyContextTests { | ||
| @Test | ||
| func concreteApplyContextInvalidatedAfterUse() async throws { | ||
| final class ApplyContextTests: XCTestCase { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. converted this to XCTest b/c when testing against the oldest version of the IssueReporting dependency we support (1.2.2), for some reason the test seemed to behave differently and didn't appear to actually 'escape' the context. i assume that means there's a bug somewhere, but did not investigate. |
||
| func testConcreteApplyContextInvalidatedAfterUse() async throws { | ||
| var escapedContext: ApplyContext<EscapingContextWorkflow>? | ||
| let onApply = { (context: ApplyContext<EscapingContextWorkflow>) in | ||
| #expect(context[workflowValue: \.property] == 42) | ||
| #expect(context.concreteStorage != nil) | ||
| XCTAssert(context[workflowValue: \.property] == 42) | ||
| XCTAssert(context.concreteStorage != nil) | ||
| escapedContext = context | ||
| } | ||
|
|
||
|
|
@@ -38,10 +38,13 @@ struct ApplyContextTests { | |
| let emitEvent = node.render() | ||
| node.enableEvents() | ||
|
|
||
| emitEvent() | ||
| // We're intentionally escaping the context | ||
| withExpectedIssue { | ||
| emitEvent() | ||
| } | ||
|
|
||
| #expect(escapedContext != nil) | ||
| #expect(escapedContext?.concreteStorage == nil) | ||
| XCTAssert(escapedContext != nil) | ||
| XCTAssert(escapedContext?.concreteStorage == nil) | ||
| } | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.