From 9a35110240c54dc33aaef2e3f04453b595c10901 Mon Sep 17 00:00:00 2001 From: Matt Birkholz Date: Sun, 30 Jul 2017 16:08:33 -0700 Subject: [PATCH] tests/runtime/test-syncproc: Enabled, with 3 more basic tests. --- tests/check.scm | 1 + tests/runtime/test-syncproc.scm | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/tests/check.scm b/tests/check.scm index 5e07df496..28032723b 100644 --- a/tests/check.scm +++ b/tests/check.scm @@ -72,6 +72,7 @@ USA. "runtime/test-string" "runtime/test-string-normalization" "runtime/test-string-search" + "runtime/test-syncproc" "runtime/test-thread-queue" "runtime/test-url" ("runtime/test-wttree" (runtime wt-tree)) diff --git a/tests/runtime/test-syncproc.scm b/tests/runtime/test-syncproc.scm index 4180a6e57..f525d6b41 100644 --- a/tests/runtime/test-syncproc.scm +++ b/tests/runtime/test-syncproc.scm @@ -52,3 +52,31 @@ USA. ;; case Scheme fails the test. (shell "pid=$$; (sleep 2; kill -CONT $pid) & sleep 1; kill -STOP $pid")) (list condition-type:subprocess-stopped)))) + +(define-test 'SUBPROCESS-INPUT + (lambda () + (let ((sample "Lorem ipsum dolor sit amet, consectetur adipiscing elit")) + (call-with-input-string sample + (lambda (in) + (run-shell-command "cat" 'input in 'output #f) + (assert-true (eof-object? (read-char in)))))))) + +(define-test 'SUBPROCESS-OUTPUT + (lambda () + (let* ((reply (call-with-output-string + (lambda (out) + (run-shell-command + "if read; then echo \"Lose\"; else echo \"Win\"; fi" + 'input #f 'output out))))) + (assert-string= reply "Win\n")))) + +(define-test 'SUBPROCESS-IO + (lambda () + (let* ((sample "Lorem ipsum dolor sit amet, consectetur adipiscing elit") + (copy + (call-with-input-string sample + (lambda (in) + (call-with-output-string + (lambda (out) + (run-shell-command "cat" 'input in 'output out))))))) + (assert-string= copy sample)))) \ No newline at end of file -- 2.25.1