Skip to content

Commit eff7c33

Browse files
authored
build: split the SwiftDocCUtilitiesTest for Windows (#608)
We need to replicate the target definition to exclude some files when building for Windows as they depend on NIO to create the PreviewServer. Rather than adding the files and conditionally removing the content, remove thee files from being built.
1 parent 96b5e48 commit eff7c33

File tree

1 file changed

+27
-11
lines changed

1 file changed

+27
-11
lines changed

Package.swift

+27-11
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ let package = Package(
105105

106106
// Command-line tool library
107107
#if os(Windows)
108-
package.targets.append(
108+
package.targets.append(contentsOf: [
109109
.target(
110110
name: "SwiftDocCUtilities",
111111
dependencies: [
@@ -120,10 +120,29 @@ package.targets.append(
120120
"ArgumentParsing/Subcommands/Preview.swift",
121121
],
122122
swiftSettings: swiftSettings
123-
)
124-
)
123+
),
124+
.testTarget(
125+
name: "SwiftDocCUtilitiesTests",
126+
dependencies: [
127+
.target(name: "SwiftDocCUtilities"),
128+
.target(name: "SwiftDocC"),
129+
.target(name: "SwiftDocCTestUtilities"),
130+
],
131+
exclude: [
132+
// PreviewServer requires NIO which cannot support non-POSIX platforms.
133+
"ArgumentParsing/PreviewSubcommandTests.swift",
134+
"PreviewActionIntegrationTests.swift",
135+
"PreviewServer",
136+
],
137+
resources: [
138+
.copy("Test Resources"),
139+
.copy("Test Bundles"),
140+
],
141+
swiftSettings: swiftSettings
142+
),
143+
])
125144
#else
126-
package.targets.append(
145+
package.targets.append(contentsOf: [
127146
.target(
128147
name: "SwiftDocCUtilities",
129148
dependencies: [
@@ -132,11 +151,7 @@ package.targets.append(
132151
.product(name: "ArgumentParser", package: "swift-argument-parser")
133152
],
134153
swiftSettings: swiftSettings
135-
)
136-
)
137-
#endif
138-
139-
package.targets.append(
154+
),
140155
.testTarget(
141156
name: "SwiftDocCUtilitiesTests",
142157
dependencies: [
@@ -149,8 +164,9 @@ package.targets.append(
149164
.copy("Test Bundles"),
150165
],
151166
swiftSettings: swiftSettings
152-
)
153-
)
167+
),
168+
])
169+
#endif
154170

155171
// If the `SWIFTCI_USE_LOCAL_DEPS` environment variable is set,
156172
// we're building in the Swift.org CI system alongside other projects in the Swift toolchain and

0 commit comments

Comments
 (0)