Skip to content

Commit 24ca7e8

Browse files
committed
Fix test runner output capture and Linux build error
- test-examples.pl: add pump() calls around SIGINT in keep-alive tests so IPC::Run drains the stdout pipe; without pumping $out stays empty causing ApplicationEnd and ContextAware to fail in interpreter mode - RunCommand.swift: guard setvbuf(stdout) with #if canImport(Darwin) to fix Swift 6 strict concurrency error on Linux where stdout is a mutable C global rather than a macro; FileHandle.standardOutput.write() bypasses C stdio buffering on Linux anyway
1 parent d53903c commit 24ca7e8

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

Sources/AROCLI/Commands/RunCommand.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,12 @@ struct RunCommand: AsyncParsableCommand {
100100
// Force unbuffered stdout so every print() reaches the pipe immediately.
101101
// Without this, Swift fully-buffers stdout when piped (e.g. during tests),
102102
// causing observer/event output to be lost until the process exits.
103+
// On Linux, stdout is a mutable C global (not a macro) which Swift 6's concurrency
104+
// checker flags as unsafe. FileHandle.standardOutput.write() bypasses C stdio
105+
// buffering on Linux anyway, so we only need setvbuf on Darwin.
106+
#if canImport(Darwin)
103107
setvbuf(stdout, nil, _IONBF, 0)
108+
#endif
104109

105110
var mutableSelf = self
106111
mutableSelf.extractRunCommandFlags()

test-examples.pl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -857,10 +857,14 @@ sub run_console_example_internal {
857857
if ($keep_alive) {
858858
# Wait for the application to start, then send SIGINT for graceful shutdown
859859
sleep 1;
860+
# Drain stdout/stderr pipe before sending SIGINT
861+
eval { pump $handle while $handle->pumpable && length($out) == 0 };
860862
say " Sending SIGINT for graceful shutdown" if $options{verbose};
861863
eval { $handle->signal('INT'); };
862864
# Allow time for Application-End handler to execute and flush output
863865
sleep 1;
866+
# Drain remaining output after SIGINT
867+
eval { pump $handle while $handle->pumpable };
864868
}
865869

866870
eval {
@@ -938,10 +942,14 @@ sub run_debug_example {
938942
if ($keep_alive) {
939943
# Wait for the application to start, then send SIGINT for graceful shutdown
940944
sleep 1;
945+
# Drain stdout/stderr pipe before sending SIGINT
946+
eval { pump $handle while $handle->pumpable && length($out) == 0 };
941947
say " Sending SIGINT for graceful shutdown" if $options{verbose};
942948
eval { $handle->signal('INT'); };
943949
# Allow time for Application-End handler to execute and flush output
944950
sleep 1;
951+
# Drain remaining output after SIGINT
952+
eval { pump $handle while $handle->pumpable };
945953
}
946954

947955
eval {

0 commit comments

Comments
 (0)