Skip to content
Open
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
8 changes: 7 additions & 1 deletion Sources/Swiftly/Install.swift
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,14 @@ struct Install: SwiftlyCommand {
let installInfo = InstallInfo(
version: version, alreadyInstalled: true
)
let pathChanged = if useInstalledToolchain {
try await Use.execute(ctx, version, globalDefault: false, verbose: verbose, &config)
} else {
false
}

try await ctx.output(installInfo)
return (nil, false)
return (nil, pathChanged)
}

// Ensure the system is set up correctly before downloading it. Problems that prevent installation
Expand Down
19 changes: 19 additions & 0 deletions Tests/SwiftlyTests/InstallTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,25 @@ import Testing
try await SwiftlyTests.validateInUse(expected: .newStable)
}

/// Verify that the pre-installed toolchain will be marked as in-use if the --use flag is specified.
@Test(.mockedSwiftlyVersion(), .testHomeMockedToolchain()) func installUseFlagOnAlreadyInstalledToolchain() async throws {
// GIVEN we install an old toolchain
try await SwiftlyTests.installMockedToolchain(toolchain: .oldStable)
// AND we use the toolchain
try await SwiftlyTests.runCommand(Use.self, ["use", ToolchainVersion.oldStable.name])
// THEN the old toolchain should be in use/selected
try await SwiftlyTests.validateInUse(expected: .oldStable)
// GIVEN a new toolchain is installled without `--use`
try await SwiftlyTests.installMockedToolchain(selector: ToolchainVersion.newStable.name)
// THEN the old toolchain is in use/selected
try await SwiftlyTests.validateInUse(expected: .oldStable)

// AND GIVEN we installing the new toolchain again with `-use`
try await SwiftlyTests.installMockedToolchain(selector: ToolchainVersion.newStable.name, args: ["--use"])
// THEN the new toolchain should be in use/selected
try await SwiftlyTests.validateInUse(expected: .newStable)
}

/// Verify that xcode can't be installed like regular toolchains
@Test(.testHomeMockedToolchain()) func installXcode() async throws {
try await #expect(throws: SwiftlyError.self) {
Expand Down