diff options
| author | Ludovic Courtès <ludo@gnu.org> | 2016-02-22 16:29:44 +0100 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2016-02-22 22:11:37 +0100 |
| commit | 7adf9b8469f3f043e61d1c9614aea8abb63fb727 (patch) | |
| tree | 38e06768a990ef6954a0ae7e11c8aa3aec723aab /tests/grafts.scm | |
| parent | 3297deedd1fcfd98641b01b477fad182f70cad61 (diff) | |
derivations: Move grafts to (guix grafts).
* guix/derivations.scm (<graft>, graft-derivation, %graft?)
(set-grafting): Move to...
* guix/grafts.scm: ... here. New file.
* guix/gexp.scm, guix/packages.scm, tests/packages.scm,
guix/scripts/build.scm: Use it.
* Makefile.am (MODULES): Add it.
(SCM_TESTS): Add tests/grafts.scm.
* tests/derivations.scm ("graft-derivation"): Move to...
* tests/grafts.scm: ... here. New file.
Diffstat (limited to 'tests/grafts.scm')
| -rw-r--r-- | tests/grafts.scm | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/tests/grafts.scm b/tests/grafts.scm new file mode 100644 index 00000000000..c11403be19e --- /dev/null +++ b/tests/grafts.scm | |||
| @@ -0,0 +1,81 @@ | |||
| 1 | ;;; GNU Guix --- Functional package management for GNU | ||
| 2 | ;;; Copyright © 2014, 2015, 2016 Ludovic Courtès <ludo@gnu.org> | ||
| 3 | ;;; | ||
| 4 | ;;; This file is part of GNU Guix. | ||
| 5 | ;;; | ||
| 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. | ||
| 10 | ;;; | ||
| 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. | ||
| 15 | ;;; | ||
| 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/>. | ||
| 18 | |||
| 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)) | ||
| 28 | |||
| 29 | (define %store | ||
| 30 | (open-connection-for-tests)) | ||
| 31 | |||
| 32 | (define (bootstrap-binary name) | ||
| 33 | (let ((bin (search-bootstrap-binary name (%current-system)))) | ||
| 34 | (and %store | ||
| 35 | (add-to-store %store name #t "sha256" bin)))) | ||
| 36 | |||
| 37 | (define %bash | ||
| 38 | (bootstrap-binary "bash")) | ||
| 39 | (define %mkdir | ||
| 40 | (bootstrap-binary "mkdir")) | ||
| 41 | |||
| 42 | |||
| 43 | (test-begin "grafts") | ||
| 44 | |||
| 45 | (test-assert "graft-derivation" | ||
| 46 | (let* ((build `(begin | ||
| 47 | (mkdir %output) | ||
| 48 | (chdir %output) | ||
| 49 | (symlink %output "self") | ||
| 50 | (call-with-output-file "text" | ||
| 51 | (lambda (output) | ||
| 52 | (format output "foo/~a/bar" ,%mkdir))) | ||
| 53 | (symlink ,%bash "sh"))) | ||
| 54 | (orig (build-expression->derivation %store "graft" build | ||
| 55 | #:inputs `(("a" ,%bash) | ||
| 56 | ("b" ,%mkdir)))) | ||
| 57 | (one (add-text-to-store %store "bash" "fake bash")) | ||
| 58 | (two (build-expression->derivation %store "mkdir" | ||
| 59 | '(call-with-output-file %output | ||
| 60 | (lambda (port) | ||
| 61 | (display "fake mkdir" port))))) | ||
| 62 | (graft (graft-derivation %store "graft" orig | ||
| 63 | (list (graft | ||
| 64 | (origin %bash) | ||
| 65 | (replacement one)) | ||
| 66 | (graft | ||
| 67 | (origin %mkdir) | ||
| 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") | ||
| 74 | get-string-all)) | ||
| 75 | (string=? (readlink (string-append graft "/sh")) one) | ||
| 76 | (string=? (readlink (string-append graft "/self")) graft)))))) | ||
| 77 | |||
| 78 | (test-end) | ||
| 79 | |||
| 80 | |||
| 81 | (exit (= (test-runner-fail-count (test-runner-current)) 0)) | ||
