Skip to content

Commit b185073

Browse files
authored
Revert #127 (#130)
1 parent 3fcc3f2 commit b185073

File tree

3 files changed

+14
-50
lines changed

3 files changed

+14
-50
lines changed

Sources/IssueReporting/Internal/SwiftTesting.swift

Lines changed: 7 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -234,19 +234,17 @@ func _withKnownIssue(
234234
await withKnownIssue(message, isIntermittent, fileID, filePath, line, column, body)
235235
}
236236
@usableFromInline
237-
func _currentTestData() -> (id: AnyHashable, isParameterized: Bool)? {
238-
guard let function = function(for: "$s25IssueReportingTestSupport08_currentC4DataypyF")
237+
func _currentTestID() -> AnyHashable? {
238+
guard let function = function(for: "$s25IssueReportingTestSupport08_currentC2IDypyF")
239239
else {
240240
#if DEBUG
241-
guard let id = Test.current?.id, let isParameterized = Test.Case.current?.isParameterized
242-
else { return nil }
243-
return (id, isParameterized)
241+
return Test.current?.id
244242
#else
245243
return nil
246244
#endif
247245
}
248246

249-
return (function as! @Sendable () -> (id: AnyHashable, isParameterized: Bool)?)()
247+
return (function as! @Sendable () -> AnyHashable?)()
250248
}
251249

252250
#if DEBUG
@@ -354,8 +352,8 @@ func _currentTestData() -> (id: AnyHashable, isParameterized: Bool)? {
354352
}
355353
}
356354

357-
private struct Test: @unchecked Sendable {
358-
fileprivate static var current: Self? {
355+
struct Test: @unchecked Sendable {
356+
static var current: Self? {
359357
guard
360358
let current = unsafeBitCast(
361359
symbol: "$s7Testing4TestV7currentACSgvgZ",
@@ -366,30 +364,7 @@ func _currentTestData() -> (id: AnyHashable, isParameterized: Bool)? {
366364
return current()
367365
}
368366

369-
fileprivate struct Case {
370-
static var current: Self? {
371-
guard
372-
let current = unsafeBitCast(
373-
symbol: "$s7Testing4TestV4CaseV7currentAESgvgZ",
374-
in: "Testing",
375-
to: (@convention(thin) () -> Test.Case?).self
376-
)
377-
else { return nil }
378-
return current()
379-
}
380-
381-
private var arguments: [Argument]
382-
private var body: @Sendable () async throws -> Void
383-
384-
fileprivate var isParameterized: Bool {
385-
!arguments.isEmpty
386-
}
387-
388-
private struct Argument: Sendable {
389-
var value: any Sendable
390-
var parameter: Parameter
391-
}
392-
}
367+
struct Case {}
393368
private var name: String
394369
private var displayName: String?
395370
private var traits: [any Trait]

Sources/IssueReporting/TestContext.swift

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ public enum TestContext: Equatable {
2323
/// If executed outside of a test process, this will return `nil`.
2424
public static var current: Self? {
2525
guard isTesting else { return nil }
26-
if case let (id, isParameterized)? = _currentTestData() {
27-
return .swiftTesting(Testing(id: id, isParameterized: isParameterized))
26+
if let currentTestID = _currentTestID() {
27+
return .swiftTesting(Testing(id: currentTestID))
2828
} else {
2929
return .xcTest
3030
}
@@ -42,11 +42,7 @@ public enum TestContext: Equatable {
4242

4343
public struct Test: Equatable, Hashable, Identifiable, Sendable {
4444
public let id: ID
45-
public let `case`: Test.Case
4645

47-
public struct Case: Equatable, Hashable, Sendable {
48-
public let isParameterized: Bool
49-
}
5046
public struct ID: Equatable, Hashable, @unchecked Sendable {
5147
fileprivate let rawValue: AnyHashable
5248
}
@@ -77,12 +73,7 @@ public enum TestContext: Equatable {
7773
}
7874

7975
extension TestContext.Testing {
80-
fileprivate init(id: AnyHashable, isParameterized: Bool) {
81-
self.init(
82-
test: Test(
83-
id: Test.ID(rawValue: id),
84-
case: Test.Case(isParameterized: isParameterized)
85-
)
86-
)
76+
fileprivate init(id: AnyHashable) {
77+
self.init(test: Test(id: Test.ID(rawValue: id)))
8778
}
8879
}

Sources/IssueReportingTestSupport/SwiftTesting.swift

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,11 @@ private func __withKnownIssueAsync(
100100
#endif
101101
}
102102

103-
public func _currentTestData() -> Any { __currentTestData }
103+
public func _currentTestID() -> Any { __currentTestID }
104104
@Sendable
105-
private func __currentTestData() -> (id: AnyHashable, isParameterized: Bool)? {
105+
private func __currentTestID() -> AnyHashable? {
106106
#if canImport(Testing)
107-
guard let id = Test.current?.id, let isParameterized = Test.Case.current?.isParameterized
108-
else { return nil }
109-
return (id, isParameterized)
107+
return Test.current?.id
110108
#else
111109
return nil
112110
#endif

0 commit comments

Comments
 (0)