summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/inferior.scm39
1 files changed, 38 insertions, 1 deletions
diff --git a/tests/inferior.scm b/tests/inferior.scm
index 56b2fcb7bce..963d405e33f 100644
--- a/tests/inferior.scm
+++ b/tests/inferior.scm
@@ -30,7 +30,8 @@
30 #:use-module (srfi srfi-1) 30 #:use-module (srfi srfi-1)
31 #:use-module (srfi srfi-34) 31 #:use-module (srfi srfi-34)
32 #:use-module (srfi srfi-64) 32 #:use-module (srfi srfi-64)
33 #:use-module (ice-9 match)) 33 #:use-module (ice-9 match)
34 #:use-module (ice-9 rdelim))
34 35
35(define %top-srcdir 36(define %top-srcdir
36 (dirname (search-path %load-path "guix.scm"))) 37 (dirname (search-path %load-path "guix.scm")))
@@ -315,4 +316,40 @@
315 (close-inferior inferior) 316 (close-inferior inferior)
316 (map manifest-entry->list (manifest-entries manifest)))) 317 (map manifest-entry->list (manifest-entries manifest))))
317 318
319(test-equal "#:error-port stderr"
320 42
321 ;; There's a special case in open-bidirectional-pipe for
322 ;; (current-error-port) being stderr, so this test just checks that
323 ;; open-inferior doesn't raise an exception
324 (let ((inferior (open-inferior %top-builddir
325 #:command "scripts/guix"
326 #:error-port (current-error-port))))
327 (and (inferior? inferior)
328 (inferior-eval '(display "test" (current-error-port)) inferior)
329 (let ((result (inferior-eval '(apply * '(6 7)) inferior)))
330 (close-inferior inferior)
331 result))))
332
333(test-equal "#:error-port pipe"
334 "42"
335 (match (pipe)
336 ((port-to-read-from . port-to-write-to)
337
338 (setvbuf port-to-read-from 'line)
339 (setvbuf port-to-write-to 'line)
340
341 (let ((inferior (open-inferior %top-builddir
342 #:command "scripts/guix"
343 #:error-port port-to-write-to)))
344 (and (inferior? inferior)
345 (begin
346 (inferior-eval '(display "42\n" (current-error-port)) inferior)
347
348 (let loop ((line (read-line port-to-read-from)))
349 (if (string=? line "42")
350 (begin
351 (close-inferior inferior)
352 line)
353 (loop (read-line port-to-read-from))))))))))
354
318(test-end "inferior") 355(test-end "inferior")