summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorEfraim Flashner <efraim@flashner.co.il>2023-01-30 11:33:18 +0200
committerEfraim Flashner <efraim@flashner.co.il>2023-01-30 12:39:40 +0200
commit4cf1acc7f3033b50b0bf19e02c9f522d522d338c (patch)
tree9fd64956ee60304c15387eb394cd649e49f01467 /tests
parentedb8c09addd186d9538d43b12af74d6c7aeea082 (diff)
parent595b53b74e3ef57a1c0c96108ba86d38a170a241 (diff)
Merge remote-tracking branch 'origin/master' into core-updates
Conflicts: doc/guix.texi gnu/local.mk gnu/packages/admin.scm gnu/packages/base.scm gnu/packages/chromium.scm gnu/packages/compression.scm gnu/packages/databases.scm gnu/packages/diffoscope.scm gnu/packages/freedesktop.scm gnu/packages/gnome.scm gnu/packages/gnupg.scm gnu/packages/guile.scm gnu/packages/inkscape.scm gnu/packages/llvm.scm gnu/packages/openldap.scm gnu/packages/pciutils.scm gnu/packages/ruby.scm gnu/packages/samba.scm gnu/packages/sqlite.scm gnu/packages/statistics.scm gnu/packages/syndication.scm gnu/packages/tex.scm gnu/packages/tls.scm gnu/packages/version-control.scm gnu/packages/xml.scm guix/build-system/copy.scm guix/scripts/home.scm
Diffstat (limited to 'tests')
-rw-r--r--tests/builders.scm1
-rw-r--r--tests/channels.scm1
-rw-r--r--tests/cpan.scm2
-rw-r--r--tests/cpio.scm12
-rw-r--r--tests/derivations.scm53
-rw-r--r--tests/gexp.scm5
-rw-r--r--tests/git.scm32
-rw-r--r--tests/gnu-maintenance.scm9
-rw-r--r--tests/grafts.scm5
-rw-r--r--tests/graph.scm1
-rw-r--r--tests/guix-build-branch.sh4
-rw-r--r--tests/guix-daemon.sh4
-rw-r--r--tests/guix-environment-container.sh67
-rw-r--r--tests/guix-home.sh16
-rw-r--r--tests/guix-pack.sh2
-rw-r--r--tests/guix-package.sh4
-rw-r--r--tests/guix-refresh.sh118
-rw-r--r--tests/guix-shell.sh3
-rw-r--r--tests/guix-system.sh10
-rw-r--r--tests/import-github.scm2
-rw-r--r--tests/import-utils.scm53
-rw-r--r--tests/lint.scm34
-rw-r--r--tests/monads.scm1
-rw-r--r--tests/pack.scm1
-rw-r--r--tests/packages.scm15
-rw-r--r--tests/pki.scm6
-rw-r--r--tests/print.scm23
-rw-r--r--tests/profiles.scm1
-rw-r--r--tests/read-print.scm7
-rw-r--r--tests/records.scm33
-rw-r--r--tests/store-deduplication.scm17
-rw-r--r--tests/substitute.scm113
-rw-r--r--tests/system.scm1
-rw-r--r--tests/transformations.scm59
-rw-r--r--tests/ui.scm11
35 files changed, 669 insertions, 57 deletions
diff --git a/tests/builders.scm b/tests/builders.scm
index 2853227465..0b5577c7a3 100644
--- a/tests/builders.scm
+++ b/tests/builders.scm
@@ -25,7 +25,6 @@
#:use-module (guix build gnu-build-system)
#:use-module (guix build utils)
#:use-module (guix build-system python)
- #:use-module (guix grafts)
#:use-module (guix store)
#:use-module (guix monads)
#:use-module (guix utils)
diff --git a/tests/channels.scm b/tests/channels.scm
index 0fe870dbaf..62312e240c 100644
--- a/tests/channels.scm
+++ b/tests/channels.scm
@@ -23,7 +23,6 @@
#:use-module ((guix build syscalls) #:select (mkdtemp!))
#:use-module (guix tests)
#:use-module (guix store)
- #:use-module ((guix grafts) #:select (%graft?))
#:use-module (guix derivations)
#:use-module (guix sets)
#:use-module (guix gexp)
diff --git a/tests/cpan.scm b/tests/cpan.scm
index b4db9e60e4..bbcd108e12 100644
--- a/tests/cpan.scm
+++ b/tests/cpan.scm
@@ -23,7 +23,7 @@
#:use-module (guix base32)
#:use-module (gcrypt hash)
#:use-module (guix tests http)
- #:use-module (guix grafts)
+ #:use-module ((guix store) #:select (%graft?))
#:use-module (srfi srfi-64)
#:use-module (web client)
#:use-module (ice-9 match))
diff --git a/tests/cpio.scm b/tests/cpio.scm
index 516de0655b..832101d1bb 100644
--- a/tests/cpio.scm
+++ b/tests/cpio.scm
@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2015 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2015, 2022 Ludovic Courtès <ludo@gnu.org>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -31,12 +31,18 @@
(define %cpio-program
(which "cpio"))
+(define %test-file
+ (search-path %load-path "guix.scm"))
+
(test-begin "cpio")
+;; The cpio format expects 'ino' to fit in 32 bits. If we have a bigger inode
+;; number, skip this test.
+(test-skip
+ (if (>= (stat:ino (lstat %test-file)) (expt 2 32)) 1 0))
(test-assert "file->cpio-header + write-cpio-header + read-cpio-header"
- (let* ((file (search-path %load-path "guix.scm"))
- (header (file->cpio-header file)))
+ (let* ((header (file->cpio-header %test-file)))
(call-with-values
(lambda ()
(open-bytevector-output-port))
diff --git a/tests/derivations.scm b/tests/derivations.scm
index 57d80412dc..66c777cfe7 100644
--- a/tests/derivations.scm
+++ b/tests/derivations.scm
@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2012-2022 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2012-2023 Ludovic Courtès <ludo@gnu.org>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -20,7 +20,6 @@
(define-module (test-derivations)
#:use-module (guix derivations)
- #:use-module (guix grafts)
#:use-module (guix store)
#:use-module (guix utils)
#:use-module ((gcrypt hash) #:prefix gcrypt:)
@@ -257,6 +256,21 @@
(build-derivations %store (list drv))
#f)))
+(test-assert "'download' built-in builder, no fixed-output hash"
+ ;; 'guix perform-download' should bail out with a message saying "not a
+ ;; fixed-output derivation".
+ (with-http-server '((200 "This should not be downloaded."))
+ (let* ((drv (derivation %store "download-without-hash"
+ "builtin:download" '()
+ #:env-vars `(("url"
+ . ,(object->string (%local-url))))
+ #:hash-algo 'sha256
+ #:hash #f)))
+ (guard (c ((store-protocol-error? c)
+ (string-contains (store-protocol-error-message c) "failed")))
+ (build-derivations %store (list drv))
+ #f))))
+
(test-assert "'download' built-in builder, check mode"
;; Make sure rebuilding the 'builtin:download' derivation in check mode
;; works. See <http://bugs.gnu.org/25089>.
@@ -317,6 +331,13 @@
#:hash hash #:hash-algo 'sha256)))
(fixed-output-derivation? drv)))
+(test-assert "fixed-output-derivation?, no hash"
+ ;; A derivation that has #:hash-algo and #:hash #f is *not* fixed-output.
+ (let* ((drv (derivation %store "not-quite-fixed"
+ "builtin:download" '()
+ #:hash #f #:hash-algo 'sha256)))
+ (not (fixed-output-derivation? drv))))
+
(test-equal "fixed-output derivation"
'(sha1 sha256 sha512)
(map (lambda (hash-algorithm)
@@ -375,6 +396,18 @@
(call-with-input-file p get-bytevector-all))
(bytevector? (query-path-hash %store p)))))))
+(test-assert "fixed-output derivation, invalid hash size"
+ (guard (c ((store-protocol-error? c)
+ (string-contains-ci (store-protocol-error-message c)
+ "invalid SHA512 hash")))
+ (derivation %store "download-with-invalid-hash"
+ "builtin:download" '()
+ #:env-vars `(("url"
+ . ,(object->string "http://example.org")))
+ #:hash-algo 'sha512
+ #:hash #vu8(1 2 3))
+ #f))
+
(test-assert "derivation with a fixed-output input"
;; A derivation D using a fixed-output derivation F doesn't has the same
;; output path when passed F or F', as long as F and F' have the same output
@@ -544,6 +577,22 @@
read-derivation)))
(equal? drv* drv)))
+(test-assert "read-derivation with hash = #f"
+ ;; Passing #:hash-algo together with #:hash #f is accepted and #:hash-algo
+ ;; is preserved. However it is not a fixed-output derivation. It used to
+ ;; be that 'read-derivation' would incorrectly return #vu8() instead of #f
+ ;; for the hash in this case:
+ ;; <https://lists.gnu.org/archive/html/guix-devel/2023-01/msg00040.html>.
+ (let* ((drv1 (derivation %store "almost-fixed-output"
+ "builtin:download" '()
+ #:env-vars `(("url" . "http://example.org"))
+ #:hash-algo 'sha256
+ #:hash #f))
+ (drv2 (call-with-input-file (derivation-file-name drv1)
+ read-derivation)))
+ (and (not (eq? drv1 drv2)) ;ensure memoization doesn't kick in
+ (equal? drv1 drv2))))
+
(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/gexp.scm b/tests/gexp.scm
index 07e940ffdc..7a90f8dcbf 100644
--- a/tests/gexp.scm
+++ b/tests/gexp.scm
@@ -21,7 +21,7 @@
#:use-module (guix store)
#:use-module (guix monads)
#:use-module (guix gexp)
- #:use-module (guix grafts)
+ #:use-module ((guix grafts) #:select (%graft-with-utf8-locale?))
#:use-module (guix derivations)
#:use-module (guix packages)
#:use-module (guix build-system trivial)
@@ -50,6 +50,9 @@
;; Globally disable grafts because they can trigger early builds.
(%graft? #f)
+;; When grafting, do not add dependency on 'glibc-utf8-locales'.
+(%graft-with-utf8-locale? #f)
+
;; For white-box testing.
(define (gexp-inputs x)
((@@ (guix gexp) gexp-inputs) x))
diff --git a/tests/git.scm b/tests/git.scm
index ca59d2a33e..9c944d65b1 100644
--- a/tests/git.scm
+++ b/tests/git.scm
@@ -22,8 +22,12 @@
#:use-module (guix git)
#:use-module (guix tests git)
#:use-module (guix build utils)
+ #:use-module ((guix utils) #:select (call-with-temporary-directory))
#:use-module (srfi srfi-1)
- #:use-module (srfi srfi-64))
+ #:use-module (srfi srfi-64)
+ #:use-module (srfi srfi-71)
+ #:use-module (ice-9 popen)
+ #:use-module (ice-9 textual-ports))
;; Test the (guix git) tools.
@@ -239,4 +243,30 @@
(tag "v1.1" "Release 1.1"))
(remote-refs directory #:tags? #t)))
+(unless (which (git-command)) (test-skip 1))
+(test-assert "update-cached-checkout, tag"
+ (call-with-temporary-directory
+ (lambda (cache)
+ (with-temporary-git-repository directory
+ '((add "a.txt" "A")
+ (commit "First commit")
+ (tag "v1.0" "release-1.0")
+ (branch "develop")
+ (checkout "develop")
+ (add "b.txt" "B")
+ (commit "Second commit")
+ (tag "v1.1" "release-1.1"))
+ (let ((directory commit relation
+ (update-cached-checkout directory
+ #:ref '(tag . "v1.1")
+ #:cache-directory cache))
+ (head (let* ((pipe (open-pipe* OPEN_READ (git-command)
+ "-C" directory
+ "rev-parse" "HEAD"))
+ (str (get-string-all pipe)))
+ (close-pipe pipe)
+ (string-trim-right str))))
+ ;; COMMIT should be the ID of the commit object, not that of the tag.
+ (string=? commit head))))))
+
(test-end "git")
diff --git a/tests/gnu-maintenance.scm b/tests/gnu-maintenance.scm
index abe74d799c..516e02ec6a 100644
--- a/tests/gnu-maintenance.scm
+++ b/tests/gnu-maintenance.scm
@@ -47,7 +47,8 @@
("guile" "guile-2.0.11.tar.gz.sig")
("mit-scheme" "mit-scheme-9.2-i386.tar.gz")
("mit-scheme" "mit-scheme-9.2-doc-pdf.tar.gz")
- ("gnutls" "gnutls-3.2.18-w32.zip")))))
+ ("gnutls" "gnutls-3.2.18-w32.zip")
+ ("valgrind" "valgrind-3.20.0.RC1.tar.bz2")))))
(test-assert "tarball->version"
(let ((tarball->version (@@ (guix gnu-maintenance) tarball->version)))
@@ -78,7 +79,7 @@
(uri (string-append (%local-url) "/foo-1.tar.gz"))))
(properties
`((release-monitoring-url . ,(%local-url))))))
- (define update ((upstream-updater-latest %generic-html-updater) package))
+ (define update ((upstream-updater-import %generic-html-updater) package))
(define expected-new-url "http://another-site/foo-2.tar.gz")
(and (pk 'u update)
(equal? (upstream-source-version update) "2")
@@ -103,7 +104,7 @@
(uri (string-append (%local-url) "/foo-1.tar.gz"))))
(properties
`((release-monitoring-url . ,(%local-url))))))
- (define update ((upstream-updater-latest %generic-html-updater) package))
+ (define update ((upstream-updater-import %generic-html-updater) package))
(define expected-new-url
(string-append (%local-url) "/foo-2.tar.gz"))
(and (pk 'u update)
@@ -134,7 +135,7 @@
(uri (string-append (%local-url) "/foo-1.tar.gz"))))
(properties
`((release-monitoring-url . ,(%local-url))))))
- (define update ((upstream-updater-latest %generic-html-updater) package))
+ (define update ((upstream-updater-import %generic-html-updater) package))
(define expected-new-url
(string-append (%local-url) "/foo-2.tar.gz"))
(define expected-signature-url
diff --git a/tests/grafts.scm b/tests/grafts.scm
index 7e1959e4a7..63dbb13830 100644
--- a/tests/grafts.scm
+++ b/tests/grafts.scm
@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2014, 2015, 2016, 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2014-2019, 2022 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2021 Mark H Weaver <mhw@netris.org>
;;;
;;; This file is part of GNU Guix.
@@ -35,6 +35,9 @@
(define %store
(open-connection-for-tests))
+;; When grafting, do not add dependency on 'glibc-utf8-locales'.
+(%graft-with-utf8-locale? #f)
+
(define (bootstrap-binary name)
(let ((bin (search-bootstrap-binary name (%current-system))))
(and %store
diff --git a/tests/graph.scm b/tests/graph.scm
index 6aa2d0e0ff..6674b5cc8f 100644
--- a/tests/graph.scm
+++ b/tests/graph.scm
@@ -24,7 +24,6 @@
#:use-module (guix derivations)
#:use-module (guix store)
#:use-module (guix monads)
- #:use-module (guix grafts)
#:use-module (guix build-system gnu)
#:use-module (guix build-system trivial)
#:use-module (guix gexp)
diff --git a/tests/guix-build-branch.sh b/tests/guix-build-branch.sh
index 79aa06a58f..7bf6a318ca 100644
--- a/tests/guix-build-branch.sh
+++ b/tests/guix-build-branch.sh
@@ -1,5 +1,5 @@
# GNU Guix --- Functional package management for GNU
-# Copyright © 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
+# Copyright © 2018, 2019, 2020, 2022 Ludovic Courtès <ludo@gnu.org>
#
# This file is part of GNU Guix.
#
@@ -54,7 +54,7 @@ test "$v0_1_0_drv" != "$orig_drv"
v0_1_0_drv="`guix build guix --with-commit=guile-gcrypt=v0.1.0 -d`"
guix gc -R "$v0_1_0_drv" | grep guile-gcrypt-0.1.0
-guix gc -R "$v0_1_0_drv" | grep guile-gcrypt-8fe64e8 # this is the tag ID
+guix gc -R "$v0_1_0_drv" | grep guile-gcrypt-9e3eacd
test "$v0_1_0_drv" != "$latest_drv"
test "$v0_1_0_drv" != "$orig_drv"
diff --git a/tests/guix-daemon.sh b/tests/guix-daemon.sh
index 330ad68835..4b09c8c162 100644
--- a/tests/guix-daemon.sh
+++ b/tests/guix-daemon.sh
@@ -27,7 +27,7 @@ guix build --version
drv="`guix build emacs -d`"
out="`guile -c ' \
- (use-modules (guix) (guix grafts) (gnu packages emacs)) \
+ (use-modules (guix) (gnu packages emacs)) \
(define store (open-connection)) \
(%graft? #f)
(display (derivation->output-path (package-derivation store emacs)))'`"
@@ -122,7 +122,7 @@ guix-daemon --no-substitutes --listen="$socket" --disable-chroot \
daemon_pid=$!
guile -c "
- (use-modules (guix) (guix grafts) (guix tests) (srfi srfi-34))
+ (use-modules (guix) (guix tests) (srfi srfi-34))
(define store (open-connection-for-tests \"$socket\"))
;; Disable grafts to avoid building more than needed.
diff --git a/tests/guix-environment-container.sh b/tests/guix-environment-container.sh
index 2e238c501d..0475405a89 100644
--- a/tests/guix-environment-container.sh
+++ b/tests/guix-environment-container.sh
@@ -1,5 +1,7 @@
# GNU Guix --- Functional package management for GNU
# Copyright © 2015 David Thompson <davet@gnu.org>
+# Copyright © 2022, 2023 John Kehayias <john.kehayias@protonmail.com>
+# Copyright © 2023 Ludovic Courtès <ludo@gnu.org>
#
# This file is part of GNU Guix.
#
@@ -197,3 +199,68 @@ then false;
else
test $? -gt 127
fi
+
+# Test the Filesystem Hierarchy Standard (FHS) container option, --emulate-fhs (-F)
+
+# As this option requires a glibc package (glibc-for-fhs), try to run these
+# tests with the user's global store to make it easier to build or download a
+# substitute.
+storedir="`guile -c '(use-modules (guix config))(display %storedir)'`"
+localstatedir="`guile -c '(use-modules (guix config))(display %localstatedir)'`"
+NIX_STORE_DIR="$storedir"
+GUIX_DAEMON_SOCKET="$localstatedir/guix/daemon-socket/socket"
+export NIX_STORE_DIR GUIX_DAEMON_SOCKET
+
+if ! guile -c '(use-modules (guix)) (exit (false-if-exception (open-connection)))'
+then
+ exit 77
+fi
+
+# Test that the container has FHS specific files/directories. Note that /bin
+# exists in a non-FHS container as it will contain sh, a symlink to the bash
+# package, so we don't test for it.
+guix shell -C --emulate-fhs --bootstrap guile-bootstrap \
+ -- guile -c '(exit (and (file-exists? "/etc/ld.so.cache")
+ (file-exists? "/lib")
+ (file-exists? "/sbin")
+ (file-exists? "/usr/bin")
+ (file-exists? "/usr/include")
+ (file-exists? "/usr/lib")
+ (file-exists? "/usr/libexec")
+ (file-exists? "/usr/sbin")
+ (file-exists? "/usr/share")))'
+
+# Test that the ld cache was generated and can be successfully read.
+guix shell -CF --bootstrap guile-bootstrap \
+ -- guile -c '(execlp "ldconfig" "ldconfig" "-p")'
+
+# Test that the package glibc-for-fhs is in the container even if there is the
+# regular glibc package from another source. See
+# <https://issues.guix.gnu.org/58861>.
+guix shell -CF --bootstrap guile-bootstrap glibc \
+ -- guile -c '(exit (if (string-contains (readlink "/lib/libc.so")
+ "glibc-for-fhs")
+ 0
+ 1))'
+
+# Test that $PATH inside the container includes the FHS directories.
+guix shell -CF coreutils -- env | grep ^PATH=/bin:/usr/bin:/sbin:/usr/sbin.*
+
+# Make sure '--preserve' is honored for $PATH, which the '--emulate-fhs'
+# option modifies. We can't (easily) check the whole $PATH as it will differ
+# inside and outside the container, so just check our test $PATH is still
+# present. See <https://issues.guix.gnu.org/60566>.
+PATH=/foo $(type -P guix) shell -CF -E ^PATH$ coreutils \
+ -- env | grep ^PATH=.*:/foo
+
+# '--symlink' works.
+echo "TESTING SYMLINK IN CONTAINER"
+guix shell --bootstrap guile-bootstrap --container \
+ --symlink=/usr/bin/guile=bin/guile -- \
+ /usr/bin/guile --version
+
+# A dangling symlink causes the command to fail.
+! guix shell --bootstrap -CS /usr/bin/python=bin/python guile-bootstrap -- exit
+
+# An invalid symlink spec causes the command to fail.
+! guix shell --bootstrap -CS bin/guile=/usr/bin/guile guile-bootstrap -- exit
diff --git a/tests/guix-home.sh b/tests/guix-home.sh
index d5e2dadbb5..3151f66683 100644
--- a/tests/guix-home.sh
+++ b/tests/guix-home.sh
@@ -1,5 +1,5 @@
# GNU Guix --- Functional package management for GNU
-# Copyright © 2021 Andrew Tropin <andrew@trop.in>
+# Copyright © 2021-2023 Andrew Tropin <andrew@trop.in>
# Copyright © 2021 Oleg Pykhalov <go.wigust@gmail.com>
# Copyright © 2022 Ludovic Courtès <ludo@gnu.org>
#
@@ -62,6 +62,7 @@ trap 'chmod -Rf +w "$test_directory"; rm -rf "$test_directory"' EXIT
(gnu home)
(gnu home services)
(gnu home services shells)
+ (gnu packages bash)
(gnu services))
(home-environment
@@ -81,7 +82,12 @@ trap 'chmod -Rf +w "$test_directory"; rm -rf "$test_directory"' EXIT
(simple-service 'add-environment-variable
home-environment-variables-service-type
- '(("TODAY" . "26 messidor")))
+ `(("TODAY" . "26 messidor")
+ ("SHELL" . ,(file-append bash "/bin/bash"))
+ ("BUILDHOST_TIME" . ,#~(strftime "%c"
+ (localtime (current-time))))
+ ("STRING_WITH_ESCAPES" . "chars: \" /\\")
+ ("LITERAL" . ,(literal-string "${abc}"))))
(simple-service 'home-bash-service-extension-test
home-bash-service-type
@@ -148,7 +154,13 @@ EOF
# the content of bashrc-test-config.sh"
grep -q "the content of ~/.config/test.conf" "${HOME}/.config/test.conf"
grep '^export PS1="\$GUIX_ENVIRONMENT λ "$' "${HOME}/.bash_profile"
+
( . "${HOME}/.guix-home/setup-environment"; test "$TODAY" = "26 messidor" )
+ ( . "${HOME}/.guix-home/setup-environment"; test "$LITERAL" = '${abc}' )
+ ( . "${HOME}/.guix-home/setup-environment";
+ test "$STRING_WITH_ESCAPES" = "chars: \" /\\")
+ ( . "${HOME}/.guix-home/setup-environment";
+ echo "$SHELL" | grep "/gnu/store/.*/bin/bash" )
# This one should still be here.
grep "stay around" "$HOME/.config/random-file"
diff --git a/tests/guix-pack.sh b/tests/guix-pack.sh
index f19a0f754e..6fc9e3723b 100644
--- a/tests/guix-pack.sh
+++ b/tests/guix-pack.sh
@@ -103,7 +103,7 @@ fi
guix pack --dry-run --bootstrap -f docker guile-bootstrap
# Build a Docker image with a symlink.
-guix pack --dry-run --bootstrap -f docker -S /opt/gnu=/ guile-bootstrap
+guix pack --dry-run --bootstrap -f docker -S /opt/gnu= guile-bootstrap
# Build a tarball pack of cross-compiled software. Use coreutils because
# guile-bootstrap is not intended to be cross-compiled.
diff --git a/tests/guix-package.sh b/tests/guix-package.sh
index dedba2fd74..cc416ec6a1 100644
--- a/tests/guix-package.sh
+++ b/tests/guix-package.sh
@@ -149,11 +149,11 @@ cat > "$module_dir/foo.scm"<<EOF
#:use-module (gnu packages base))
(define-public deprecated
- (deprecated-package "fileutils" coreutils))
+ (deprecated-package "fileutils-is-the-old-name" coreutils))
EOF
guix build -L "$module_dir" -e '(@ (foo) deprecated)' -n
-test "`guix package -L "$module_dir" -s ^fileutils$ | grep ^name:`" = ""
+test "`guix package -L "$module_dir" -s ^fileutils-is-the-old-name$ | grep ^name:`" = ""
rm -rf "$module_dir"
diff --git a/tests/guix-refresh.sh b/tests/guix-refresh.sh
new file mode 100644
index 0000000000..c5214e1d6e
--- /dev/null
+++ b/tests/guix-refresh.sh
@@ -0,0 +1,118 @@
+# GNU Guix --- Functional package management for GNU
+# Copyright © 2023 Ludovic Courtès <ludo@gnu.org>
+#
+# 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 <http://www.gnu.org/licenses/>.
+
+#
+# Test the 'guix refresh' command-line utility.
+#
+
+guix refresh --version
+
+manifest="t-guix-refresh-manifest-$$.scm"
+module_dir="t-guix-refresh-modules-$$"
+trap 'rm -f "$manifest"; rm -rf "$module_dir"' EXIT
+
+# Tell the 'test' updater what to simulate.
+export GUIX_TEST_UPDATER_TARGETS
+idutils_version="$(guix package -A ^idutils$ | cut -f2)"
+GUIX_TEST_UPDATER_TARGETS='
+ (("guile" "3" (("12.5" "file:///dev/null")
+ ("1.6.4" "file:///dev/null")))
+ ("libreoffice" "" (("1.0" "file:///dev/null")))
+ ("idutils" "" (("'$idutils_version'" "file:///dev/null")))
+ ("the-test-package" "" (("5.5" "file://'$PWD/$module_dir'/source"))))'
+
+# No newer version available.
+! guix refresh -t test idutils
+case "$(guix refresh -t test idutils 2>&1)" in
+ *"$idutils_version"*"already the latest version"*) true;;
+ *) false;;
+esac
+! guix refresh -t test libreoffice
+case "$(guix refresh -t test libreoffice 2>&1)" in
+ *"greater than the latest known version"*"1.0"*) true;;
+ *) false;;
+esac
+
+# Various ways to specify packages.
+cat > "$manifest" <<EOF
+(specifications->manifest (list "guile@3.0"))
+EOF
+default_IFS="$IFS"
+IFS=_
+for spec in "guile" \
+ "guile@3.0" \
+ "-e_(@ (gnu packages guile) guile-3.0)" \
+ "-m_$manifest" \
+ "-r_guile" \
+ "-s_core"
+do
+ guix refresh -t test $spec
+ case "$(guix refresh -t test $spec 2>&1)" in
+ *"would be upgraded"*"12.5"*)
+ true;;
+ *)
+ false;;
+ esac
+done
+IFS="$default_IFS"
+
+# Actually updating.
+mkdir "$module_dir"
+echo hello > "$module_dir/source"
+cat > "$module_dir/sample.scm"<<EOF
+(define-module (sample)
+ #:use-module (guix packages)
+ #:use-module (guix download)
+ #:use-module (gnu packages base))
+
+(define-public my-thing
+ (package
+ (inherit hello)
+ (name "the-test-package")
+ (version "4.3")
+ (source (origin
+ (method url-fetch)
+ (uri (string-append "mirror://gnu/hello/hello-" version
+ ".tar.gz"))
+ (sha256
+ (base32
+ "086vqwk2wl8zfs47sq2xpjc9k066ilmb8z6dn0q6ymwjzlm196cd"))))))
+EOF
+guix refresh -t test -L "$module_dir" the-test-package
+guix refresh -t test -L "$module_dir" the-test-package -u \
+ --keyring="$module_dir/keyring.kbx" # so we don't create $HOME/.config
+grep 'version "5.5"' "$module_dir/sample.scm"
+grep "$(guix hash -H sha256 -f nix-base32 "$module_dir/source")" "$module_dir/sample.scm"
+
+# Specifying a target version.
+! guix refresh -t test guile=2.0.0
+case "$(guix refresh -t test guile=2.0.0 2>&1)" in
+ *"failed to find"*"2.0.0"*) true;;
+ *) false;;
+esac
+for spec in "guile=1.6.4" "guile@3=1.6.4"
+do
+ guix refresh -t test "$spec"
+ case "$(guix refresh -t test "$spec" 2>&1)" in
+ *"would be downgraded"*"1.6.4"*) true;;
+ *) false;;
+ esac
+done
+
+# Listing updaters. This should work whether or not networking is available.
+guix refresh --list-updaters
diff --git a/tests/guix-shell.sh b/tests/guix-shell.sh
index 9a6b055264..cb2b53466d 100644
--- a/tests/guix-shell.sh
+++ b/tests/guix-shell.sh
@@ -32,6 +32,9 @@ export XDG_CONFIG_HOME
guix shell --bootstrap --pure guile-bootstrap -- guile --version
+# '--symlink' can only be used with --container.
+! guix shell --bootstrap guile-bootstrap -S /dummy=bin/guile
+
# '--ad-hoc' is a thing of the past.
! guix shell --ad-hoc guile-bootstrap
diff --git a/tests/guix-system.sh b/tests/guix-system.sh
index f76a5ce119..16c02e6e4c 100644
--- a/tests/guix-system.sh
+++ b/tests/guix-system.sh
@@ -342,6 +342,10 @@ for example in gnu/system/examples/*.tmpl; do
# 'asus-c201.tmpl' uses 'linux-libre-arm-generic', which is an
# ARM-only package.
options="--system=armhf-linux";;
+ *raspberry*)
+ # The Raspberry Pi templates 'linux-libre-arm64-generic', which is
+ # an ARM-only package.
+ options="--system=aarch64-linux";;
*vm-image*)
# The VM image tries to build 'current-guix' as per 'guix pull'.
# Skip it.
@@ -354,6 +358,12 @@ for example in gnu/system/examples/*.tmpl; do
guix system -n disk-image $options "$example"
done
+# Make sure the desktop image can be built on major architectures.
+for system in x86_64-linux i686-linux aarch64-linux
+do
+ guix system -n image -s "$system" gnu/system/examples/desktop.tmpl
+done
+
# Verify that the images can be built.
guix system -n vm gnu/system/examples/bare-bones.tmpl
guix system -n image gnu/system/images/pinebook-pro.scm
diff --git a/tests/import-github.scm b/tests/import-github.scm
index 4d3f8cfc7e..5100296540 100644
--- a/tests/import-github.scm
+++ b/tests/import-github.scm
@@ -92,7 +92,7 @@
(define* (found-sexp old-version old-commit tags releases)
(and=>
(call-with-releases (lambda ()
- ((upstream-updater-latest %github-updater)
+ ((upstream-updater-import %github-updater)
(example-package old-version old-commit)))
tags releases)
upstream-source->sexp))
diff --git a/tests/import-utils.scm b/tests/import-utils.scm
index 7c6c782917..44dff14597 100644
--- a/tests/import-utils.scm
+++ b/tests/import-utils.scm
@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2015, 2017 Ricardo Wurmus <rekado@elephly.net>
+;;; Copyright © 2015, 2017, 2022 Ricardo Wurmus <rekado@elephly.net>
;;; Copyright © 2016 Ben Woodcroft <donttrustben@gmail.com>
;;; Copyright © 2020 Martin Becze <mjbecze@riseup.net>
;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev>
@@ -32,14 +32,27 @@
(test-begin "import-utils")
(test-equal "beautify-description: use double spacing"
- "This is a package. It is great. Trust me Mr. Hendrix."
+ "\
+Trust me Mr. Hendrix, M. Night Shyamalan et al. \
+Differences are hard to spot,
+e.g. in CLOS vs. GOOPS."
(beautify-description
- "This is a package. It is great. Trust me Mr. Hendrix."))
+ "
+Trust me Mr. Hendrix, M. Night Shyamalan et al. \
+Differences are hard to spot, e.g. in CLOS vs. GOOPS."))
(test-equal "beautify-description: transform fragment into sentence"
"This package provides a function to establish world peace"
(beautify-description "A function to establish world peace"))
+(test-equal "beautify-description: remove single quotes"
+ "CRAN likes to quote acronyms and function names."
+ (beautify-description "CRAN likes to 'quote' acronyms and 'function' names."))
+
+(test-equal "beautify-description: escape @"
+ "This @@ is not Texinfo syntax. Neither is this %@@>%."
+ (beautify-description "This @ is not Texinfo syntax. Neither is this %@>%."))
+
(test-equal "license->symbol"
'license:lgpl2.0
(license->symbol license:lgpl2.0))
@@ -54,12 +67,12 @@
#:repo 'repo
#:repo->guix-package
(match-lambda*
- (("foo" #:version #f #:repo 'repo)
+ (("foo" #:repo 'repo . rest)
(values '(package
(name "foo")
(inputs `(("bar" ,bar))))
'("bar")))
- (("bar" #:version #f #:repo 'repo)
+ (("bar" #:repo 'repo . rest)
(values '(package
(name "bar"))
'())))
@@ -71,7 +84,7 @@
#:repo 'repo
#:repo->guix-package
(match-lambda*
- (("foo" #:version #f #:repo 'repo)
+ (("foo" #:repo 'repo . rest)
(values #f '())))
#:guix-name identity))
@@ -83,12 +96,12 @@
#:repo 'repo
#:repo->guix-package
(match-lambda*
- (("foo" #:version #f #:repo 'repo)
+ (("foo" #:repo 'repo . rest)
(values '(package
(name "foo")
(inputs `(("bar" ,bar))))
'("bar")))
- (("bar" #:version #f #:repo 'repo)
+ (("bar" #:repo 'repo . rest)
(values #f '())))
#:guix-name identity))
@@ -203,4 +216,28 @@
("license" . #f))))
(package-native-inputs (alist->package meta))))
+(test-assert "alist->package with properties"
+ (let* ((meta '(("name" . "hello")
+ ("version" . "2.10")
+ ("source" .
+ ;; Use a 'file://' URI so that we don't cause a download.
+ ,(string-append "file://"
+ (search-path %load-path "guix.scm")))
+ ("build-system" . "gnu")
+ ("properties" . (("hidden?" . #t)
+ ("upstream-name" . "hello-upstream")))
+ ("home-page" . "https://gnu.org")
+ ("synopsis" . "Say hi")
+ ("description" . "This package says hi.")
+ ("license" . "GPL-3.0+")))
+ (pkg (alist->package meta)))
+ (and (package? pkg)
+ (equal? (package-upstream-name pkg) "hello-upstream")
+ (hidden-package? pkg))))
+
+(test-equal "spdx-string->license"
+ '(license:gpl3+ license:agpl3 license:gpl2+)
+ (map spdx-string->license
+ '("GPL-3.0-oR-LaTeR" "AGPL-3.0" "GPL-2.0+")))
+
(test-end "import-utils")
diff --git a/tests/lint.scm b/tests/lint.scm
index 8be74d2604..ce22e2355a 100644
--- a/tests/lint.scm
+++ b/tests/lint.scm
@@ -1,7 +1,7 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2012, 2013 Cyril Roelandt <tipecaml@gmail.com>
;;; Copyright © 2014, 2015, 2016 Eric Bavier <bavier@member.fsf.org>
-;;; Copyright © 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2014-2022 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2015, 2016 Mathieu Lirzin <mthl@gnu.org>
;;; Copyright © 2016 Hartmut Goebel <h.goebel@crazy-compilers.com>
;;; Copyright © 2017 Alex Kost <alezost@gmail.com>
@@ -35,6 +35,7 @@
#:use-module (guix tests http)
#:use-module (guix download)
#:use-module (guix git-download)
+ #:use-module (guix svn-download)
#:use-module (guix build-system texlive)
#:use-module (guix build-system emacs)
#:use-module (guix build-system gnu)
@@ -49,7 +50,7 @@
#:use-module (gnu packages)
#:use-module (gnu packages glib)
#:use-module (gnu packages pkg-config)
- #:use-module (gnu packages python-xyz)
+ #:use-module (gnu packages python-build)
#:use-module ((gnu packages bash) #:select (bash bash-minimal))
#:use-module (web uri)
#:use-module (web server)
@@ -1085,6 +1086,35 @@
(and (? lint-warning?) second-warning))
(lint-warning-message second-warning)))))))))
+(test-equal "source: svn-reference, HTTP 200"
+ '()
+ (with-http-server `((200 ,%long-string))
+ (let ((pkg (package
+ (inherit (dummy-package "x"))
+ (source (origin
+ (method svn-fetch)
+ (uri (svn-reference
+ (url (%local-url))
+ (revision 1234)))
+ (sha256 %null-sha256))))))
+ (check-source pkg))))
+
+(with-http-server `((404 ,%long-string))
+ (test-equal "source: svn-reference, HTTP 404"
+ (format #f "URI ~a not reachable: 404 (\"Such is life\")"
+ (%local-url))
+ (let ((pkg (package
+ (inherit (dummy-package "x"))
+ (source (origin
+ (method svn-fetch)
+ (uri (svn-reference
+ (url (%local-url))
+ (revision 1234)))
+ (sha256 %null-sha256))))))
+ (match (check-source pkg)
+ ((warning)
+ (lint-warning-message warning))))))
+
(test-equal "mirror-url"
'()
(let ((source (origin
diff --git a/tests/monads.scm b/tests/monads.scm
index 19b74f4fb9..7f255f02bf 100644
--- a/tests/monads.scm
+++ b/tests/monads.scm
@@ -20,7 +20,6 @@
#:use-module (guix tests)
#:use-module (guix store)
#:use-module (guix monads)
- #:use-module (guix grafts)
#:use-module (guix derivations)
#:use-module (guix packages)
#:use-module (gnu packages)
diff --git a/tests/pack.scm b/tests/pack.scm
index 98bfedf21c..a4c388d93e 100644
--- a/tests/pack.scm
+++ b/tests/pack.scm
@@ -25,7 +25,6 @@
#:use-module (guix profiles)
#:use-module (guix packages)
#:use-module (guix monads)
- #:use-module (guix grafts)
#:use-module (guix tests)
#:use-module (guix gexp)
#:use-module (guix modules)
diff --git a/tests/packages.scm b/tests/packages.scm
index 6cbc34ba0b..f58c47817b 100644
--- a/tests/packages.scm
+++ b/tests/packages.scm
@@ -23,7 +23,6 @@
#:use-module (guix tests)
#:use-module (guix store)
#:use-module (guix monads)
- #:use-module (guix grafts)
#:use-module (guix gexp)
#:use-module (guix utils)
#:use-module ((guix build utils) #:select (tarball?))
@@ -76,6 +75,9 @@
;; can trigger builds early.)
(%graft? #f)
+;; When grafting, do not add dependency on 'glibc-utf8-locales'.
+(%graft-with-utf8-locale? #f)
+
(test-begin "packages")
@@ -94,6 +96,13 @@
(write
(dummy-package "foo" (location #f)))))))
+(test-equal "license type checking"
+ 'bad-license
+ (guard (c ((package-license-error? c)
+ (package-error-invalid-license c)))
+ (dummy-package "foo"
+ (license 'bad-license))))
+
(test-assert "hidden-package"
(and (hidden-package? (hidden-package (dummy-package "foo")))
(not (hidden-package? (dummy-package "foo")))))
@@ -617,6 +626,10 @@
(build-derivations %store (list drv))
(call-with-input-file output get-string-all)))
+(test-equal "package-upstream-name*"
+ (package-upstream-name* (specification->package "guile-gcrypt"))
+ "gcrypt")
+
;;;
;;; Source derivation with snippets.
diff --git a/tests/pki.scm b/tests/pki.scm
index d6a6b476c7..86daff8ddf 100644
--- a/tests/pki.scm
+++ b/tests/pki.scm
@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2013, 2014 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2013, 2014, 2022 Ludovic Courtès <ludo@gnu.org>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -66,6 +66,10 @@
(test-assert "authorized-key? public-key singleton"
(authorized-key? %public-key (public-keys->acl (list %public-key))))
+(test-equal "public-keys->acl deduplication"
+ (public-keys->acl (list %public-key))
+ (public-keys->acl (make-list 10 %public-key)))
+
(test-assert "signature-case valid-signature"
(let* ((hash (sha256 #vu8(1 2 3)))
(data (bytevector->hash-data hash #:key-type (key-type %public-key)))
diff --git a/tests/print.scm b/tests/print.scm
index d9710d1ed3..b4f193b905 100644
--- a/tests/print.scm
+++ b/tests/print.scm
@@ -139,6 +139,25 @@
(description "This is a dummy package.")
(license license:gpl3+)))
+(define-with-source pkg-with-properties pkg-with-properties-source
+ (package
+ (name "test")
+ (version "1.2.3")
+ (source (origin
+ (method url-fetch)
+ (uri (string-append "file:///tmp/test-"
+ version ".tar.gz"))
+ (sha256
+ (base32
+ "070pwb7brdcn1mfvplkd56vjc7lbz4iznzkqvfsakvgbv68k71ah"))))
+ (properties
+ `((hidden? . #t) (upstream-name "test-upstream")))
+ (build-system (@ (guix build-system gnu) gnu-build-system))
+ (home-page "http://gnu.org")
+ (synopsis "Dummy")
+ (description "This is a dummy package.")
+ (license license:gpl3+)))
+
(test-equal "simple package"
`(define-public test ,pkg-source)
(package->code pkg))
@@ -159,4 +178,8 @@
`(define-public test ,pkg-with-arguments-source)
(package->code pkg-with-arguments))
+(test-equal "package with properties"
+ `(define-public test ,pkg-with-properties-source)
+ (package->code pkg-with-properties))
+
(test-end "print")
diff --git a/tests/profiles.scm b/tests/profiles.scm
index 7bed946bf3..9ad03f2b24 100644
--- a/tests/profiles.scm
+++ b/tests/profiles.scm
@@ -23,7 +23,6 @@
#:use-module (guix gexp)
#:use-module (guix store)
#:use-module (guix monads)
- #:use-module (guix grafts)
#:use-module (guix packages)
#:use-module (guix derivations)
#:use-module (guix build-system trivial)
diff --git a/tests/read-print.scm b/tests/read-print.scm
index ea52a52145..79a4101be6 100644
--- a/tests/read-print.scm
+++ b/tests/read-print.scm
@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2021-2022 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2021-2023 Ludovic Courtès <ludo@gnu.org>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -143,6 +143,11 @@ expressions."
#:max-width 11)
(test-pretty-print "\
+(begin
+ 1+ 1- 123/ 456*
+ (1+ 41))")
+
+(test-pretty-print "\
(lambda (x y)
;; This is a procedure.
(let ((z (+ x y)))
diff --git a/tests/records.scm b/tests/records.scm
index 00c58b0736..b1203dfeb7 100644
--- a/tests/records.scm
+++ b/tests/records.scm
@@ -528,4 +528,37 @@ Description: 1st line,
'("a" "b" "c")
'("a")))
+(test-equal "match-record, simple"
+ '((1 2) (a b))
+ (let ()
+ (define-record-type* <foo> foo make-foo
+ foo?
+ (first foo-first (default 1))
+ (second foo-second))
+
+ (list (match-record (foo (second 2)) <foo>
+ (first second)
+ (list first second))
+ (match-record (foo (first 'a) (second 'b)) <foo>
+ (second (first first/new-var))
+ (list first/new-var second)))))
+
+(test-equal "match-record, unknown field"
+ 'syntax-error
+ (catch 'syntax-error
+ (lambda ()
+ (eval '(begin
+ (use-modules (guix records))
+
+ (define-record-type* <foo> foo make-foo
+ foo?
+ (first foo-first (default 1))
+ (second foo-second))
+
+ (match-record (foo (second 2)) <foo>
+ (one two)
+ #f))
+ (make-fresh-user-module)))
+ (lambda (key . args) key)))
+
(test-end)
diff --git a/tests/store-deduplication.scm b/tests/store-deduplication.scm
index 2950fbc1a3..f1845035d8 100644
--- a/tests/store-deduplication.scm
+++ b/tests/store-deduplication.scm
@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2018, 2020-2021 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2018, 2020-2022 Ludovic Courtès <ludo@gnu.org>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -136,6 +136,21 @@
(cons (apply = (map (compose stat:ino stat) identical))
(map (compose stat:nlink stat) identical))))))
+(test-assert "copy-file/deduplicate, below %deduplication-minimum-size"
+ (call-with-temporary-directory
+ (lambda (store)
+ (let ((source (string-append store "/input")))
+ (call-with-output-file source
+ (lambda (port)
+ (display "Hello!\n" port)))
+ (copy-file/deduplicate source
+ (string-append store "/a")
+ #:store store)
+ (and (not (directory-exists? (string-append store "/.links")))
+ (file=? source (string-append store "/a"))
+ (not (= (stat:ino (stat (string-append store "/a")))
+ (stat:ino (stat source)))))))))
+
(test-assert "copy-file/deduplicate"
(call-with-temporary-directory
(lambda (store)
diff --git a/tests/substitute.scm b/tests/substitute.scm
index 5315292987..9032a50268 100644
--- a/tests/substitute.scm
+++ b/tests/substitute.scm
@@ -523,6 +523,119 @@ System: mips64el-linux\n")))
(lambda ()
(false-if-exception (delete-file "substitute-retrieved")))))))
+(test-equal "substitute, first URL has narinfo but lacks nar, second URL unauthorized"
+ "Substitutable data."
+ (with-narinfo*
+ (string-append %narinfo "Signature: "
+ (signature-field
+ %narinfo
+ #:public-key %wrong-public-key))
+ %alternate-substitute-directory
+
+ (with-narinfo* (string-append %narinfo "Signature: "
+ (signature-field %narinfo))
+ %main-substitute-directory
+
+ (dynamic-wind
+ (const #t)
+ (lambda ()
+ ;; Remove this file so that the substitute can only be retrieved
+ ;; from %ALTERNATE-SUBSTITUTE-DIRECTORY.
+ (delete-file (string-append %main-substitute-directory
+ "/example.nar"))
+
+ (parameterize ((substitute-urls
+ (map (cut string-append "file://" <>)
+ (list %main-substitute-directory
+ %alternate-substitute-directory))))
+ (request-substitution (string-append (%store-prefix)
+ "/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-foo")
+ "substitute-retrieved"))
+ (call-with-input-file "substitute-retrieved" get-string-all))
+ (lambda ()
+ (false-if-exception (delete-file "substitute-retrieved")))))))
+
+(test-equal "substitute, first URL has narinfo but nar is 404, both URLs authorized"
+ "Substitutable data."
+ (with-narinfo*
+ (string-append %narinfo "Signature: "
+ (signature-field %narinfo))
+ %main-substitute-directory
+
+ (with-http-server `((200 ,(string-append %narinfo "Signature: "
+ (signature-field %narinfo)))
+ (404 "Sorry, nar is missing!"))
+ (dynamic-wind
+ (const #t)
+ (lambda ()
+ (parameterize ((substitute-urls
+ (list (%local-url)
+ (string-append "file://"
+ %main-substitute-directory))))
+ (request-substitution (string-append (%store-prefix)
+ "/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-foo")
+ "substitute-retrieved"))
+ (call-with-input-file "substitute-retrieved" get-string-all))
+ (lambda ()
+ (false-if-exception (delete-file "substitute-retrieved")))))))
+
+(test-equal "substitute, first URL has narinfo but nar is 404, one URL authorized"
+ "Substitutable data."
+ (with-narinfo*
+ (string-append %narinfo "Signature: "
+ (signature-field
+ %narinfo
+ #:public-key %wrong-public-key))
+ %main-substitute-directory
+
+ (with-http-server `((200 ,(string-append %narinfo "Signature: "
+ (signature-field
+ %narinfo
+ #:public-key %wrong-public-key)))
+ (404 "Sorry, nar is missing!"))
+ (let ((url1 (%local-url)))
+ (parameterize ((%http-server-port 0))
+ (with-http-server `((200 ,(string-append %narinfo "Signature: "
+ (signature-field %narinfo)))
+ (404 "Sorry, nar is missing!"))
+ (let ((url2 (%local-url)))
+ (dynamic-wind
+ (const #t)
+ (lambda ()
+ (parameterize ((substitute-urls
+ (list url1 url2
+ (string-append "file://"
+ %main-substitute-directory))))
+ (request-substitution (string-append (%store-prefix)
+ "/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-foo")
+ "substitute-retrieved"))
+ (call-with-input-file "substitute-retrieved" get-string-all))
+ (lambda ()
+ (false-if-exception (delete-file "substitute-retrieved")))))))))))
+
+(test-quit "substitute, narinfo is available but nar is missing"
+ "failed to find alternative substitute"
+ (with-narinfo*
+ (string-append %narinfo "Signature: "
+ (signature-field
+ %narinfo
+ #:public-key %wrong-public-key))
+ %main-substitute-directory
+
+ (with-http-server `((200 ,(string-append %narinfo "Signature: "
+ (signature-field %narinfo)))
+ (404 "Sorry, nar is missing!"))
+ (parameterize ((substitute-urls
+ (list (%local-url)
+ (string-append "file://"
+ %main-substitute-directory))))
+ (delete-file (string-append %main-substitute-directory
+ "/example.nar"))
+ (request-substitution (string-append (%store-prefix)
+ "/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-foo")
+ "substitute-retrieved")
+ (not (file-exists? "substitute-retrieved"))))))
+
(test-equal "substitute, first narinfo is unsigned and has wrong hash"
"Substitutable data."
(with-narinfo* (regexp-substitute #f
diff --git a/tests/system.scm b/tests/system.scm
index 873fed4aee..876e15a25e 100644
--- a/tests/system.scm
+++ b/tests/system.scm
@@ -24,7 +24,6 @@
#:use-module (guix monads)
#:use-module ((guix gexp) #:select (lower-object))
#:use-module ((guix utils) #:select (%current-system))
- #:use-module (guix grafts)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-64))
diff --git a/tests/transformations.scm b/tests/transformations.scm
index dbfe523518..1fa2c0bba8 100644
--- a/tests/transformations.scm
+++ b/tests/transformations.scm
@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2016-2017, 2019-2022 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2016-2017, 2019-2023 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2021 Marius Bakke <marius@gnu.org>
;;;
;;; This file is part of GNU Guix.
@@ -103,16 +103,11 @@
"sha256" f))))))))))
(test-assert "options->transformation, with-source, no matches"
- ;; When a transformation in not applicable, a warning must be raised.
(let* ((p (dummy-package "foobar"))
(s (search-path %load-path "guix.scm"))
(t (options->transformation `((with-source . ,s)))))
- (let* ((port (open-output-string))
- (new (parameterize ((guix-warning-port port))
- (t p))))
- (and (eq? new p)
- (string-contains (get-output-string port)
- "had no effect")))))
+ (eq? (package-source (t p))
+ (package-source p))))
(test-assert "options->transformation, with-source, PKG=URI"
(let* ((p (dummy-package "foo"))
@@ -147,6 +142,29 @@
(add-to-store store (basename s) #t
"sha256" s)))))))
+(test-assert "options->transformation, with-source, in depth"
+ (let* ((p0 (dummy-package "foo" (version "0.0")))
+ (s (search-path %load-path "guix.scm"))
+ (f (string-append "foo@42.0=" s))
+ (t (options->transformation `((with-source . ,f))))
+ (p1 (dummy-package "bar" (inputs (list p0))))
+ (p2 (dummy-package "baz" (inputs (list p1)))))
+ (with-store store
+ (let ((new (t p2)))
+ (and (not (eq? new p2))
+ (match (package-inputs new)
+ ((("bar" p1*))
+ (match (package-inputs p1*)
+ ((("foo" p0*))
+ (and (not (eq? p0* p0))
+ (string=? (package-name p0*) (package-name p0))
+ (string=? (package-version p0*) "42.0")
+ (string=? (add-to-store store (basename s) #t
+ "sha256" s)
+ (run-with-store store
+ (lower-object
+ (package-source p0*))))))))))))))
+
(test-assert "options->transformation, with-input"
(let* ((p (dummy-package "guix.scm"
(inputs `(("foo" ,(specification->package "coreutils"))
@@ -470,15 +488,32 @@
(name 'dummy)
(pred (const #t))
(description "")
- (latest (const (upstream-source
- (package "foo")
- (version "42.0")
- (urls '("http://example.org")))))))))
+ (import (const (upstream-source
+ (package "foo")
+ (version "42.0")
+ (urls '("http://example.org")))))))))
(let* ((p (dummy-package "foo" (version "1.0")))
(t (options->transformation
`((with-latest . "foo")))))
(package-version (t p)))))
+(test-equal "options->transformation, with-version"
+ "1.0"
+ (mock ((guix upstream) %updaters
+ (delay (list (upstream-updater
+ (name 'dummy)
+ (pred (const #t))
+ (description "")
+ (import (const (upstream-source
+ (package "foo")
+ (version "1.0")
+ (urls '("http://example.org")))))))))
+ (let* ((p0 (dummy-package "foo" (version "7.7")))
+ (p1 (dummy-package "bar" (inputs (list p0))))
+ (t (options->transformation
+ `((with-version . "foo=1.0")))))
+ (package-version (lookup-package-input (t p1) "foo")))))
+
(test-equal "options->transformation, tune"
'(cpu-tuning . "superfast")
(let* ((p0 (dummy-package "p0"))
diff --git a/tests/ui.scm b/tests/ui.scm
index 6a25a204ca..438acae525 100644
--- a/tests/ui.scm
+++ b/tests/ui.scm
@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2013-2017, 2019-2020, 2022 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2022 Taiju HIGASHI <higashi@taiju.info>
;;;
;;; This file is part of GNU Guix.
@@ -294,6 +294,15 @@ Second line" 24))
(>0 (package-relevance libb2
(map rx '("crypto" "library")))))))
+(test-assert "package-relevance and upstream name"
+ ;; https://issues.guix.gnu.org/58136
+ (let ((ggplot2 (specification->package "r-ggplot2"))
+ (ggstance (specification->package "r-ggstance"))
+ (rx (make-regexp "ggplot2" regexp/icase)))
+ (> (package-relevance ggplot2 (list rx))
+ (package-relevance ggstance (list rx))
+ 0)))
+
(define (make-empty-file directory file)
;; Create FILE in DIRECTORY.
(close-port (open-output-file (in-vicinity directory file))))