Peter Bex avatar Peter Bex committed a86c716

Fix run/collecting* and add a testcase for it

Comments (0)

Files changed (2)

 ;; Documented under
 (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)))
-         (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)
           (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"
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.