From patchwork Thu Jan 20 13:08:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: M X-Patchwork-Id: 36646 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 DF8A927BBEA; Thu, 20 Jan 2022 18:05:44 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id A25A027BBE9 for ; Thu, 20 Jan 2022 18:05:44 +0000 (GMT) Received: from localhost ([::1]:45506 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nAbod-0000yE-P6 for patchwork@mira.cbaines.net; Thu, 20 Jan 2022 13:05:43 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50838) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nAXCZ-0004Ee-9G for guix-patches@gnu.org; Thu, 20 Jan 2022 08:10:08 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:35576) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nAXCX-0006Yb-2N for guix-patches@gnu.org; Thu, 20 Jan 2022 08:10:06 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nAXCW-0004tX-UG for guix-patches@gnu.org; Thu, 20 Jan 2022 08:10:04 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#53389] [PATCH 8/9] tests/cpan: Verify URIs. Resent-From: Maxime Devos Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 20 Jan 2022 13:10:04 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 53389 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 53389@debbugs.gnu.org Cc: ludo@gnu.org, Maxime Devos Received: via spool by 53389-submit@debbugs.gnu.org id=B53389.164268415918708 (code B ref 53389); Thu, 20 Jan 2022 13:10:04 +0000 Received: (at 53389) by debbugs.gnu.org; 20 Jan 2022 13:09:19 +0000 Received: from localhost ([127.0.0.1]:56706 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nAXBn-0004rb-Ie for submit@debbugs.gnu.org; Thu, 20 Jan 2022 08:09:19 -0500 Received: from baptiste.telenet-ops.be ([195.130.132.51]:42086) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nAXBM-0004p0-Qp for 53389@debbugs.gnu.org; Thu, 20 Jan 2022 08:08:55 -0500 Received: from localhost.localdomain ([IPv6:2a02:1811:8c09:9d00:3c5f:2eff:feb0:ba5a]) by baptiste.telenet-ops.be with bizsmtp id l18q2600H4UW6Th0118sP2; Thu, 20 Jan 2022 14:08:52 +0100 From: Maxime Devos Date: Thu, 20 Jan 2022 13:08:48 +0000 Message-Id: <20220120130849.292178-8-maximedevos@telenet.be> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220120130849.292178-1-maximedevos@telenet.be> References: <20220120130849.292178-1-maximedevos@telenet.be> MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telenet.be; s=r22; t=1642684132; bh=Yb+CBeWIUkyWzCg0FPTKESsj5EpnOre7F80LbkZWId4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=bWgCBPuEQMcviFwNL927pKyKSQQhoLGAf4m0PXdaFBDQ73gLeo2Tt1SapAeU1HCj6 kYhUX8jJavWUbFJvT44vYo1vfaFKCqGFGnwBhvNicGGyiQxdCrWHeAaktUCAFp7tdl tCAQUKPquzI7JT6JGR5p836ODvjThdIL1dcfop/GFkuzD5drHB7rjymEK/4A8DOqCI g/9oMeP03Gu4obO9SfcJ0JRViVeaA5AHtNkmT4HV6btwT8HlVfJc6ZAJzDjsf4zIZW Zh1oe3BYY2DtVakhZV4Ask6k2BfoEShoyPiKmAMgeZmBrB4BnQ/noLYuB603XHD8NE wnDYTouQsnTyA== X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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 This restores some functionality lost in commit 4aea90b1876179aab8d603a42533a6bdf97ccd3c. * tests/cpan.scm (test-json): Thunk and construct the download URL with '%local-url*'. ("cpan->guix-package"): For simplicity, don't use the HTTP server as a proxy. Verify the contacted URLs. Adjust for thunking. Adjust for new download URL. --- tests/cpan.scm | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/tests/cpan.scm b/tests/cpan.scm index 89e6be0b4f..e6fa965969 100644 --- a/tests/cpan.scm +++ b/tests/cpan.scm @@ -2,6 +2,7 @@ ;;; Copyright © 2015 Eric Bavier ;;; Copyright © 2016 Alex Sassmannshausen ;;; Copyright © 2020 Ludovic Courtès +;;; Copyright © 2022 Maxime Devos ;;; ;;; This file is part of GNU Guix. ;;; @@ -31,8 +32,9 @@ ;; Globally disable grafts because they can trigger early builds. (%graft? #f) -(define test-json - "{ +(define (test-json) + (string-append + "{ \"metadata\" : { \"name\" : \"Foo-Bar\", \"version\" : \"0.1\" @@ -50,10 +52,10 @@ } ], \"abstract\" : \"Fizzle Fuzz\", - \"download_url\" : \"http://example.com/Foo-Bar-0.1.tar.gz\", + \"download_url\" : \"" (%local-url* "/Foo-Bar-0.1.tar.gz") "\" \"author\" : \"Guix\", \"version\" : \"0.1\" -}") +}")) (define test-source "foobar") @@ -62,18 +64,19 @@ (test-assert "cpan->guix-package" ;; Replace network resources with sample data. - (with-http-server `((200 ,test-json) - (200 ,test-source) - (200 "{ \"distribution\" : \"Test-Script\" }")) - (parameterize ((%metacpan-base-url (%local-url)) - (current-http-proxy (%local-url))) + (with-http-server `(("/release/Foo-Bar" 200 ,(test-json)) + ("/Foo-Bar-0.1.tar.gz" 200 ,test-source) + ("/module/Test::Script?fields=distribution" + 200 "{ \"distribution\" : \"Test-Script\" }")) + (parameterize ((%metacpan-base-url (%local-url* "")) + (current-http-proxy #false)) (match (cpan->guix-package "Foo::Bar") (('package ('name "perl-foo-bar") ('version "0.1") ('source ('origin ('method 'url-fetch) - ('uri ('string-append "http://example.com/Foo-Bar-" + ('uri ('string-append (? string? base-uri) 'version ".tar.gz")) ('sha256 ('base32 @@ -86,9 +89,10 @@ ('synopsis "Fizzle Fuzz") ('description 'fill-in-yourself!) ('license 'perl-license)) - (string=? (bytevector->nix-base32-string - (call-with-input-string test-source port-sha256)) - hash)) + (and (string=? base-uri (%local-url* "/Foo-Bar-")) + (string=? (bytevector->nix-base32-string + (call-with-input-string test-source port-sha256)) + hash))) (x (pk 'fail x #f))))))