From 850edd77f92c1f40a1593f3505ff82fdd8719bad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Tue, 14 Mar 2017 22:43:10 +0100 Subject: 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. --- tests/pack.scm | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 tests/pack.scm (limited to 'tests') diff --git a/tests/pack.scm b/tests/pack.scm new file mode 100644 index 0000000000..de9ef8e6ab --- /dev/null +++ b/tests/pack.scm @@ -0,0 +1,79 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2017 Ludovic Courtès +;;; +;;; This file is part of GNU Guix. +;;; +;;; GNU Guix is free software; you can redistribute it and/or modify it +;;; under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 3 of the License, or (at +;;; your option) any later version. +;;; +;;; GNU Guix is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with GNU Guix. If not, see . + +(define-module (test-pack) + #:use-module (guix scripts pack) + #:use-module (guix store) + #:use-module (guix derivations) + #:use-module (guix profiles) + #:use-module (guix monads) + #:use-module (guix grafts) + #:use-module (guix tests) + #:use-module (guix gexp) + #:use-module (gnu packages bootstrap) + #:use-module (srfi srfi-64)) + +(define %store + (open-connection-for-tests)) + +;; Globally disable grafts because they can trigger early builds. +(%graft? #f) + +(define-syntax-rule (test-assertm name exp) + (test-assert name + (run-with-store %store exp + #:guile-for-build (%guile-for-build)))) + +(define %gzip-compressor + ;; Compressor that uses the bootstrap 'gzip'. + ((@ (guix scripts pack) compressor) "gzip" + %bootstrap-coreutils&co "gz" '("gzip" "-6n"))) + +(define %tar-bootstrap %bootstrap-coreutils&co) + + +(test-begin "pack") + +(test-assertm "self-contained-tarball" + (mlet* %store-monad + ((profile (profile-derivation (packages->manifest + (list %bootstrap-guile)) + #:hooks '() + #:locales? #f)) + (tarball (self-contained-tarball "pack" profile + #:symlinks '(("/bin/Guile" + -> "bin/guile")) + #:compressor %gzip-compressor + #:tar %tar-bootstrap)) + (check (gexp->derivation + "check-tarball" + #~(let ((guile (string-append "." #$profile "/bin"))) + (setenv "PATH" + (string-append #$%tar-bootstrap "/bin")) + (system* "tar" "xvf" #$tarball) + (mkdir #$output) + (exit + (and (file-exists? (string-append guile "/guile")) + (string=? (string-append #$%bootstrap-guile "/bin") + (readlink guile)) + (string=? (string-append (string-drop guile 1) + "/guile") + (readlink "bin/Guile")))))))) + (built-derivations (list check)))) + +(test-end) -- cgit v1.2.3 From 81a0f1cdf12e7bcc34c1203f034a323fa8f52cf5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Wed, 15 Mar 2017 10:40:51 +0100 Subject: zlib: Don't rely on EBADF being ignored by 'fport_close'. In 2.2, 'fport_close' no longer swallows EBADF and instead raises a 'system-error' for this. This commit adjusts for 2.2. * guix/zlib.scm (close-procedure): Remove. (make-gzip-input-port): Use 'port->fdes' instead of 'fileno'. Use 'gzclose' instead of 'close-procedure'. (make-gzip-output-port): Likewise. * tests/zlib.scm ("compression/decompression pipe"): Don't check whether PARENT is closed using 'port-closed?'. Instead, use 'seek' on the underlying FD and check for EBADF. --- tests/zlib.scm | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/zlib.scm b/tests/zlib.scm index 5455240a71..f71609b7c5 100644 --- a/tests/zlib.scm +++ b/tests/zlib.scm @@ -57,7 +57,16 @@ (match (waitpid pid) ((_ . status) (and (zero? status) - (port-closed? parent) + + ;; PORT itself isn't closed but its underlying file + ;; descriptor must have been closed by 'gzclose'. + (catch 'system-error + (lambda () + (seek (fileno parent) 0 SEEK_CUR) + #f) + (lambda args + (= EBADF (system-error-errno args)))) + (bytevector=? received data)))))))))))) (test-end) -- cgit v1.2.3 From a9a0227c0127e1813190a7664f7ad858e791480d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Wed, 15 Mar 2017 13:54:29 +0100 Subject: store: Adjust UTF-8 test to Guile 2.2. * tests/store.scm ("current-build-output-port, UTF-8 + garbage"): On Guile 2.2, expect REPLACEMENT CHARACTER instead of '?'. --- tests/store.scm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/store.scm b/tests/store.scm index 64d3553f25..c0ebe7b941 100644 --- a/tests/store.scm +++ b/tests/store.scm @@ -383,7 +383,9 @@ (package-derivation %store %bootstrap-guile)))) (guard (c ((nix-protocol-error? c) #t)) (build-derivations %store (list d)))))))) - "garbage: ?lambda: λ")) + (cond-expand + (guile-2.0 "garbage: ?lambda: λ") + (else "garbage: �lambda: λ")))) (test-assert "log-file, derivation" (let* ((b (add-text-to-store %store "build" "echo $foo > $out" '())) -- cgit v1.2.3 From 13159c68ef912a77e5718232f6cf7a0deec4ecde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Wed, 15 Mar 2017 15:08:39 +0100 Subject: tests: Expect less accurate location info in 2.2.0. * tests/guix-system.sh: Work around inaccurate location info in 2.2.0. --- tests/guix-system.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/guix-system.sh b/tests/guix-system.sh index 77d4e28999..de6db0928c 100644 --- a/tests/guix-system.sh +++ b/tests/guix-system.sh @@ -76,7 +76,14 @@ EOF if guix system build "$tmpfile" -n 2> "$errorfile" then false else - grep "$tmpfile:9:.*[Uu]nbound variable.*GRUB-config" "$errorfile" + if test "`guile -c '(display (effective-version))'`" = 2.2 + then + # FIXME: With Guile 2.2.0 the error is reported on line 4. + # See . + grep "$tmpfile:[49]:.*[Uu]nbound variable.*GRUB-config" "$errorfile" + else + grep "$tmpfile:9:.*[Uu]nbound variable.*GRUB-config" "$errorfile" + fi fi OS_BASE=' -- cgit v1.2.3