Skip to content

Commit 03b599f

Browse files
committed
Update CompatibilityTests logic
1 parent cd96220 commit 03b599f

File tree

4 files changed

+41
-32
lines changed

4 files changed

+41
-32
lines changed

Package.swift

Lines changed: 19 additions & 10 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: true)
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(
@@ -213,14 +221,21 @@ let package = Package(
213221
openAttributeGraphTarget,
214222
openAttributeGraphSPITarget,
215223
openAttributeGraphShimsTarget,
224+
],
225+
cxxLanguageStandard: .cxx20
226+
)
216227

228+
if !compatibilityTestCondition {
229+
package.targets += [
217230
openAttributeGraphTestsTarget,
218231
openAttributeGraphCxxTestsTarget,
219232
openAttributeGraphShimsTestsTarget,
220-
openAttributeGraphCompatibilityTestsTarget,
221-
],
222-
cxxLanguageStandard: .cxx20
223-
)
233+
]
234+
}
235+
236+
if buildForDarwinPlatform {
237+
package.targets.append(openAttributeGraphCompatibilityTestsTarget)
238+
}
224239

225240
extension Target {
226241
func addAGSettings() {
@@ -267,12 +282,6 @@ if attributeGraphCondition {
267282
package.platforms = [.iOS(.v13), .macOS(.v10_15), .macCatalyst(.v13), .tvOS(.v13), .watchOS(.v5)]
268283
}
269284

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

277286
extension [Platform] {
278287
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)