mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2026-04-05 02:40:08 +02:00
🐛 Fix issue with RealShell.attach output being omitted
This commit is contained in:
@@ -277,10 +277,10 @@ class RealShell: ShellProtocol {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !output.err.isEmpty {
|
if !output.err.isEmpty {
|
||||||
continuation.resume(returning: (process, .err(output.err)))
|
Log.perf("Received unexpected error output for attached command '\(command)'.")
|
||||||
} else {
|
|
||||||
continuation.resume(returning: (process, .out(output.out)))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
continuation.resume(returning: (process, output))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -83,16 +83,11 @@ struct RealShellTest {
|
|||||||
// from multiple readability handlers don't cause data races or crashes.
|
// from multiple readability handlers don't cause data races or crashes.
|
||||||
// Without the serial queue, rapid interleaved output causes undefined behavior.
|
// Without the serial queue, rapid interleaved output causes undefined behavior.
|
||||||
|
|
||||||
let script = """
|
let phpScript = "php -r 'for ($i = 1; $i <= 500; $i++) { fwrite(STDOUT, \"stdout-$i\" . PHP_EOL); fwrite(STDERR, \"stderr-$i\" . PHP_EOL); flush(); }'"
|
||||||
for i in {1..200}; do
|
|
||||||
echo "stdout-$i" >&1
|
|
||||||
echo "stderr-$i" >&2
|
|
||||||
done
|
|
||||||
"""
|
|
||||||
|
|
||||||
var receivedChunks = 0
|
var receivedChunks = 0
|
||||||
let (_, shellOutput) = try await container.shell.attach(
|
let (_, shellOutput) = try await container.shell.attach(
|
||||||
script,
|
phpScript,
|
||||||
didReceiveOutput: { _, _ in
|
didReceiveOutput: { _, _ in
|
||||||
receivedChunks += 1
|
receivedChunks += 1
|
||||||
},
|
},
|
||||||
@@ -107,8 +102,8 @@ struct RealShellTest {
|
|||||||
.components(separatedBy: "\n")
|
.components(separatedBy: "\n")
|
||||||
.filter { !$0.isEmpty }
|
.filter { !$0.isEmpty }
|
||||||
|
|
||||||
#expect(stdoutLines.count == 200)
|
#expect(stdoutLines.count == 500)
|
||||||
#expect(stderrLines.count == 200)
|
#expect(stderrLines.count == 500)
|
||||||
|
|
||||||
// Verify content integrity - each line should match the pattern
|
// Verify content integrity - each line should match the pattern
|
||||||
for i in 1...200 {
|
for i in 1...200 {
|
||||||
|
|||||||
Reference in New Issue
Block a user