hydra: 'evaluate' now validates job alists.
authorLudovic Courtès <ludo@gnu.org>
Tue, 21 Jun 2016 13:50:51 +0000 (15:50 +0200)
committerLudovic Courtès <ludo@gnu.org>
Tue, 21 Jun 2016 13:59:06 +0000 (15:59 +0200)
* build-aux/hydra/evaluate.scm (assert-valid-job): New procedure.
<top level>: Use it.

build-aux/hydra/evaluate.scm

index afc7730..ab10253 100644 (file)
@@ -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)
+
 \f
 ;; 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 _ ...)