summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2014-10-07 23:23:09 +0200
committerLudovic Courtès <ludo@gnu.org>2014-10-08 12:01:49 +0200
commitfb59e275dd84152cf04f89cd5192145ccf071853 (patch)
tree49b04f16b355fae967a8474922377cf66350edd5 /tests
parent3c762a13bf0a8e15f2cf67d6a9eb27cf6d55267d (diff)
downloadguix-fb59e275dd84152cf04f89cd5192145ccf071853.tar.gz
derivations: Add 'graft-derivation'.
* guix/derivations.scm (graft-derivation): New procedure.
* guix/build/graft.scm: New file.
* Makefile.am (MODULES): Add it.
* tests/derivations.scm ("graft-derivation"): New test.
Diffstat (limited to 'tests')
-rw-r--r--tests/derivations.scm29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/derivations.scm b/tests/derivations.scm
index 855b059d16..48d12990e6 100644
--- a/tests/derivations.scm
+++ b/tests/derivations.scm
@@ -813,6 +813,35 @@ Deriver: ~a~%"
                                      (string<? p1 p2)))))))))))))
 
 
+(test-assert "graft-derivation"
+  (let* ((build `(begin
+                   (mkdir %output)
+                   (chdir %output)
+                   (symlink %output "self")
+                   (call-with-output-file "text"
+                     (lambda (output)
+                       (format output "foo/~a/bar" ,%mkdir)))
+                   (symlink ,%bash "sh")))
+         (orig  (build-expression->derivation %store "graft" build
+                                              #:inputs `(("a" ,%bash)
+                                                         ("b" ,%mkdir))))
+         (one   (add-text-to-store %store "bash" "fake bash"))
+         (two   (build-expression->derivation %store "mkdir"
+                                              '(call-with-output-file %output
+                                                 (lambda (port)
+                                                   (display "fake mkdir" port)))))
+         (graft (graft-derivation %store "graft" orig
+                                  `(((,%bash) . (,one))
+                                    ((,%mkdir) . (,two))))))
+    (and (build-derivations %store (list graft))
+         (let ((two   (derivation->output-path two))
+               (graft (derivation->output-path graft)))
+           (and (string=? (format #f "foo/~a/bar" two)
+                          (call-with-input-file (string-append graft "/text")
+                            get-string-all))
+                (string=? (readlink (string-append graft "/sh")) one)
+                (string=? (readlink (string-append graft "/self")) graft))))))
+
 (test-equal "map-derivation"
   "hello"
   (let* ((joke (package-derivation %store guile-1.8))