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
19 changes: 7 additions & 12 deletions Tests/CLITests/Subcommands/Build/CLIRunBase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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 {
Expand All @@ -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
Expand Down
3 changes: 1 addition & 2 deletions Tests/CLITests/Subcommands/Build/TestCLITermIO.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down