Skip to content
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

Use XCTExpectFailure from XCTestDynamicOverlay #2721

Merged
merged 1 commit into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/xctest-dynamic-overlay",
"state" : {
"revision" : "23cbf2294e350076ea4dbd7d5d047c1e76b03631",
"version" : "1.0.2"
"revision" : "b58e6627149808b40634c4552fcf2f44d0b3ca87",
"version" : "1.1.0"
}
}
],
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ let package = Package(
.package(url: "https://github.com/pointfreeco/swift-dependencies", from: "1.0.0"),
.package(url: "https://github.com/pointfreeco/swift-identified-collections", from: "1.0.0"),
.package(url: "https://github.com/pointfreeco/swiftui-navigation", from: "1.1.0"),
.package(url: "https://github.com/pointfreeco/xctest-dynamic-overlay", from: "1.0.0"),
.package(url: "https://github.com/pointfreeco/xctest-dynamic-overlay", from: "1.1.0"),
],
targets: [
.target(
Expand Down
2 changes: 1 addition & 1 deletion [email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ let package = Package(
.package(url: "https://github.com/pointfreeco/swift-identified-collections", from: "1.0.0"),
.package(url: "https://github.com/pointfreeco/swift-macro-testing", from: "0.2.0"),
.package(url: "https://github.com/pointfreeco/swiftui-navigation", from: "1.1.0"),
.package(url: "https://github.com/pointfreeco/xctest-dynamic-overlay", from: "1.0.0"),
.package(url: "https://github.com/pointfreeco/xctest-dynamic-overlay", from: "1.1.0"),
],
targets: [
.target(
Expand Down
31 changes: 2 additions & 29 deletions Sources/ComposableArchitecture/TestStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1042,7 +1042,7 @@ extension TestStore where State: Equatable {
{
var expectedWhenGivenPreviousState = current
if let updateStateToExpectedResult = updateStateToExpectedResult {
_XCTExpectFailure(strict: false) {
XCTExpectFailure(strict: false) {
do {
try Dependencies.withDependencies {
$0 = self.reducer.dependencies
Expand Down Expand Up @@ -2077,7 +2077,7 @@ extension TestStore {
case .on:
XCTFail(message, file: file, line: line)
case .off(showSkippedAssertions: true):
_XCTExpectFailure {
XCTExpectFailure {
XCTFail(
"""
Skipped assertions: …
Expand Down Expand Up @@ -2474,33 +2474,6 @@ public enum Exhaustivity: Equatable, Sendable {
public static let off = Self.off(showSkippedAssertions: false)
}

@_transparent
private func _XCTExpectFailure(
_ failureReason: String? = nil,
strict: Bool = true,
failingBlock: () -> Void
) {
#if DEBUG
guard
let XCTExpectedFailureOptions = NSClassFromString("XCTExpectedFailureOptions")
as Any as? NSObjectProtocol,
let options = strict
? XCTExpectedFailureOptions
.perform(NSSelectorFromString("alloc"))?.takeUnretainedValue()
.perform(NSSelectorFromString("init"))?.takeUnretainedValue()
: XCTExpectedFailureOptions
.perform(NSSelectorFromString("nonStrictOptions"))?.takeUnretainedValue()
else { return }

let XCTExpectFailureWithOptionsInBlock = unsafeBitCast(
dlsym(dlopen(nil, RTLD_LAZY), "XCTExpectFailureWithOptionsInBlock"),
to: (@convention(c) (String?, AnyObject, () -> Void) -> Void).self
)

XCTExpectFailureWithOptionsInBlock(failureReason, options, failingBlock)
#endif
}

extension TestStore {
@MainActor
@available(
Expand Down