Skip to content

Commit 2bba828

Browse files
authored
Update CompatibilityTests logic (#187)
1 parent cd96220 commit 2bba828

File tree

5 files changed

+46
-44
lines changed

5 files changed

+46
-44
lines changed

Package.resolved

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,14 @@ if libraryEvolutionCondition {
133133
sharedSwiftSettings.append(.unsafeFlags(["-enable-library-evolution", "-no-verify-emitted-module-interface"]))
134134
}
135135

136+
// MARK: - [env] OPENATTRIBUTEGRAPH_COMPATIBILITY_TEST
137+
138+
let compatibilityTestCondition = envEnable("OPENATTRIBUTEGRAPH_COMPATIBILITY_TEST", default: false)
139+
sharedCSettings.append(.define("OPENATTRIBUTEGRAPH", to: compatibilityTestCondition ? "1" : "0"))
140+
if !compatibilityTestCondition {
141+
sharedSwiftSettings.append(.define("OPENATTRIBUTEGRAPH"))
142+
}
143+
136144
// MARK: - Targets
137145

138146
let openAttributeGraphTarget = Target.target(
@@ -192,7 +200,7 @@ let openAttributeGraphCompatibilityTestsTarget = Target.testTarget(
192200
name: "OpenAttributeGraphCompatibilityTests",
193201
dependencies: [
194202
.product(name: "Numerics", package: "swift-numerics"),
195-
],
203+
] + (compatibilityTestCondition ? [] : ["OpenAttributeGraph"]),
196204
exclude: ["README.md"],
197205
cSettings: sharedCSettings,
198206
swiftSettings: sharedSwiftSettings
@@ -213,11 +221,6 @@ let package = Package(
213221
openAttributeGraphTarget,
214222
openAttributeGraphSPITarget,
215223
openAttributeGraphShimsTarget,
216-
217-
openAttributeGraphTestsTarget,
218-
openAttributeGraphCxxTestsTarget,
219-
openAttributeGraphShimsTestsTarget,
220-
openAttributeGraphCompatibilityTestsTarget,
221224
],
222225
cxxLanguageStandard: .cxx20
223226
)
@@ -231,15 +234,20 @@ extension Target {
231234
swiftSettings.append(.define("OPENATTRIBUTEGRAPH_ATTRIBUTEGRAPH"))
232235
self.swiftSettings = swiftSettings
233236
}
234-
235-
func addCompatibilitySettings() {
236-
dependencies.append(
237-
.product(name: "AttributeGraph", package: "DarwinPrivateFrameworks")
238-
)
239-
var swiftSettings = swiftSettings ?? []
240-
swiftSettings.append(.define("OPENATTRIBUTEGRAPH_COMPATIBILITY_TEST"))
241-
self.swiftSettings = swiftSettings
242-
}
237+
}
238+
239+
if !compatibilityTestCondition {
240+
package.targets += [
241+
openAttributeGraphTestsTarget,
242+
openAttributeGraphCxxTestsTarget,
243+
openAttributeGraphShimsTestsTarget,
244+
]
245+
} else {
246+
openAttributeGraphCompatibilityTestsTarget.addAGSettings()
247+
}
248+
249+
if buildForDarwinPlatform {
250+
package.targets.append(openAttributeGraphCompatibilityTestsTarget)
243251
}
244252

245253
let useLocalDeps = envEnable("OPENATTRIBUTEGRAPH_USE_LOCAL_DEPS")
@@ -267,12 +275,6 @@ if attributeGraphCondition {
267275
package.platforms = [.iOS(.v13), .macOS(.v10_15), .macCatalyst(.v13), .tvOS(.v13), .watchOS(.v5)]
268276
}
269277

270-
let compatibilityTestCondition = envEnable("OPENATTRIBUTEGRAPH_COMPATIBILITY_TEST")
271-
if compatibilityTestCondition && attributeGraphCondition {
272-
openAttributeGraphCompatibilityTestsTarget.addCompatibilitySettings()
273-
} else {
274-
openAttributeGraphCompatibilityTestsTarget.dependencies.append("OpenAttributeGraph")
275-
}
276278

277279
extension [Platform] {
278280
static var nonDarwinPlatforms: [Platform] {

Tests/OpenAttributeGraphCompatibilityTests/Attribute/AttributeTestBase.swift

Whitespace-only changes.

Tests/OpenAttributeGraphCompatibilityTests/GraphShims.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,15 @@
22
// GraphShims.swift
33
// OpenAttributeGraphCompatibilityTests
44

5-
#if OPENATTRIBUTEGRAPH_COMPATIBILITY_TEST
5+
#if OPENATTRIBUTEGRAPH
6+
@_exported import OpenAttributeGraph
7+
let compatibilityTestEnabled = false
8+
#if OPENATTRIBUTEGRAPH_SWIFT_TOOLCHAIN_SUPPORTED
9+
public let swiftToolchainSupported = true
10+
#else
11+
public let swiftToolchainSupported = false
12+
#endif
13+
#else
614
@_exported public import AttributeGraph
715
public typealias OAGAttributeInfo = AGAttributeInfo
816
public typealias OAGCachedValueOptions = AGCachedValueOptions
@@ -12,12 +20,4 @@ public typealias OAGValue = AGValue
1220
public typealias OAGValueOptions = AGValueOptions
1321
public let compatibilityTestEnabled = true
1422
public let swiftToolchainSupported = true
15-
#else
16-
@_exported import OpenAttributeGraph
17-
let compatibilityTestEnabled = false
18-
#if OPENATTRIBUTEGRAPH_SWIFT_TOOLCHAIN_SUPPORTED
19-
public let swiftToolchainSupported = true
20-
#else
21-
public let swiftToolchainSupported = false
22-
#endif
2323
#endif

Tests/OpenAttributeGraphCompatibilityTests/VersionTests.swift renamed to Tests/OpenAttributeGraphCompatibilityTests/VersionCompatibilityTests.swift

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// VersionTests.swift
2+
// VersionCompatibilityTests.swift
33
// OpenAttributeGraphCompatibilityTests
44

55
import Testing
@@ -9,18 +9,7 @@ struct VersionTests {
99
@Test
1010
func versionNumber() async {
1111
await confirmation { confirm in
12-
#if OPENATTRIBUTEGRAPH_COMPATIBILITY_TEST
13-
switch Int32(ATTRIBUTEGRAPH_RELEASE) {
14-
case ATTRIBUTEGRAPH_RELEASE_2021:
15-
#expect(AGVersion == 0x20014)
16-
confirm()
17-
case ATTRIBUTEGRAPH_RELEASE_2024:
18-
#expect(AGVersion == 0x2001e)
19-
confirm()
20-
default:
21-
break
22-
}
23-
#else
12+
#if OPENATTRIBUTEGRAPH
2413
switch Int32(OPENATTRIBUTEGRAPH_RELEASE) {
2514
case OPENATTRIBUTEGRAPH_RELEASE_2021:
2615
#expect(OpenAttributeGraphVersionNumber.isApproximatelyEqual(to: 3.2))
@@ -33,6 +22,17 @@ struct VersionTests {
3322
default:
3423
break
3524
}
25+
#else
26+
switch Int32(ATTRIBUTEGRAPH_RELEASE) {
27+
case ATTRIBUTEGRAPH_RELEASE_2021:
28+
#expect(AGVersion == 0x20014)
29+
confirm()
30+
case ATTRIBUTEGRAPH_RELEASE_2024:
31+
#expect(AGVersion == 0x2001e)
32+
confirm()
33+
default:
34+
break
35+
}
3636
#endif
3737
}
3838
}

0 commit comments

Comments
 (0)