diff options
| author | Peter Bex <peter@more-magic.net> | 2012-10-02 00:41:27 +0100 | 
|---|---|---|
| committer | Peter Bex <peter@more-magic.net> | 2012-10-02 00:41:27 +0100 | 
| commit | 0dd1e60a9cb3df9a275be60d558dccb2a4cc5061 (patch) | |
| tree | 457c717c3baf9c592dab53dc42b0a36727287edb | |
| parent | aa8b8adf9492108580194a49fd98888a6dbc1909 (diff) | |
| download | scsh-process-0dd1e60a9cb3df9a275be60d558dccb2a4cc5061.tar.gz | |
Fix run/collecting* and add a testcase for it
| -rw-r--r-- | scsh-process.scm | 12 | ||||
| -rw-r--r-- | tests/run.scm | 8 | 
2 files changed, 14 insertions, 6 deletions
| diff --git a/scsh-process.scm b/scsh-process.scm index 2700640..7350edb 100644 --- a/scsh-process.scm +++ b/scsh-process.scm @@ -117,12 +117,14 @@  ;; Documented under http://www.scsh.net/docu/html/man-Z-H-3.html#node_sec_2.4.2  (define (run/collecting* fds thunk) -  (let* ((temp-files (map (lambda () (open-input-file (create-temporary-file))) +  (let* ((temp-files (map (lambda (fd) (open-input-file (create-temporary-file)))                            fds)) -         (conns (map (lambda (temp-fd from-fd) -                       (list from-fd (open-input-file* temp-fd))) -                     temp-files fds))) -    (apply values (fork/pipe+ conns thunk) temp-files))) +         (conns (map (lambda (from-fd temp-file) +                       (list from-fd (port->fileno temp-file))) +                     fds temp-files))) +    (receive (p s code) +      (process-wait (fork/pipe+ conns thunk)) +      (apply values code temp-files))))  (define (run/port* thunk)    (receive (in out) diff --git a/tests/run.scm b/tests/run.scm index fbb1019..3526ec0 100644 --- a/tests/run.scm +++ b/tests/run.scm @@ -69,7 +69,13 @@            "foo\n"            (run/string (pipe+ ((1 0))                               (pipe+ ((2 0)) (sh -c "echo foo >&2") (cat)) -                             (cat))))) +                             (cat)))) + +    (test "Collecting FDs" +          (list 0 "foo\n" "bar\n") +          (receive (status port1 port2) +            (run/collecting (2 1) (sh -c "echo foo >&2; echo bar")) +            (list status (read-all port1) (read-all port2)))))    (test-group "Conditional process sequencing forms"      (test "&& runs for all true values" | 
