From 7ab932856b7d1d32b61c548fd91b43e069a991c3 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sat, 23 Apr 2022 09:35:56 -0700 Subject: fork/streams: new failing test. This test case exemplifies code that will work as expected when *stdout* is a TTY device, such that line buffering is in effect, but then break when standard output is redirected to a file. The issue is that the controlling process is not flushing its standard output when calling the external script, so the script's output gets placed ahead of the process' own earlier output. * tests/018/forkflush.tl: New file. * tests/018/forkflush.expected: New file. --- tests/018/forkflush.expected | 12 ++++++++++++ tests/018/forkflush.tl | 31 +++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 tests/018/forkflush.expected create mode 100644 tests/018/forkflush.tl diff --git a/tests/018/forkflush.expected b/tests/018/forkflush.expected new file mode 100644 index 00000000..475f87b1 --- /dev/null +++ b/tests/018/forkflush.expected @@ -0,0 +1,12 @@ +A +B +C +D +E +F +G +H +I +J +K +L diff --git a/tests/018/forkflush.tl b/tests/018/forkflush.tl new file mode 100644 index 00000000..078fe2b9 --- /dev/null +++ b/tests/018/forkflush.tl @@ -0,0 +1,31 @@ +(load "../common") + +(push-after-load (remove-path "tmpfile")) + +(with-stream (*stdout* (open-file "tmpfile" "w")) + (put-line "A") + (sh "echo B") + (put-line "C") + (sh "echo D")) + +(put-string (file-get-string "tmpfile")) + +(with-stream (*stdout* (open-file "tmpfile" "w")) + (put-line "E") + (with-stream (s (open-process "cat" "w")) + (put-line "F" s)) + (put-line "G") + (with-stream (s (open-process "cat" "w")) + (put-line "H" s))) + +(put-string (file-get-string "tmpfile")) + +(with-stream (*stdout* (open-file "tmpfile" "w")) + (put-line "I") + (with-stream (s (open-command "cat" "w")) + (put-line "J" s)) + (put-line "K") + (with-stream (s (open-command "cat" "w")) + (put-line "L" s))) + +(put-string (file-get-string "tmpfile")) -- cgit v1.2.3