diff options
author | Peter Bex <peter@more-magic.net> | 2025-02-07 10:50:29 +0100 |
---|---|---|
committer | Peter Bex <peter@more-magic.net> | 2025-02-07 10:50:29 +0100 |
commit | 5d2659453493d7a1de7b80257763c72236c4008f (patch) | |
tree | 5e655749831d6ef9073002cddc2a94f6fc25bf42 /tests | |
parent | e520d20700e513d69c5c83a03b48d89f4194fe63 (diff) | |
download | scsh-process-5d2659453493d7a1de7b80257763c72236c4008f.tar.gz |
This allows us to reduce the code considerably because CHICKEN 6 now
has native process objects, so we don't need to keep our own version
of process tracking.
Note that we still need to keep our own list of child processes
created by "fork", because we want the automatic subprocess reaper to
be able to work in a thread. This means we still need to have a
central mapping of our own subprocesses to condition object so we can
signal the thread which is waiting.
After all I'm not so sure if this was such a great idea, but it's kind
of a neat feature that could be useful, so keep it for now.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/run.scm | 60 |
1 files changed, 25 insertions, 35 deletions
diff --git a/tests/run.scm b/tests/run.scm index b5fa419..85a6b11 100644 --- a/tests/run.scm +++ b/tests/run.scm @@ -1,27 +1,18 @@ +;;(include "../scsh-process.scm") (module scsh-tests () -(import scheme) - -(cond-expand - (chicken-5 (import (chicken base) (chicken port) (chicken condition) - (chicken io) (chicken file) (chicken file posix) - (chicken process signal) - (chicken fixnum) ;; Why is this needed?! - srfi-18 test) - #;(include "../scsh-process.scm") - (import scsh-process) - - (define (read-all #!optional file-or-port) - (cond ((string? file-or-port) - (with-input-from-file file-or-port read-string)) - (file-or-port (read-string #f file-or-port)) - (else (read-string)))) - ) - (else (import chicken) - #;(include "../scsh-process.scm") - (use scsh-process) - (use test utils extras ports files posix - srfi-13 srfi-18 (only setup-api version>=?)))) +(import (scheme base) (scheme write) (scheme read) + (chicken base) (chicken port) (chicken condition) + (chicken io) (chicken file) (chicken file posix) + (chicken process signal) + srfi-18 test) +(import scsh-process) + +(define (read-all #!optional file-or-port) + (cond ((string? file-or-port) + (with-input-from-file file-or-port read-string)) + (file-or-port (read-string #f file-or-port)) + (else (read-string)))) (test-begin "scsh-process") @@ -149,19 +140,16 @@ (test "run/string with begin form" "hi, there\n" (run/string (pipe (begin (print "hi, there")) (cat)))) - (when (cond-expand - (chicken-5 #t) - (else (version>=? (chicken-version) "4.8.1"))) - (let ((child? #f)) - (thread-start! (lambda () - (thread-sleep! 0.5) - (when child? (print "haihai")))) - (test "Simple 'begin' form with threading" - "hi, there\n" - (run/string (pipe (begin (set! child? #t) - (thread-sleep! 1) - (print "hi, there")) - (cat)))))) + (let ((child? #f)) + (thread-start! (lambda () + (thread-sleep! 0.5) + (when child? (print "haihai")))) + (test "Simple 'begin' form with threading" + "hi, there\n" + (run/string (pipe (begin (set! child? #t) + (thread-sleep! 1) + (print "hi, there")) + (cat))))) (let ((the-outfile "outfile")) (test "Subprocess writing to a file" @@ -245,6 +233,8 @@ (|| (false) (epf (sh -c "echo hi && false") (- 1)))))) (test-group "finalization" + ;; Ensure the automatic reaping thread has a chance to run + (thread-yield!) ;; TODO: Find a way to test that the input port didn't get replaced by ;; one from a subshell. This happened before, but not sure how ;; to detect this except running it manually from the REPL. |