Skip to content

Commit c7467d2

Browse files
committed
Automatically enable swift-testing support when building swift-testing.
Follow-up to #7220. swift-testing itself should get swift-testing support enabled by default, but it doesn't list itself as a dependency. This change extends the code in that PR to also check the identities of the packages being built (rather than just their dependencies.) If the package being built is named "swift-testing", then support is enabled.
1 parent 6995433 commit c7467d2

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

Sources/Commands/SwiftTestTool.swift

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,15 +101,32 @@ struct SharedOptions: ParsableArguments {
101101
completion: $0
102102
)
103103
}
104+
105+
// Is swift-testing among the dependencies of the package being built?
106+
// If so, enable support.
104107
let isEnabledByDependency = rootManifests.values.lazy
105108
.flatMap(\.dependencies)
106109
.map(\.identity)
107110
.map(String.init(describing:))
108111
.contains("swift-testing")
109112
if isEnabledByDependency {
110113
swiftTool.observabilityScope.emit(debug: "Enabling swift-testing support due to its presence as a package dependency.")
114+
return true
115+
}
116+
117+
// Is swift-testing the package being built itself (unlikely)? If so,
118+
// enable support.
119+
let isEnabledByName = root.packages.lazy
120+
.map(PackageIdentity.init(path:))
121+
.map(String.init(describing:))
122+
.contains("swift-testing")
123+
if isEnabledByName {
124+
swiftTool.observabilityScope.emit(debug: "Enabling swift-testing support because it is a root package.")
125+
return true
111126
}
112-
return isEnabledByDependency
127+
128+
// Default to disabled since swift-testing is experimental (opt-in.)
129+
return false
113130
}
114131
}
115132

0 commit comments

Comments
 (0)