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
5 changes: 5 additions & 0 deletions Sources/Swiftly/Run.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ struct Run: SwiftlyCommand {
throw CleanExit.helpRequest(self)
}

// Handle the spcific case where version is requested of the run subcommand
if command == ["--version"] {
throw CleanExit.message(String(describing: SwiftlyCore.version))
}

let (command, selector) = try Self.extractProxyArguments(command: self.command)

let toolchain: ToolchainVersion?
Expand Down
11 changes: 11 additions & 0 deletions Tests/SwiftlyTests/RunTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,15 @@ import Testing
#expect(error is CleanExit)
}
}

/// Tests the version functionality of the `run` command
@Test(.testHomeMockedToolchain()) func runVersion() async throws {
// Test --version is handled correctly
do {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: in future you can do this more cleanly with #expect(throws:) https://developer.apple.com/documentation/testing/expect(throws:_:sourcelocation:performing:)-1hfms

try await SwiftlyTests.runCommand(Run.self, ["run", "--version"])
#expect(false)
} catch {
#expect(error is CleanExit)
}
}
}