summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2022-04-23 09:35:56 -0700
committerKaz Kylheku <kaz@kylheku.com>2022-04-23 09:35:56 -0700
commit7ab932856b7d1d32b61c548fd91b43e069a991c3 (patch)
treebac6b8f48a8467713a2680c911ee9be399280721
parentc7f4032e91289d1c44a49fc6a0ca1ec9c940fd32 (diff)
downloadtxr-7ab932856b7d1d32b61c548fd91b43e069a991c3.tar.gz
txr-7ab932856b7d1d32b61c548fd91b43e069a991c3.tar.bz2
txr-7ab932856b7d1d32b61c548fd91b43e069a991c3.zip
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.
-rw-r--r--tests/018/forkflush.expected12
-rw-r--r--tests/018/forkflush.tl31
2 files changed, 43 insertions, 0 deletions
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"))