diff --git a/Tests/CLITests/Subcommands/Build/CLIRunBase.swift b/Tests/CLITests/Subcommands/Build/CLIRunBase.swift index c8abb1fd..82ea0132 100644 --- a/Tests/CLITests/Subcommands/Build/CLIRunBase.swift +++ b/Tests/CLITests/Subcommands/Build/CLIRunBase.swift @@ -20,8 +20,7 @@ import ContainerizationOS import Foundation import Testing -// This test class is not thread safe -class TestCLIRunBase: CLITest, @unchecked Sendable { +class TestCLIRunBase: CLITest { var terminal: Terminal! var containerName: String = UUID().uuidString @@ -62,7 +61,12 @@ class TestCLIRunBase: CLITest, @unchecked Sendable { func containerRun(stdin: [String], findMessage: String) async throws -> Bool { let stdout = FileHandle(fileDescriptor: terminal.handle.fileDescriptor, closeOnDealloc: false) let stdoutListenTask = Task { - try await findStdoutOutput(stdout: stdout, findMessage: findMessage) + for try await line in stdout.bytes.lines { + if line.contains(findMessage) && !line.contains("echo") { + return true + } + } + return false } let timeoutTask = Task { @@ -82,15 +86,6 @@ class TestCLIRunBase: CLITest, @unchecked Sendable { } } - func findStdoutOutput(stdout: FileHandle, findMessage: String) async throws -> Bool { - for try await line in stdout.bytes.lines { - if line.contains(findMessage) && !line.contains("echo") { - return true - } - } - return false - } - func exec(commands: [String]) throws { let stdin = FileHandle(fileDescriptor: terminal.handle.fileDescriptor, closeOnDealloc: false) try commands.forEach { cmd in diff --git a/Tests/CLITests/Subcommands/Build/TestCLITermIO.swift b/Tests/CLITests/Subcommands/Build/TestCLITermIO.swift index 26bc68d0..35519f67 100644 --- a/Tests/CLITests/Subcommands/Build/TestCLITermIO.swift +++ b/Tests/CLITests/Subcommands/Build/TestCLITermIO.swift @@ -21,8 +21,7 @@ import Foundation import Testing extension TestCLIRunBase { - // This test class is NOT thread safe - class TestCLITermIO: TestCLIRunBase, @unchecked Sendable { + class TestCLITermIO: TestCLIRunBase { override var ContainerImage: String { "ghcr.io/linuxcontainers/alpine:3.20" }