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
51 changes: 15 additions & 36 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -199,25 +199,26 @@ endef
# concurrent pass. WARMUP_FILTER, CONCURRENT_FILTER, and GLOBAL_FILTER select
# the three phases. Expand the filter lists as suites are migrated from CLITests.
PARALLEL_WIDTH ?= 2
WARMUP_FILTER = ImageWarmup

CONCURRENT_TEST_SUITES ?= \
TestCLIExportCommand/ \
TestCLIHelp \
TestCLIMachineCommand/ \
TestCLIRmRaceCondition/ \
TestCLIStatus \
TestCLIStop/ \
TestCLIVersion/
WARMUP_FILTER = ImageWarmup/

CONCURRENT_TEST_SUITES ?= $(sort $(addsuffix /,$(basename $(notdir \
$(shell find Tests/IntegrationTests -name 'TestCLI*.swift' \
! -name '*Serial.swift' 2>/dev/null)))))
CONCURRENT_FILTER = $(subst $(space),|,$(strip $(CONCURRENT_TEST_SUITES)))

GLOBAL_TEST_SUITES ?= \
TestCLIBuilderLifecycleSerial/ \
TestCLIBuilderSerial/ \
TestCLIBuilderEnvOnlySerial/ \
TestCLIBuilderLifecycleSerial/ \
TestCLIBuilderLocalOutputSerial/ \
TestCLIBuilderSerial/ \
TestCLIBuilderTarExportSerial/ \
TestCLIMachineRuntimeSerial/
TestCLIKernelSetSerial/ \
TestCLIMachineRuntimeSerial/ \
TestCLIPruneCommandSerial/ \
TestCLIRemoveSerial/ \
TestCLIRunLifecycleSerial/ \
TestCLISystemDFSerial/ \
TestCLIVolumesSerial/
GLOBAL_FILTER = $(subst $(space),|,$(strip $(GLOBAL_TEST_SUITES)))

INTEGRATION_SWIFT_EXTRA ?=
Expand Down Expand Up @@ -273,29 +274,7 @@ coverage-integration-new: all
@mkdir -p $(COVERAGE_OUTPUT_DIR)/integration
$(RUN_INTEGRATION)

INTEGRATION_TEST_SUITES ?= \
TestCLINetwork \
TestCLIRunLifecycle \
TestCLIRunCapabilities \
TestCLIExecCommand \
TestCLICreateCommand \
TestCLIRunCommand1 \
TestCLIRunCommand2 \
TestCLIRunCommand3 \
TestCLIPruneCommand \
TestCLIRegistry \
TestCLIStatsCommand \
TestCLIImagesCommand \
TestCLIRunBase \
TestCLIRunInitImage \
TestCLIBuildBase \
TestCLIVolumes \
TestCLIKernelSet \
TestCLIAnonymousVolumes \
TestCLINotFound \
TestCLISystemDF \
TestCLINoParallelCases \
TestCLICopyCommand
INTEGRATION_TEST_SUITES ?= NoTests/

empty :=
space := $(empty) $(empty)
Expand Down
70 changes: 0 additions & 70 deletions Tests/CLITests/Subcommands/Images/TestCLIProgressAuto.swift

This file was deleted.

48 changes: 0 additions & 48 deletions Tests/CLITests/Subcommands/Registry/TestCLIRegistry.swift

This file was deleted.

69 changes: 69 additions & 0 deletions Tests/IntegrationTests/Images/TestCLIProgressAuto.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
//===----------------------------------------------------------------------===//
// Copyright © 2026 Apple Inc. and the container project authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//===----------------------------------------------------------------------===//

import Testing

@Suite
struct TestCLIProgressAuto {
private let alpine = ContainerFixture.warmupImages[0]

@Test func testAutoProgressFallsBackToPlainWhenPiped() async throws {
try await ContainerFixture.with { f in
let result = try f.run(["image", "pull", "--progress", "auto", alpine])
#expect(result.status == 0, "image pull should succeed, stderr: \(result.error)")
let lines = result.error.components(separatedBy: .newlines)
.filter { !$0.contains("Warning! Running debug build") && !$0.isEmpty }
#expect(!lines.isEmpty, "expected plain progress output on stderr when piped")
#expect(!result.error.contains("\u{1B}["), "expected no ANSI escapes in piped output")
}
}

@Test func testExplicitPlainProgress() async throws {
try await ContainerFixture.with { f in
let result = try f.run(["image", "pull", "--progress", "plain", alpine])
#expect(
result.status == 0,
"image pull --progress plain should succeed, stderr: \(result.error)")
let lines = result.error.components(separatedBy: .newlines)
.filter { !$0.contains("Warning! Running debug build") && !$0.isEmpty }
#expect(!lines.isEmpty, "expected plain progress output on stderr")
#expect(!result.error.contains("\u{1B}["), "expected no ANSI escapes with --progress plain")
}
}

