Skip to content
Merged
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
21 changes: 9 additions & 12 deletions Tests/CLITests/Subcommands/System/TestCLIVersion.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,12 @@ final class TestCLIVersion: CLITest {
let server: VersionInfo?
}

private func expectedBuildType() throws -> String {
let path = try executablePath
if path.path.contains("/debug/") {
return "debug"
} else if path.path.contains("/release/") {
return "release"
}
// Fallback: prefer debug when ambiguous (matches SwiftPM default for tests)
private func expectedBuildType() -> String {
#if DEBUG
return "debug"
#else
return "release"
#endif
}

@Test func defaultDisplaysTable() throws {
Expand All @@ -60,7 +57,7 @@ final class TestCLIVersion: CLITest {
#expect(lines[1].hasPrefix("container"))

// Build should reflect the binary we are running (debug/release)
let expected = try expectedBuildType()
let expected = expectedBuildType()
#expect(lines.joined(separator: "\n").contains(" \(expected) "))
_ = data // silence unused warning if assertions short-circuit
}
Expand All @@ -75,7 +72,7 @@ final class TestCLIVersion: CLITest {
#expect(!decoded[0].version.isEmpty)
#expect(!decoded[0].commit.isEmpty)

let expected = try expectedBuildType()
let expected = expectedBuildType()
#expect(decoded[0].buildType == expected)
}

Expand All @@ -89,7 +86,7 @@ final class TestCLIVersion: CLITest {
#expect(!decoded[0].version.isEmpty)
#expect(!decoded[0].commit.isEmpty)

let expected = try expectedBuildType()
let expected = expectedBuildType()
#expect(decoded[0].buildType == expected)
}

Expand All @@ -110,7 +107,7 @@ final class TestCLIVersion: CLITest {
#expect(status == 0, "version --format json should succeed, stderr: \(err)")
let decoded = try JSONDecoder().decode([VersionOutput].self, from: data)

let expected = try expectedBuildType()
let expected = expectedBuildType()
#expect(decoded[0].buildType == expected, "Expected build type \(expected) but got \(decoded[0].buildType)")
}
}