From 4a7906059558689b584e1e99efcf460df12a25ea Mon Sep 17 00:00:00 2001 From: Kathryn Baldauf Date: Wed, 1 Jul 2026 16:03:03 -0700 Subject: [PATCH] Ensure test filenames match test suite names and each file has a single suite defined (#1877) This PR cleans up some of the new IntegrationTests files to ensure that each file has a single test suite defined within it and the name of the file matches the name of the test suite. Signed-off-by: Kathryn Baldauf --- ...CLICopy.swift => TestCLICopyCommand.swift} | 0 ...reate.swift => TestCLICreateCommand.swift} | 0 ...CLIExec.swift => TestCLIExecCommand.swift} | 0 .../Containers/TestCLIRemove.swift | 55 -------------- .../Containers/TestCLIRemoveSerial.swift | 73 +++++++++++++++++++ ...IStats.swift => TestCLIStatsCommand.swift} | 0 6 files changed, 73 insertions(+), 55 deletions(-) rename Tests/IntegrationTests/Containers/{TestCLICopy.swift => TestCLICopyCommand.swift} (100%) rename Tests/IntegrationTests/Containers/{TestCLICreate.swift => TestCLICreateCommand.swift} (100%) rename Tests/IntegrationTests/Containers/{TestCLIExec.swift => TestCLIExecCommand.swift} (100%) create mode 100644 Tests/IntegrationTests/Containers/TestCLIRemoveSerial.swift rename Tests/IntegrationTests/Containers/{TestCLIStats.swift => TestCLIStatsCommand.swift} (100%) diff --git a/Tests/IntegrationTests/Containers/TestCLICopy.swift b/Tests/IntegrationTests/Containers/TestCLICopyCommand.swift similarity index 100% rename from Tests/IntegrationTests/Containers/TestCLICopy.swift rename to Tests/IntegrationTests/Containers/TestCLICopyCommand.swift diff --git a/Tests/IntegrationTests/Containers/TestCLICreate.swift b/Tests/IntegrationTests/Containers/TestCLICreateCommand.swift similarity index 100% rename from Tests/IntegrationTests/Containers/TestCLICreate.swift rename to Tests/IntegrationTests/Containers/TestCLICreateCommand.swift diff --git a/Tests/IntegrationTests/Containers/TestCLIExec.swift b/Tests/IntegrationTests/Containers/TestCLIExecCommand.swift similarity index 100% rename from Tests/IntegrationTests/Containers/TestCLIExec.swift rename to Tests/IntegrationTests/Containers/TestCLIExecCommand.swift diff --git a/Tests/IntegrationTests/Containers/TestCLIRemove.swift b/Tests/IntegrationTests/Containers/TestCLIRemove.swift index 0ef6b8d9..9d8f6a8d 100644 --- a/Tests/IntegrationTests/Containers/TestCLIRemove.swift +++ b/Tests/IntegrationTests/Containers/TestCLIRemove.swift @@ -90,58 +90,3 @@ struct TestCLIRemove { } } } - -/// Serial removal tests that use `delete --all` and affect global container state. -@Suite(.serialized) -struct TestCLIRemoveSerial { - @Test func testDeleteAllStopped() async throws { - try await ContainerFixture.with { f in - let image = try f.copyWarmupImage(ContainerFixture.warmupImages[0]) - let name1 = "\(f.testID)-c1" - let name2 = "\(f.testID)-c2" - try f.doCreate(name: name1, image: image) - f.addCleanup { try f.doRemoveIfExists(name1, ignoreFailure: true) } - try f.doCreate(name: name2, image: image) - f.addCleanup { try f.doRemoveIfExists(name2, ignoreFailure: true) } - - try f.run(["delete", "--all"]).check() - - #expect(try f.run(["inspect", name1]).status != 0, "name1 should be deleted") - #expect(try f.run(["inspect", name2]).status != 0, "name2 should be deleted") - } - } - - @Test func testDeleteAllSkipsRunning() async throws { - try await ContainerFixture.with { f in - let image = try f.copyWarmupImage(ContainerFixture.warmupImages[0]) - let runningName = "\(f.testID)-running" - let stoppedName = "\(f.testID)-stopped" - - try f.doLongRun(name: runningName, image: image, autoRemove: false) - f.addCleanup { - try? f.doStop(runningName) - try? f.doRemove(runningName) - } - try f.doCreate(name: stoppedName, image: image) - f.addCleanup { try f.doRemoveIfExists(stoppedName, ignoreFailure: true) } - - try f.run(["delete", "--all"]).check() - - #expect(try f.getContainerStatus(runningName) == "running", "running container should survive delete --all") - #expect(try f.run(["inspect", stoppedName]).status != 0, "stopped container should be deleted") - } - } - - @Test func testDeleteAllForce() async throws { - try await ContainerFixture.with { f in - let image = try f.copyWarmupImage(ContainerFixture.warmupImages[0]) - let name = "\(f.testID)-c" - try f.doLongRun(name: name, image: image, autoRemove: false) - f.addCleanup { try f.doRemoveIfExists(name, force: true, ignoreFailure: true) } - - try f.run(["delete", "--all", "--force"]).check() - - #expect(try f.run(["inspect", name]).status != 0, "container should be deleted by --force") - } - } -} diff --git a/Tests/IntegrationTests/Containers/TestCLIRemoveSerial.swift b/Tests/IntegrationTests/Containers/TestCLIRemoveSerial.swift new file mode 100644 index 00000000..c3055328 --- /dev/null +++ b/Tests/IntegrationTests/Containers/TestCLIRemoveSerial.swift @@ -0,0 +1,73 @@ +//===----------------------------------------------------------------------===// +// 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 + +/// Serial removal tests that use `delete --all` and affect global container state. +@Suite(.serialized) +struct TestCLIRemoveSerial { + @Test func testDeleteAllStopped() async throws { + try await ContainerFixture.with { f in + let image = try f.copyWarmupImage(ContainerFixture.warmupImages[0]) + let name1 = "\(f.testID)-c1" + let name2 = "\(f.testID)-c2" + try f.doCreate(name: name1, image: image) + f.addCleanup { try f.doRemoveIfExists(name1, ignoreFailure: true) } + try f.doCreate(name: name2, image: image) + f.addCleanup { try f.doRemoveIfExists(name2, ignoreFailure: true) } + + try f.run(["delete", "--all"]).check() + + #expect(try f.run(["inspect", name1]).status != 0, "name1 should be deleted") + #expect(try f.run(["inspect", name2]).status != 0, "name2 should be deleted") + } + } + + @Test func testDeleteAllSkipsRunning() async throws { + try await ContainerFixture.with { f in + let image = try f.copyWarmupImage(ContainerFixture.warmupImages[0]) + let runningName = "\(f.testID)-running" + let stoppedName = "\(f.testID)-stopped" + + try f.doLongRun(name: runningName, image: image, autoRemove: false) + f.addCleanup { + try? f.doStop(runningName) + try? f.doRemove(runningName) + } + try f.doCreate(name: stoppedName, image: image) + f.addCleanup { try f.doRemoveIfExists(stoppedName, ignoreFailure: true) } + + try f.run(["delete", "--all"]).check() + + #expect(try f.getContainerStatus(runningName) == "running", "running container should survive delete --all") + #expect(try f.run(["inspect", stoppedName]).status != 0, "stopped container should be deleted") + } + } + + @Test func testDeleteAllForce() async throws { + try await ContainerFixture.with { f in + let image = try f.copyWarmupImage(ContainerFixture.warmupImages[0]) + let name = "\(f.testID)-c" + try f.doLongRun(name: name, image: image, autoRemove: false) + f.addCleanup { try f.doRemoveIfExists(name, force: true, ignoreFailure: true) } + + try f.run(["delete", "--all", "--force"]).check() + + #expect(try f.run(["inspect", name]).status != 0, "container should be deleted by --force") + } + } +} diff --git a/Tests/IntegrationTests/Containers/TestCLIStats.swift b/Tests/IntegrationTests/Containers/TestCLIStatsCommand.swift similarity index 100% rename from Tests/IntegrationTests/Containers/TestCLIStats.swift rename to Tests/IntegrationTests/Containers/TestCLIStatsCommand.swift