Skip to content

Commit 969b573

Browse files
authored
Use XCTExpectFailure from XCTestDynamicOverlay (#2721)
The test store has dynamically loaded this helper for awhile now, but now we can offload that work to another library.
1 parent 11184df commit 969b573

File tree

4 files changed

+6
-33
lines changed

4 files changed

+6
-33
lines changed

ComposableArchitecture.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ let package = Package(
2727
.package(url: "https://github.com/pointfreeco/swift-dependencies", from: "1.0.0"),
2828
.package(url: "https://github.com/pointfreeco/swift-identified-collections", from: "1.0.0"),
2929
.package(url: "https://github.com/pointfreeco/swiftui-navigation", from: "1.1.0"),
30-
.package(url: "https://github.com/pointfreeco/xctest-dynamic-overlay", from: "1.0.0"),
30+
.package(url: "https://github.com/pointfreeco/xctest-dynamic-overlay", from: "1.1.0"),
3131
],
3232
targets: [
3333
.target(

[email protected]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ let package = Package(
3030
.package(url: "https://github.com/pointfreeco/swift-identified-collections", from: "1.0.0"),
3131
.package(url: "https://github.com/pointfreeco/swift-macro-testing", from: "0.2.0"),
3232
.package(url: "https://github.com/pointfreeco/swiftui-navigation", from: "1.1.0"),
33-
.package(url: "https://github.com/pointfreeco/xctest-dynamic-overlay", from: "1.0.0"),
33+
.package(url: "https://github.com/pointfreeco/xctest-dynamic-overlay", from: "1.1.0"),
3434
],
3535
targets: [
3636
.target(

Sources/ComposableArchitecture/TestStore.swift

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,7 +1042,7 @@ extension TestStore where State: Equatable {
10421042
{
10431043
var expectedWhenGivenPreviousState = current
10441044
if let updateStateToExpectedResult = updateStateToExpectedResult {
1045-
_XCTExpectFailure(strict: false) {
1045+
XCTExpectFailure(strict: false) {
10461046
do {
10471047
try Dependencies.withDependencies {
10481048
$0 = self.reducer.dependencies
@@ -2077,7 +2077,7 @@ extension TestStore {
20772077
case .on:
20782078
XCTFail(message, file: file, line: line)
20792079
case .off(showSkippedAssertions: true):
2080-
_XCTExpectFailure {
2080+
XCTExpectFailure {
20812081
XCTFail(
20822082
"""
20832083
Skipped assertions: …
@@ -2474,33 +2474,6 @@ public enum Exhaustivity: Equatable, Sendable {
24742474
public static let off = Self.off(showSkippedAssertions: false)
24752475
}
24762476

2477-
@_transparent
2478-
private func _XCTExpectFailure(
2479-
_ failureReason: String? = nil,
2480-
strict: Bool = true,
2481-
failingBlock: () -> Void
2482-
) {
2483-
#if DEBUG
2484-
guard
2485-
let XCTExpectedFailureOptions = NSClassFromString("XCTExpectedFailureOptions")
2486-
as Any as? NSObjectProtocol,
2487-
let options = strict
2488-
? XCTExpectedFailureOptions
2489-
.perform(NSSelectorFromString("alloc"))?.takeUnretainedValue()
2490-
.perform(NSSelectorFromString("init"))?.takeUnretainedValue()
2491-
: XCTExpectedFailureOptions
2492-
.perform(NSSelectorFromString("nonStrictOptions"))?.takeUnretainedValue()
2493-
else { return }
2494-
2495-
let XCTExpectFailureWithOptionsInBlock = unsafeBitCast(
2496-
dlsym(dlopen(nil, RTLD_LAZY), "XCTExpectFailureWithOptionsInBlock"),
2497-
to: (@convention(c) (String?, AnyObject, () -> Void) -> Void).self
2498-
)
2499-
2500-
XCTExpectFailureWithOptionsInBlock(failureReason, options, failingBlock)
2501-
#endif
2502-
}
2503-
25042477
extension TestStore {
25052478
@MainActor
25062479
@available(

0 commit comments

Comments
 (0)