summary refs log tree commit diff
path: root/tests/grafts.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2016-05-20 22:14:46 +0200
committerLudovic Courtès <ludo@gnu.org>2016-05-21 01:35:14 +0200
commitece6864bd04fc2f9ff86fd4ac9cb0712dd71c094 (patch)
tree53334de02ef208350cdb7d9d05306e729ed2633f /tests/grafts.scm
parentcf8b312d1872aec1f38a179eeb981d79bf7faa03 (diff)
downloadguix-ece6864bd04fc2f9ff86fd4ac9cb0712dd71c094.tar.gz
grafts: Rename files whose name matches a graft.
Fixes <http://bugs.gnu.org/23132>.
Reported by Mark H Weaver <mhw@netris.org>.

* guix/build/graft.scm (rename-matching-files): New procedure.
(rewrite-directory): Use it.
* tests/grafts.scm ("graft-derivation, renaming"): New test.
Diffstat (limited to 'tests/grafts.scm')
-rw-r--r--tests/grafts.scm17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/grafts.scm b/tests/grafts.scm
index f8c9eced1d..8cd048552c 100644
--- a/tests/grafts.scm
+++ b/tests/grafts.scm
@@ -182,4 +182,21 @@
            (and (string=? (readlink one) repl)
                 (string=? (readlink two) one))))))
 
+(test-assert "graft-derivation, renaming"         ;<http://bugs.gnu.org/23132>
+  (let* ((build `(begin
+                   (use-modules (guix build utils))
+                   (mkdir-p (string-append (assoc-ref %outputs "out") "/"
+                                           (assoc-ref %build-inputs "in")))))
+         (orig  (build-expression->derivation %store "thing-to-graft" build
+                                              #:modules '((guix build utils))
+                                              #:inputs `(("in" ,%bash))))
+         (repl  (add-text-to-store %store "bash" "fake bash"))
+         (grafted (graft-derivation %store orig
+                                    (list (graft
+                                            (origin %bash)
+                                            (replacement repl))))))
+    (and (build-derivations %store (list grafted))
+         (let ((out (derivation->output-path grafted)))
+           (file-is-directory? (string-append out "/" repl))))))
+
 (test-end)