Skip to content

Commit 4c22305

Browse files
authored
Fix TestCLIVersion build-type check for release CI (apple#1627)
Fix TestCLIVersion build-type check for release CI (apple#1627) - Refer to apple#1626
1 parent e20aca8 commit 4c22305

1 file changed

Lines changed: 9 additions & 12 deletions

File tree

Tests/CLITests/Subcommands/System/TestCLIVersion.swift

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,12 @@ final class TestCLIVersion: CLITest {
3636
let server: VersionInfo?
3737
}
3838

39-
private func expectedBuildType() throws -> String {
40-
let path = try executablePath
41-
if path.path.contains("/debug/") {
42-
return "debug"
43-
} else if path.path.contains("/release/") {
44-
return "release"
45-
}
46-
// Fallback: prefer debug when ambiguous (matches SwiftPM default for tests)
39+
private func expectedBuildType() -> String {
40+
#if DEBUG
4741
return "debug"
42+
#else
43+
return "release"
44+
#endif
4845
}
4946

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

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

78-
let expected = try expectedBuildType()
75+
let expected = expectedBuildType()
7976
#expect(decoded[0].buildType == expected)
8077
}
8178

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

92-
let expected = try expectedBuildType()
89+
let expected = expectedBuildType()
9390
#expect(decoded[0].buildType == expected)
9491
}
9592

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

113-
let expected = try expectedBuildType()
110+
let expected = expectedBuildType()
114111
#expect(decoded[0].buildType == expected, "Expected build type \(expected) but got \(decoded[0].buildType)")
115112
}
116113
}

0 commit comments

Comments
 (0)