Peter Bex  committed 104eaa0

Improve test for <<-redirection by making it less dependent on random factors that determine process interleaving, ensuring it gets processed through the pipeline rather than on the same descriptor by mangling it through 'tr'. Fix <<-redirection by reopening output port on new descriptor and explicitly setting up the input port to the given fd in the parent process

  • Participants
  • Parent commits 49ff15a

Comments (0)

Files changed (2)

File scsh-process.scm

      (duplicate-fileno (file-open (maybe->string `?file-name) open/rdonly)
     ((_ (<< ?fd ?object))
-     (fork/pipe (lambda () (display `?object))))
+     (fork/pipe+ `((1 ?fd)) (lambda () (display `?object (open-output-file* 1)))))
     ((_ (= ?fd-from ?fd/port-to))
      (let* ((fd/port-to ?fd/port-to)    ; Evaluate once
             (fd-to (if (port? fd/port-to)

File tests/run.scm

 (include "../scsh-process.scm")
 (import scsh-process)
-(use test posix)
+(use test posix srfi-13)
 (test-begin "scsh-process")
       (let ((message "testing, 1 2 3"))
         (test "Redirecting from object"
-              `("blah" "foo" ,message)
-              (run/strings (cat ,tmpfile -) (<< ,message))))
+              `("blah" "foo" ,(string-delete #\t message))
+              (run/strings (pipe (epf (tr -d t) (<< ,message))
+                                 (cat ,tmpfile -)))))
       (delete-file* tmpfile)))
   (test-group "Subprocesses"