From 9b2bca55277984dd5c84be47bbb74f10ee7e99b8 Mon Sep 17 00:00:00 2001 From: Matthew Bastien Date: Tue, 30 Sep 2025 15:41:18 -0400 Subject: [PATCH] sort Swiftly toolchains in descending order --- src/commands/installSwiftlyToolchain.ts | 65 +-- src/toolchain/swiftly.ts | 179 +++--- src/ui/ToolchainSelection.ts | 9 +- src/utilities/version.ts | 4 + test/unit-tests/toolchain/swiftly.test.ts | 528 ++++++++++-------- test/unit-tests/ui/ToolchainSelection.test.ts | 4 +- 6 files changed, 416 insertions(+), 373 deletions(-) diff --git a/src/commands/installSwiftlyToolchain.ts b/src/commands/installSwiftlyToolchain.ts index 3903229f0..5feadcb99 100644 --- a/src/commands/installSwiftlyToolchain.ts +++ b/src/commands/installSwiftlyToolchain.ts @@ -16,17 +16,11 @@ import { QuickPickItem } from "vscode"; import { WorkspaceContext } from "../WorkspaceContext"; import { SwiftLogger } from "../logging/SwiftLogger"; -import { - Swiftly, - SwiftlyProgressData, - SwiftlyToolchain, - isSnapshotVersion, - isStableVersion, -} from "../toolchain/swiftly"; +import { AvailableToolchain, Swiftly, SwiftlyProgressData } from "../toolchain/swiftly"; import { showReloadExtensionNotification } from "../ui/ReloadExtension"; interface SwiftlyToolchainItem extends QuickPickItem { - toolchain: SwiftlyToolchain; + toolchain: AvailableToolchain; } async function downloadAndInstallToolchain(selected: SwiftlyToolchainItem, ctx: WorkspaceContext) { @@ -147,15 +141,10 @@ export async function installSwiftlyToolchain(ctx: WorkspaceContext): Promise toolchain.version.type === "stable") - ); - ctx.logger.debug( - `Available toolchains for installation: ${sortedToolchains.map(t => t.version.name).join(", ")}` + `Available toolchains for installation: ${uninstalledToolchains.map(t => t.version.name).join(", ")}` ); - const quickPickItems = sortedToolchains.map(toolchain => ({ + const quickPickItems = uninstalledToolchains.map(toolchain => ({ label: `$(cloud-download) ${toolchain.version.name}`, toolchain: toolchain, })); @@ -226,10 +215,7 @@ export async function installSwiftlySnapshotToolchain(ctx: WorkspaceContext): Pr return; } - // Sort toolchains with most recent versions first - const sortedToolchains = sortToolchainsByVersion(uninstalledSnapshotToolchains); - - const quickPickItems = sortedToolchains.map(toolchain => ({ + const quickPickItems = uninstalledSnapshotToolchains.map(toolchain => ({ label: `$(cloud-download) ${toolchain.version.name}`, description: "snapshot", detail: `Date: ${ @@ -250,44 +236,3 @@ export async function installSwiftlySnapshotToolchain(ctx: WorkspaceContext): Pr await downloadAndInstallToolchain(selected, ctx); } - -/** - * Sorts toolchains by version with most recent first - */ -function sortToolchainsByVersion(toolchains: SwiftlyToolchain[]): SwiftlyToolchain[] { - return toolchains.sort((a, b) => { - // First sort by type (stable before snapshot) - if (a.version.type !== b.version.type) { - return isStableVersion(a.version) ? -1 : 1; - } - - // For stable releases, sort by semantic version - if (isStableVersion(a.version) && isStableVersion(b.version)) { - const versionA = a.version; - const versionB = b.version; - - if (versionA && versionB) { - if (versionA.major !== versionB.major) { - return versionB.major - versionA.major; - } - if (versionA.minor !== versionB.minor) { - return versionB.minor - versionA.minor; - } - return versionB.patch - versionA.patch; - } - } - - // For snapshots, sort by date (newer first) - if (isSnapshotVersion(a.version) && isSnapshotVersion(b.version)) { - const dateA = a.version.date; - const dateB = b.version.date; - - if (dateA && dateB) { - return dateB.localeCompare(dateA); - } - } - - // Fallback to string comparison - return b.version.name.localeCompare(a.version.name); - }); -} diff --git a/src/toolchain/swiftly.ts b/src/toolchain/swiftly.ts index d2012fb61..7674b7dc7 100644 --- a/src/toolchain/swiftly.ts +++ b/src/toolchain/swiftly.ts @@ -31,91 +31,77 @@ import { ExecFileError, execFile, execFileStreamOutput } from "../utilities/util import { Version } from "../utilities/version"; import { SwiftlyConfig } from "./ToolchainVersion"; -const ListResult = z.object({ - toolchains: z.array( - z.object({ - inUse: z.boolean(), - isDefault: z.boolean(), - version: z.union([ - z.object({ - major: z.union([z.number(), z.undefined()]), - minor: z.union([z.number(), z.undefined()]), - patch: z.union([z.number(), z.undefined()]), - name: z.string(), - type: z.literal("stable"), - }), - z.object({ - major: z.union([z.number(), z.undefined()]), - minor: z.union([z.number(), z.undefined()]), - branch: z.string(), - date: z.string(), - name: z.string(), - type: z.literal("snapshot"), - }), - z.object({ - name: z.string(), - type: z.literal("system"), - }), - z.object(), - ]), - }) - ), -}); - -const InUseVersionResult = z.object({ - version: z.string(), +const SystemVersion = z.object({ + type: z.literal("system"), + name: z.string(), }); +export type SystemVersion = z.infer; const StableVersion = z.object({ + type: z.literal("stable"), + name: z.string(), + major: z.number(), minor: z.number(), patch: z.number(), - name: z.string(), - type: z.literal("stable"), }); - export type StableVersion = z.infer; const SnapshotVersion = z.object({ - major: z.union([z.number(), z.undefined()]), - minor: z.union([z.number(), z.undefined()]), + type: z.literal("snapshot"), + name: z.string(), + + major: z.optional(z.number()), + minor: z.optional(z.number()), branch: z.string(), date: z.string(), - name: z.string(), - type: z.literal("snapshot"), }); - export type SnapshotVersion = z.infer; -export interface SwiftlyToolchain { +export type ToolchainVersion = SystemVersion | StableVersion | SnapshotVersion; + +export interface AvailableToolchain { inUse: boolean; installed: boolean; isDefault: boolean; - version: StableVersion | SnapshotVersion; + version: ToolchainVersion; } -const AvailableToolchain = z.object({ - inUse: z.boolean(), - installed: z.boolean(), - isDefault: z.boolean(), - version: z.union([StableVersion, SnapshotVersion, z.object()]), +const SwiftlyListResult = z.object({ + toolchains: z.array( + z.object({ + inUse: z.boolean(), + isDefault: z.boolean(), + version: z.union([ + SystemVersion, + StableVersion, + SnapshotVersion, + // Allow matching against unexpected future version types + z.object(), + ]), + }) + ), }); -type AvailableToolchain = z.infer; - -export function isStableVersion( - version: StableVersion | SnapshotVersion -): version is StableVersion { - return version.type === "stable"; -} -export function isSnapshotVersion( - version: StableVersion | SnapshotVersion -): version is SnapshotVersion { - return version.type === "snapshot"; -} +const SwiftlyListAvailableResult = z.object({ + toolchains: z.array( + z.object({ + inUse: z.boolean(), + installed: z.boolean(), + isDefault: z.boolean(), + version: z.union([ + SystemVersion, + StableVersion, + SnapshotVersion, + // Allow matching against unexpected future version types + z.object(), + ]), + }) + ), +}); -const ListAvailableResult = z.object({ - toolchains: z.array(AvailableToolchain), +const InUseVersionResult = z.object({ + version: z.string(), }); export interface SwiftlyProgressData { @@ -228,6 +214,8 @@ export class Swiftly { /** * Finds the list of toolchains installed via Swiftly. * + * Toolchains will be sorted by version number in descending order. + * * @returns an array of toolchain version names. */ public static async list(logger?: SwiftLogger): Promise { @@ -250,10 +238,13 @@ export class Swiftly { private static async listUsingJSONFormat(logger?: SwiftLogger): Promise { try { const { stdout } = await execFile("swiftly", ["list", "--format=json"]); - const response = ListResult.parse(JSON.parse(stdout)); - return response.toolchains - .filter(t => ["stable", "snapshot", "system"].includes(t.version?.type)) - .map(t => t.version.name); + return SwiftlyListResult.parse(JSON.parse(stdout)) + .toolchains.map(toolchain => toolchain.version) + .filter((version): version is ToolchainVersion => + ["system", "stable", "snapshot"].includes(version.type) + ) + .sort(compareSwiftlyToolchainVersion) + .map(version => version.name); } catch (error) { logger?.error(`Failed to retrieve Swiftly installations: ${error}`); return []; @@ -274,8 +265,14 @@ export class Swiftly { if (!Array.isArray(installedToolchains)) { return []; } - return installedToolchains.filter( - (toolchain): toolchain is string => typeof toolchain === "string" + return ( + installedToolchains + .filter((toolchain): toolchain is string => typeof toolchain === "string") + // Sort alphabetically in descending order. + // + // This isn't perfect (e.g. "5.10" will come before "5.9"), but this is + // good enough for legacy support. + .sort((lhs, rhs) => rhs.localeCompare(lhs)) ); } catch (error) { logger?.error(`Failed to retrieve Swiftly installations: ${error}`); @@ -421,6 +418,8 @@ export class Swiftly { /** * Lists all toolchains available for installation from swiftly. * + * Toolchains will be sorted by version number in descending order. + * * @param branch Optional branch to filter available toolchains (e.g., "main" for snapshots). * @param logger Optional logger for error reporting. * @returns Array of available toolchains. @@ -428,7 +427,7 @@ export class Swiftly { public static async listAvailable( branch?: string, logger?: SwiftLogger - ): Promise { + ): Promise { if (!this.isSupported()) { return []; } @@ -450,10 +449,11 @@ export class Swiftly { args.push(branch); } const { stdout: availableStdout } = await execFile("swiftly", args); - const result = ListAvailableResult.parse(JSON.parse(availableStdout)); - return result.toolchains.filter((t): t is SwiftlyToolchain => - ["stable", "snapshot"].includes(t.version.type) - ); + return SwiftlyListAvailableResult.parse(JSON.parse(availableStdout)) + .toolchains.filter((t): t is AvailableToolchain => + ["system", "stable", "snapshot"].includes(t.version.type) + ) + .sort(compareSwiftlyToolchain); } catch (error) { logger?.error(`Failed to retrieve available Swiftly toolchains: ${error}`); return []; @@ -878,3 +878,36 @@ export function checkForSwiftlyInstallation(contextKeys: ContextKeys, logger: Sw }); }); } + +function compareSwiftlyToolchain(lhs: AvailableToolchain, rhs: AvailableToolchain): number { + return compareSwiftlyToolchainVersion(lhs.version, rhs.version); +} + +function compareSwiftlyToolchainVersion(lhs: ToolchainVersion, rhs: ToolchainVersion): number { + switch (lhs.type) { + case "system": { + if (rhs.type === "system") { + return lhs.name.localeCompare(rhs.name); + } + return -1; + } + case "stable": { + if (rhs.type === "stable") { + const lhsVersion = new Version(lhs.major, lhs.minor, lhs.patch); + const rhsVersion = new Version(rhs.major, rhs.minor, rhs.patch); + return rhsVersion.compare(lhsVersion); + } + if (rhs.type === "system") { + return 1; + } + return -1; + } + case "snapshot": + if (rhs.type === "snapshot") { + const lhsDate = new Date(lhs.date); + const rhsDate = new Date(rhs.date); + return rhsDate.getTime() - lhsDate.getTime(); + } + return 1; + } +} diff --git a/src/ui/ToolchainSelection.ts b/src/ui/ToolchainSelection.ts index 93cf89cf2..74846b78a 100644 --- a/src/ui/ToolchainSelection.ts +++ b/src/ui/ToolchainSelection.ts @@ -237,10 +237,8 @@ async function getQuickPickItems( }); // Find any Swift toolchains installed via Swiftly - const swiftlyToolchains = (await Swiftly.list(logger)) - // Sort in descending order alphabetically - .sort((a, b) => -a.localeCompare(b)) - .map(toolchainPath => ({ + const swiftlyToolchains = (await Swiftly.list(logger)).map( + toolchainPath => ({ type: "toolchain", label: path.basename(toolchainPath), category: "swiftly", @@ -267,7 +265,8 @@ async function getQuickPickItems( ); } }, - })); + }) + ); if (activeToolchain) { const currentSwiftlyVersion = activeToolchain.isSwiftlyManaged diff --git a/src/utilities/version.ts b/src/utilities/version.ts index 2209e92c4..c1ed2de6d 100644 --- a/src/utilities/version.ts +++ b/src/utilities/version.ts @@ -87,4 +87,8 @@ export class Version implements VersionInterface { isGreaterThanOrEqual(rhs: VersionInterface): boolean { return !this.isLessThan(rhs); } + + compare(rhs: VersionInterface): number { + return this.isGreaterThan(rhs) ? 1 : this.isLessThan(rhs) ? -1 : 0; + } } diff --git a/test/unit-tests/toolchain/swiftly.test.ts b/test/unit-tests/toolchain/swiftly.test.ts index 75b489eb1..cefca73d8 100644 --- a/test/unit-tests/toolchain/swiftly.test.ts +++ b/test/unit-tests/toolchain/swiftly.test.ts @@ -112,65 +112,102 @@ suite("Swiftly Unit Tests", () => { }); // Mock list command with JSON output - const jsonOutput = { - toolchains: [ - { - inUse: false, - isDefault: false, - version: { - name: "xcode", - type: "system", + mockUtilities.execFile.withArgs("swiftly", ["list", "--format=json"]).resolves({ + stdout: JSON.stringify({ + toolchains: [ + { + inUse: true, + isDefault: true, + version: { + major: 5, + minor: 9, + patch: 0, + name: "swift-5.9.0-RELEASE", + type: "stable", + }, }, - }, - { - inUse: true, - isDefault: true, - version: { - major: 5, - minor: 9, - patch: 0, - name: "swift-5.9.0-RELEASE", - type: "stable", + { + inUse: true, + isDefault: true, + version: { + major: 5, + minor: 10, + patch: 0, + name: "swift-5.10.0-RELEASE", + type: "stable", + }, }, - }, - { - inUse: false, - isDefault: false, - version: { - major: 5, - minor: 8, - patch: 0, - name: "swift-5.8.0-RELEASE", - type: "stable", + { + inUse: true, + isDefault: true, + version: { + major: 5, + minor: 10, + patch: 1, + name: "swift-5.10.1-RELEASE", + type: "stable", + }, }, - }, - { - inUse: false, - isDefault: false, - version: { - major: 5, - minor: 10, - branch: "development", - date: "2023-10-15", - name: "swift-DEVELOPMENT-SNAPSHOT-2023-10-15-a", - type: "snapshot", + { + inUse: false, + isDefault: false, + version: { + name: "xcode", + type: "system", + }, }, - }, - ], - }; - - mockUtilities.execFile.withArgs("swiftly", ["list", "--format=json"]).resolves({ - stdout: JSON.stringify(jsonOutput), + { + inUse: false, + isDefault: false, + version: { + major: 5, + minor: 10, + branch: "development", + date: "2021-10-15", + name: "swift-DEVELOPMENT-SNAPSHOT-2021-10-15-a", + type: "snapshot", + }, + }, + { + inUse: false, + isDefault: false, + version: { + major: 5, + minor: 10, + branch: "development", + date: "2023-10-15", + name: "swift-DEVELOPMENT-SNAPSHOT-2023-10-15-a", + type: "snapshot", + }, + }, + { + inUse: false, + isDefault: false, + version: { + major: 5, + minor: 8, + patch: 0, + name: "swift-5.8.0-RELEASE", + type: "stable", + }, + }, + ], + }), stderr: "", }); const result = await Swiftly.list(); + // Toolchains should be sorted newest to oldest with system toolchains appearing first, followed by + // stable toolchains, and finally snapshot toolchains. expect(result).to.deep.equal([ "xcode", + "swift-5.10.1-RELEASE", + "swift-5.10.0-RELEASE", "swift-5.9.0-RELEASE", "swift-5.8.0-RELEASE", "swift-DEVELOPMENT-SNAPSHOT-2023-10-15-a", + "swift-DEVELOPMENT-SNAPSHOT-2021-10-15-a", ]); expect(mockUtilities.execFile).to.have.been.calledWith("swiftly", ["--version"]); @@ -186,74 +223,71 @@ suite("Swiftly Unit Tests", () => { stdout: "1.1.0\n", stderr: "", }); - - // Mock list-available command with JSON output - const jsonOutput = { - toolchains: [ - { - inUse: false, - isDefault: false, - version: { - name: "xcode", - type: "system", + // Mock list command with JSON output + mockUtilities.execFile.withArgs("swiftly", ["list", "--format=json"]).resolves({ + stdout: JSON.stringify({ + toolchains: [ + { + inUse: false, + isDefault: false, + version: { + name: "xcode", + type: "system", + newProp: 1, // Try adding a new property. + }, newProp: 1, // Try adding a new property. }, - newProp: 1, // Try adding a new property. - }, - { - inUse: false, - isDefault: false, - version: { - // Try adding an unexpected version type. - type: "something_else", - }, - newProp: 1, // Try adding a new property. - }, - { - inUse: true, - isDefault: true, - version: { - major: 5, - minor: 9, - patch: 0, - name: "swift-5.9.0-RELEASE", - type: "stable", + { + inUse: false, + isDefault: false, + version: { + // Try adding an unexpected version type. + type: "something_else", + }, newProp: 1, // Try adding a new property. }, - newProp: 1, // Try adding a new property. - }, - { - inUse: false, - isDefault: false, - version: { - major: 5, - minor: 8, - patch: 0, - name: "swift-5.8.0-RELEASE", - type: "stable", + { + inUse: true, + isDefault: true, + version: { + major: 5, + minor: 9, + patch: 0, + name: "swift-5.9.0-RELEASE", + type: "stable", + newProp: 1, // Try adding a new property. + }, newProp: 1, // Try adding a new property. }, - newProp: "", // Try adding a new property. - }, - { - inUse: false, - isDefault: false, - version: { - major: 5, - minor: 10, - branch: "development", - date: "2023-10-15", - name: "swift-DEVELOPMENT-SNAPSHOT-2023-10-15-a", - type: "snapshot", + { + inUse: false, + isDefault: false, + version: { + major: 5, + minor: 8, + patch: 0, + name: "swift-5.8.0-RELEASE", + type: "stable", + newProp: 1, // Try adding a new property. + }, + newProp: "", // Try adding a new property. + }, + { + inUse: false, + isDefault: false, + version: { + major: 5, + minor: 10, + branch: "development", + date: "2023-10-15", + name: "swift-DEVELOPMENT-SNAPSHOT-2023-10-15-a", + type: "snapshot", + newProp: 1, // Try adding a new property. + }, newProp: 1, // Try adding a new property. }, - newProp: 1, // Try adding a new property. - }, - ], - }; - - mockUtilities.execFile.withArgs("swiftly", ["list", "--format=json"]).resolves({ - stdout: JSON.stringify(jsonOutput), + ], + }), stderr: "", }); @@ -290,7 +324,8 @@ suite("Swiftly Unit Tests", () => { const result = await Swiftly.list(); - expect(result).to.deep.equal(["swift-5.9.0", "swift-6.0.0"]); + // Toolchains should be sorted by name in descending order + expect(result).to.deep.equal(["swift-6.0.0", "swift-5.9.0"]); }); test("should return empty array when platform is not supported", async () => { @@ -520,156 +555,183 @@ suite("Swiftly Unit Tests", () => { test("should return available toolchains with installation status", async () => { mockedPlatform.setValue("darwin"); - mockUtilities.execFile.withArgs("swiftly", ["--version"]).resolves({ stdout: "1.1.0\n", stderr: "", }); - - const availableResponse = { - toolchains: [ - { - inUse: false, - installed: false, - isDefault: false, - version: { - type: "stable", - major: 6, - minor: 0, - patch: 0, - name: "6.0.0", - }, - }, - { - inUse: false, - installed: false, - isDefault: false, - version: { - type: "snapshot", - major: 6, - minor: 1, - branch: "main", - date: "2025-01-15", - name: "main-snapshot-2025-01-15", - }, - }, - ], - }; - mockUtilities.execFile .withArgs("swiftly", ["list-available", "--format=json"]) .resolves({ - stdout: JSON.stringify(availableResponse), + stdout: JSON.stringify({ + toolchains: [ + { + inUse: false, + installed: false, + isDefault: false, + version: { + type: "stable", + major: 6, + minor: 0, + patch: 0, + name: "6.0.0", + }, + }, + { + inUse: false, + installed: true, + isDefault: false, + version: { + type: "system", + name: "xcode", + }, + }, + { + inUse: false, + installed: false, + isDefault: false, + version: { + type: "stable", + major: 6, + minor: 0, + patch: 1, + name: "6.0.1", + }, + }, + { + inUse: false, + installed: false, + isDefault: false, + version: { + type: "snapshot", + major: 6, + minor: 1, + branch: "main", + date: "2025-01-15", + name: "main-snapshot-2025-01-15", + }, + }, + { + inUse: false, + installed: false, + isDefault: false, + version: { + type: "stable", + major: 5, + minor: 9, + patch: 0, + name: "5.9.0", + }, + }, + { + inUse: false, + installed: false, + isDefault: false, + version: { + type: "snapshot", + major: 5, + minor: 9, + branch: "main", + date: "2023-01-15", + name: "main-snapshot-2023-01-15", + }, + }, + { + inUse: false, + installed: false, + isDefault: false, + version: { + type: "stable", + major: 5, + minor: 10, + patch: 0, + name: "5.10.0", + }, + }, + { + inUse: false, + installed: false, + isDefault: false, + version: { + type: "stable", + major: 5, + minor: 10, + patch: 1, + name: "5.10.1", + }, + }, + ], + }), stderr: "", }); - const installedResponse = { - toolchains: [ - { - inUse: true, - isDefault: true, - version: { - type: "stable", - major: 6, - minor: 0, - patch: 0, - name: "6.0.0", - }, - }, - ], - }; - - mockUtilities.execFile.withArgs("swiftly", ["list", "--format=json"]).resolves({ - stdout: JSON.stringify(installedResponse), - stderr: "", - }); - const result = await Swiftly.listAvailable(); - expect(result).to.deep.equal([ - { - inUse: false, - installed: false, - isDefault: false, - version: { - type: "stable", - major: 6, - minor: 0, - patch: 0, - name: "6.0.0", - }, - }, - { - inUse: false, - installed: false, - isDefault: false, - version: { - type: "snapshot", - major: 6, - minor: 1, - branch: "main", - date: "2025-01-15", - name: "main-snapshot-2025-01-15", - }, - }, + + // Toolchains should be sorted newest to oldest with system toolchains appearing first, followed by + // stable toolchains, and finally snapshot toolchains. + expect(result.map(toolchain => toolchain.version.name)).to.deep.equal([ + "xcode", + "6.0.1", + "6.0.0", + "5.10.1", + "5.10.0", + "5.9.0", + "main-snapshot-2025-01-15", + "main-snapshot-2023-01-15", ]); }); test("should be able to parse future additions to the output and ignore unexpected types", async () => { mockedPlatform.setValue("darwin"); - mockUtilities.execFile.withArgs("swiftly", ["--version"]).resolves({ stdout: "1.1.0\n", stderr: "", }); - - const availableResponse = { - toolchains: [ - { - inUse: false, - installed: false, - isDefault: false, - version: { - // Try adding an unexpected version type. - type: "something_else", - }, - newProp: 1, // Try adding a new property. - }, - { - inUse: false, - installed: false, - isDefault: false, - version: { - type: "stable", - major: 6, - minor: 0, - patch: 0, - name: "6.0.0", - newProp: 1, // Try adding a new property. - }, - newProp: 1, // Try adding a new property. - }, - { - inUse: false, - installed: false, - isDefault: false, - version: { - type: "snapshot", - major: 6, - minor: 1, - branch: "main", - date: "2025-01-15", - name: "main-snapshot-2025-01-15", - newProp: 1, // Try adding a new property. - }, - newProp: 1, // Try adding a new property. - }, - ], - }; - mockUtilities.execFile .withArgs("swiftly", ["list-available", "--format=json"]) .resolves({ - stdout: JSON.stringify(availableResponse), + stdout: JSON.stringify({ + toolchains: [ + { + inUse: false, + installed: false, + isDefault: false, + version: { + // Try adding an unexpected version type. + type: "something_else", + }, + newProp: 1, // Try adding a new property. + }, + { + inUse: false, + installed: false, + isDefault: false, + version: { + type: "stable", + major: 6, + minor: 0, + patch: 0, + name: "6.0.0", + newProp: 1, // Try adding a new property. + }, + newProp: 1, // Try adding a new property. + }, + { + inUse: false, + installed: false, + isDefault: false, + version: { + type: "snapshot", + major: 6, + minor: 1, + branch: "main", + date: "2025-01-15", + name: "main-snapshot-2025-01-15", + newProp: 1, // Try adding a new property. + }, + newProp: 1, // Try adding a new property. + }, + ], + }), stderr: "", }); diff --git a/test/unit-tests/ui/ToolchainSelection.test.ts b/test/unit-tests/ui/ToolchainSelection.test.ts index 98d2dd65b..5c7ee7067 100644 --- a/test/unit-tests/ui/ToolchainSelection.test.ts +++ b/test/unit-tests/ui/ToolchainSelection.test.ts @@ -204,7 +204,7 @@ suite("ToolchainSelection Unit Test Suite", () => { }); test("shows toolchains installed via Swiftly", async () => { - mockedSwiftly.list.resolves(["6.0.0", "6.2.0", "5.9.3"]); + mockedSwiftly.list.resolves(["6.2.0", "6.0.0", "5.9.3"]); // Extract the Swiftly toolchain labels and simulate user cancellation let swiftlyToolchains: string[] = []; mockedVSCodeWindow.showQuickPick @@ -296,7 +296,7 @@ suite("ToolchainSelection Unit Test Suite", () => { }); test("shows toolchains installed via Swiftly", async () => { - mockedSwiftly.list.resolves(["6.0.0", "6.2.0", "5.9.3"]); + mockedSwiftly.list.resolves(["6.2.0", "6.0.0", "5.9.3"]); // Extract the Swiftly toolchain labels and simulate user cancellation let swiftlyToolchains: string[] = []; mockedVSCodeWindow.showQuickPick