aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/derivations.scm27
-rw-r--r--tests/grafts.scm41
-rw-r--r--tests/guix-graph.sh18
3 files changed, 85 insertions, 1 deletions
diff --git a/tests/derivations.scm b/tests/derivations.scm
index cb7196e2a9..d8553b223e 100644
--- a/tests/derivations.scm
+++ b/tests/derivations.scm
@@ -367,6 +367,33 @@
(and (eq? 'one (call-with-input-file one read))
(eq? 'two (call-with-input-file two read)))))))
+(test-assert "read-derivation vs. derivation"
+ ;; Make sure 'derivation' and 'read-derivation' return objects that are
+ ;; identical.
+ (let* ((sources (unfold (cut >= <> 10)
+ (lambda (n)
+ (add-text-to-store %store
+ (format #f "input~a" n)
+ (random-text)))
+ 1+
+ 0))
+ (inputs (map (lambda (file)
+ (derivation %store "derivation-input"
+ %bash '()
+ #:inputs `((,%bash) (,file))))
+ sources))
+ (builder (add-text-to-store %store "builder.sh"
+ "echo one > $one ; echo two > $two"
+ '()))
+ (drv (derivation %store "derivation"
+ %bash `(,builder)
+ #:inputs `((,%bash) (,builder)
+ ,@(map list (append sources inputs)))
+ #:outputs '("two" "one")))
+ (drv* (call-with-input-file (derivation-file-name drv)
+ read-derivation)))
+ (equal? drv* drv)))
+
(test-assert "multiple-output derivation, derivation-path->output-path"
(let* ((builder (add-text-to-store %store "builder.sh"
"echo one > $out ; echo two > $second"
diff --git a/tests/grafts.scm b/tests/grafts.scm
index afed704cde..8cd048552c 100644
--- a/tests/grafts.scm
+++ b/tests/grafts.scm
@@ -127,6 +127,30 @@
(list one two dep)
(references %store dep)))))))
+(test-assert "graft-derivation, preserve empty directories"
+ (run-with-store %store
+ (mlet* %store-monad ((fake (text-file "bash" "Fake bash."))
+ (graft -> (graft
+ (origin %bash)
+ (replacement fake)))
+ (drv (gexp->derivation
+ "to-graft"
+ #~(begin
+ (use-modules (guix build utils))
+ (mkdir-p (string-append #$output
+ "/a/b/c/d"))
+ (symlink #$%bash
+ (string-append #$output
+ "/bash")))
+ #:modules '((guix build utils))))
+ (grafted ((store-lift graft-derivation) drv
+ (list graft)))
+ (_ (built-derivations (list grafted)))
+ (out -> (derivation->output-path grafted)))
+ (return (and (string=? (readlink (string-append out "/bash"))
+ fake)
+ (file-is-directory? (string-append out "/a/b/c/d")))))))
+
(test-assert "graft-derivation, no dependencies on grafted output"
(run-with-store %store
(mlet* %store-monad ((fake (text-file "bash" "Fake bash."))
@@ -158,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)
diff --git a/tests/guix-graph.sh b/tests/guix-graph.sh
index 4d5a755bc1..1ec99706fd 100644
--- a/tests/guix-graph.sh
+++ b/tests/guix-graph.sh
@@ -1,5 +1,5 @@
# GNU Guix --- Functional package management for GNU
-# Copyright © 2015 Ludovic Courtès <ludo@gnu.org>
+# Copyright © 2015, 2016 Ludovic Courtès <ludo@gnu.org>
#
# This file is part of GNU Guix.
#
@@ -20,6 +20,10 @@
# Test the 'guix graph' command-line utility.
#
+tmpfile1="t-guix-graph1-$$"
+tmpfile2="t-guix-graph2-$$"
+trap 'rm -f "$tmpfile1" "$tmpfile2"' EXIT
+
guix graph --version
for package in guile-bootstrap coreutils python
@@ -37,3 +41,15 @@ guix graph -e '(@ (gnu packages bootstrap) %bootstrap-guile)' \
| grep guile-bootstrap
if guix graph -e +; then false; else true; fi
+
+# Try passing store file names.
+
+guix graph -t references guile-bootstrap > "$tmpfile1"
+guix graph -t references `guix build guile-bootstrap` > "$tmpfile2"
+cmp "$tmpfile1" "$tmpfile2"
+
+# XXX: Filter the file names in the graph to work around the fact that we get
+# a mixture of relative and absolute file names.
+guix graph -t derivation coreutils > "$tmpfile1"
+guix graph -t derivation `guix build -d coreutils` > "$tmpfile2"
+cmp "$tmpfile1" "$tmpfile2"