guix-commits
[Top][All Lists]
Advanced

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

01/02: hydra: 'evaluate' now validates job alists.


From: Ludovic Courtès
Subject: 01/02: hydra: 'evaluate' now validates job alists.
Date: Tue, 21 Jun 2016 13:59:27 +0000 (UTC)

civodul pushed a commit to branch master
in repository guix.

commit 4c9243b688b4df2310b7fba65ef53e2f52f76bce
Author: Ludovic Courtès <address@hidden>
Date:   Tue Jun 21 15:50:51 2016 +0200

    hydra: 'evaluate' now validates job alists.
    
    * build-aux/hydra/evaluate.scm (assert-valid-job): New procedure.
    <top level>: Use it.
---
 build-aux/hydra/evaluate.scm |   15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/build-aux/hydra/evaluate.scm b/build-aux/hydra/evaluate.scm
index afc7730..ab10253 100644
--- a/build-aux/hydra/evaluate.scm
+++ b/build-aux/hydra/evaluate.scm
@@ -49,6 +49,17 @@ values."
                  (/ (time-nanosecond time) 1e9)))
       (apply values results))))
 
+(define (assert-valid-job job thing)
+  "Raise an error if THING is not an alist with a valid 'derivation' entry.
+Otherwise return THING."
+  (unless (and (list? thing)
+               (and=> (assoc-ref thing 'derivation)
+                      (lambda (value)
+                        (and (string? value)
+                             (string-suffix? ".drv" value)))))
+    (error "job did not produce a valid alist" job thing))
+  thing)
+
 
 ;; Without further ado...
 (match (command-line)
@@ -83,7 +94,9 @@ values."
            (map (lambda (job thunk)
                   (format (current-error-port) "evaluating '~a'... " job)
                   (force-output (current-error-port))
-                  (cons job (call-with-time-display thunk)))
+                  (cons job
+                        (assert-valid-job job
+                                          (call-with-time-display thunk))))
                 names thunks)))
         port))))
   ((command _ ...)



reply via email to

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