1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2014, 2015, 2016 Ludovic Courtès <ludo@gnu.org>
4 ;;; This file is part of GNU Guix.
6 ;;; GNU Guix is free software; you can redistribute it and/or modify it
7 ;;; under the terms of the GNU General Public License as published by
8 ;;; the Free Software Foundation; either version 3 of the License, or (at
9 ;;; your option) any later version.
11 ;;; GNU Guix is distributed in the hope that it will be useful, but
12 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;;; GNU General Public License for more details.
16 ;;; You should have received a copy of the GNU General Public License
17 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
19 (define-module (test-grafts)
20 #:use-module (guix derivations)
21 #:use-module (guix store)
22 #:use-module (guix utils)
23 #:use-module (guix grafts)
24 #:use-module (guix tests)
25 #:use-module ((gnu packages) #:select (search-bootstrap-binary))
26 #:use-module (srfi srfi-64)
27 #:use-module (rnrs io ports))
30 (open-connection-for-tests))
32 (define (bootstrap-binary name)
33 (let ((bin (search-bootstrap-binary name (%current-system))))
35 (add-to-store %store name #t "sha256" bin))))
38 (bootstrap-binary "bash"))
40 (bootstrap-binary "mkdir"))
45 (test-assert "graft-derivation"
49 (symlink %output "self")
50 (call-with-output-file "text"
52 (format output "foo/~a/bar" ,%mkdir)))
53 (symlink ,%bash "sh")))
54 (orig (build-expression->derivation %store "graft" build
55 #:inputs `(("a" ,%bash)
57 (one (add-text-to-store %store "bash" "fake bash"))
58 (two (build-expression->derivation %store "mkdir"
59 '(call-with-output-file %output
61 (display "fake mkdir" port)))))
62 (graft (graft-derivation %store "graft" orig
68 (replacement two))))))
69 (and (build-derivations %store (list graft))
70 (let ((two (derivation->output-path two))
71 (graft (derivation->output-path graft)))
72 (and (string=? (format #f "foo/~a/bar" two)
73 (call-with-input-file (string-append graft "/text")
75 (string=? (readlink (string-append graft "/sh")) one)
76 (string=? (readlink (string-append graft "/self")) graft))))))
81 (exit (= (test-runner-fail-count (test-runner-current)) 0))