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

Disfavor another unimplemented deprecation #123

Merged
merged 3 commits into from
Sep 6, 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
4 changes: 2 additions & 2 deletions Examples/ExamplesTests/SwiftTestingTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
withKnownIssue {
reportIssue()
} matching: { issue in
issue.description == "Expectation failed: "
issue.description == "Issue recorded"
}
}

@Test func reportIssue_CustomMessage() {
withKnownIssue {
reportIssue("Something went wrong")
} matching: { issue in
issue.description == "Expectation failed: Something went wrong"
issue.description == "Issue recorded: Something went wrong"
}
}

Expand Down
19 changes: 3 additions & 16 deletions Sources/XCTestDynamicOverlay/Internal/Deprecations.swift
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ public var XCTCurrentTestCase: AnyObject? {
}

@_disfavoredOverload
@available(*, deprecated, renamed: "unimplemented(_:placeholder:)")
@available(*, unavailable, renamed: "unimplemented(_:placeholder:)")
public func unimplemented<Result>(
_ description: @autoclosure @escaping @Sendable () -> String = "",
file filePath: StaticString = #filePath,
Expand All @@ -260,23 +260,10 @@ public func unimplemented<Result>(
line: UInt = #line,
column: UInt = #column
) -> Result {
let description = description()
_fail(
description,
nil,
fileID: fileID,
filePath: filePath,
function: function,
line: line,
column: column
)
do {
return try _generatePlaceholder()
} catch {
_unimplementedFatalError(description, file: filePath, line: line)
}
fatalError()
}

@_disfavoredOverload
@available(*, deprecated, renamed: "unimplemented(_:placeholder:)")
public func unimplemented<each Argument, Result>(
_ description: @autoclosure @escaping @Sendable () -> String = "",
Expand Down
29 changes: 29 additions & 0 deletions Tests/IssueReportingTests/UnimplementedTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -122,5 +122,34 @@
"""
}
}

@MainActor
@Test func mainActor() throws {
final class Model: Sendable {
let line = #line + 1
let callback: @Sendable @MainActor () throws -> Void = IssueReporting.unimplemented()
}

let model = Model()
try withKnownIssue {
try withKnownIssue {
_ = try model.callback()
} matching: { issue in
issue.description == """
Issue recorded: Unimplemented …

Defined in 'Model' at:
IssueReportingTests/UnimplementedTests.swift:\(model.line)

Invoked with:
()
"""
}
} matching: { issue in
issue.description == """
Caught error: UnimplementedFailure(description: "")
"""
}
}
}
#endif
9 changes: 4 additions & 5 deletions Tests/XCTestDynamicOverlayTests/TestHelpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,11 @@ struct User { let id: UUID }
@available(*, deprecated)
@MainActor let fm01: @MainActor () -> Int = unimplemented("fm01")

@available(*, deprecated)
private struct Autoclosing {
init(
_: @autoclosure () -> Int = unimplemented(),
_: @autoclosure () async -> Int = unimplemented(),
_: @autoclosure () throws -> Int = unimplemented(),
_: @autoclosure () async throws -> Int = unimplemented()
_: @autoclosure () -> Int = unimplemented(placeholder: 0),
_: @autoclosure () async -> Int = unimplemented(placeholder: 0),
_: @autoclosure () throws -> Int = unimplemented(placeholder: 0),
_: @autoclosure () async throws -> Int = unimplemented(placeholder: 0)
) async {}
}
Loading