Skip to content

Set correct minimum OS targets for new packages using swift-testing #7333

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Sources/Workspace/InitPackage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,8 @@ public final class InitPackage {

var platforms = options.platforms

// Macros require macOS 10.15, iOS 13, etc.
if packageType == .macro {
// Macros and swift-testing require macOS 10.15, iOS 13, etc.
if packageType == .macro || options.supportedTestingLibraries.contains(.swiftTesting) {
func addIfMissing(_ newPlatform: SupportedPlatform) {
if platforms.contains(where: { platform in
platform.platform == newPlatform.platform
Expand Down
10 changes: 10 additions & 0 deletions Tests/WorkspaceTests/InitTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,11 @@ class InitTests: XCTestCase {
let manifest = path.appending("Package.swift")
XCTAssertFileExists(manifest)
let manifestContents: String = try localFileSystem.readFileContents(manifest)
XCTAssertMatch(manifestContents, .contains(#".macOS(.v10_15)"#))
XCTAssertMatch(manifestContents, .contains(#".iOS(.v13)"#))
XCTAssertMatch(manifestContents, .contains(#".tvOS(.v13)"#))
XCTAssertMatch(manifestContents, .contains(#".watchOS(.v6)"#))
XCTAssertMatch(manifestContents, .contains(#".macCatalyst(.v13)"#))
XCTAssertMatch(manifestContents, .contains(#"swift-testing.git", from: "0.2.0""#))
XCTAssertMatch(manifestContents, .contains(#".product(name: "Testing", package: "swift-testing")"#))

Expand Down Expand Up @@ -208,6 +213,11 @@ class InitTests: XCTestCase {
let manifest = path.appending("Package.swift")
XCTAssertFileExists(manifest)
let manifestContents: String = try localFileSystem.readFileContents(manifest)
XCTAssertMatch(manifestContents, .contains(#".macOS(.v10_15)"#))
XCTAssertMatch(manifestContents, .contains(#".iOS(.v13)"#))
XCTAssertMatch(manifestContents, .contains(#".tvOS(.v13)"#))
XCTAssertMatch(manifestContents, .contains(#".watchOS(.v6)"#))
XCTAssertMatch(manifestContents, .contains(#".macCatalyst(.v13)"#))
XCTAssertMatch(manifestContents, .contains(#"swift-testing.git", from: "0.2.0""#))
XCTAssertMatch(manifestContents, .contains(#".product(name: "Testing", package: "swift-testing")"#))

Expand Down