From 0e9399d0993c046c1f666f22d25bdf57ef113602 Mon Sep 17 00:00:00 2001 From: ChengHao Yang <17496418+tico88612@users.noreply.github.com> Date: Sat, 14 Mar 2026 23:15:30 +0800 Subject: [PATCH 1/2] Add the TestCLIVersion in intergration test Signed-off-by: ChengHao Yang <17496418+tico88612@users.noreply.github.com> --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 547b18fc7..704dbf977 100644 --- a/Makefile +++ b/Makefile @@ -188,6 +188,7 @@ integration: init-block { \ exit_code=0; \ CLITEST_LOG_ROOT=$(LOG_ROOT) && export CLITEST_LOG_ROOT ; \ + $(SWIFT) test -c $(BUILD_CONFIGURATION) $(SWIFT_CONFIGURATION) --filter TestCLIVersion || exit_code=1 ; \ $(SWIFT) test -c $(BUILD_CONFIGURATION) $(SWIFT_CONFIGURATION) --filter TestCLINetwork || exit_code=1 ; \ $(SWIFT) test -c $(BUILD_CONFIGURATION) $(SWIFT_CONFIGURATION) --filter TestCLIRunLifecycle || exit_code=1 ; \ $(SWIFT) test -c $(BUILD_CONFIGURATION) $(SWIFT_CONFIGURATION) --filter TestCLIExecCommand || exit_code=1 ; \ From cb82b1c4b8b3f9f0954a1bb57a4835d937161100 Mon Sep 17 00:00:00 2001 From: ChengHao Yang <17496418+tico88612@users.noreply.github.com> Date: Sat, 14 Mar 2026 23:15:57 +0800 Subject: [PATCH 2/2] Fixed the TestCLIVersion failing test Signed-off-by: ChengHao Yang <17496418+tico88612@users.noreply.github.com> --- .../Subcommands/System/TestCLIVersion.swift | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/Tests/CLITests/Subcommands/System/TestCLIVersion.swift b/Tests/CLITests/Subcommands/System/TestCLIVersion.swift index e9592a9be..f3985f0e6 100644 --- a/Tests/CLITests/Subcommands/System/TestCLIVersion.swift +++ b/Tests/CLITests/Subcommands/System/TestCLIVersion.swift @@ -55,11 +55,10 @@ final class TestCLIVersion: CLITest { .components(separatedBy: .newlines) #expect(lines.count >= 2) // header + at least CLI row #expect(lines[0].contains("COMPONENT") && lines[0].contains("VERSION") && lines[0].contains("BUILD") && lines[0].contains("COMMIT")) - #expect(lines[1].hasPrefix("CLI ")) + #expect(lines[1].hasPrefix("container")) // Build should reflect the binary we are running (debug/release) let expected = try expectedBuildType() - #expect(lines.joined(separator: "\n").contains(" CLI ")) #expect(lines.joined(separator: "\n").contains(" \(expected) ")) _ = data // silence unused warning if assertions short-circuit } @@ -69,13 +68,13 @@ final class TestCLIVersion: CLITest { #expect(status == 0, "system version --format json should succeed, stderr: \(err)") #expect(!out.isEmpty) - let decoded = try JSONDecoder().decode(VersionJSON.self, from: data) - #expect(decoded.appName == "container CLI") - #expect(!decoded.version.isEmpty) - #expect(!decoded.commit.isEmpty) + let decoded = try JSONDecoder().decode([VersionJSON].self, from: data) + #expect(decoded[0].appName == "container") + #expect(!decoded[0].version.isEmpty) + #expect(!decoded[0].commit.isEmpty) let expected = try expectedBuildType() - #expect(decoded.buildType == expected) + #expect(decoded[0].buildType == expected) } @Test func explicitTableFormat() throws { @@ -87,16 +86,15 @@ final class TestCLIVersion: CLITest { .components(separatedBy: .newlines) #expect(lines.count >= 2) #expect(lines[0].contains("COMPONENT") && lines[0].contains("VERSION") && lines[0].contains("BUILD") && lines[0].contains("COMMIT")) - #expect(lines[1].hasPrefix("CLI ")) } @Test func buildTypeMatchesBinary() throws { // Validate build type via JSON to avoid parsing table text loosely let (data, _, err, status) = try run(arguments: ["system", "version", "--format", "json"]) #expect(status == 0, "version --format json should succeed, stderr: \(err)") - let decoded = try JSONDecoder().decode(VersionJSON.self, from: data) + let decoded = try JSONDecoder().decode([VersionJSON].self, from: data) let expected = try expectedBuildType() - #expect(decoded.buildType == expected, "Expected build type \(expected) but got \(decoded.buildType)") + #expect(decoded[0].buildType == expected, "Expected build type \(expected) but got \(decoded[0].buildType)") } }