Skip to content

Commit d3a5118

Browse files
committed
Migrates registry, image progress, plugin tests.
- Part of #1833.
1 parent 3842977 commit d3a5118

6 files changed

Lines changed: 169 additions & 159 deletions

File tree

Makefile

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -199,25 +199,48 @@ endef
199199
# concurrent pass. WARMUP_FILTER, CONCURRENT_FILTER, and GLOBAL_FILTER select
200200
# the three phases. Expand the filter lists as suites are migrated from CLITests.
201201
PARALLEL_WIDTH ?= 2
202-
WARMUP_FILTER = ImageWarmup
202+
WARMUP_FILTER = ImageWarmup/
203203

204204
CONCURRENT_TEST_SUITES ?= \
205+
TestCLIAnonymousVolumes/ \
206+
TestCLICopyCommand/ \
207+
TestCLICreateCommand/ \
208+
TestCLIExecCommand/ \
205209
TestCLIExportCommand/ \
206-
TestCLIHelp \
210+
TestCLIHelp/ \
211+
TestCLIImagesCommand/ \
207212
TestCLIMachineCommand/ \
213+
TestCLINetwork/ \
214+
TestCLINotFound/ \
215+
TestCLIPluginErrors/ \
216+
TestCLIProgressAuto/ \
217+
TestCLIRegistry/ \
218+
TestCLIRemove/ \
208219
TestCLIRmRaceCondition/ \
209-
TestCLIStatus \
220+
TestCLIRunCapabilities/ \
221+
TestCLIRunCommand/ \
222+
TestCLIRunInitImage/ \
223+
TestCLIRunLifecycle/ \
224+
TestCLIStatsCommand/ \
225+
TestCLIStatus/ \
210226
TestCLIStop/ \
211-
TestCLIVersion/
227+
TestCLIVersion/ \
228+
TestCLIVolumes/
212229
CONCURRENT_FILTER = $(subst $(space),|,$(strip $(CONCURRENT_TEST_SUITES)))
213230

214231
GLOBAL_TEST_SUITES ?= \
215-
TestCLIBuilderLifecycleSerial/ \
216-
TestCLIBuilderSerial/ \
217232
TestCLIBuilderEnvOnlySerial/ \
233+
TestCLIBuilderLifecycleSerial/ \
218234
TestCLIBuilderLocalOutputSerial/ \
235+
TestCLIBuilderSerial/ \
219236
TestCLIBuilderTarExportSerial/ \
220-
TestCLIMachineRuntimeSerial/
237+
TestCLIKernelSetSerial/ \
238+
TestCLIMachineRuntimeSerial/ \
239+
TestCLIPruneCommandSerial/ \
240+
TestCLIRemoveSerial/ \
241+
TestCLIRunLifecycleSerial/ \
242+
TestCLISystemDFSerial/ \
243+
TestCLIVolumesSerial/
221244
GLOBAL_FILTER = $(subst $(space),|,$(strip $(GLOBAL_TEST_SUITES)))
222245

223246
INTEGRATION_SWIFT_EXTRA ?=
@@ -273,29 +296,7 @@ coverage-integration-new: all
273296
@mkdir -p $(COVERAGE_OUTPUT_DIR)/integration
274297
$(RUN_INTEGRATION)
275298

276-
INTEGRATION_TEST_SUITES ?= \
277-
TestCLINetwork \
278-
TestCLIRunLifecycle \
279-
TestCLIRunCapabilities \
280-
TestCLIExecCommand \
281-
TestCLICreateCommand \
282-
TestCLIRunCommand1 \
283-
TestCLIRunCommand2 \
284-
TestCLIRunCommand3 \
285-
TestCLIPruneCommand \
286-
TestCLIRegistry \
287-
TestCLIStatsCommand \
288-
TestCLIImagesCommand \
289-
TestCLIRunBase \
290-
TestCLIRunInitImage \
291-
TestCLIBuildBase \
292-
TestCLIVolumes \
293-
TestCLIKernelSet \
294-
TestCLIAnonymousVolumes \
295-
TestCLINotFound \
296-
TestCLISystemDF \
297-
TestCLINoParallelCases \
298-
TestCLICopyCommand
299+
INTEGRATION_TEST_SUITES ?=
299300

300301
empty :=
301302
space := $(empty) $(empty)

Tests/CLITests/Subcommands/Images/TestCLIProgressAuto.swift

Lines changed: 0 additions & 70 deletions
This file was deleted.

Tests/CLITests/Subcommands/Registry/TestCLIRegistry.swift

