Skip to content

Commit 5f8d860

Browse files
committed
Backwards compat
1 parent d1b834b commit 5f8d860

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

Sources/IssueReporting/TestContext.swift

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/// A type representing the context in which a test is being run, _i.e._ either in Swift's native
22
/// Testing framework, or Xcode's XCTest framework.
3-
public enum TestContext: Equatable {
3+
public enum TestContext {
44
/// The Swift Testing framework.
5-
case swiftTesting(Testing)
5+
case swiftTesting(Testing?)
66

77
/// The XCTest framework.
88
case xcTest
@@ -55,3 +55,23 @@ extension TestContext.Testing {
5555
self.init(test: Test(id: Test.ID(rawValue: id)))
5656
}
5757
}
58+
59+
extension TestContext: Equatable {
60+
public static func == (lhs: Self, rhs: Self) -> Bool {
61+
switch (lhs, rhs) {
62+
case (.swiftTesting(nil), .swiftTesting),
63+
(.swiftTesting, .swiftTesting(nil)),
64+
(.xcTest, .xcTest):
65+
return true
66+
case (.swiftTesting(let lhs), .swiftTesting(let rhs)):
67+
return lhs == rhs
68+
default:
69+
return false
70+
}
71+
}
72+
73+
@available(*, deprecated, message: "Test for '.swiftTesting' using pattern matching, instead.")
74+
public static var swiftTesting: Self {
75+
.swiftTesting(nil)
76+
}
77+
}

0 commit comments

Comments
 (0)