Skip to content
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
10 changes: 6 additions & 4 deletions Sources/Testing/Events/TimeValue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,17 @@ struct TimeValue: Sendable, RawRepresentable {
init(rawValue: Duration) {
(seconds, attoseconds) = rawValue.components
}

init(_ components: (seconds: Int64, attoseconds: Int64)) {
(seconds, attoseconds) = components
}
#else
var rawValue: Duration
#endif
}

extension TimeValue {
init(_ components: (seconds: Int64, attoseconds: Int64)) {
self.init(rawValue: Duration(secondsComponent: components.seconds, attosecondsComponent: components.attoseconds))
}
}

#if !SWT_NO_SNAPSHOT_TYPES
// MARK: - Codable

Expand Down
16 changes: 5 additions & 11 deletions Sources/Testing/Issues/Issue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,7 @@ public struct Issue: Sendable {
///
/// - Parameters:
/// - timeLimitComponents: The time limit reached by the test.
///
/// @Comment {
/// - Bug: The associated value of this enumeration case should be an
/// instance of `Duration`, but the testing library's deployment target
/// predates the introduction of that type.
/// }
indirect case timeLimitExceeded(timeLimit: Duration)
indirect case timeLimitExceeded(timeLimitComponents: (seconds: Int64, attoseconds: Int64))

/// A known issue was expected, but was not recorded.
case knownIssueNotRecorded
Expand Down Expand Up @@ -310,8 +304,8 @@ extension Issue.Kind: CustomStringConvertible {
return "Confirmation was confirmed \(actual.counting("time")), but expected to be confirmed \(String(describingForTest: expected)) time(s)"
case let .errorCaught(error):
return "Caught error: \(String(describingForTest: error))"
case let .timeLimitExceeded(timeLimit):
return "Time limit was exceeded: \(TimeValue(rawValue: timeLimit))"
case let .timeLimitExceeded(timeLimitComponents):
return "Time limit was exceeded: \(TimeValue(timeLimitComponents))"
case .knownIssueNotRecorded:
return "Known issue was not recorded"
case let .valueAttachmentFailed(error):
Expand Down Expand Up @@ -493,8 +487,8 @@ extension Issue.Kind {
.unconditional
case let .errorCaught(error), let .valueAttachmentFailed(error):
.errorCaught(ErrorSnapshot(snapshotting: error))
case let .timeLimitExceeded(timeLimit):
.timeLimitExceeded(timeLimitComponents: timeLimit.components)
case let .timeLimitExceeded(timeLimitComponents):
.timeLimitExceeded(timeLimitComponents: timeLimitComponents)
case .knownIssueNotRecorded:
.knownIssueNotRecorded
case .apiMisused:
Expand Down
2 changes: 1 addition & 1 deletion Sources/Testing/Running/Runner.swift
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ extension Runner {
}
} timeoutHandler: { timeLimit in
let issue = Issue(
kind: .timeLimitExceeded(timeLimit: timeLimit),
kind: .timeLimitExceeded(timeLimitComponents: timeLimit.components),
comments: [],
sourceContext: .init(backtrace: .current(), sourceLocation: sourceLocation)
)
Expand Down
2 changes: 1 addition & 1 deletion Tests/TestingTests/IssueTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1721,7 +1721,7 @@ struct IssueCodingTests {
Issue.Kind.expectationFailed(Expectation(evaluatedExpression: .init("abc"), isPassing: true, isRequired: true, sourceLocation: #_sourceLocation)),
Issue.Kind.knownIssueNotRecorded,
Issue.Kind.system,
Issue.Kind.timeLimitExceeded(timeLimit: .seconds(123)),
Issue.Kind.timeLimitExceeded(timeLimitComponents: (123, 0)),
Issue.Kind.unconditional,
]

Expand Down
2 changes: 1 addition & 1 deletion Tests/TestingTests/Traits/TimeLimitTraitTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ struct TimeLimitTraitTests {
]
)
func timeLimitExceededDescription(seconds: Int64, attoseconds: Int64, description: String) async throws {
let issueKind = Issue.Kind.timeLimitExceeded(timeLimit: Duration(secondsComponent: seconds, attosecondsComponent: attoseconds))
let issueKind = Issue.Kind.timeLimitExceeded(timeLimitComponents: (seconds, attoseconds))
#expect(String(describing: issueKind) == "Time limit was exceeded: \(description) seconds")
}
}
Expand Down
Loading