From c3a83a348060850aa37d9de6ad8c8addf4f33e7a Mon Sep 17 00:00:00 2001 From: Kyle Date: Wed, 20 Aug 2025 00:39:18 +0800 Subject: [PATCH 1/3] Add GraphEnvironmentTrait --- .../AttributeCompatibilityTests.swift | 5 +- .../Attribute/AttributeTestBase.swift | 24 -- .../Helper/AsyncSemaphore.swift | 253 ++++++++++++++++++ .../Helper/AttributeTestBase.swift | 53 ++++ .../AttributeTestHelper.swift | 4 +- 5 files changed, 310 insertions(+), 29 deletions(-) delete mode 100644 Tests/OpenGraphCompatibilityTests/Attribute/AttributeTestBase.swift create mode 100644 Tests/OpenGraphCompatibilityTests/Helper/AsyncSemaphore.swift create mode 100644 Tests/OpenGraphCompatibilityTests/Helper/AttributeTestBase.swift rename Tests/OpenGraphCompatibilityTests/{Attribute => Helper}/AttributeTestHelper.swift (84%) diff --git a/Tests/OpenGraphCompatibilityTests/Attribute/Attribute/AttributeCompatibilityTests.swift b/Tests/OpenGraphCompatibilityTests/Attribute/Attribute/AttributeCompatibilityTests.swift index 86eed2f9..a1b8b486 100644 --- a/Tests/OpenGraphCompatibilityTests/Attribute/Attribute/AttributeCompatibilityTests.swift +++ b/Tests/OpenGraphCompatibilityTests/Attribute/Attribute/AttributeCompatibilityTests.swift @@ -5,8 +5,9 @@ import Testing #if canImport(Darwin) -@Suite(.disabled(if: !compatibilityTestEnabled, "Attribute is not implemented")) -final class AttributeCompatibilityTests: AttributeTestBase { +@MainActor +@Suite(.disabled(if: !compatibilityTestEnabled, "Attribute is not implemented"), .graphScope) +struct AttributeCompatibilityTests { @Test func initWithValue() { let intAttribute = Attribute(value: 0) diff --git a/Tests/OpenGraphCompatibilityTests/Attribute/AttributeTestBase.swift b/Tests/OpenGraphCompatibilityTests/Attribute/AttributeTestBase.swift deleted file mode 100644 index 95294511..00000000 --- a/Tests/OpenGraphCompatibilityTests/Attribute/AttributeTestBase.swift +++ /dev/null @@ -1,24 +0,0 @@ -// -// AttributeTestBase.swift -// -// -// - -import Testing - -/// Base class for Attribute Related test case -class AttributeTestBase { - private static let sharedGraph = Graph() - private var graph: Graph - private var subgraph: Subgraph - - init() { - graph = Graph(shared: Self.sharedGraph) - subgraph = Subgraph(graph: graph) - Subgraph.current = subgraph - } - - deinit { - Subgraph.current = nil - } -} diff --git a/Tests/OpenGraphCompatibilityTests/Helper/AsyncSemaphore.swift b/Tests/OpenGraphCompatibilityTests/Helper/AsyncSemaphore.swift new file mode 100644 index 00000000..8ab5bdc2 --- /dev/null +++ b/Tests/OpenGraphCompatibilityTests/Helper/AsyncSemaphore.swift @@ -0,0 +1,253 @@ +// Copyright (C) 2022 Gwendal Roué +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +import Foundation + +/// An object that controls access to a resource across multiple execution +/// contexts through use of a traditional counting semaphore. +/// +/// You increment a semaphore count by calling the ``signal()`` method, and +/// decrement a semaphore count by calling ``wait()`` or one of its variants. +/// +/// ## Topics +/// +/// ### Creating a Semaphore +/// +/// - ``init(value:)`` +/// +/// ### Signaling the Semaphore +/// +/// - ``signal()`` +/// +/// ### Waiting for the Semaphore +/// +/// - ``wait()`` +/// - ``waitUnlessCancelled()`` +public final class AsyncSemaphore: @unchecked Sendable { + /// `Suspension` is the state of a task waiting for a signal. + /// + /// It is a class because instance identity helps `waitUnlessCancelled()` + /// deal with both early and late cancellation. + /// + /// We make it @unchecked Sendable in order to prevent compiler warnings: + /// instances are always protected by the semaphore's lock. + private class Suspension: @unchecked Sendable { + enum State { + /// Initial state. Next is suspendedUnlessCancelled, or cancelled. + case pending + + /// Waiting for a signal, with support for cancellation. + case suspendedUnlessCancelled(UnsafeContinuation) + + /// Waiting for a signal, with no support for cancellation. + case suspended(UnsafeContinuation) + + /// Cancelled before we have started waiting. + case cancelled + } + + var state: State + + init(state: State) { + self.state = state + } + } + + // MARK: - Internal State + + /// The semaphore value. + private var value: Int + + /// As many elements as there are suspended tasks waiting for a signal. + private var suspensions: [Suspension] = [] + + /// The lock that protects `value` and `suspensions`. + /// + /// It is recursive in order to handle cancellation (see the implementation + /// of ``waitUnlessCancelled()``). + private let _lock = NSRecursiveLock() + + // MARK: - Creating a Semaphore + + /// Creates a semaphore. + /// + /// - parameter value: The starting value for the semaphore. Do not pass a + /// value less than zero. + public init(value: Int) { + precondition(value >= 0, "AsyncSemaphore requires a value equal or greater than zero") + self.value = value + } + + deinit { + precondition(suspensions.isEmpty, "AsyncSemaphore is deallocated while some task(s) are suspended waiting for a signal.") + } + + // MARK: - Locking + + // Let's hide the locking primitive in order to avoid a compiler warning: + // + // > Instance method 'lock' is unavailable from asynchronous contexts; + // > Use async-safe scoped locking instead; this is an error in Swift 6. + // + // We're not sweeping bad stuff under the rug. We really need to protect + // our inner state (`value` and `suspension`) across the calls to + // `withUnsafeContinuation`. Unfortunately, this method introduces a + // suspension point. So we need a lock. + private func lock() { _lock.lock() } + private func unlock() { _lock.unlock() } + + // MARK: - Waiting for the Semaphore + + /// Waits for, or decrements, a semaphore. + /// + /// Decrement the counting semaphore. If the resulting value is less than + /// zero, this function suspends the current task until a signal occurs, + /// without blocking the underlying thread. Otherwise, no suspension happens. + public func wait() async { + lock() + + value -= 1 + if value >= 0 { + unlock() + return + } + + await withUnsafeContinuation { continuation in + // Register the continuation that `signal` will resume. + let suspension = Suspension(state: .suspended(continuation)) + suspensions.insert(suspension, at: 0) // FIFO + unlock() + } + } + + /// Waits for, or decrements, a semaphore, with support for cancellation. + /// + /// Decrement the counting semaphore. If the resulting value is less than + /// zero, this function suspends the current task until a signal occurs, + /// without blocking the underlying thread. Otherwise, no suspension happens. + /// + /// If the task is canceled before a signal occurs, this function + /// throws `CancellationError`. + public func waitUnlessCancelled() async throws { + lock() + + value -= 1 + if value >= 0 { + defer { unlock() } + + do { + // All code paths check for cancellation + try Task.checkCancellation() + } catch { + // Cancellation is like a signal: we don't really "consume" + // the semaphore, and restore the value. + value += 1 + throw error + } + + return + } + + // Get ready for being suspended waiting for a continuation, or for + // early cancellation. + let suspension = Suspension(state: .pending) + + try await withTaskCancellationHandler { + try await withUnsafeThrowingContinuation { (continuation: UnsafeContinuation) in + if case .cancelled = suspension.state { + // Early cancellation: waitUnlessCancelled() is called from + // a cancelled task, and the `onCancel` closure below + // has marked the suspension as cancelled. + // Resume with a CancellationError. + unlock() + continuation.resume(throwing: CancellationError()) + } else { + // Current task is not cancelled: register the continuation + // that `signal` will resume. + suspension.state = .suspendedUnlessCancelled(continuation) + suspensions.insert(suspension, at: 0) // FIFO + unlock() + } + } + } onCancel: { + // withTaskCancellationHandler may immediately call this block (if + // the current task is cancelled), or call it later (if the task is + // cancelled later). In the first case, we're still holding the lock, + // waiting for the continuation. In the second case, we do not hold + // the lock. Being able to handle both situations is the reason why + // we use a recursive lock. + lock() + + // We're no longer waiting for a signal + value += 1 + if let index = suspensions.firstIndex(where: { $0 === suspension }) { + suspensions.remove(at: index) + } + + if case let .suspendedUnlessCancelled(continuation) = suspension.state { + // Late cancellation: the task is cancelled while waiting + // from the semaphore. Resume with a CancellationError. + unlock() + continuation.resume(throwing: CancellationError()) + } else { + // Early cancellation: waitUnlessCancelled() is called from + // a cancelled task. + // + // The next step is the `withTaskCancellationHandler` + // operation closure right above. + suspension.state = .cancelled + unlock() + } + } + } + + // MARK: - Signaling the Semaphore + + /// Signals (increments) a semaphore. + /// + /// Increment the counting semaphore. If the previous value was less than + /// zero, this function resumes a task currently suspended in ``wait()`` + /// or ``waitUnlessCancelled()``. + /// + /// - returns: This function returns true if a suspended task is + /// resumed. Otherwise, the result is false, meaning that no task was + /// waiting for the semaphore. + @discardableResult + public func signal() -> Bool { + lock() + + value += 1 + + switch suspensions.popLast()?.state { // FIFO + case let .suspendedUnlessCancelled(continuation): + unlock() + continuation.resume() + return true + case let .suspended(continuation): + unlock() + continuation.resume() + return true + default: + unlock() + return false + } + } +} diff --git a/Tests/OpenGraphCompatibilityTests/Helper/AttributeTestBase.swift b/Tests/OpenGraphCompatibilityTests/Helper/AttributeTestBase.swift new file mode 100644 index 00000000..2bb80850 --- /dev/null +++ b/Tests/OpenGraphCompatibilityTests/Helper/AttributeTestBase.swift @@ -0,0 +1,53 @@ +// +// AttributeTestBase.swift +// OpenGraphCompatibilityTests + +import Testing +import Foundation + +/// Base class for Attribute Related test case +@available(*, deprecated, message: "Use GraphEnvironmentTrait instead") +class AttributeTestBase { + private static let sharedGraph = Graph() + private var graph: Graph + private var subgraph: Subgraph + + init() { + graph = Graph(shared: Self.sharedGraph) + subgraph = Subgraph(graph: graph) + Subgraph.current = subgraph + } + + deinit { + Subgraph.current = nil + } +} + +struct GraphEnvironmentTrait: TestTrait, TestScoping, SuiteTrait { + private static let sharedGraph = Graph() + private let semaphore = AsyncSemaphore(value: 1) + + + @MainActor + func provideScope(for test: Test, testCase: Test.Case?, performing function: @Sendable () async throws -> Void) async throws { + await semaphore.wait() + defer { semaphore.signal() } + let graph = Graph(shared: Self.sharedGraph) + let subgraph = Subgraph(graph: graph) + let oldSubgraph = Subgraph.current + + Subgraph.current = subgraph + try await function() + Subgraph.current = oldSubgraph + } + + var isRecursive: Bool { + true + } +} + +extension Trait where Self == GraphEnvironmentTrait { + static var graphScope: Self { + GraphEnvironmentTrait() + } +} diff --git a/Tests/OpenGraphCompatibilityTests/Attribute/AttributeTestHelper.swift b/Tests/OpenGraphCompatibilityTests/Helper/AttributeTestHelper.swift similarity index 84% rename from Tests/OpenGraphCompatibilityTests/Attribute/AttributeTestHelper.swift rename to Tests/OpenGraphCompatibilityTests/Helper/AttributeTestHelper.swift index 4b72d16d..b5e00afc 100644 --- a/Tests/OpenGraphCompatibilityTests/Attribute/AttributeTestHelper.swift +++ b/Tests/OpenGraphCompatibilityTests/Helper/AttributeTestHelper.swift @@ -1,8 +1,6 @@ // // AttributeTestHelper.swift -// -// -// +// OpenGraphCompatibilityTests struct Tuple { var first: A From 6834a90f9fec9793dbdf918a13e5c58a424c7a0d Mon Sep 17 00:00:00 2001 From: Kyle Date: Wed, 20 Aug 2025 01:01:37 +0800 Subject: [PATCH 2/3] Update test case --- Package.resolved | 2 +- Package.swift | 34 ++++++++---- .../AsyncSemaphore.swift | 0 .../OpenGraphTestsSupport/DataHelper.swift | 25 +++++++++ .../GraphEnvironmentTrait.swift | 39 ++++++++++++++ .../AnyAttributeCompatibilityTests.swift | 7 +-- .../AttributeCompatibilityTests.swift | 1 + .../ExternalCompatibilityTests.swift | 6 ++- .../Attribute/FocusCompatibilityTests.swift | 6 ++- .../PointerOffsetCompatibilityTests.swift | 1 + .../IndirectAttributeCompatibilityTests.swift | 6 ++- ...yOptionalAttributeCompatibilityTests.swift | 6 ++- .../OptionalAttributeCompatibilityTests.swift | 4 +- .../Rule/MapCompatibilityTests.swift | 6 ++- .../AnyWeakAttributeCompatibilityTests.swift | 7 +-- .../WeakAttributeCompatibilityTests.swift | 6 ++- .../Graph/SubgraphCompatibilityTests.swift | 3 +- .../Helper/AttributeTestBase.swift | 53 ------------------- .../Helper/AttributeTestHelper.swift | 14 ----- 19 files changed, 127 insertions(+), 99 deletions(-) rename {Tests/OpenGraphCompatibilityTests/Helper => Sources/OpenGraphTestsSupport}/AsyncSemaphore.swift (100%) create mode 100644 Sources/OpenGraphTestsSupport/DataHelper.swift create mode 100644 Sources/OpenGraphTestsSupport/GraphEnvironmentTrait.swift delete mode 100644 Tests/OpenGraphCompatibilityTests/Helper/AttributeTestBase.swift delete mode 100644 Tests/OpenGraphCompatibilityTests/Helper/AttributeTestHelper.swift diff --git a/Package.resolved b/Package.resolved index c13f1c30..8aa9784c 100644 --- a/Package.resolved +++ b/Package.resolved @@ -1,5 +1,5 @@ { - "originHash" : "65c4762fc267e15331f3aed90105265c610242906b39cfe4fb1bd366ae5ddcca", + "originHash" : "217b2951abc95116105194b510d8119d5c5ef524e1ba89fd9e593cba3f060bdf", "pins" : [ { "identity" : "darwinprivateframeworks", diff --git a/Package.swift b/Package.swift index 09d48338..5249e33b 100644 --- a/Package.swift +++ b/Package.swift @@ -158,38 +158,47 @@ let openGraphShimsTarget = Target.target( cSettings: sharedCSettings, swiftSettings: sharedSwiftSettings ) +let openGraphTestsSupportTarget = Target.target( + name: "OpenGraphTestsSupport", + cSettings: sharedCSettings, + swiftSettings: sharedSwiftSettings +) // MARK: - Test Targets -let openGraphTestTarget = Target.testTarget( +let openGraphTestsTarget = Target.testTarget( name: "OpenGraphTests", dependencies: [ "OpenGraph", + "OpenGraphTestsSupport", ], exclude: ["README.md"], cSettings: sharedCSettings, swiftSettings: sharedSwiftSettings ) -let openGraphSPITestTarget = Target.testTarget( +let openGraphCxxTestsTarget = Target.testTarget( name: "OpenGraphCxxTests", dependencies: [ "OpenGraphCxx", + "OpenGraphTestsSupport", ], exclude: ["README.md"], swiftSettings: sharedSwiftSettings + [.interoperabilityMode(.Cxx)] ) -let openGraphShimsTestTarget = Target.testTarget( +let openGraphShimsTestsTarget = Target.testTarget( name: "OpenGraphShimsTests", dependencies: [ "OpenGraphShims", + "OpenGraphTestsSupport", ], exclude: ["README.md"], cSettings: sharedCSettings, swiftSettings: sharedSwiftSettings ) -let openGraphCompatibilityTestTarget = Target.testTarget( +let openGraphCompatibilityTestsTarget = Target.testTarget( name: "OpenGraphCompatibilityTests", dependencies: [ + "OpenGraphTestsSupport", .product(name: "Numerics", package: "swift-numerics"), ], exclude: ["README.md"], @@ -212,11 +221,12 @@ let package = Package( openGraphTarget, openGraphSPITarget, openGraphShimsTarget, - - openGraphTestTarget, - openGraphSPITestTarget, - openGraphShimsTestTarget, - openGraphCompatibilityTestTarget, + openGraphTestsSupportTarget, + + openGraphTestsTarget, + openGraphCxxTestsTarget, + openGraphShimsTestsTarget, + openGraphCompatibilityTestsTarget, ], cxxLanguageStandard: .cxx20 ) @@ -268,9 +278,11 @@ if attributeGraphCondition { let compatibilityTestCondition = envEnable("OPENGRAPH_COMPATIBILITY_TEST") if compatibilityTestCondition && attributeGraphCondition { - openGraphCompatibilityTestTarget.addCompatibilitySettings() + openGraphTestsSupportTarget.addCompatibilitySettings() + openGraphCompatibilityTestsTarget.addCompatibilitySettings() } else { - openGraphCompatibilityTestTarget.dependencies.append("OpenGraph") + openGraphTestsSupportTarget.dependencies.append("OpenGraph") + openGraphCompatibilityTestsTarget.dependencies.append("OpenGraph") } extension [Platform] { diff --git a/Tests/OpenGraphCompatibilityTests/Helper/AsyncSemaphore.swift b/Sources/OpenGraphTestsSupport/AsyncSemaphore.swift similarity index 100% rename from Tests/OpenGraphCompatibilityTests/Helper/AsyncSemaphore.swift rename to Sources/OpenGraphTestsSupport/AsyncSemaphore.swift diff --git a/Sources/OpenGraphTestsSupport/DataHelper.swift b/Sources/OpenGraphTestsSupport/DataHelper.swift new file mode 100644 index 00000000..ce2bc940 --- /dev/null +++ b/Sources/OpenGraphTestsSupport/DataHelper.swift @@ -0,0 +1,25 @@ +// +// DataHelper.swift +// OpenGraphTestsSupport + +public struct Tuple { + public var first: A + public var second: B + + public init(first: A, second: B) { + self.first = first + self.second = second + } +} + +public struct Triple { + public var first: A + public var second: B + public var third: C + + public init(first: A, second: B, third: C) { + self.first = first + self.second = second + self.third = third + } +} diff --git a/Sources/OpenGraphTestsSupport/GraphEnvironmentTrait.swift b/Sources/OpenGraphTestsSupport/GraphEnvironmentTrait.swift new file mode 100644 index 00000000..03089c3e --- /dev/null +++ b/Sources/OpenGraphTestsSupport/GraphEnvironmentTrait.swift @@ -0,0 +1,39 @@ +// +// GraphEnvironmentTrait.swift +// OpenGraphTestsSupport + +public import Testing + +#if OPENGRAPH_COMPATIBILITY_TEST +@_exported public import AttributeGraph +#else +@_exported import OpenGraph +#endif + +public struct GraphEnvironmentTrait: TestTrait, TestScoping, SuiteTrait { + private static let sharedGraph = Graph() + private static let semaphore = AsyncSemaphore(value: 1) + + @MainActor + public func provideScope(for test: Test, testCase: Test.Case?, performing function: @Sendable () async throws -> Void) async throws { + await Self.semaphore.wait() + defer { Self.semaphore.signal() } + let graph = Graph(shared: Self.sharedGraph) + let subgraph = Subgraph(graph: graph) + let oldSubgraph = Subgraph.current + + Subgraph.current = subgraph + try await function() + Subgraph.current = oldSubgraph + } + + public var isRecursive: Bool { + true + } +} + +extension Trait where Self == GraphEnvironmentTrait { + public static var graphScope: Self { + GraphEnvironmentTrait() + } +} diff --git a/Tests/OpenGraphCompatibilityTests/Attribute/Attribute/AnyAttributeCompatibilityTests.swift b/Tests/OpenGraphCompatibilityTests/Attribute/Attribute/AnyAttributeCompatibilityTests.swift index 757dcc7d..757ec38d 100644 --- a/Tests/OpenGraphCompatibilityTests/Attribute/Attribute/AnyAttributeCompatibilityTests.swift +++ b/Tests/OpenGraphCompatibilityTests/Attribute/Attribute/AnyAttributeCompatibilityTests.swift @@ -3,14 +3,15 @@ // OpenGraphCompatibilityTests import Testing +import OpenGraphTestsSupport // *** Program crashed: Bad pointer dereference at 0x0000000ffff9400a *** // swift-testing framework will crash here on Linux // Report to upstream for investigation when we bump to 5.10 #if canImport(Darwin) -//@Suite(.disabled(if: !compatibilityTestEnabled, "Attribute is not implemented")) -@Suite(.disabled("Skip flaky CI tests after #154 temporary, See more info on #157")) -final class AnyAttributeCompatibilityTests: AttributeTestBase { +//@Suite(.disabled(if: !compatibilityTestEnabled, "Attribute is not implemented"), .graphScope) +@Suite(.disabled("Skip flaky CI tests after #154 temporary, See more info on #157"), .graphScope) +struct AnyAttributeCompatibilityTests { @Test func constantValue() throws { let attributeNil = AnyAttribute.nil diff --git a/Tests/OpenGraphCompatibilityTests/Attribute/Attribute/AttributeCompatibilityTests.swift b/Tests/OpenGraphCompatibilityTests/Attribute/Attribute/AttributeCompatibilityTests.swift index a1b8b486..23d5057a 100644 --- a/Tests/OpenGraphCompatibilityTests/Attribute/Attribute/AttributeCompatibilityTests.swift +++ b/Tests/OpenGraphCompatibilityTests/Attribute/Attribute/AttributeCompatibilityTests.swift @@ -3,6 +3,7 @@ // OpenGraphCompatibilityTests import Testing +import OpenGraphTestsSupport #if canImport(Darwin) @MainActor diff --git a/Tests/OpenGraphCompatibilityTests/Attribute/Attribute/ExternalCompatibilityTests.swift b/Tests/OpenGraphCompatibilityTests/Attribute/Attribute/ExternalCompatibilityTests.swift index f7d28593..63d55ea5 100644 --- a/Tests/OpenGraphCompatibilityTests/Attribute/Attribute/ExternalCompatibilityTests.swift +++ b/Tests/OpenGraphCompatibilityTests/Attribute/Attribute/ExternalCompatibilityTests.swift @@ -3,13 +3,15 @@ // OpenGraphCompatibilityTests import Testing +import OpenGraphTestsSupport // *** Program crashed: Bad pointer dereference at 0x0000000ffff9400a *** // swift-testing framework will crash here on Linux // Report to upstream for investigation when we bump to 5.10 #if canImport(Darwin) -@Suite(.disabled(if: !compatibilityTestEnabled, "Attribute is not implemented")) -final class ExternalCompatibilityTests: AttributeTestBase { +@MainActor +@Suite(.disabled(if: !compatibilityTestEnabled, "Attribute is not implemented"), .graphScope) +struct ExternalCompatibilityTests { @Test func example() throws { let type = External.self diff --git a/Tests/OpenGraphCompatibilityTests/Attribute/Attribute/FocusCompatibilityTests.swift b/Tests/OpenGraphCompatibilityTests/Attribute/Attribute/FocusCompatibilityTests.swift index 709f457c..b97cdaf1 100644 --- a/Tests/OpenGraphCompatibilityTests/Attribute/Attribute/FocusCompatibilityTests.swift +++ b/Tests/OpenGraphCompatibilityTests/Attribute/Attribute/FocusCompatibilityTests.swift @@ -3,10 +3,12 @@ // OpenGraphCompatibilityTests import Testing +import OpenGraphTestsSupport #if canImport(Darwin) -@Suite(.disabled(if: !compatibilityTestEnabled, "Attribute is not implemented")) -final class FocusCompatibilityTests: AttributeTestBase { +@MainActor +@Suite(.disabled(if: !compatibilityTestEnabled, "Attribute is not implemented"), .graphScope) +struct FocusCompatibilityTests { struct Demo { var a: Int var b: Double diff --git a/Tests/OpenGraphCompatibilityTests/Attribute/Attribute/PointerOffsetCompatibilityTests.swift b/Tests/OpenGraphCompatibilityTests/Attribute/Attribute/PointerOffsetCompatibilityTests.swift index ba9af6fb..e078dc79 100644 --- a/Tests/OpenGraphCompatibilityTests/Attribute/Attribute/PointerOffsetCompatibilityTests.swift +++ b/Tests/OpenGraphCompatibilityTests/Attribute/Attribute/PointerOffsetCompatibilityTests.swift @@ -4,6 +4,7 @@ import RealModule import Testing +import OpenGraphTestsSupport struct PointerOffsetCompatibilityTests { @Test diff --git a/Tests/OpenGraphCompatibilityTests/Attribute/Indirect/IndirectAttributeCompatibilityTests.swift b/Tests/OpenGraphCompatibilityTests/Attribute/Indirect/IndirectAttributeCompatibilityTests.swift index 6017ed34..68f5e51c 100644 --- a/Tests/OpenGraphCompatibilityTests/Attribute/Indirect/IndirectAttributeCompatibilityTests.swift +++ b/Tests/OpenGraphCompatibilityTests/Attribute/Indirect/IndirectAttributeCompatibilityTests.swift @@ -3,10 +3,12 @@ // OpenGraphCompatibilityTests import Testing +import OpenGraphTestsSupport #if canImport(Darwin) -@Suite(.disabled(if: !compatibilityTestEnabled, "IndirectAttribute is not implemented")) -final class IndirectAttributeCompatibilityTests: AttributeTestBase { +@MainActor +@Suite(.disabled(if: !compatibilityTestEnabled, "IndirectAttribute is not implemented"), .graphScope) +struct IndirectAttributeCompatibilityTests { @Test func basic() { let source = Attribute(value: 0) diff --git a/Tests/OpenGraphCompatibilityTests/Attribute/Optional/AnyOptionalAttributeCompatibilityTests.swift b/Tests/OpenGraphCompatibilityTests/Attribute/Optional/AnyOptionalAttributeCompatibilityTests.swift index 1ae19d91..21e74ba5 100644 --- a/Tests/OpenGraphCompatibilityTests/Attribute/Optional/AnyOptionalAttributeCompatibilityTests.swift +++ b/Tests/OpenGraphCompatibilityTests/Attribute/Optional/AnyOptionalAttributeCompatibilityTests.swift @@ -3,10 +3,12 @@ // OpenGraphCompatibilityTests import Testing +import OpenGraphTestsSupport #if canImport(Darwin) -@Suite(.disabled(if: !compatibilityTestEnabled, "AnyOptionalAttribute is not implemented")) -final class AnyOptionalAttributeCompatibilityTests: AttributeTestBase { +@MainActor +@Suite(.disabled(if: !compatibilityTestEnabled, "AnyOptionalAttribute is not implemented"), .graphScope) +struct AnyOptionalAttributeCompatibilityTests { @Test func basicInit() { let o1 = AnyOptionalAttribute() diff --git a/Tests/OpenGraphCompatibilityTests/Attribute/Optional/OptionalAttributeCompatibilityTests.swift b/Tests/OpenGraphCompatibilityTests/Attribute/Optional/OptionalAttributeCompatibilityTests.swift index 317ca5ef..173f79d9 100644 --- a/Tests/OpenGraphCompatibilityTests/Attribute/Optional/OptionalAttributeCompatibilityTests.swift +++ b/Tests/OpenGraphCompatibilityTests/Attribute/Optional/OptionalAttributeCompatibilityTests.swift @@ -3,10 +3,12 @@ // OpenGraphCompatibilityTests import Testing +import OpenGraphTestsSupport #if canImport(Darwin) +@MainActor @Suite(.disabled(if: !compatibilityTestEnabled, "OptionalAttribute is not implemented")) -final class OptionalAttributeCompatibilityTests: AttributeTestBase { +struct OptionalAttributeCompatibilityTests { @Test func basicInit() { let ao1 = AnyOptionalAttribute() diff --git a/Tests/OpenGraphCompatibilityTests/Attribute/Rule/MapCompatibilityTests.swift b/Tests/OpenGraphCompatibilityTests/Attribute/Rule/MapCompatibilityTests.swift index 4ee6a7d7..b566973c 100644 --- a/Tests/OpenGraphCompatibilityTests/Attribute/Rule/MapCompatibilityTests.swift +++ b/Tests/OpenGraphCompatibilityTests/Attribute/Rule/MapCompatibilityTests.swift @@ -3,9 +3,11 @@ // OpenGraphCompatibilityTests import Testing +import OpenGraphTestsSupport -@Suite(.disabled(if: !compatibilityTestEnabled)) -final class MapCompatibilityTests: AttributeTestBase { +@MainActor +@Suite(.disabled(if: !compatibilityTestEnabled), .graphScope) +struct MapCompatibilityTests { @Test func description() throws { let map = Map(.init(value: 2)) { $0.description } diff --git a/Tests/OpenGraphCompatibilityTests/Attribute/Weak/AnyWeakAttributeCompatibilityTests.swift b/Tests/OpenGraphCompatibilityTests/Attribute/Weak/AnyWeakAttributeCompatibilityTests.swift index b36c5bbb..e9b4fec0 100644 --- a/Tests/OpenGraphCompatibilityTests/Attribute/Weak/AnyWeakAttributeCompatibilityTests.swift +++ b/Tests/OpenGraphCompatibilityTests/Attribute/Weak/AnyWeakAttributeCompatibilityTests.swift @@ -3,11 +3,12 @@ // OpenGraphCompatibilityTests import Testing +import OpenGraphTestsSupport #if canImport(Darwin) - -@Suite(.enabled(if: compatibilityTestEnabled)) -final class AnyWeakAttributeCompatibilityTests: AttributeTestBase { +@MainActor +@Suite(.enabled(if: compatibilityTestEnabled), .graphScope) +struct AnyWeakAttributeCompatibilityTests { @Test func basic() { let w1 = AnyWeakAttribute(nil) diff --git a/Tests/OpenGraphCompatibilityTests/Attribute/Weak/WeakAttributeCompatibilityTests.swift b/Tests/OpenGraphCompatibilityTests/Attribute/Weak/WeakAttributeCompatibilityTests.swift index 40aa33f2..14f04c7c 100644 --- a/Tests/OpenGraphCompatibilityTests/Attribute/Weak/WeakAttributeCompatibilityTests.swift +++ b/Tests/OpenGraphCompatibilityTests/Attribute/Weak/WeakAttributeCompatibilityTests.swift @@ -3,10 +3,12 @@ // OpenGraphCompatibilityTests import Testing +import OpenGraphTestsSupport #if canImport(Darwin) -@Suite(.enabled(if: compatibilityTestEnabled)) -final class WeakAttributeCompatibilityTests: AttributeTestBase { +@MainActor +@Suite(.enabled(if: compatibilityTestEnabled), .graphScope) +struct WeakAttributeCompatibilityTests { @Test func initTest() { let _ = WeakAttribute() diff --git a/Tests/OpenGraphCompatibilityTests/Graph/SubgraphCompatibilityTests.swift b/Tests/OpenGraphCompatibilityTests/Graph/SubgraphCompatibilityTests.swift index 17c47fb9..35b1343d 100644 --- a/Tests/OpenGraphCompatibilityTests/Graph/SubgraphCompatibilityTests.swift +++ b/Tests/OpenGraphCompatibilityTests/Graph/SubgraphCompatibilityTests.swift @@ -4,7 +4,8 @@ import Testing -@Suite(.enabled(if: compatibilityTestEnabled)) +@MainActor +@Suite(.enabled(if: compatibilityTestEnabled), .graphScope) struct SubgraphCompatibilityTests { @Test func shouldRecordTree() { diff --git a/Tests/OpenGraphCompatibilityTests/Helper/AttributeTestBase.swift b/Tests/OpenGraphCompatibilityTests/Helper/AttributeTestBase.swift deleted file mode 100644 index 2bb80850..00000000 --- a/Tests/OpenGraphCompatibilityTests/Helper/AttributeTestBase.swift +++ /dev/null @@ -1,53 +0,0 @@ -// -// AttributeTestBase.swift -// OpenGraphCompatibilityTests - -import Testing -import Foundation - -/// Base class for Attribute Related test case -@available(*, deprecated, message: "Use GraphEnvironmentTrait instead") -class AttributeTestBase { - private static let sharedGraph = Graph() - private var graph: Graph - private var subgraph: Subgraph - - init() { - graph = Graph(shared: Self.sharedGraph) - subgraph = Subgraph(graph: graph) - Subgraph.current = subgraph - } - - deinit { - Subgraph.current = nil - } -} - -struct GraphEnvironmentTrait: TestTrait, TestScoping, SuiteTrait { - private static let sharedGraph = Graph() - private let semaphore = AsyncSemaphore(value: 1) - - - @MainActor - func provideScope(for test: Test, testCase: Test.Case?, performing function: @Sendable () async throws -> Void) async throws { - await semaphore.wait() - defer { semaphore.signal() } - let graph = Graph(shared: Self.sharedGraph) - let subgraph = Subgraph(graph: graph) - let oldSubgraph = Subgraph.current - - Subgraph.current = subgraph - try await function() - Subgraph.current = oldSubgraph - } - - var isRecursive: Bool { - true - } -} - -extension Trait where Self == GraphEnvironmentTrait { - static var graphScope: Self { - GraphEnvironmentTrait() - } -} diff --git a/Tests/OpenGraphCompatibilityTests/Helper/AttributeTestHelper.swift b/Tests/OpenGraphCompatibilityTests/Helper/AttributeTestHelper.swift deleted file mode 100644 index b5e00afc..00000000 --- a/Tests/OpenGraphCompatibilityTests/Helper/AttributeTestHelper.swift +++ /dev/null @@ -1,14 +0,0 @@ -// -// AttributeTestHelper.swift -// OpenGraphCompatibilityTests - -struct Tuple { - var first: A - var second: B -} - -struct Triple { - var first: A - var second: B - var third: C -} From 5fc3b7e94783f57bc29ba37bd94e252dcc053663 Mon Sep 17 00:00:00 2001 From: Kyle Date: Wed, 20 Aug 2025 01:22:12 +0800 Subject: [PATCH 3/3] Remove TestsSupport target --- Package.resolved | 2 +- Package.swift | 12 ------------ .../Attribute/AnyAttributeCompatibilityTests.swift | 1 - .../Attribute/AttributeCompatibilityTests.swift | 1 - .../Attribute/ExternalCompatibilityTests.swift | 1 - .../Attribute/FocusCompatibilityTests.swift | 1 - .../Attribute/PointerOffsetCompatibilityTests.swift | 1 - .../IndirectAttributeCompatibilityTests.swift | 1 - .../AnyOptionalAttributeCompatibilityTests.swift | 1 - .../OptionalAttributeCompatibilityTests.swift | 1 - .../Attribute/Rule/MapCompatibilityTests.swift | 1 - .../Weak/AnyWeakAttributeCompatibilityTests.swift | 1 - .../Weak/WeakAttributeCompatibilityTests.swift | 1 - .../OpenGraphTestsSupport | 1 + Tests/OpenGraphShimsTests/Export.swift | 5 +++++ Tests/OpenGraphShimsTests/MetadataDebugTests.swift | 2 +- Tests/OpenGraphShimsTests/OpenGraphTestsSupport | 1 + .../OpenGraphTestsSupport/AsyncSemaphore.swift | 0 .../OpenGraphTestsSupport/DataHelper.swift | 0 .../GraphEnvironmentTrait.swift | 6 ------ 20 files changed, 9 insertions(+), 31 deletions(-) create mode 120000 Tests/OpenGraphCompatibilityTests/OpenGraphTestsSupport create mode 100644 Tests/OpenGraphShimsTests/Export.swift create mode 120000 Tests/OpenGraphShimsTests/OpenGraphTestsSupport rename {Sources => Tests}/OpenGraphTestsSupport/AsyncSemaphore.swift (100%) rename {Sources => Tests}/OpenGraphTestsSupport/DataHelper.swift (100%) rename {Sources => Tests}/OpenGraphTestsSupport/GraphEnvironmentTrait.swift (89%) diff --git a/Package.resolved b/Package.resolved index 8aa9784c..ffd7382e 100644 --- a/Package.resolved +++ b/Package.resolved @@ -1,5 +1,5 @@ { - "originHash" : "217b2951abc95116105194b510d8119d5c5ef524e1ba89fd9e593cba3f060bdf", + "originHash" : "7ad3e8511a63915009dd025ffe4d701d034989c2468ac56c7d063a0c962dca4b", "pins" : [ { "identity" : "darwinprivateframeworks", diff --git a/Package.swift b/Package.swift index 5249e33b..285d7fe4 100644 --- a/Package.swift +++ b/Package.swift @@ -158,11 +158,6 @@ let openGraphShimsTarget = Target.target( cSettings: sharedCSettings, swiftSettings: sharedSwiftSettings ) -let openGraphTestsSupportTarget = Target.target( - name: "OpenGraphTestsSupport", - cSettings: sharedCSettings, - swiftSettings: sharedSwiftSettings -) // MARK: - Test Targets @@ -170,7 +165,6 @@ let openGraphTestsTarget = Target.testTarget( name: "OpenGraphTests", dependencies: [ "OpenGraph", - "OpenGraphTestsSupport", ], exclude: ["README.md"], cSettings: sharedCSettings, @@ -180,7 +174,6 @@ let openGraphCxxTestsTarget = Target.testTarget( name: "OpenGraphCxxTests", dependencies: [ "OpenGraphCxx", - "OpenGraphTestsSupport", ], exclude: ["README.md"], swiftSettings: sharedSwiftSettings + [.interoperabilityMode(.Cxx)] @@ -189,7 +182,6 @@ let openGraphShimsTestsTarget = Target.testTarget( name: "OpenGraphShimsTests", dependencies: [ "OpenGraphShims", - "OpenGraphTestsSupport", ], exclude: ["README.md"], cSettings: sharedCSettings, @@ -198,7 +190,6 @@ let openGraphShimsTestsTarget = Target.testTarget( let openGraphCompatibilityTestsTarget = Target.testTarget( name: "OpenGraphCompatibilityTests", dependencies: [ - "OpenGraphTestsSupport", .product(name: "Numerics", package: "swift-numerics"), ], exclude: ["README.md"], @@ -221,7 +212,6 @@ let package = Package( openGraphTarget, openGraphSPITarget, openGraphShimsTarget, - openGraphTestsSupportTarget, openGraphTestsTarget, openGraphCxxTestsTarget, @@ -278,10 +268,8 @@ if attributeGraphCondition { let compatibilityTestCondition = envEnable("OPENGRAPH_COMPATIBILITY_TEST") if compatibilityTestCondition && attributeGraphCondition { - openGraphTestsSupportTarget.addCompatibilitySettings() openGraphCompatibilityTestsTarget.addCompatibilitySettings() } else { - openGraphTestsSupportTarget.dependencies.append("OpenGraph") openGraphCompatibilityTestsTarget.dependencies.append("OpenGraph") } diff --git a/Tests/OpenGraphCompatibilityTests/Attribute/Attribute/AnyAttributeCompatibilityTests.swift b/Tests/OpenGraphCompatibilityTests/Attribute/Attribute/AnyAttributeCompatibilityTests.swift index 757ec38d..c11e80b4 100644 --- a/Tests/OpenGraphCompatibilityTests/Attribute/Attribute/AnyAttributeCompatibilityTests.swift +++ b/Tests/OpenGraphCompatibilityTests/Attribute/Attribute/AnyAttributeCompatibilityTests.swift @@ -3,7 +3,6 @@ // OpenGraphCompatibilityTests import Testing -import OpenGraphTestsSupport // *** Program crashed: Bad pointer dereference at 0x0000000ffff9400a *** // swift-testing framework will crash here on Linux diff --git a/Tests/OpenGraphCompatibilityTests/Attribute/Attribute/AttributeCompatibilityTests.swift b/Tests/OpenGraphCompatibilityTests/Attribute/Attribute/AttributeCompatibilityTests.swift index 23d5057a..a1b8b486 100644 --- a/Tests/OpenGraphCompatibilityTests/Attribute/Attribute/AttributeCompatibilityTests.swift +++ b/Tests/OpenGraphCompatibilityTests/Attribute/Attribute/AttributeCompatibilityTests.swift @@ -3,7 +3,6 @@ // OpenGraphCompatibilityTests import Testing -import OpenGraphTestsSupport #if canImport(Darwin) @MainActor diff --git a/Tests/OpenGraphCompatibilityTests/Attribute/Attribute/ExternalCompatibilityTests.swift b/Tests/OpenGraphCompatibilityTests/Attribute/Attribute/ExternalCompatibilityTests.swift index 63d55ea5..96425283 100644 --- a/Tests/OpenGraphCompatibilityTests/Attribute/Attribute/ExternalCompatibilityTests.swift +++ b/Tests/OpenGraphCompatibilityTests/Attribute/Attribute/ExternalCompatibilityTests.swift @@ -3,7 +3,6 @@ // OpenGraphCompatibilityTests import Testing -import OpenGraphTestsSupport // *** Program crashed: Bad pointer dereference at 0x0000000ffff9400a *** // swift-testing framework will crash here on Linux diff --git a/Tests/OpenGraphCompatibilityTests/Attribute/Attribute/FocusCompatibilityTests.swift b/Tests/OpenGraphCompatibilityTests/Attribute/Attribute/FocusCompatibilityTests.swift index b97cdaf1..c7d565a7 100644 --- a/Tests/OpenGraphCompatibilityTests/Attribute/Attribute/FocusCompatibilityTests.swift +++ b/Tests/OpenGraphCompatibilityTests/Attribute/Attribute/FocusCompatibilityTests.swift @@ -3,7 +3,6 @@ // OpenGraphCompatibilityTests import Testing -import OpenGraphTestsSupport #if canImport(Darwin) @MainActor diff --git a/Tests/OpenGraphCompatibilityTests/Attribute/Attribute/PointerOffsetCompatibilityTests.swift b/Tests/OpenGraphCompatibilityTests/Attribute/Attribute/PointerOffsetCompatibilityTests.swift index e078dc79..ba9af6fb 100644 --- a/Tests/OpenGraphCompatibilityTests/Attribute/Attribute/PointerOffsetCompatibilityTests.swift +++ b/Tests/OpenGraphCompatibilityTests/Attribute/Attribute/PointerOffsetCompatibilityTests.swift @@ -4,7 +4,6 @@ import RealModule import Testing -import OpenGraphTestsSupport struct PointerOffsetCompatibilityTests { @Test diff --git a/Tests/OpenGraphCompatibilityTests/Attribute/Indirect/IndirectAttributeCompatibilityTests.swift b/Tests/OpenGraphCompatibilityTests/Attribute/Indirect/IndirectAttributeCompatibilityTests.swift index 68f5e51c..0435cbee 100644 --- a/Tests/OpenGraphCompatibilityTests/Attribute/Indirect/IndirectAttributeCompatibilityTests.swift +++ b/Tests/OpenGraphCompatibilityTests/Attribute/Indirect/IndirectAttributeCompatibilityTests.swift @@ -3,7 +3,6 @@ // OpenGraphCompatibilityTests import Testing -import OpenGraphTestsSupport #if canImport(Darwin) @MainActor diff --git a/Tests/OpenGraphCompatibilityTests/Attribute/Optional/AnyOptionalAttributeCompatibilityTests.swift b/Tests/OpenGraphCompatibilityTests/Attribute/Optional/AnyOptionalAttributeCompatibilityTests.swift index 21e74ba5..1c7d6e00 100644 --- a/Tests/OpenGraphCompatibilityTests/Attribute/Optional/AnyOptionalAttributeCompatibilityTests.swift +++ b/Tests/OpenGraphCompatibilityTests/Attribute/Optional/AnyOptionalAttributeCompatibilityTests.swift @@ -3,7 +3,6 @@ // OpenGraphCompatibilityTests import Testing -import OpenGraphTestsSupport #if canImport(Darwin) @MainActor diff --git a/Tests/OpenGraphCompatibilityTests/Attribute/Optional/OptionalAttributeCompatibilityTests.swift b/Tests/OpenGraphCompatibilityTests/Attribute/Optional/OptionalAttributeCompatibilityTests.swift index 173f79d9..236b596a 100644 --- a/Tests/OpenGraphCompatibilityTests/Attribute/Optional/OptionalAttributeCompatibilityTests.swift +++ b/Tests/OpenGraphCompatibilityTests/Attribute/Optional/OptionalAttributeCompatibilityTests.swift @@ -3,7 +3,6 @@ // OpenGraphCompatibilityTests import Testing -import OpenGraphTestsSupport #if canImport(Darwin) @MainActor diff --git a/Tests/OpenGraphCompatibilityTests/Attribute/Rule/MapCompatibilityTests.swift b/Tests/OpenGraphCompatibilityTests/Attribute/Rule/MapCompatibilityTests.swift index b566973c..bfb74af4 100644 --- a/Tests/OpenGraphCompatibilityTests/Attribute/Rule/MapCompatibilityTests.swift +++ b/Tests/OpenGraphCompatibilityTests/Attribute/Rule/MapCompatibilityTests.swift @@ -3,7 +3,6 @@ // OpenGraphCompatibilityTests import Testing -import OpenGraphTestsSupport @MainActor @Suite(.disabled(if: !compatibilityTestEnabled), .graphScope) diff --git a/Tests/OpenGraphCompatibilityTests/Attribute/Weak/AnyWeakAttributeCompatibilityTests.swift b/Tests/OpenGraphCompatibilityTests/Attribute/Weak/AnyWeakAttributeCompatibilityTests.swift index e9b4fec0..f9b08a94 100644 --- a/Tests/OpenGraphCompatibilityTests/Attribute/Weak/AnyWeakAttributeCompatibilityTests.swift +++ b/Tests/OpenGraphCompatibilityTests/Attribute/Weak/AnyWeakAttributeCompatibilityTests.swift @@ -3,7 +3,6 @@ // OpenGraphCompatibilityTests import Testing -import OpenGraphTestsSupport #if canImport(Darwin) @MainActor diff --git a/Tests/OpenGraphCompatibilityTests/Attribute/Weak/WeakAttributeCompatibilityTests.swift b/Tests/OpenGraphCompatibilityTests/Attribute/Weak/WeakAttributeCompatibilityTests.swift index 14f04c7c..4f944134 100644 --- a/Tests/OpenGraphCompatibilityTests/Attribute/Weak/WeakAttributeCompatibilityTests.swift +++ b/Tests/OpenGraphCompatibilityTests/Attribute/Weak/WeakAttributeCompatibilityTests.swift @@ -3,7 +3,6 @@ // OpenGraphCompatibilityTests import Testing -import OpenGraphTestsSupport #if canImport(Darwin) @MainActor diff --git a/Tests/OpenGraphCompatibilityTests/OpenGraphTestsSupport b/Tests/OpenGraphCompatibilityTests/OpenGraphTestsSupport new file mode 120000 index 00000000..d79343a8 --- /dev/null +++ b/Tests/OpenGraphCompatibilityTests/OpenGraphTestsSupport @@ -0,0 +1 @@ +../OpenGraphTestsSupport/ \ No newline at end of file diff --git a/Tests/OpenGraphShimsTests/Export.swift b/Tests/OpenGraphShimsTests/Export.swift new file mode 100644 index 00000000..95a0d190 --- /dev/null +++ b/Tests/OpenGraphShimsTests/Export.swift @@ -0,0 +1,5 @@ +// +// Export.swift +// OpenGraphShimsTests + +@_exported import OpenGraphShims diff --git a/Tests/OpenGraphShimsTests/MetadataDebugTests.swift b/Tests/OpenGraphShimsTests/MetadataDebugTests.swift index 6d8b0678..ba0a6a43 100644 --- a/Tests/OpenGraphShimsTests/MetadataDebugTests.swift +++ b/Tests/OpenGraphShimsTests/MetadataDebugTests.swift @@ -1,6 +1,6 @@ // // MetadataDebugTests.swift -// OpenGraphTests +// OpenGraphShimsTests @_spi(Debug) import OpenGraphShims import Testing diff --git a/Tests/OpenGraphShimsTests/OpenGraphTestsSupport b/Tests/OpenGraphShimsTests/OpenGraphTestsSupport new file mode 120000 index 00000000..d79343a8 --- /dev/null +++ b/Tests/OpenGraphShimsTests/OpenGraphTestsSupport @@ -0,0 +1 @@ +../OpenGraphTestsSupport/ \ No newline at end of file diff --git a/Sources/OpenGraphTestsSupport/AsyncSemaphore.swift b/Tests/OpenGraphTestsSupport/AsyncSemaphore.swift similarity index 100% rename from Sources/OpenGraphTestsSupport/AsyncSemaphore.swift rename to Tests/OpenGraphTestsSupport/AsyncSemaphore.swift diff --git a/Sources/OpenGraphTestsSupport/DataHelper.swift b/Tests/OpenGraphTestsSupport/DataHelper.swift similarity index 100% rename from Sources/OpenGraphTestsSupport/DataHelper.swift rename to Tests/OpenGraphTestsSupport/DataHelper.swift diff --git a/Sources/OpenGraphTestsSupport/GraphEnvironmentTrait.swift b/Tests/OpenGraphTestsSupport/GraphEnvironmentTrait.swift similarity index 89% rename from Sources/OpenGraphTestsSupport/GraphEnvironmentTrait.swift rename to Tests/OpenGraphTestsSupport/GraphEnvironmentTrait.swift index 03089c3e..2b61892d 100644 --- a/Sources/OpenGraphTestsSupport/GraphEnvironmentTrait.swift +++ b/Tests/OpenGraphTestsSupport/GraphEnvironmentTrait.swift @@ -4,12 +4,6 @@ public import Testing -#if OPENGRAPH_COMPATIBILITY_TEST -@_exported public import AttributeGraph -#else -@_exported import OpenGraph -#endif - public struct GraphEnvironmentTrait: TestTrait, TestScoping, SuiteTrait { private static let sharedGraph = Graph() private static let semaphore = AsyncSemaphore(value: 1)