Skip to content

Commit 5313447

Browse files
committed
Rework validation import conditions to dependency conditionals
1 parent ac3175b commit 5313447

File tree

5 files changed

+80
-26
lines changed

5 files changed

+80
-26
lines changed

Package.swift

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,13 @@
33
import PackageDescription
44
import CompilerPluginSupport
55

6-
// Availability Macros
7-
8-
let supportedTestingPlatforms: [Platform] = [
9-
.macOS,
10-
.iOS,
11-
.tvOS,
12-
.watchOS,
13-
.visionOS,
14-
.macCatalyst,
15-
.android,
16-
.linux,
17-
.openbsd,
18-
.wasi,
19-
]
20-
216
let availabilityMacros: [SwiftSetting] = [
227
.enableExperimentalFeature(
238
"AvailabilityMacro=AsyncAlgorithms 1.0:macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0"
249
),
2510
.enableExperimentalFeature(
2611
"AvailabilityMacro=AsyncAlgorithms 1.1:macOS 15.0, iOS 18.0, tvOS 18.0, watchOS 11.0, visionOS 2.0"
27-
),
12+
)
2813
]
2914

3015
let package = Package(
@@ -56,17 +41,41 @@ let package = Package(
5641
dependencies: ["AsyncAlgorithms", "AsyncSequenceValidation"],
5742
swiftSettings: availabilityMacros + [
5843
.enableExperimentalFeature("StrictConcurrency=complete")
59-
],
60-
condition: .when(platforms: supportedTestingPlatforms)
44+
]
6145
),
6246
.testTarget(
6347
name: "AsyncAlgorithmsTests",
64-
dependencies: ["AsyncAlgorithms", "AsyncSequenceValidation", "AsyncAlgorithms_XCTest"],
48+
dependencies: [
49+
.target(name: "AsyncAlgorithms"),
50+
.target(name: "AsyncSequenceValidation", condition: .when(platforms: [
51+
.macOS,
52+
.iOS,
53+
.tvOS,
54+
.watchOS,
55+
.visionOS,
56+
.macCatalyst,
57+
.android,
58+
.linux,
59+
.openbsd,
60+
.wasi
61+
])),
62+
.target(name: "AsyncAlgorithms_XCTest", condition: .when(platforms: [
63+
.macOS,
64+
.iOS,
65+
.tvOS,
66+
.watchOS,
67+
.visionOS,
68+
.macCatalyst,
69+
.android,
70+
.linux,
71+
.openbsd,
72+
.wasi
73+
]))
74+
],
6575
swiftSettings: availabilityMacros + [
6676
.enableExperimentalFeature("StrictConcurrency=complete")
67-
],
68-
condition: .when(platforms: supportedTestingPlatforms)
69-
),
77+
]
78+
)
7079
]
7180
)
7281

[email protected]

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,12 @@ import CompilerPluginSupport
66
// Availability Macros
77

88
let availabilityMacros: [SwiftSetting] = [
9-
.enableExperimentalFeature("AvailabilityMacro=AsyncAlgorithms 1.0:macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0"),
10-
.enableExperimentalFeature("AvailabilityMacro=AsyncAlgorithms 1.1:macOS 15.0, iOS 18.0, tvOS 18.0, watchOS 11.0, visionOS 2.0"),
9+
.enableExperimentalFeature(
10+
"AvailabilityMacro=AsyncAlgorithms 1.0:macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0"
11+
),
12+
.enableExperimentalFeature(
13+
"AvailabilityMacro=AsyncAlgorithms 1.1:macOS 15.0, iOS 18.0, tvOS 18.0, watchOS 11.0, visionOS 2.0"
14+
),
1115
]
1216

1317
let package = Package(
@@ -43,7 +47,33 @@ let package = Package(
4347
),
4448
.testTarget(
4549
name: "AsyncAlgorithmsTests",
46-
dependencies: ["AsyncAlgorithms", "AsyncSequenceValidation", "AsyncAlgorithms_XCTest"],
50+
dependencies: [
51+
.target(name: "AsyncAlgorithms"),
52+
.target(name: "AsyncSequenceValidation", condition: .when(platforms: [
53+
.macOS,
54+
.iOS,
55+
.tvOS,
56+
.watchOS,
57+
.visionOS,
58+
.macCatalyst,
59+
.android,
60+
.linux,
61+
.openbsd,
62+
.wasi
63+
])),
64+
.target(name: "AsyncAlgorithms_XCTest", condition: .when(platforms: [
65+
.macOS,
66+
.iOS,
67+
.tvOS,
68+
.watchOS,
69+
.visionOS,
70+
.macCatalyst,
71+
.android,
72+
.linux,
73+
.openbsd,
74+
.wasi
75+
]))
76+
],
4777
swiftSettings: availabilityMacros + [
4878
.enableExperimentalFeature("StrictConcurrency=complete")
4979
]
@@ -53,7 +83,7 @@ let package = Package(
5383

5484
if Context.environment["SWIFTCI_USE_LOCAL_DEPS"] == nil {
5585
package.dependencies += [
56-
.package(url: "https://github.com/apple/swift-collections.git", from: "1.1.0"),
86+
.package(url: "https://github.com/apple/swift-collections.git", from: "1.1.0")
5787
]
5888
} else {
5989
package.dependencies += [

Tests/AsyncAlgorithmsTests/TestChunk.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
//===----------------------------------------------------------------------===//
1111

1212
import XCTest
13+
14+
#if canImport(Darwin) || canImport(Glibc) || canImport(Musl) || canImport(Bionic) || canImport(wasi_pthread)
15+
1316
import AsyncSequenceValidation
1417
import AsyncAlgorithms
1518

@@ -334,3 +337,5 @@ final class TestChunk: XCTestCase {
334337
}
335338
}
336339
}
340+
341+
#endif

Tests/AsyncAlgorithmsTests/TestTimer.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
//===----------------------------------------------------------------------===//
1111

1212
import XCTest
13+
14+
#if canImport(Darwin) || canImport(Glibc) || canImport(Musl) || canImport(Bionic) || canImport(wasi_pthread)
15+
1316
import AsyncAlgorithms
1417
import AsyncSequenceValidation
1518

@@ -57,3 +60,5 @@ final class TestTimer: XCTestCase {
5760
}
5861
}
5962
}
63+
64+
#endif

Tests/AsyncAlgorithmsTests/TestValidationTests.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
//===----------------------------------------------------------------------===//
1111

1212
import XCTest
13+
14+
#if canImport(Darwin) || canImport(Glibc) || canImport(Musl) || canImport(Bionic) || canImport(wasi_pthread)
15+
1316
import AsyncAlgorithms
1417
import AsyncSequenceValidation
1518
@testable import AsyncAlgorithms_XCTest
@@ -354,3 +357,5 @@ struct LaggingAsyncSequence<Base: AsyncSequence, C: Clock>: AsyncSequence {
354357
self.clock = clock
355358
}
356359
}
360+
361+
#endif

0 commit comments

Comments
 (0)