Skip to content

Commit 37282dd

Browse files
authored
Sort swift experimental-sdk list stdout output (#6942)
With a lot of Swift SDKs installed it's not as easy to navigate through a long unsorted list of strings.
1 parent 0e998cb commit 37282dd

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

Sources/PackageModel/SwiftSDKBundle.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,4 +487,8 @@ extension [SwiftSDKBundle] {
487487

488488
return matchedByID?.swiftSDK ?? matchedByTriple?.swiftSDK
489489
}
490+
491+
public var sortedArtifactIDs: [String] {
492+
self.flatMap(\.artifacts.keys).sorted()
493+
}
490494
}

Sources/SwiftSDKTool/ListSwiftSDKs.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ public struct ListSwiftSDKs: SwiftSDKSubcommand {
4646
return
4747
}
4848

49-
for bundle in validBundles {
50-
bundle.artifacts.keys.forEach { print($0) }
49+
for artifactID in validBundles.sortedArtifactIDs {
50+
print(artifactID)
5151
}
5252
}
5353
}

Tests/PackageModelTests/SwiftSDKBundleTests.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,8 @@ final class SwiftSDKBundleTests: XCTestCase {
213213
func testList() async throws {
214214
let (fileSystem, bundles, swiftSDKsDirectory) = try generateTestFileSystem(
215215
bundleArtifacts: [
216+
.init(id: "\(testArtifactID)2", supportedTriples: [i686Triple]),
216217
.init(id: "\(testArtifactID)1", supportedTriples: [arm64Triple]),
217-
.init(id: "\(testArtifactID)2", supportedTriples: [i686Triple])
218218
]
219219
)
220220
let system = ObservabilitySystem.makeForTesting()
@@ -236,6 +236,8 @@ final class SwiftSDKBundleTests: XCTestCase {
236236
)
237237

238238
XCTAssertEqual(validBundles.count, bundles.count)
239+
240+
XCTAssertEqual(validBundles.sortedArtifactIDs, ["\(testArtifactID)1", "\(testArtifactID)2"])
239241
}
240242

241243
func testBundleSelection() async throws {

0 commit comments

Comments
 (0)