From aa71809da6e7db5aec39635bf631aa391bd3737d Mon Sep 17 00:00:00 2001 From: Dmitry Kovba Date: Tue, 24 Jun 2025 10:45:21 -0700 Subject: [PATCH] Remove `@unchecked Sendable` (#250) This PR removes `@unchecked Sendable` from the tests. --- .../Subcommands/Build/CLIRunBase.swift | 19 +++++++------------ .../Subcommands/Build/TestCLITermIO.swift | 3 +-- 2 files changed, 8 insertions(+), 14 deletions(-) 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" }