From patchwork Wed Jul 10 17:11:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 14565 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 44DAB171E2; Wed, 10 Jul 2019 18:13:21 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTP id BD434171DD for ; Wed, 10 Jul 2019 18:13:20 +0100 (BST) Received: from localhost ([::1]:35546 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hlG9g-000855-DG for patchwork@mira.cbaines.net; Wed, 10 Jul 2019 13:13:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45515) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hlG9W-0007rf-Jz for guix-patches@gnu.org; Wed, 10 Jul 2019 13:13:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hlG9S-0003Fu-Kj for guix-patches@gnu.org; Wed, 10 Jul 2019 13:13:10 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:55962) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hlG9Q-0003BO-Lm for guix-patches@gnu.org; Wed, 10 Jul 2019 13:13:06 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hlG9Q-0001De-DA for guix-patches@gnu.org; Wed, 10 Jul 2019 13:13:04 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#36578] [PATCH 6/9] derivations: Update tests to use new calling convention. Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 10 Jul 2019 17:13:04 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 36578 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 36578@debbugs.gnu.org Received: via spool by 36578-submit@debbugs.gnu.org id=B36578.15627787294564 (code B ref 36578); Wed, 10 Jul 2019 17:13:04 +0000 Received: (at 36578) by debbugs.gnu.org; 10 Jul 2019 17:12:09 +0000 Received: from localhost ([127.0.0.1]:36538 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hlG8W-0001BT-EA for submit@debbugs.gnu.org; Wed, 10 Jul 2019 13:12:08 -0400 Received: from eggs.gnu.org ([209.51.188.92]:60819) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hlG8U-0001A8-Kl for 36578@debbugs.gnu.org; Wed, 10 Jul 2019 13:12:07 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:47974) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hlG8P-00023h-Gn; Wed, 10 Jul 2019 13:12:01 -0400 Received: from [81.18.188.212] (port=57592 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1hlG8O-0005OT-9v; Wed, 10 Jul 2019 13:12:01 -0400 From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Wed, 10 Jul 2019 19:11:25 +0200 Message-Id: <20190710171128.21568-6-ludo@gnu.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190710171128.21568-1-ludo@gnu.org> References: <20190710171128.21568-1-ludo@gnu.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * tests/derivations.scm ("build derivation with 1 source"): Adjust to new 'derivation' calling convention. ("identical files are deduplicated"): Likewise. ("fixed-output-derivation?"): Likewise. ("fixed-output derivation"): Likewise. ("fixed-output derivation, recursive"): Likewise. ("derivation with a fixed-output input"): Likewise. ("multiple-output derivation"): Likewise. ("multiple-output derivation, non-alphabetic order"): Likewise. ("read-derivation vs. derivation"): Likewise. ("user of multiple-output derivation"): Likewise. ("derivation with #:references-graphs"): Likewise. ("derivation #:allowed-references, ok"): Likewise. ("derivation #:allowed-references, not allowed"): Likewise. ("derivation #:allowed-references, self allowed"): Likewise. ("derivation #:allowed-references, self not allowed"): Likewise. ("derivation #:disallowed-references, ok"): Likewise. ("derivation #:disallowed-references, not ok"): Likewise. ("derivation #:leaked-env-vars"): Likewise. ("build derivation with coreutils"): Likewise. ("map-derivation, sources"): Likewise. ("derivation with local file as input"): Remove. --- tests/derivations.scm | 89 +++++++++++++++++-------------------------- 1 file changed, 35 insertions(+), 54 deletions(-) diff --git a/tests/derivations.scm b/tests/derivations.scm index 7be7726163..368012d2b2 100644 --- a/tests/derivations.scm +++ b/tests/derivations.scm @@ -137,7 +137,7 @@ #:env-vars '(("HOME" . "/homeless") ("zzz" . "Z!") ("AAA" . "A!")) - #:inputs `((,%bash) (,builder)))) + #:sources `(,%bash ,builder))) (succeeded? (build-derivations %store (list drv)))) (and succeeded? @@ -146,36 +146,13 @@ (string=? (call-with-input-file path read-line) "hello, world")))))) -(test-assert "derivation with local file as input" - (let* ((builder (add-text-to-store - %store "my-builder.sh" - "(while read line ; do echo \"$line\" ; done) < $in > $out" - '())) - (input (search-path %load-path "ice-9/boot-9.scm")) - (input* (add-to-store %store (basename input) - #t "sha256" input)) - (drv (derivation %store "derivation-with-input-file" - %bash `(,builder) - - ;; Cheat to pass the actual file name to the - ;; builder. - #:env-vars `(("in" . ,input*)) - - #:inputs `((,%bash) - (,builder) - (,input))))) ; ← local file name - (and (build-derivations %store (list drv)) - ;; Note: we can't compare the files because the above trick alters - ;; the contents. - (valid-path? %store (derivation->output-path drv))))) - (test-assert "derivation fails but keep going" ;; In keep-going mode, 'build-derivations' should fail because of D1, but it ;; must return only after D2 has succeeded. (with-store store (let* ((d1 (derivation %store "fails" %bash `("-c" "false") - #:inputs `((,%bash)))) + #:sources (list %bash))) (d2 (build-expression->derivation %store "sleep-then-succeed" `(begin ,(random-text) @@ -205,10 +182,10 @@ '())) (drv1 (derivation %store "foo" %bash `(,build1) - #:inputs `((,%bash) (,build1)))) + #:sources `(,%bash ,build1))) (drv2 (derivation %store "bar" %bash `(,build2) - #:inputs `((,%bash) (,build2))))) + #:sources `(,%bash ,build2)))) (and (build-derivations %store (list drv1 drv2)) (let ((file1 (derivation->output-path drv1)) (file2 (derivation->output-path drv2))) @@ -344,7 +321,7 @@ (hash (sha256 (string->utf8 "hello"))) (drv (derivation %store "fixed" %bash `(,builder) - #:inputs `((,builder)) + #:sources (list builder) #:hash hash #:hash-algo 'sha256))) (fixed-output-derivation? drv))) @@ -354,7 +331,7 @@ (hash (sha256 (string->utf8 "hello"))) (drv (derivation %store "fixed" %bash `(,builder) - #:inputs `((,builder)) ; optional + #:sources `(,builder) ;optional #:hash hash #:hash-algo 'sha256)) (succeeded? (build-derivations %store (list drv)))) (and succeeded? @@ -386,7 +363,7 @@ (hash (sha256 (string->utf8 "hello"))) (drv (derivation %store "fixed-rec" %bash `(,builder) - #:inputs `((,builder)) + #:sources (list builder) #:hash (base32 "0sg9f58l1jj88w6pdrfdpj5x9b1zrwszk84j81zvby36q9whhhqa") #:hash-algo 'sha256 #:recursive? #t)) @@ -420,11 +397,13 @@ (final1 (derivation %store "final" %bash `(,builder3) #:env-vars `(("in" . ,fixed-out)) - #:inputs `((,%bash) (,builder3) (,fixed1)))) + #:sources (list %bash builder3) + #:inputs (list (derivation-input fixed1)))) (final2 (derivation %store "final" %bash `(,builder3) #:env-vars `(("in" . ,fixed-out)) - #:inputs `((,%bash) (,builder3) (,fixed2)))) + #:sources (list %bash builder3) + #:inputs (list (derivation-input fixed2)))) (succeeded? (build-derivations %store (list final1 final2)))) (and succeeded? @@ -440,7 +419,7 @@ #:env-vars '(("HOME" . "/homeless") ("zzz" . "Z!") ("AAA" . "A!")) - #:inputs `((,%bash) (,builder)) + #:sources `(,%bash ,builder) #:outputs '("out" "second"))) (succeeded? (build-derivations %store (list drv)))) (and succeeded? @@ -460,7 +439,7 @@ '())) (drv (derivation %store "fixed" %bash `(,builder) - #:inputs `((,%bash) (,builder)) + #:sources `(,%bash ,builder) #:outputs '("out" "AAA"))) (succeeded? (build-derivations %store (list drv)))) (and succeeded? @@ -482,15 +461,15 @@ (inputs (map (lambda (file) (derivation %store "derivation-input" %bash '() - #:inputs `((,%bash) (,file)))) + #:sources `(,%bash ,file))) sources)) (builder (add-text-to-store %store "builder.sh" "echo one > $one ; echo two > $two" '())) (drv (derivation %store "derivation" %bash `(,builder) - #:inputs `((,%bash) (,builder) - ,@(map list (append sources inputs))) + #:sources `(,%bash ,builder ,@sources) + #:inputs (map derivation-input inputs) #:outputs '("two" "one"))) (drv* (call-with-input-file (derivation-file-name drv) read-derivation))) @@ -521,7 +500,7 @@ '())) (mdrv (derivation %store "multiple-output" %bash `(,builder1) - #:inputs `((,%bash) (,builder1)) + #:sources (list %bash builder1) #:outputs '("out" "two"))) (builder2 (add-text-to-store %store "my-mo-user-builder.sh" "read x < $one; @@ -536,11 +515,11 @@ ("two" . ,(derivation->output-path mdrv "two"))) - #:inputs `((,%bash) - (,builder2) - ;; two occurrences of MDRV: - (,mdrv) - (,mdrv "two"))))) + #:sources (list %bash builder2) + ;; two occurrences of MDRV: + #:inputs + (list (derivation-input mdrv) + (derivation-input mdrv '("two")))))) (and (build-derivations %store (list (pk 'udrv udrv))) (let ((p (derivation->output-path udrv))) (and (valid-path? %store p) @@ -566,7 +545,7 @@ `(("bash" . ,%bash) ("input1" . ,input1) ("input2" . ,input2)) - #:inputs `((,%bash) (,builder)))) + #:sources (list %bash builder))) (out (derivation->output-path drv))) (define (deps path . deps) (let ((count (length deps))) @@ -599,7 +578,7 @@ (test-assert "derivation #:allowed-references, ok" (let ((drv (derivation %store "allowed" %bash '("-c" "echo hello > $out") - #:inputs `((,%bash)) + #:sources (list %bash) #:allowed-references '()))) (build-derivations %store (list drv)))) @@ -607,7 +586,7 @@ (let* ((txt (add-text-to-store %store "foo" "Hello, world.")) (drv (derivation %store "disallowed" %bash `("-c" ,(string-append "echo " txt "> $out")) - #:inputs `((,%bash) (,txt)) + #:sources (list %bash txt) #:allowed-references '()))) (guard (c ((store-protocol-error? c) ;; There's no specific error message to check for. @@ -618,14 +597,14 @@ (test-assert "derivation #:allowed-references, self allowed" (let ((drv (derivation %store "allowed" %bash '("-c" "echo $out > $out") - #:inputs `((,%bash)) + #:sources (list %bash) #:allowed-references '("out")))) (build-derivations %store (list drv)))) (test-assert "derivation #:allowed-references, self not allowed" (let ((drv (derivation %store "disallowed" %bash `("-c" ,"echo $out > $out") - #:inputs `((,%bash)) + #:sources (list %bash) #:allowed-references '()))) (guard (c ((store-protocol-error? c) ;; There's no specific error message to check for. @@ -636,7 +615,7 @@ (test-assert "derivation #:disallowed-references, ok" (let ((drv (derivation %store "disallowed" %bash '("-c" "echo hello > $out") - #:inputs `((,%bash)) + #:sources (list %bash) #:disallowed-references '("out")))) (build-derivations %store (list drv)))) @@ -644,7 +623,7 @@ (let* ((txt (add-text-to-store %store "foo" "Hello, world.")) (drv (derivation %store "disdisallowed" %bash `("-c" ,(string-append "echo " txt "> $out")) - #:inputs `((,%bash) (,txt)) + #:sources (list %bash txt) #:disallowed-references (list txt)))) (guard (c ((store-protocol-error? c) ;; There's no specific error message to check for. @@ -663,7 +642,7 @@ '("-c" "echo -n $GUIX_STATE_DIRECTORY > $out") #:hash (sha256 (string->utf8 value)) #:hash-algo 'sha256 - #:inputs `((,%bash)) + #:sources (list %bash) #:leaked-env-vars '("GUIX_STATE_DIRECTORY")))) (and (build-derivations %store (list drv)) (call-with-input-file (derivation->output-path drv) @@ -689,8 +668,8 @@ ,(string-append (derivation->output-path %coreutils) "/bin"))) - #:inputs `((,builder) - (,%coreutils)))) + #:sources (list builder) + #:inputs (list (derivation-input %coreutils)))) (succeeded? (build-derivations %store (list drv)))) (and succeeded? @@ -1240,7 +1219,9 @@ (derivation->output-path bash-full) `("-e" ,script1) - #:inputs `((,bash-full) (,script1)))) + #:sources (list script1) + #:inputs + (list (derivation-input bash-full '("out"))))) (drv2 (map-derivation %store drv1 `((,bash-full . ,%bash) (,script1 . ,script2))))