From 67e9e7944953203ffe98fa3cc2d05fe6c11918ed Mon Sep 17 00:00:00 2001 From: Stephen Celis Date: Wed, 2 Apr 2025 08:49:24 -0700 Subject: [PATCH 01/10] Expose test traits dynamically --- Package.swift | 13 +++++++++++-- Package@swift-6.0.swift | 13 +++++++++++-- .../IssueReporting/Internal/SwiftTesting.swift | 11 ++++++----- Sources/IssueReporting/TestContext.swift | 17 +++++++++++++---- .../IssueReportingPackageSupport/_Test.swift | 14 ++++++++++++++ .../SwiftTesting.swift | 8 +++++--- 6 files changed, 60 insertions(+), 16 deletions(-) create mode 100644 Sources/IssueReportingPackageSupport/_Test.swift diff --git a/Package.swift b/Package.swift index f3a8668..1c50b17 100644 --- a/Package.swift +++ b/Package.swift @@ -22,7 +22,13 @@ let package = Package( ], targets: [ .target( - name: "IssueReporting" + name: "IssueReportingPackageSupport" + ), + .target( + name: "IssueReporting", + dependencies: [ + "IssueReportingPackageSupport" + ] ), .testTarget( name: "IssueReportingTests", @@ -32,7 +38,10 @@ let package = Package( ] ), .target( - name: "IssueReportingTestSupport" + name: "IssueReportingTestSupport", + dependencies: [ + "IssueReportingPackageSupport" + ] ), .target( name: "XCTestDynamicOverlay", diff --git a/Package@swift-6.0.swift b/Package@swift-6.0.swift index 22f30ee..308b8c2 100644 --- a/Package@swift-6.0.swift +++ b/Package@swift-6.0.swift @@ -21,7 +21,13 @@ let package = Package( ], targets: [ .target( - name: "IssueReporting" + name: "IssueReportingPackageSupport" + ), + .target( + name: "IssueReporting", + dependencies: [ + "IssueReportingPackageSupport", + ] ), .testTarget( name: "IssueReportingTests", @@ -31,7 +37,10 @@ let package = Package( ] ), .target( - name: "IssueReportingTestSupport" + name: "IssueReportingTestSupport", + dependencies: [ + "IssueReportingPackageSupport", + ] ), .target( name: "XCTestDynamicOverlay", diff --git a/Sources/IssueReporting/Internal/SwiftTesting.swift b/Sources/IssueReporting/Internal/SwiftTesting.swift index d31860c..e370435 100644 --- a/Sources/IssueReporting/Internal/SwiftTesting.swift +++ b/Sources/IssueReporting/Internal/SwiftTesting.swift @@ -1,4 +1,5 @@ import Foundation +import IssueReportingPackageSupport #if canImport(WinSDK) import WinSDK @@ -313,17 +314,17 @@ func _withKnownIssue( #endif @usableFromInline -func _currentTestID() -> AnyHashable? { - guard let function = function(for: "$s25IssueReportingTestSupport08_currentC2IDypyF") +func _currentTest() -> _Test? { + guard let function = function(for: "$s25IssueReportingTestSupport08_currentC0ypyF") else { #if DEBUG - return Test.current?.id + return Test.current.map { _Test(id: $0.id, traits: $0.traits) } #else return nil #endif } - return (function as! @Sendable () -> AnyHashable?)() + return (function as! @Sendable () -> _Test?)() } #if DEBUG @@ -446,7 +447,7 @@ func _currentTestID() -> AnyHashable? { struct Case {} private var name: String private var displayName: String? - private var traits: [any Trait] + fileprivate var traits: [any Trait] private var sourceLocation: SourceLocation private var containingTypeInfo: TypeInfo? private var xcTestCompatibleSelector: __XCTestCompatibleSelector? diff --git a/Sources/IssueReporting/TestContext.swift b/Sources/IssueReporting/TestContext.swift index 9d8c612..e6affc9 100644 --- a/Sources/IssueReporting/TestContext.swift +++ b/Sources/IssueReporting/TestContext.swift @@ -23,8 +23,8 @@ public enum TestContext: Equatable, Sendable { /// If executed outside of a test process, this will return `nil`. public static var current: Self? { guard isTesting else { return nil } - if let currentTestID = _currentTestID() { - return .swiftTesting(Testing(id: currentTestID)) + if let currentTest = _currentTest() { + return .swiftTesting(Testing(id: currentTest.id, traits: currentTest.traits)) } else { return .xcTest } @@ -42,10 +42,19 @@ public enum TestContext: Equatable, Sendable { public struct Test: Equatable, Hashable, Identifiable, Sendable { public let id: ID + public let traits: [any Sendable] public struct ID: Equatable, Hashable, @unchecked Sendable { public let rawValue: AnyHashable } + + public static func == (lhs: Self, rhs: Self) -> Bool { + lhs.id == rhs.id + } + + public func hash(into hasher: inout Hasher) { + hasher.combine(id) + } } } @@ -73,7 +82,7 @@ public enum TestContext: Equatable, Sendable { } extension TestContext.Testing { - fileprivate init(id: AnyHashable) { - self.init(test: Test(id: Test.ID(rawValue: id))) + fileprivate init(id: AnyHashable, traits: [any Sendable]) { + self.init(test: Test(id: Test.ID(rawValue: id), traits: traits)) } } diff --git a/Sources/IssueReportingPackageSupport/_Test.swift b/Sources/IssueReportingPackageSupport/_Test.swift new file mode 100644 index 0000000..81819f5 --- /dev/null +++ b/Sources/IssueReportingPackageSupport/_Test.swift @@ -0,0 +1,14 @@ +@usableFromInline +package struct _Test { + @usableFromInline + package let id: AnyHashable + + @usableFromInline + package let traits: [any Sendable] + + @usableFromInline + package init(id: AnyHashable, traits: [any Sendable]) { + self.id = id + self.traits = traits + } +} diff --git a/Sources/IssueReportingTestSupport/SwiftTesting.swift b/Sources/IssueReportingTestSupport/SwiftTesting.swift index 030631b..0107ed4 100644 --- a/Sources/IssueReportingTestSupport/SwiftTesting.swift +++ b/Sources/IssueReportingTestSupport/SwiftTesting.swift @@ -1,3 +1,5 @@ +import IssueReportingPackageSupport + #if canImport(Testing) import Testing #endif @@ -134,11 +136,11 @@ private func __withKnownIssueAsync( } #endif -public func _currentTestID() -> Any { __currentTestID } +public func _currentTest() -> Any { __currentTest } @Sendable -private func __currentTestID() -> AnyHashable? { +private func __currentTest() -> _Test? { #if canImport(Testing) - return Test.current?.id + return Test.current.map { _Test(id: $0.id, traits: $0.traits) } #else return nil #endif From ccc75ae935e2fee1b2c7d8040c21538def4310d8 Mon Sep 17 00:00:00 2001 From: Stephen Celis Date: Sun, 13 Apr 2025 09:32:09 -0700 Subject: [PATCH 02/10] wip --- Sources/IssueReporting/Internal/SwiftTesting.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/IssueReporting/Internal/SwiftTesting.swift b/Sources/IssueReporting/Internal/SwiftTesting.swift index e370435..884ab0f 100644 --- a/Sources/IssueReporting/Internal/SwiftTesting.swift +++ b/Sources/IssueReporting/Internal/SwiftTesting.swift @@ -324,7 +324,7 @@ func _currentTest() -> _Test? { #endif } - return (function as! @Sendable () -> _Test?)() + return unsafeBitCast(function, to: (@Sendable () -> _Test?).self)() } #if DEBUG From 715530e0d98314fcf90f33eabc8f355fe2fc3ece Mon Sep 17 00:00:00 2001 From: Brandon Williams Date: Thu, 17 Apr 2025 11:53:36 -0700 Subject: [PATCH 03/10] test --- Examples/Examples.xcodeproj/project.pbxproj | 29 ++++++++++++++++----- Examples/Examples/ExampleTrait.swift | 14 ++++++++++ Examples/ExamplesTests/TraitTests.swift | 17 ++++++++++++ 3 files changed, 53 insertions(+), 7 deletions(-) create mode 100644 Examples/Examples/ExampleTrait.swift create mode 100644 Examples/ExamplesTests/TraitTests.swift diff --git a/Examples/Examples.xcodeproj/project.pbxproj b/Examples/Examples.xcodeproj/project.pbxproj index 841dcda..8427517 100644 --- a/Examples/Examples.xcodeproj/project.pbxproj +++ b/Examples/Examples.xcodeproj/project.pbxproj @@ -7,13 +7,14 @@ objects = { /* Begin PBXBuildFile section */ + CA1972D72DB1836900351823 /* TraitTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA1972D62DB1836900351823 /* TraitTests.swift */; }; + CA1972D92DB1847200351823 /* ExampleTrait.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA1972D82DB1847200351823 /* ExampleTrait.swift */; }; CADE79AE2C4A9D2C005A85F7 /* ExamplesApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = CADE79AD2C4A9D2C005A85F7 /* ExamplesApp.swift */; }; CADE79B22C4A9D2D005A85F7 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = CADE79B12C4A9D2D005A85F7 /* Assets.xcassets */; }; CADE79DA2C4A9D3A005A85F7 /* IssueReporting in Frameworks */ = {isa = PBXBuildFile; productRef = CADE79D92C4A9D3A005A85F7 /* IssueReporting */; }; CADE79DD2C4A9E59005A85F7 /* SwiftTestingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CADE79DB2C4A9E59005A85F7 /* SwiftTestingTests.swift */; }; CADE79DE2C4A9E59005A85F7 /* XCTestTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CADE79DC2C4A9E59005A85F7 /* XCTestTests.swift */; }; CADE79E02C4ABD94005A85F7 /* Examples.xctestplan in Resources */ = {isa = PBXBuildFile; fileRef = CADE79DF2C4ABD94005A85F7 /* Examples.xctestplan */; }; - CADE79E22C4ABE90005A85F7 /* IssueReporting in Frameworks */ = {isa = PBXBuildFile; productRef = CADE79E12C4ABE90005A85F7 /* IssueReporting */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -26,7 +27,22 @@ }; /* End PBXContainerItemProxy section */ +/* Begin PBXCopyFilesBuildPhase section */ + CA1972DD2DB1854600351823 /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + /* Begin PBXFileReference section */ + CA1972D62DB1836900351823 /* TraitTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TraitTests.swift; sourceTree = ""; }; + CA1972D82DB1847200351823 /* ExampleTrait.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExampleTrait.swift; sourceTree = ""; }; CADE79AA2C4A9D2C005A85F7 /* Examples.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Examples.app; sourceTree = BUILT_PRODUCTS_DIR; }; CADE79AD2C4A9D2C005A85F7 /* ExamplesApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExamplesApp.swift; sourceTree = ""; }; CADE79B12C4A9D2D005A85F7 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; @@ -50,7 +66,6 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - CADE79E22C4ABE90005A85F7 /* IssueReporting in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -80,6 +95,7 @@ isa = PBXGroup; children = ( CADE79AD2C4A9D2C005A85F7 /* ExamplesApp.swift */, + CA1972D82DB1847200351823 /* ExampleTrait.swift */, CADE79B12C4A9D2D005A85F7 /* Assets.xcassets */, CADE79B32C4A9D2D005A85F7 /* Examples.entitlements */, ); @@ -92,6 +108,7 @@ CADE79DF2C4ABD94005A85F7 /* Examples.xctestplan */, CADE79DB2C4A9E59005A85F7 /* SwiftTestingTests.swift */, CADE79DC2C4A9E59005A85F7 /* XCTestTests.swift */, + CA1972D62DB1836900351823 /* TraitTests.swift */, ); path = ExamplesTests; sourceTree = ""; @@ -133,6 +150,7 @@ CADE79B72C4A9D2D005A85F7 /* Sources */, CADE79B82C4A9D2D005A85F7 /* Frameworks */, CADE79B92C4A9D2D005A85F7 /* Resources */, + CA1972DD2DB1854600351823 /* Embed Frameworks */, ); buildRules = ( ); @@ -141,7 +159,6 @@ ); name = ExamplesTests; packageProductDependencies = ( - CADE79E12C4ABE90005A85F7 /* IssueReporting */, ); productName = ExamplesTests; productReference = CADE79BB2C4A9D2D005A85F7 /* ExamplesTests.xctest */; @@ -210,6 +227,7 @@ buildActionMask = 2147483647; files = ( CADE79AE2C4A9D2C005A85F7 /* ExamplesApp.swift in Sources */, + CA1972D92DB1847200351823 /* ExampleTrait.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -219,6 +237,7 @@ files = ( CADE79DD2C4A9E59005A85F7 /* SwiftTestingTests.swift in Sources */, CADE79DE2C4A9E59005A85F7 /* XCTestTests.swift in Sources */, + CA1972D72DB1836900351823 /* TraitTests.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -504,10 +523,6 @@ isa = XCSwiftPackageProductDependency; productName = IssueReporting; }; - CADE79E12C4ABE90005A85F7 /* IssueReporting */ = { - isa = XCSwiftPackageProductDependency; - productName = IssueReporting; - }; /* End XCSwiftPackageProductDependency section */ }; rootObject = CADE79A22C4A9D2C005A85F7 /* Project object */; diff --git a/Examples/Examples/ExampleTrait.swift b/Examples/Examples/ExampleTrait.swift new file mode 100644 index 0000000..acc3b8b --- /dev/null +++ b/Examples/Examples/ExampleTrait.swift @@ -0,0 +1,14 @@ +import IssueReporting + +public struct ExampleTrait: Sendable { + public init() {} + + public static func hasTrait() -> Bool { + switch TestContext.current { + case .none, .some(.xcTest): + return false + case .some(.swiftTesting(let testing)): + return testing?.test.traits.contains { $0 is Self } ?? false + } + } +} diff --git a/Examples/ExamplesTests/TraitTests.swift b/Examples/ExamplesTests/TraitTests.swift new file mode 100644 index 0000000..1133d9a --- /dev/null +++ b/Examples/ExamplesTests/TraitTests.swift @@ -0,0 +1,17 @@ +import IssueReporting +import Testing +import Examples + +extension ExampleTrait: @retroactive SuiteTrait, @retroactive TestTrait { +} + +@Suite +struct TraitTests { + @Test(ExampleTrait()) func hasTrait() { + #expect(ExampleTrait.hasTrait()) + } + + @Test func doesNotHaveTrait() { + #expect(ExampleTrait.hasTrait() == false) + } +} From ce818aca9c97258bd4ef81156a3fe9d08446524a Mon Sep 17 00:00:00 2001 From: Brandon Williams Date: Thu, 17 Apr 2025 12:08:44 -0700 Subject: [PATCH 04/10] wip --- Examples/Examples.xcodeproj/project.pbxproj | 11 +++++++++++ Examples/ExamplesTests/TraitTests.swift | 4 ++++ 2 files changed, 15 insertions(+) diff --git a/Examples/Examples.xcodeproj/project.pbxproj b/Examples/Examples.xcodeproj/project.pbxproj index 8427517..b5d5d63 100644 --- a/Examples/Examples.xcodeproj/project.pbxproj +++ b/Examples/Examples.xcodeproj/project.pbxproj @@ -38,6 +38,16 @@ name = "Embed Frameworks"; runOnlyForDeploymentPostprocessing = 0; }; + CA1972E12DB186BC00351823 /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ @@ -130,6 +140,7 @@ CADE79A62C4A9D2C005A85F7 /* Sources */, CADE79A72C4A9D2C005A85F7 /* Frameworks */, CADE79A82C4A9D2C005A85F7 /* Resources */, + CA1972E12DB186BC00351823 /* Embed Frameworks */, ); buildRules = ( ); diff --git a/Examples/ExamplesTests/TraitTests.swift b/Examples/ExamplesTests/TraitTests.swift index 1133d9a..3e13efe 100644 --- a/Examples/ExamplesTests/TraitTests.swift +++ b/Examples/ExamplesTests/TraitTests.swift @@ -8,7 +8,11 @@ extension ExampleTrait: @retroactive SuiteTrait, @retroactive TestTrait { @Suite struct TraitTests { @Test(ExampleTrait()) func hasTrait() { + #if DEBUG #expect(ExampleTrait.hasTrait()) + #else + #expect(ExampleTrait.hasTrait() == false) + #endif } @Test func doesNotHaveTrait() { From 799d0eb43fe54af6a6ebd6ecd675f3a5d4df1eba Mon Sep 17 00:00:00 2001 From: Brandon Williams Date: Thu, 17 Apr 2025 12:19:10 -0700 Subject: [PATCH 05/10] wip --- .../TestHelpers.swift | 240 +++++++++--------- 1 file changed, 120 insertions(+), 120 deletions(-) diff --git a/Tests/XCTestDynamicOverlayTests/TestHelpers.swift b/Tests/XCTestDynamicOverlayTests/TestHelpers.swift index b51846b..937f65f 100644 --- a/Tests/XCTestDynamicOverlayTests/TestHelpers.swift +++ b/Tests/XCTestDynamicOverlayTests/TestHelpers.swift @@ -1,120 +1,120 @@ -import Foundation -import XCTestDynamicOverlay - -func MyXCTFail(_ message: String) { - XCTFail(message) -} - -#if canImport(ObjectiveC) - func MyXCTExpectFailure( - _ failureReason: String, - enabled: Bool = true, - strict: Bool = true, - failingBlock: () -> Void, - issueMatcher: ((_XCTIssue) -> Bool)? = nil - ) { - XCTExpectFailure( - failureReason, - enabled: enabled, - strict: strict, - failingBlock: failingBlock, - issueMatcher: issueMatcher - ) - } - - func MyXCTExpectFailure( - _ failureReason: String, - enabled: Bool = true, - strict: Bool = true, - issueMatcher: ((_XCTIssue) -> Bool)? = nil - ) { - XCTExpectFailure( - failureReason, - enabled: enabled, - strict: strict, - issueMatcher: issueMatcher - ) - } -#endif - -@available(*, deprecated) -struct Client { - var p00: () -> Int - var p01: () throws -> Int - var p02: () async -> Int - var p03: () async throws -> Int - var p04: (Int) -> Int - var p05: (Int) throws -> Int - var p06: (Int) async -> Int - var p07: (Int) async throws -> Int - var p08: (Int, Int) -> Int - var p09: (Int, Int) throws -> Int - var p10: (Int, Int) async -> Int - var p11: (Int, Int) async throws -> Int - var p12: (Int, Int, Int) -> Int - var p13: (Int, Int, Int) throws -> Int - var p14: (Int, Int, Int) async -> Int - var p15: (Int, Int, Int) async throws -> Int - var p16: (Int, Int, Int, Int) -> Int - var p17: (Int, Int, Int, Int) throws -> Int - var p18: (Int, Int, Int, Int) async -> Int - var p19: (Int, Int, Int, Int) async throws -> Int - var p20: (Int, Int, Int, Int, Int) -> Int - var p21: (Int, Int, Int, Int, Int) throws -> Int - var p22: (Int, Int, Int, Int, Int) async -> Int - var p23: (Int, Int, Int, Int, Int) async throws -> Int - - static var testValue: Self { - Self( - p00: unimplemented("\(Self.self).p00"), - p01: unimplemented("\(Self.self).p01"), - p02: unimplemented("\(Self.self).p02"), - p03: unimplemented("\(Self.self).p03"), - p04: unimplemented("\(Self.self).p04"), - p05: unimplemented("\(Self.self).p05"), - p06: unimplemented("\(Self.self).p06"), - p07: unimplemented("\(Self.self).p07"), - p08: unimplemented("\(Self.self).p08"), - p09: unimplemented("\(Self.self).p09"), - p10: unimplemented("\(Self.self).p10"), - p11: unimplemented("\(Self.self).p11"), - p12: unimplemented("\(Self.self).p12"), - p13: unimplemented("\(Self.self).p13"), - p14: unimplemented("\(Self.self).p14"), - p15: unimplemented("\(Self.self).p15"), - p16: unimplemented("\(Self.self).p16"), - p17: unimplemented("\(Self.self).p17"), - p18: unimplemented("\(Self.self).p18"), - p19: unimplemented("\(Self.self).p19"), - p20: unimplemented("\(Self.self).p20"), - p21: unimplemented("\(Self.self).p21"), - p22: unimplemented("\(Self.self).p22"), - p23: unimplemented("\(Self.self).p23") - ) - } -} - -struct User { let id: UUID } - -@MainActor let f00: () -> Int = unimplemented("f00", placeholder: 42) -@MainActor let f01: (String) -> Int = unimplemented("f01", placeholder: 42) -@MainActor let f02: (String, Int) -> Int = unimplemented("f02", placeholder: 42) -@MainActor let f03: (String, Int, Double) -> Int = unimplemented("f03", placeholder: 42) -@MainActor let f04: (String, Int, Double, [Int]) -> Int = unimplemented("f04", placeholder: 42) -@MainActor let f05: (String, Int, Double, [Int], User) -> Int = unimplemented( - "f05", placeholder: 42) - -@available(*, deprecated) -@MainActor let fm00: () -> Int = unimplemented("fm00") - -@available(*, deprecated) -@MainActor let fm01: @MainActor () -> Int = unimplemented("fm01") - -private struct Autoclosing { - init( - _: @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 {} -} +//import Foundation +//import XCTestDynamicOverlay +// +//func MyXCTFail(_ message: String) { +// XCTFail(message) +//} +// +//#if canImport(ObjectiveC) +// func MyXCTExpectFailure( +// _ failureReason: String, +// enabled: Bool = true, +// strict: Bool = true, +// failingBlock: () -> Void, +// issueMatcher: ((_XCTIssue) -> Bool)? = nil +// ) { +// XCTExpectFailure( +// failureReason, +// enabled: enabled, +// strict: strict, +// failingBlock: failingBlock, +// issueMatcher: issueMatcher +// ) +// } +// +// func MyXCTExpectFailure( +// _ failureReason: String, +// enabled: Bool = true, +// strict: Bool = true, +// issueMatcher: ((_XCTIssue) -> Bool)? = nil +// ) { +// XCTExpectFailure( +// failureReason, +// enabled: enabled, +// strict: strict, +// issueMatcher: issueMatcher +// ) +// } +//#endif +// +//@available(*, deprecated) +//struct Client { +// var p00: () -> Int +// var p01: () throws -> Int +// var p02: () async -> Int +// var p03: () async throws -> Int +// var p04: (Int) -> Int +// var p05: (Int) throws -> Int +// var p06: (Int) async -> Int +// var p07: (Int) async throws -> Int +// var p08: (Int, Int) -> Int +// var p09: (Int, Int) throws -> Int +// var p10: (Int, Int) async -> Int +// var p11: (Int, Int) async throws -> Int +// var p12: (Int, Int, Int) -> Int +// var p13: (Int, Int, Int) throws -> Int +// var p14: (Int, Int, Int) async -> Int +// var p15: (Int, Int, Int) async throws -> Int +// var p16: (Int, Int, Int, Int) -> Int +// var p17: (Int, Int, Int, Int) throws -> Int +// var p18: (Int, Int, Int, Int) async -> Int +// var p19: (Int, Int, Int, Int) async throws -> Int +// var p20: (Int, Int, Int, Int, Int) -> Int +// var p21: (Int, Int, Int, Int, Int) throws -> Int +// var p22: (Int, Int, Int, Int, Int) async -> Int +// var p23: (Int, Int, Int, Int, Int) async throws -> Int +// +// static var testValue: Self { +// Self( +// p00: unimplemented("\(Self.self).p00"), +// p01: unimplemented("\(Self.self).p01"), +// p02: unimplemented("\(Self.self).p02"), +// p03: unimplemented("\(Self.self).p03"), +// p04: unimplemented("\(Self.self).p04"), +// p05: unimplemented("\(Self.self).p05"), +// p06: unimplemented("\(Self.self).p06"), +// p07: unimplemented("\(Self.self).p07"), +// p08: unimplemented("\(Self.self).p08"), +// p09: unimplemented("\(Self.self).p09"), +// p10: unimplemented("\(Self.self).p10"), +// p11: unimplemented("\(Self.self).p11"), +// p12: unimplemented("\(Self.self).p12"), +// p13: unimplemented("\(Self.self).p13"), +// p14: unimplemented("\(Self.self).p14"), +// p15: unimplemented("\(Self.self).p15"), +// p16: unimplemented("\(Self.self).p16"), +// p17: unimplemented("\(Self.self).p17"), +// p18: unimplemented("\(Self.self).p18"), +// p19: unimplemented("\(Self.self).p19"), +// p20: unimplemented("\(Self.self).p20"), +// p21: unimplemented("\(Self.self).p21"), +// p22: unimplemented("\(Self.self).p22"), +// p23: unimplemented("\(Self.self).p23") +// ) +// } +//} +// +//struct User { let id: UUID } +// +//@MainActor let f00: () -> Int = unimplemented("f00", placeholder: 42) +//@MainActor let f01: (String) -> Int = unimplemented("f01", placeholder: 42) +//@MainActor let f02: (String, Int) -> Int = unimplemented("f02", placeholder: 42) +//@MainActor let f03: (String, Int, Double) -> Int = unimplemented("f03", placeholder: 42) +//@MainActor let f04: (String, Int, Double, [Int]) -> Int = unimplemented("f04", placeholder: 42) +//@MainActor let f05: (String, Int, Double, [Int], User) -> Int = unimplemented( +// "f05", placeholder: 42) +// +//@available(*, deprecated) +//@MainActor let fm00: () -> Int = unimplemented("fm00") +// +//@available(*, deprecated) +//@MainActor let fm01: @MainActor () -> Int = unimplemented("fm01") +// +//private struct Autoclosing { +// init( +// _: @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 {} +//} From 425d087986c07bf8f5ebab650a5bf4cf3e6b22d9 Mon Sep 17 00:00:00 2001 From: Brandon Williams Date: Thu, 17 Apr 2025 12:19:49 -0700 Subject: [PATCH 06/10] wip --- Tests/XCTestDynamicOverlayTests/TestHelpers.swift | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Tests/XCTestDynamicOverlayTests/TestHelpers.swift b/Tests/XCTestDynamicOverlayTests/TestHelpers.swift index 937f65f..d8bf6b2 100644 --- a/Tests/XCTestDynamicOverlayTests/TestHelpers.swift +++ b/Tests/XCTestDynamicOverlayTests/TestHelpers.swift @@ -1,9 +1,9 @@ -//import Foundation -//import XCTestDynamicOverlay -// -//func MyXCTFail(_ message: String) { -// XCTFail(message) -//} +import Foundation +import XCTestDynamicOverlay + +func MyXCTFail(_ message: String) { + XCTFail(message) +} // //#if canImport(ObjectiveC) // func MyXCTExpectFailure( From 24c6dc323056e9fae1075a06808873c2584ecfc5 Mon Sep 17 00:00:00 2001 From: Stephen Celis Date: Thu, 17 Apr 2025 12:41:01 -0700 Subject: [PATCH 07/10] wip --- .../Internal/SwiftTesting.swift | 2 +- .../TestHelpers.swift | 228 +++++++++--------- 2 files changed, 115 insertions(+), 115 deletions(-) diff --git a/Sources/IssueReporting/Internal/SwiftTesting.swift b/Sources/IssueReporting/Internal/SwiftTesting.swift index 884ab0f..e370435 100644 --- a/Sources/IssueReporting/Internal/SwiftTesting.swift +++ b/Sources/IssueReporting/Internal/SwiftTesting.swift @@ -324,7 +324,7 @@ func _currentTest() -> _Test? { #endif } - return unsafeBitCast(function, to: (@Sendable () -> _Test?).self)() + return (function as! @Sendable () -> _Test?)() } #if DEBUG diff --git a/Tests/XCTestDynamicOverlayTests/TestHelpers.swift b/Tests/XCTestDynamicOverlayTests/TestHelpers.swift index d8bf6b2..b51846b 100644 --- a/Tests/XCTestDynamicOverlayTests/TestHelpers.swift +++ b/Tests/XCTestDynamicOverlayTests/TestHelpers.swift @@ -4,117 +4,117 @@ import XCTestDynamicOverlay func MyXCTFail(_ message: String) { XCTFail(message) } -// -//#if canImport(ObjectiveC) -// func MyXCTExpectFailure( -// _ failureReason: String, -// enabled: Bool = true, -// strict: Bool = true, -// failingBlock: () -> Void, -// issueMatcher: ((_XCTIssue) -> Bool)? = nil -// ) { -// XCTExpectFailure( -// failureReason, -// enabled: enabled, -// strict: strict, -// failingBlock: failingBlock, -// issueMatcher: issueMatcher -// ) -// } -// -// func MyXCTExpectFailure( -// _ failureReason: String, -// enabled: Bool = true, -// strict: Bool = true, -// issueMatcher: ((_XCTIssue) -> Bool)? = nil -// ) { -// XCTExpectFailure( -// failureReason, -// enabled: enabled, -// strict: strict, -// issueMatcher: issueMatcher -// ) -// } -//#endif -// -//@available(*, deprecated) -//struct Client { -// var p00: () -> Int -// var p01: () throws -> Int -// var p02: () async -> Int -// var p03: () async throws -> Int -// var p04: (Int) -> Int -// var p05: (Int) throws -> Int -// var p06: (Int) async -> Int -// var p07: (Int) async throws -> Int -// var p08: (Int, Int) -> Int -// var p09: (Int, Int) throws -> Int -// var p10: (Int, Int) async -> Int -// var p11: (Int, Int) async throws -> Int -// var p12: (Int, Int, Int) -> Int -// var p13: (Int, Int, Int) throws -> Int -// var p14: (Int, Int, Int) async -> Int -// var p15: (Int, Int, Int) async throws -> Int -// var p16: (Int, Int, Int, Int) -> Int -// var p17: (Int, Int, Int, Int) throws -> Int -// var p18: (Int, Int, Int, Int) async -> Int -// var p19: (Int, Int, Int, Int) async throws -> Int -// var p20: (Int, Int, Int, Int, Int) -> Int -// var p21: (Int, Int, Int, Int, Int) throws -> Int -// var p22: (Int, Int, Int, Int, Int) async -> Int -// var p23: (Int, Int, Int, Int, Int) async throws -> Int -// -// static var testValue: Self { -// Self( -// p00: unimplemented("\(Self.self).p00"), -// p01: unimplemented("\(Self.self).p01"), -// p02: unimplemented("\(Self.self).p02"), -// p03: unimplemented("\(Self.self).p03"), -// p04: unimplemented("\(Self.self).p04"), -// p05: unimplemented("\(Self.self).p05"), -// p06: unimplemented("\(Self.self).p06"), -// p07: unimplemented("\(Self.self).p07"), -// p08: unimplemented("\(Self.self).p08"), -// p09: unimplemented("\(Self.self).p09"), -// p10: unimplemented("\(Self.self).p10"), -// p11: unimplemented("\(Self.self).p11"), -// p12: unimplemented("\(Self.self).p12"), -// p13: unimplemented("\(Self.self).p13"), -// p14: unimplemented("\(Self.self).p14"), -// p15: unimplemented("\(Self.self).p15"), -// p16: unimplemented("\(Self.self).p16"), -// p17: unimplemented("\(Self.self).p17"), -// p18: unimplemented("\(Self.self).p18"), -// p19: unimplemented("\(Self.self).p19"), -// p20: unimplemented("\(Self.self).p20"), -// p21: unimplemented("\(Self.self).p21"), -// p22: unimplemented("\(Self.self).p22"), -// p23: unimplemented("\(Self.self).p23") -// ) -// } -//} -// -//struct User { let id: UUID } -// -//@MainActor let f00: () -> Int = unimplemented("f00", placeholder: 42) -//@MainActor let f01: (String) -> Int = unimplemented("f01", placeholder: 42) -//@MainActor let f02: (String, Int) -> Int = unimplemented("f02", placeholder: 42) -//@MainActor let f03: (String, Int, Double) -> Int = unimplemented("f03", placeholder: 42) -//@MainActor let f04: (String, Int, Double, [Int]) -> Int = unimplemented("f04", placeholder: 42) -//@MainActor let f05: (String, Int, Double, [Int], User) -> Int = unimplemented( -// "f05", placeholder: 42) -// -//@available(*, deprecated) -//@MainActor let fm00: () -> Int = unimplemented("fm00") -// -//@available(*, deprecated) -//@MainActor let fm01: @MainActor () -> Int = unimplemented("fm01") -// -//private struct Autoclosing { -// init( -// _: @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 {} -//} + +#if canImport(ObjectiveC) + func MyXCTExpectFailure( + _ failureReason: String, + enabled: Bool = true, + strict: Bool = true, + failingBlock: () -> Void, + issueMatcher: ((_XCTIssue) -> Bool)? = nil + ) { + XCTExpectFailure( + failureReason, + enabled: enabled, + strict: strict, + failingBlock: failingBlock, + issueMatcher: issueMatcher + ) + } + + func MyXCTExpectFailure( + _ failureReason: String, + enabled: Bool = true, + strict: Bool = true, + issueMatcher: ((_XCTIssue) -> Bool)? = nil + ) { + XCTExpectFailure( + failureReason, + enabled: enabled, + strict: strict, + issueMatcher: issueMatcher + ) + } +#endif + +@available(*, deprecated) +struct Client { + var p00: () -> Int + var p01: () throws -> Int + var p02: () async -> Int + var p03: () async throws -> Int + var p04: (Int) -> Int + var p05: (Int) throws -> Int + var p06: (Int) async -> Int + var p07: (Int) async throws -> Int + var p08: (Int, Int) -> Int + var p09: (Int, Int) throws -> Int + var p10: (Int, Int) async -> Int + var p11: (Int, Int) async throws -> Int + var p12: (Int, Int, Int) -> Int + var p13: (Int, Int, Int) throws -> Int + var p14: (Int, Int, Int) async -> Int + var p15: (Int, Int, Int) async throws -> Int + var p16: (Int, Int, Int, Int) -> Int + var p17: (Int, Int, Int, Int) throws -> Int + var p18: (Int, Int, Int, Int) async -> Int + var p19: (Int, Int, Int, Int) async throws -> Int + var p20: (Int, Int, Int, Int, Int) -> Int + var p21: (Int, Int, Int, Int, Int) throws -> Int + var p22: (Int, Int, Int, Int, Int) async -> Int + var p23: (Int, Int, Int, Int, Int) async throws -> Int + + static var testValue: Self { + Self( + p00: unimplemented("\(Self.self).p00"), + p01: unimplemented("\(Self.self).p01"), + p02: unimplemented("\(Self.self).p02"), + p03: unimplemented("\(Self.self).p03"), + p04: unimplemented("\(Self.self).p04"), + p05: unimplemented("\(Self.self).p05"), + p06: unimplemented("\(Self.self).p06"), + p07: unimplemented("\(Self.self).p07"), + p08: unimplemented("\(Self.self).p08"), + p09: unimplemented("\(Self.self).p09"), + p10: unimplemented("\(Self.self).p10"), + p11: unimplemented("\(Self.self).p11"), + p12: unimplemented("\(Self.self).p12"), + p13: unimplemented("\(Self.self).p13"), + p14: unimplemented("\(Self.self).p14"), + p15: unimplemented("\(Self.self).p15"), + p16: unimplemented("\(Self.self).p16"), + p17: unimplemented("\(Self.self).p17"), + p18: unimplemented("\(Self.self).p18"), + p19: unimplemented("\(Self.self).p19"), + p20: unimplemented("\(Self.self).p20"), + p21: unimplemented("\(Self.self).p21"), + p22: unimplemented("\(Self.self).p22"), + p23: unimplemented("\(Self.self).p23") + ) + } +} + +struct User { let id: UUID } + +@MainActor let f00: () -> Int = unimplemented("f00", placeholder: 42) +@MainActor let f01: (String) -> Int = unimplemented("f01", placeholder: 42) +@MainActor let f02: (String, Int) -> Int = unimplemented("f02", placeholder: 42) +@MainActor let f03: (String, Int, Double) -> Int = unimplemented("f03", placeholder: 42) +@MainActor let f04: (String, Int, Double, [Int]) -> Int = unimplemented("f04", placeholder: 42) +@MainActor let f05: (String, Int, Double, [Int], User) -> Int = unimplemented( + "f05", placeholder: 42) + +@available(*, deprecated) +@MainActor let fm00: () -> Int = unimplemented("fm00") + +@available(*, deprecated) +@MainActor let fm01: @MainActor () -> Int = unimplemented("fm01") + +private struct Autoclosing { + init( + _: @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 {} +} From 814bce4074339759a0ebb191651aa74100d91c46 Mon Sep 17 00:00:00 2001 From: Stephen Celis Date: Thu, 17 Apr 2025 12:47:46 -0700 Subject: [PATCH 08/10] wip --- Sources/IssueReporting/Internal/SwiftTesting.swift | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Sources/IssueReporting/Internal/SwiftTesting.swift b/Sources/IssueReporting/Internal/SwiftTesting.swift index e370435..de0b688 100644 --- a/Sources/IssueReporting/Internal/SwiftTesting.swift +++ b/Sources/IssueReporting/Internal/SwiftTesting.swift @@ -324,7 +324,11 @@ func _currentTest() -> _Test? { #endif } - return (function as! @Sendable () -> _Test?)() + return withUnsafePointer(to: function) { + $0.withMemoryRebound(to: (() -> _Test?).self, capacity: 1) { + $0.pointee() + } + } } #if DEBUG From a373b13eb2fe415c511053ccc73bf9101b3a5231 Mon Sep 17 00:00:00 2001 From: Stephen Celis Date: Thu, 17 Apr 2025 14:01:47 -0700 Subject: [PATCH 09/10] wip --- Sources/IssueReporting/Internal/SwiftTesting.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/IssueReporting/Internal/SwiftTesting.swift b/Sources/IssueReporting/Internal/SwiftTesting.swift index de0b688..ac8aa47 100644 --- a/Sources/IssueReporting/Internal/SwiftTesting.swift +++ b/Sources/IssueReporting/Internal/SwiftTesting.swift @@ -325,7 +325,7 @@ func _currentTest() -> _Test? { } return withUnsafePointer(to: function) { - $0.withMemoryRebound(to: (() -> _Test?).self, capacity: 1) { + $0.withMemoryRebound(to: (@Sendable () -> _Test?).self, capacity: 1) { $0.pointee() } } From a887d6a880952a53b06ea6c2354d4a1725d22e84 Mon Sep 17 00:00:00 2001 From: Brandon Williams Date: Wed, 30 Apr 2025 18:57:50 -0500 Subject: [PATCH 10/10] disable android ci --- .github/workflows/ci.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b2033d8..b95959d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -135,10 +135,10 @@ jobs: # - name: Run tests (debug only) # run: swift test - android: - name: Android - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: "Test Swift Package on Android" - uses: skiptools/swift-android-action@v2 + # android: + # name: Android + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v4 + # - name: "Test Swift Package on Android" + # uses: skiptools/swift-android-action@v2