diff options
| author | Ludovic Courtès <ludo@gnu.org> | 2017-03-14 22:43:10 +0100 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2017-03-14 23:18:32 +0100 |
| commit | 850edd77f92c1f40a1593f3505ff82fdd8719bad (patch) | |
| tree | 75381e7abef46571bf0e2ec766821da4addda24b /tests/pack.scm | |
| parent | 36f213fb704b96856d037df26e8e125aeb08edf2 (diff) | |
pack: Add unit test.
* guix/scripts/pack.scm (self-contained-tarball): Add #:tar option.
[build](tar-supports-sort?): New variable. Use it.
* tests/pack.scm: New file.
* Makefile.am (SCM_TESTS): Add it.
Diffstat (limited to 'tests/pack.scm')
| -rw-r--r-- | tests/pack.scm | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/tests/pack.scm b/tests/pack.scm new file mode 100644 index 00000000000..de9ef8e6ab3 --- /dev/null +++ b/tests/pack.scm | |||
| @@ -0,0 +1,79 @@ | |||
| 1 | ;;; GNU Guix --- Functional package management for GNU | ||
| 2 | ;;; Copyright © 2017 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-pack) | ||
| 20 | #:use-module (guix scripts pack) | ||
| 21 | #:use-module (guix store) | ||
| 22 | #:use-module (guix derivations) | ||
| 23 | #:use-module (guix profiles) | ||
| 24 | #:use-module (guix monads) | ||
| 25 | #:use-module (guix grafts) | ||
| 26 | #:use-module (guix tests) | ||
| 27 | #:use-module (guix gexp) | ||
| 28 | #:use-module (gnu packages bootstrap) | ||
| 29 | #:use-module (srfi srfi-64)) | ||
| 30 | |||
| 31 | (define %store | ||
| 32 | (open-connection-for-tests)) | ||
| 33 | |||
| 34 | ;; Globally disable grafts because they can trigger early builds. | ||
| 35 | (%graft? #f) | ||
| 36 | |||
| 37 | (define-syntax-rule (test-assertm name exp) | ||
| 38 | (test-assert name | ||
| 39 | (run-with-store %store exp | ||
| 40 | #:guile-for-build (%guile-for-build)))) | ||
| 41 | |||
| 42 | (define %gzip-compressor | ||
| 43 | ;; Compressor that uses the bootstrap 'gzip'. | ||
| 44 | ((@ (guix scripts pack) compressor) "gzip" | ||
| 45 | %bootstrap-coreutils&co "gz" '("gzip" "-6n"))) | ||
| 46 | |||
| 47 | (define %tar-bootstrap %bootstrap-coreutils&co) | ||
| 48 | |||
| 49 | |||
| 50 | (test-begin "pack") | ||
| 51 | |||
| 52 | (test-assertm "self-contained-tarball" | ||
| 53 | (mlet* %store-monad | ||
| 54 | ((profile (profile-derivation (packages->manifest | ||
| 55 | (list %bootstrap-guile)) | ||
| 56 | #:hooks '() | ||
| 57 | #:locales? #f)) | ||
| 58 | (tarball (self-contained-tarball "pack" profile | ||
| 59 | #:symlinks '(("/bin/Guile" | ||
| 60 | -> "bin/guile")) | ||
| 61 | #:compressor %gzip-compressor | ||
| 62 | #:tar %tar-bootstrap)) | ||
| 63 | (check (gexp->derivation | ||
| 64 | "check-tarball" | ||
| 65 | #~(let ((guile (string-append "." #$profile "/bin"))) | ||
| 66 | (setenv "PATH" | ||
| 67 | (string-append #$%tar-bootstrap "/bin")) | ||
| 68 | (system* "tar" "xvf" #$tarball) | ||
| 69 | (mkdir #$output) | ||
| 70 | (exit | ||
| 71 | (and (file-exists? (string-append guile "/guile")) | ||
| 72 | (string=? (string-append #$%bootstrap-guile "/bin") | ||
| 73 | (readlink guile)) | ||
| 74 | (string=? (string-append (string-drop guile 1) | ||
| 75 | "/guile") | ||
| 76 | (readlink "bin/Guile")))))))) | ||
| 77 | (built-derivations (list check)))) | ||
| 78 | |||
| 79 | (test-end) | ||
