guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

03/06: marionette: 'wait-for-file' really raises an error when a file is


From: Ludovic Courtès
Subject: 03/06: marionette: 'wait-for-file' really raises an error when a file is missing.
Date: Mon, 28 Aug 2017 04:19:07 -0400 (EDT)

civodul pushed a commit to branch master
in repository guix.

commit 8bd5231485cdeb02078c4294badb3a1e7caa0fe0
Author: Ludovic Courtès <address@hidden>
Date:   Sun Aug 27 20:58:33 2017 +0200

    marionette: 'wait-for-file' really raises an error when a file is missing.
    
    * gnu/build/marionette.scm (wait-for-file): Arrange to call 'error' on
    the host, not in the guest.
---
 gnu/build/marionette.scm | 24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/gnu/build/marionette.scm b/gnu/build/marionette.scm
index 424f2b6..789dab3 100644
--- a/gnu/build/marionette.scm
+++ b/gnu/build/marionette.scm
@@ -168,16 +168,20 @@ QEMU monitor and to the guest's backdoor REPL."
 (define* (wait-for-file file marionette #:key (timeout 10))
   "Wait until FILE exists in MARIONETTE; 'read' its content and return it.  If
 FILE has not shown up after TIMEOUT seconds, raise an error."
-  (marionette-eval
-   `(let loop ((i ,timeout))
-      (cond ((file-exists? ,file)
-             (call-with-input-file ,file read))
-            ((> i 0)
-             (sleep 1)
-             (loop (- i 1)))
-            (else
-             (error "file didn't show up" ,file))))
-   marionette))
+  (match (marionette-eval
+          `(let loop ((i ,timeout))
+             (cond ((file-exists? ,file)
+                    (cons 'success (call-with-input-file ,file read)))
+                   ((> i 0)
+                    (sleep 1)
+                    (loop (- i 1)))
+                   (else
+                    'failure)))
+          marionette)
+    (('success . result)
+     result)
+    ('failure
+     (error "file didn't show up" file))))
 
 (define (marionette-control command marionette)
   "Run COMMAND in the QEMU monitor of MARIONETTE.  COMMAND is a string such as



reply via email to

[Prev in Thread] Current Thread [Next in Thread]