Skip to content

Commit 8ed0492

Browse files
committed
Revert "[Build] BuildPlan: Always discover test modules through their aggrega… (#7879)"
This reverts commit 6481220.
1 parent 126ced2 commit 8ed0492

File tree

4 files changed

+6
-29
lines changed

4 files changed

+6
-29
lines changed

Sources/Build/BuildPlan/BuildPlan.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -986,9 +986,9 @@ extension BuildPlan {
986986
}
987987

988988
for module in package.modules {
989-
// Tests are discovered through an aggregate product which also
990-
// informs their destination.
991-
if case .test = module.underlying.type {
989+
if case .test = module.underlying.type,
990+
!graph.rootPackages.contains(id: package.id)
991+
{
992992
continue
993993
}
994994

@@ -1002,7 +1002,7 @@ extension BuildPlan {
10021002
for product: ResolvedProduct,
10031003
destination: Destination
10041004
) -> [TraversalNode] {
1005-
guard destination == .host || product.underlying.type == .test else {
1005+
guard destination == .host else {
10061006
return []
10071007
}
10081008

Sources/_InternalTestSupport/MockPackageGraphs.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@ package func macrosTestsPackageGraph() throws -> MockPackageGraph {
137137
"/swift-mmio/Sources/MMIOMacros/source.swift",
138138
"/swift-mmio/Sources/MMIOMacrosTests/source.swift",
139139
"/swift-mmio/Sources/MMIOMacro+PluginTests/source.swift",
140-
"/swift-mmio/Sources/NOOPTests/source.swift",
141140
"/swift-syntax/Sources/SwiftSyntax/source.swift",
142141
"/swift-syntax/Sources/SwiftSyntaxMacrosTestSupport/source.swift",
143142
"/swift-syntax/Sources/SwiftSyntaxMacros/source.swift",
@@ -204,11 +203,6 @@ package func macrosTestsPackageGraph() throws -> MockPackageGraph {
204203
.target(name: "MMIOMacros")
205204
],
206205
type: .test
207-
),
208-
TargetDescription(
209-
name: "NOOPTests",
210-
dependencies: [],
211-
type: .test
212206
)
213207
]
214208
),

Tests/BuildTests/CrossCompilationBuildPlanTests.swift

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -295,15 +295,9 @@ final class CrossCompilationBuildPlanTests: XCTestCase {
295295
fileSystem: fs,
296296
observabilityScope: scope
297297
)
298-
299-
// Make sure that build plan doesn't have any "target" tests.
300-
for (_, description) in plan.targetMap where description.module.underlying.type == .test {
301-
XCTAssertEqual(description.buildParameters.destination, .host)
302-
}
303-
304298
let result = try BuildPlanResult(plan: plan)
305299
result.checkProductsCount(2)
306-
result.checkTargetsCount(17)
300+
result.checkTargetsCount(16)
307301

308302
XCTAssertTrue(try result.allTargets(named: "SwiftSyntax")
309303
.map { try $0.swift() }

Tests/PackageGraphTests/CrossCompilationPackageGraphTests.swift

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,7 @@ final class CrossCompilationPackageGraphTests: XCTestCase {
116116
"SwiftSyntaxMacrosTestSupport",
117117
"SwiftSyntaxMacrosTestSupport"
118118
)
119-
// TODO: NOOPTests are mentioned twice because in the graph they appear
120-
// as if they target both "tools" and "destination", see the test below.
121-
// Once the `buildTriple` is gone, there is going to be only one mention
122-
// left.
123-
result.check(testModules: "MMIOMacrosTests", "MMIOMacro+PluginTests", "NOOPTests", "NOOPTests")
119+
result.check(testModules: "MMIOMacrosTests", "MMIOMacro+PluginTests")
124120
result.checkTarget("MMIO") { result in
125121
result.check(buildTriple: .destination)
126122
result.check(dependencies: "MMIOMacros")
@@ -184,13 +180,6 @@ final class CrossCompilationPackageGraphTests: XCTestCase {
184180
XCTAssertEqual(graph.package(for: result.target)?.identity, .plain("swift-syntax"))
185181
}
186182
}
187-
188-
result.checkTargets("NOOPTests") { results in
189-
XCTAssertEqual(results.count, 2)
190-
191-
XCTAssertEqual(results.filter({ $0.target.buildTriple == .tools }).count, 1)
192-
XCTAssertEqual(results.filter({ $0.target.buildTriple == .destination }).count, 1)
193-
}
194183
}
195184
}
196185

0 commit comments

Comments
 (0)