Skip to content
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
1 change: 1 addition & 0 deletions Tests/SwiftlyTests/SwiftlyTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ public enum SwiftlyTests {
if cleanBinDir {
try await fs.remove(atPath: Swiftly.currentPlatform.swiftlyBinDir(Self.ctx))
}
throw error
}
}
}
Expand Down
29 changes: 21 additions & 8 deletions Tests/SwiftlyTests/UseTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,17 @@ import Testing
/// Execute a `use` command with the provided argument. Then validate that the configuration is updated properly and
/// the in-use swift executable prints the the provided expectedVersion.
func useAndValidate(argument: String, expectedVersion: ToolchainVersion) async throws {
try await SwiftlyTests.runCommand(Use.self, ["use", "-g", argument])
do {
try await SwiftlyTests.runCommand(Use.self, ["use", "-g", argument])
} catch {
// Swallow any errors. Some of these tests verify that switching to
// a non-existent toolchain does not change the version
// configuration.
// Swiftly should emit an error message, but we don't care.
}

#expect(try await Config.load().inUse == expectedVersion)
let useToolchain = try await Config.load().inUse
#expect(useToolchain == expectedVersion)
}

/// Tests that the `use` command can switch between installed stable release toolchains.
Expand Down Expand Up @@ -201,15 +209,20 @@ import Testing
/// Tests that the `use` command gracefully exits when executed before any toolchains have been installed.
@Test(.mockedSwiftlyVersion(), .mockHomeToolchains(toolchains: []))
func useNoInstalledToolchains() async throws {
try await SwiftlyTests.runCommand(Use.self, ["use", "-g", "latest"])
do {
try await SwiftlyTests.runCommand(Use.self, ["use", "-g", "latest"])

var config = try await Config.load()
#expect(config.inUse == nil)
var config = try await Config.load()
#expect(config.inUse == nil)

try await SwiftlyTests.runCommand(Use.self, ["use", "-g", "5.6.0"])
try await SwiftlyTests.runCommand(Use.self, ["use", "-g", "5.6.0"])

config = try await Config.load()
#expect(config.inUse == nil)
config = try await Config.load()
#expect(config.inUse == nil)
} catch {
// Swallow errors. This test is verifying that we don't change the
// in-use toolchain if no toolchains are installed
}
}

/// Tests that the `use` command gracefully handles being executed with toolchain names that haven't been installed.
Expand Down
Loading