@Test func testExplicitAnsiProgress() async throws {
try await ContainerFixture.with { f in
let result = try f.run(["image", "pull", "--progress", "ansi", alpine])
// Verify the command succeeds; ANSI output is suppressed in non-TTY contexts
// so we don't assert on stderr content here.
#expect(
result.status == 0,
"image pull --progress ansi should succeed, stderr: \(result.error)")
}
}

@Test func testNoneProgressSuppressesOutput() async throws {
try await ContainerFixture.with { f in
let result = try f.run(["image", "pull", "--progress", "none", alpine])
#expect(
result.status == 0,
"image pull --progress none should succeed, stderr: \(result.error)")
let lines = result.error.components(separatedBy: .newlines)
.filter { !$0.contains("Warning! Running debug build") && !$0.isEmpty }
#expect(lines.isEmpty, "expected no progress output on stderr with --progress none")
}
}
}
55 changes: 55 additions & 0 deletions Tests/IntegrationTests/Registry/TestCLIRegistry.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
//===----------------------------------------------------------------------===//
// Copyright © 2026 Apple Inc. and the container project authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//===----------------------------------------------------------------------===//

import Foundation
import Testing

@Suite
struct TestCLIRegistry {
@Test func testListDefaultFormat() async throws {
try await ContainerFixture.with { f in
let result = try f.run(["registry", "list"])
#expect(result.status == 0, "registry list should succeed, stderr: \(result.error)")

let requiredHeaders = ["HOSTNAME", "USERNAME", "MODIFIED", "CREATED"]
#expect(
requiredHeaders.allSatisfy { result.output.contains($0) },
"output should contain all required headers"
)
}
}

@Test func testListJSONFormat() async throws {
try await ContainerFixture.with { f in
let result = try f.run(["registry", "list", "--format", "json"])
#expect(
result.status == 0,
"registry list --format json should succeed, stderr: \(result.error)")

let json = try JSONSerialization.jsonObject(with: result.outputData, options: [])
#expect(json is [Any], "JSON output should be an array")
}
}

@Test func testListQuietMode() async throws {
try await ContainerFixture.with { f in
let result = try f.run(["registry", "list", "-q"])
#expect(result.status == 0, "registry list -q should succeed, stderr: \(result.error)")
#expect(!result.output.contains("HOSTNAME"), "quiet mode should not contain headers")
#expect(!result.output.contains("USERNAME"), "quiet mode should not contain headers")
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//===----------------------------------------------------------------------===//
// Copyright © 2025-2026 Apple Inc. and the container project authors.
// Copyright © 2026 Apple Inc. and the container project authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -16,19 +16,22 @@

import Testing

@Suite
struct TestCLIPluginErrors {
@Test
func testHelpfulMessageWhenPluginsUnavailable() throws {
@Test func testHelpfulMessageWhenPluginsUnavailable() async throws {
// Intentionally invoke an unknown plugin command. In CI this should run
// without the APIServer started, so DefaultCommand will fail to create
// a PluginLoader and emit the improved guidance.
let cli = try CLITest()
let (_, _, stderr, status) = try cli.run(arguments: ["nosuchplugin"]) // non-existent plugin name

#expect(status != 0)
#expect(stderr.contains("container system start"))
#expect(stderr.contains("Plugins are unavailable") || stderr.contains("Plugin 'container-"))
// Should include at least one computed plugin search path hint
#expect(stderr.contains("container-plugins") || stderr.contains("container/plugins"))
try await ContainerFixture.with { f in
let result = try f.run(["nosuchplugin"])
#expect(result.status != 0)
#expect(result.error.contains("container system start"))
#expect(
result.error.contains("Plugins are unavailable")
|| result.error.contains("Plugin 'container-"))
#expect(
result.error.contains("container-plugins")
|| result.error.contains("container/plugins"))
}
}
}