Lines changed: 0 additions & 48 deletions
This file was deleted.
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
//===----------------------------------------------------------------------===//
2+
// Copyright © 2026 Apple Inc. and the container project authors.
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// https://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
//===----------------------------------------------------------------------===//
16+
17+
import Testing
18+
19+
@Suite
20+
struct TestCLIProgressAuto {
21+
private let alpine = ContainerFixture.warmupImages[0]
22+
23+
@Test func testAutoProgressFallsBackToPlainWhenPiped() async throws {
24+
try await ContainerFixture.with { f in
25+
let result = try f.run(["image", "pull", "--progress", "auto", alpine])
26+
#expect(result.status == 0, "image pull should succeed, stderr: \(result.error)")
27+
let lines = result.error.components(separatedBy: .newlines)
28+
.filter { !$0.contains("Warning! Running debug build") && !$0.isEmpty }
29+
#expect(!lines.isEmpty, "expected plain progress output on stderr when piped")
30+
#expect(!result.error.contains("\u{1B}["), "expected no ANSI escapes in piped output")
31+
}
32+
}
33+
34+
@Test func testExplicitPlainProgress() async throws {
35+
try await ContainerFixture.with { f in
36+
let result = try f.run(["image", "pull", "--progress", "plain", alpine])
37+
#expect(
38+
result.status == 0,
39+
"image pull --progress plain should succeed, stderr: \(result.error)")
40+
let lines = result.error.components(separatedBy: .newlines)
41+
.filter { !$0.contains("Warning! Running debug build") && !$0.isEmpty }
42+
#expect(!lines.isEmpty, "expected plain progress output on stderr")
43+
#expect(!result.error.contains("\u{1B}["), "expected no ANSI escapes with --progress plain")
44+
}
45+
}
46+
47+
@Test func testExplicitAnsiProgress() async throws {
48+
try await ContainerFixture.with { f in
49+
let result = try f.run(["image", "pull", "--progress", "ansi", alpine])
50+
// Verify the command succeeds; ANSI output is suppressed in non-TTY contexts
51+
// so we don't assert on stderr content here.
52+
#expect(
53+
result.status == 0,
54+
"image pull --progress ansi should succeed, stderr: \(result.error)")
55+
}
56+
}
57+
58+
@Test func testNoneProgressSuppressesOutput() async throws {
59+
try await ContainerFixture.with { f in
60+
let result = try f.run(["image", "pull", "--progress", "none", alpine])
61+
#expect(
62+
result.status == 0,
63+
"image pull --progress none should succeed, stderr: \(result.error)")
64+
let lines = result.error.components(separatedBy: .newlines)
65+
.filter { !$0.contains("Warning! Running debug build") && !$0.isEmpty }
66+
#expect(lines.isEmpty, "expected no progress output on stderr with --progress none")
67+
}
68+
}
69+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
//===----------------------------------------------------------------------===//
2+
// Copyright © 2026 Apple Inc. and the container project authors.
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// https://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
//===----------------------------------------------------------------------===//
16+
17+
import Foundation
18+
import Testing
19+
20+
@Suite
21+
struct TestCLIRegistry {
22+
@Test func testListDefaultFormat() async throws {
23+
try await ContainerFixture.with { f in
24+
let result = try f.run(["registry", "list"])
25+
#expect(result.status == 0, "registry list should succeed, stderr: \(result.error)")
26+
27+
let requiredHeaders = ["HOSTNAME", "USERNAME", "MODIFIED", "CREATED"]
28+
#expect(
29+
requiredHeaders.allSatisfy { result.output.contains($0) },
30+
"output should contain all required headers"
31+
)
32+
}
33+
}
34+
35+
@Test func testListJSONFormat() async throws {
36+
try await ContainerFixture.with { f in
37+
let result = try f.run(["registry", "list", "--format", "json"])
38+
#expect(
39+
result.status == 0,
40+
"registry list --format json should succeed, stderr: \(result.error)")
41+
42+
let json = try JSONSerialization.jsonObject(with: result.outputData, options: [])
43+
#expect(json is [Any], "JSON output should be an array")
44+
}
45+
}
46+
47+
@Test func testListQuietMode() async throws {
48+
try await ContainerFixture.with { f in
49+
let result = try f.run(["registry", "list", "-q"])
50+
#expect(result.status == 0, "registry list -q should succeed, stderr: \(result.error)")
51+
#expect(!result.output.contains("HOSTNAME"), "quiet mode should not contain headers")
52+
#expect(!result.output.contains("USERNAME"), "quiet mode should not contain headers")
53+
}
54+
}
55+
}

Tests/CLITests/Subcommands/Plugins/TestCLIPluginErrors.swift renamed to Tests/IntegrationTests/System/TestCLIPluginErrors.swift

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//===----------------------------------------------------------------------===//
2-
// Copyright © 2025-2026 Apple Inc. and the container project authors.
2+
// Copyright © 2026 Apple Inc. and the container project authors.
33
//
44
// Licensed under the Apache License, Version 2.0 (the "License");
55
// you may not use this file except in compliance with the License.
@@ -16,19 +16,22 @@
1616

1717
import Testing
1818

19+
@Suite
1920
struct TestCLIPluginErrors {
20-
@Test
21-
func testHelpfulMessageWhenPluginsUnavailable() throws {
21+
@Test func testHelpfulMessageWhenPluginsUnavailable() async throws {
2222
// Intentionally invoke an unknown plugin command. In CI this should run
2323
// without the APIServer started, so DefaultCommand will fail to create
2424
// a PluginLoader and emit the improved guidance.
25-
let cli = try CLITest()
26-
let (_, _, stderr, status) = try cli.run(arguments: ["nosuchplugin"]) // non-existent plugin name
27-
28-
#expect(status != 0)
29-
#expect(stderr.contains("container system start"))
30-
#expect(stderr.contains("Plugins are unavailable") || stderr.contains("Plugin 'container-"))
31-
// Should include at least one computed plugin search path hint
32-
#expect(stderr.contains("container-plugins") || stderr.contains("container/plugins"))
25+
try await ContainerFixture.with { f in
26+
let result = try f.run(["nosuchplugin"])
27+
#expect(result.status != 0)
28+
#expect(result.error.contains("container system start"))
29+
#expect(
30+
result.error.contains("Plugins are unavailable")
31+
|| result.error.contains("Plugin 'container-"))
32+
#expect(
33+
result.error.contains("container-plugins")
34+
|| result.error.contains("container/plugins"))
35+
}
3336
}
3437
}

0 commit comments

Comments
 (0)