summary refs log tree commit diff
path: root/tests/derivations.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2012-06-16 16:46:29 +0200
committerLudovic Courtès <ludo@gnu.org>2012-06-16 16:46:29 +0200
commitdb393b333f77ffbb573faf47b6df74dc65a0e85b (patch)
treecf549558a8dfc042319d27fb8e7b8313ea28f736 /tests/derivations.scm
parent9f55cf8d56bc10ebe54902a98942dc895ccd837c (diff)
downloadguix-db393b333f77ffbb573faf47b6df74dc65a0e85b.tar.gz
build-expression->derivation: Have the build fail when EXP returns #f.
* guix/derivations.scm (build-expression->derivation)[builder]: Pass the
  result of EXP to `exit'.

* tests/derivations.scm ("build-expression->derivation with expression
  returning #f"): New test.
Diffstat (limited to 'tests/derivations.scm')
-rw-r--r--tests/derivations.scm16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/derivations.scm b/tests/derivations.scm
index 4a81a70f65..1e9a136d04 100644
--- a/tests/derivations.scm
+++ b/tests/derivations.scm
@@ -29,6 +29,7 @@
   #:use-module (rnrs io ports)
   #:use-module (rnrs bytevectors)
   #:use-module (ice-9 rdelim)
+  #:use-module (ice-9 regex)
   #:use-module (ice-9 ftw)
   #:use-module (ice-9 match))
 
@@ -181,6 +182,20 @@
            (equal? '(hello guix)
                    (call-with-input-file (string-append p "/test") read))))))
 
+(test-assert "build-expression->derivation with expression returning #f"
+  (let* ((builder  '(begin
+                      (mkdir %output)
+                      #f))                        ; fail!
+         (drv-path (build-expression->derivation %store "fail" (%current-system)
+                                                 builder '())))
+    (guard (c ((nix-protocol-error? c)
+               ;; Note that the output path may exist at this point, but it
+               ;; is invalid.
+               (not (not (string-match "build .* failed"
+                                       (nix-protocol-error-message c))))))
+      (build-derivations %store (list drv-path))
+      #f)))
+
 (test-assert "build-expression->derivation with two outputs"
   (let* ((builder    '(begin
                         (call-with-output-file (assoc-ref %outputs "out")
@@ -265,4 +280,5 @@
 
 ;;; Local Variables:
 ;;; eval: (put 'test-assert 'scheme-indent-function 1)
+;;; eval: (put 'guard 'scheme-indent-function 1)
 ;;; End: