diff options
author | Efraim Flashner <efraim@flashner.co.il> | 2023-01-30 11:33:18 +0200 |
---|---|---|
committer | Efraim Flashner <efraim@flashner.co.il> | 2023-01-30 12:39:40 +0200 |
commit | 4cf1acc7f3033b50b0bf19e02c9f522d522d338c (patch) | |
tree | 9fd64956ee60304c15387eb394cd649e49f01467 /tests/derivations.scm | |
parent | edb8c09addd186d9538d43b12af74d6c7aeea082 (diff) | |
parent | 595b53b74e3ef57a1c0c96108ba86d38a170a241 (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/derivations.scm')
-rw-r--r-- | tests/derivations.scm | 53 |
1 files changed, 51 insertions, 2 deletions
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" |