Skip to content

Commit 5d83b59

Browse files
authored
ManifestSourceGeneration incorrectly writes out DriverKit instead of driverKit (#6405)
The manifest source generation uses the wrong spelling for this enum. AFAIK there haven't been any reports of this affecting anyone yet — this was found during code inspection while making another change. The incorrect spelling is for both the platform version declaration and the spelling in the condition. This change also adds a unit test to check the latest versions of each of the platforms, and another one to check all the supported platform conditions. rdar://107795051
1 parent a801f39 commit 5d83b59

File tree

2 files changed

+54
-2
lines changed

2 files changed

+54
-2
lines changed

Sources/PackageModel/ManifestSourceGeneration.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ fileprivate extension SourceCodeFragment {
143143
case "watchos":
144144
self.init(enum: "watchOS", string: platform.version)
145145
case "driverkit":
146-
self.init(enum: "DriverKit", string: platform.version)
146+
self.init(enum: "driverKit", string: platform.version)
147147
default:
148148
self.init(enum: "custom", subnodes: [ .init(string: platform.platformName), .init(key: "versionString", string: platform.version) ])
149149
}
@@ -367,7 +367,7 @@ fileprivate extension SourceCodeFragment {
367367
case "ios": return SourceCodeFragment(enum: "iOS")
368368
case "tvos": return SourceCodeFragment(enum: "tvOS")
369369
case "watchos": return SourceCodeFragment(enum: "watchOS")
370-
case "driverkit": return SourceCodeFragment(enum: "DriverKit")
370+
case "driverkit": return SourceCodeFragment(enum: "driverKit")
371371
default: return SourceCodeFragment(enum: platformName)
372372
}
373373
}

Tests/WorkspaceTests/ManifestSourceGenerationTests.swift

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,58 @@ class ManifestSourceGenerationTests: XCTestCase {
423423
XCTAssertTrue(newContents.contains("import Foundation\n"), "contents: \(newContents)")
424424
}
425425

426+
func testLatestPlatformVersions() throws {
427+
let manifestContents = """
428+
// swift-tools-version: 5.9
429+
// The swift-tools-version declares the minimum version of Swift required to build this package.
430+
431+
import PackageDescription
432+
433+
let package = Package(
434+
name: "MyPackage",
435+
platforms: [
436+
.macOS(.v13),
437+
.iOS(.v16),
438+
.tvOS(.v16),
439+
.watchOS(.v9),
440+
.macCatalyst(.v16),
441+
.driverKit(.v22)
442+
],
443+
targets: [
444+
]
445+
)
446+
"""
447+
try testManifestWritingRoundTrip(manifestContents: manifestContents, toolsVersion: .v5_9)
448+
}
449+
450+
func testTargetPlatformConditions() throws {
451+
let manifestContents = """
452+
// swift-tools-version: 5.9
453+
// The swift-tools-version declares the minimum version of Swift required to build this package.
454+
455+
import PackageDescription
456+
457+
let package = Package(
458+
name: "MyPackage",
459+
targets: [
460+
.target(
461+
name: "MyExe",
462+
dependencies: [
463+
.target(name: "MyLib", condition: .when(platforms: [
464+
.macOS, .macCatalyst, .iOS, .tvOS, .watchOS, .driverKit,
465+
.linux, .windows, .android, .wasi, .openbsd
466+
]))
467+
]
468+
),
469+
.target(
470+
name: "MyLib"
471+
),
472+
]
473+
)
474+
"""
475+
try testManifestWritingRoundTrip(manifestContents: manifestContents, toolsVersion: .v5_9)
476+
}
477+
426478
func testCustomProductSourceGeneration() throws {
427479
// Create a manifest containing a product for which we'd like to do custom source fragment generation.
428480
let packageDir = AbsolutePath("/tmp/MyLibrary")

0 commit comments

Comments
 (0)