From patchwork Thu Jan 20 13:08:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: M X-Patchwork-Id: 36651 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 DC0BE27BBEA; Thu, 20 Jan 2022 19:45:05 +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 2F87E27BBE9 for ; Thu, 20 Jan 2022 19:45:05 +0000 (GMT) Received: from localhost ([::1]:55912 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nAdMk-0001Wb-LX for patchwork@mira.cbaines.net; Thu, 20 Jan 2022 14:45:02 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50804) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nAXCX-0004EI-8F for guix-patches@gnu.org; Thu, 20 Jan 2022 08:10:06 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:35573) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nAXCV-0006Sf-MZ for guix-patches@gnu.org; Thu, 20 Jan 2022 08:10:04 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nAXCV-0004tA-IH for guix-patches@gnu.org; Thu, 20 Jan 2022 08:10:03 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#53389] [PATCH 1/9] tests: Support arbitrary HTTP request handlers. References: <6b1c1d98514b2547907a81a04c1241d9b865d6fa.camel@telenet.be> In-Reply-To: <6b1c1d98514b2547907a81a04c1241d9b865d6fa.camel@telenet.be> Resent-From: Maxime Devos Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 20 Jan 2022 13:10:03 +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.164268415818687 (code B ref 53389); Thu, 20 Jan 2022 13:10:03 +0000 Received: (at 53389) by debbugs.gnu.org; 20 Jan 2022 13:09:18 +0000 Received: from localhost ([127.0.0.1]:56700 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nAXBm-0004rF-1p for submit@debbugs.gnu.org; Thu, 20 Jan 2022 08:09:18 -0500 Received: from baptiste.telenet-ops.be ([195.130.132.51]:41976) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nAXBM-0004op-08 for 53389@debbugs.gnu.org; Thu, 20 Jan 2022 08:08:54 -0500 Received: from localhost.localdomain ([IPv6:2a02:1811:8c09:9d00:3c5f:2eff:feb0:ba5a]) by baptiste.telenet-ops.be with bizsmtp id l18q2600H4UW6Th0118qN2; Thu, 20 Jan 2022 14:08:50 +0100 From: Maxime Devos Date: Thu, 20 Jan 2022 13:08:41 +0000 Message-Id: <20220120130849.292178-1-maximedevos@telenet.be> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telenet.be; s=r22; t=1642684130; bh=+gPR/bwIo+N5qZniBsvVIBPU7dairx51qt2DzoeadNg=; h=From:To:Cc:Subject:Date; b=PZEIpQUAjd9W5GonwE4N8TbjIf6B2UeNQN9I2btDdTT0Q8IwjjxtLIHmXLn39PQH6 2DqHy3CKUQMCxUpL7o3ynfKI01+nk+Kg7AhTv4zydWEtJ5TPoO7HYf2uQgSjnQt5Si 0Pi5F+PVNYNzmvJzdF2b5+RoBp7Fg8rj3o9OJtEeMsUctRHtrX2lOXjGrDs1qXVsm4 elv4RafZ5f5bETmk4JHpX9ypHDE1ZWeT6e7lNPeBW6AJwOtvzv7+RB4NRP3AwQQ1Ev ZktAJ1Mdp+fGLzsyQlxPUF3zSMShkoBgswe1xfHz2pi8dy6c+ZnIBiEutx0EFMW8+W R2nVsYvVKD9HQ== 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 An incompatible change to with-http-server has been made: it now also exits when the thunk exits. This change allows implementing with-http-server*. It also keeps threads from lingering if the thunk doesn't access all of RESPONSES+DATA. Usually, this change is fine, but it does not interact nicely with monads in tests/challenge, so a variant with-http-server/lingering preserving the old behaviour has been defined. * guix/tests/http.scm (call-with-http-server): Extract most functionality to ... (call-with-http-server*): ... this new procedure. Also stop the server thread after 'thunk' returns instead of when the last response has been sent unless requested not to. (with-http-server/keep-lingering): New macro. * tests/challenge.scm (call-mismatch-test): Use the 'keep-lingering' variant of 'with-http-server'. --- guix/tests/http.scm | 96 +++++++++++++++++++++++++++++++-------------- tests/challenge.scm | 24 ++++++------ 2 files changed, 80 insertions(+), 40 deletions(-) base-commit: 1bd250783d7118c3101dd2a6e090f3d6904b24a0 diff --git a/guix/tests/http.scm b/guix/tests/http.scm index 8f50eaefca..c42b4b8176 100644 --- a/guix/tests/http.scm +++ b/guix/tests/http.scm @@ -1,6 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2014, 2015, 2016, 2017, 2019 Ludovic Courtès -;;; Copyright © 2021 Maxime Devos +;;; Copyright © 2021, 2022 Maxime Devos ;;; ;;; This file is part of GNU Guix. ;;; @@ -26,7 +26,10 @@ #:use-module (srfi srfi-39) #:use-module (ice-9 match) #:export (with-http-server + with-http-server/keep-lingering + with-http-server* call-with-http-server + call-with-http-server* %http-server-port %local-url)) @@ -68,23 +71,15 @@ actually listened at (in case %http-server-port was 0)." (string-append "http://localhost:" (number->string port) "/foo/bar")) -(define* (call-with-http-server responses+data thunk) - "Call THUNK with an HTTP server running and returning RESPONSES+DATA on HTTP -requests. Each element of RESPONSES+DATA must be a tuple containing a -response and a string, or an HTTP response code and a string. +(define* (call-with-http-server* handle thunk #:key (keep-lingering? #false) + (last-response? (const #false))) + "Call THUNK with an HTTP server running and responding to HTTP requests +with HANDLE (see (guile)Web Server). %http-server-port will be set to the port listened at -The port listened at will be set for the dynamic extent of THUNK." - (define responses - (map (match-lambda - (((? response? response) data) - (list response data)) - (((? integer? code) data) - (list (build-response #:code code - #:reason-phrase "Such is life") - data))) - responses+data)) - +The port listened at will be set for the dynamic extent of THUNK. +The server will quit after THUNK returns, unless KEEP-LINGERING? is true. +It will also quit if LAST-RESPONSE? returns true." (define (http-write server client response body) "Write RESPONSE." (let* ((response (write-response response client)) @@ -94,8 +89,8 @@ The port listened at will be set for the dynamic extent of THUNK." (else (write-response-body response body))) (close-port port) - (when (null? responses) - (quit #t)) ;exit the server thread + (when (last-response?) + (throw 'quit)) (values))) ;; Mutex and condition variable to synchronize with the HTTP server. @@ -118,18 +113,15 @@ The port listened at will be set for the dynamic extent of THUNK." (@@ (web server http) http-close)) (define (server-body) - (define (handle request body) - (match responses - (((response data) rest ...) - (set! responses rest) - (values response data)))) - (let-values (((socket port) (open-http-server-socket))) (set! %http-real-server-port port) (catch 'quit (lambda () - (run-server handle stub-http-server - `(#:socket ,socket))) + ;; HANDLE might want to include the port in its responses, + ;; so set %http-server-port here as well. + (parameterize ((%http-server-port port)) + (run-server handle stub-http-server + `(#:socket ,socket)))) (lambda _ (close-port socket))))) @@ -137,12 +129,58 @@ The port listened at will be set for the dynamic extent of THUNK." (let ((server (make-thread server-body))) (wait-condition-variable %http-server-ready %http-server-lock) ;; Normally SERVER exits automatically once it has received a request. - (parameterize ((%http-server-port %http-real-server-port)) - (thunk))))) + (let-values ((results + (parameterize ((%http-server-port %http-real-server-port)) + (thunk)))) + (unless keep-lingering? + ;; exit the server thread + (system-async-mark (lambda () (throw 'quit)) server)) + (apply values results))))) + + +(define* (call-with-http-server responses+data thunk #:key (keep-lingering? #false)) + "Call THUNK with an HTTP server running and returning RESPONSES+DATA +on HTTP requests. Each element of RESPONSES+DATA must be a tuple containing a +response and a string, or an HTTP response code and a string. + +The argument RESPONSES+DATA is thunked. As such, RESPONSES+DATA can use +%http-server-port. %http-server-port will be set to the port listened at. +It will be set for the dynamic extent of THUNK and RESPONSES+DATA. + +The server will exit after the last response. When KEEP-LINGERING? is false, +the server will also exit after THUNK returns." + (define (responses) + (map (match-lambda + (((? response? response) data) + (list response data)) + (((? integer? code) data) + (list (build-response #:code code + #:reason-phrase "Such is life") + data))) + (responses+data))) + (define (handle request body) + (match (responses) + (((response data) rest ...) + (set! responses (const rest)) + (values response data)))) + (call-with-http-server* handle thunk #:keep-lingering? keep-lingering? + #:last-response? + (lambda () (null? (responses))))) (define-syntax with-http-server (syntax-rules () ((_ responses+data body ...) - (call-with-http-server responses+data (lambda () body ...))))) + (call-with-http-server (lambda () responses+data) (lambda () body ...))))) + +(define-syntax with-http-server/keep-lingering + (syntax-rules () + ((_ responses+data body ...) + (call-with-http-server (lambda () responses+data) (lambda () body ...) + #:keep-lingering? #true)))) + +(define-syntax with-http-server* + (syntax-rules () + ((_ handle body ...) + (call-with-http-server* handle (lambda () body ...))))) ;;; http.scm ends here diff --git a/tests/challenge.scm b/tests/challenge.scm index fdd5fd238e..c9de33ed34 100644 --- a/tests/challenge.scm +++ b/tests/challenge.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2015, 2017, 2019, 2020 Ludovic Courtès +;;; Copyright © 2022 Maxime Devos ;;; ;;; This file is part of GNU Guix. ;;; @@ -198,17 +199,18 @@ value." (lambda (port) (write-file out2 port))))) (parameterize ((%http-server-port 9000)) - (with-http-server `((200 ,(make-narinfo item size1 hash1)) - (200 ,nar1)) - (parameterize ((%http-server-port 9001)) - (with-http-server `((200 ,(make-narinfo item size2 hash2)) - (200 ,nar2)) - (mlet* %store-monad ((urls -> (list (%local-url 9000) - (%local-url 9001))) - (reports (compare-contents (list item) - urls))) - (pk 'report reports) - (return (proc (car reports)))))))))))) + (with-http-server/keep-lingering + `((200 ,(make-narinfo item size1 hash1)) + (200 ,nar1)) + (parameterize ((%http-server-port 9001)) + (with-http-server/keep-lingering + `((200 ,(make-narinfo item size2 hash2)) + (200 ,nar2)) + (mlet* %store-monad ((urls -> (list (%local-url 9000) + (%local-url 9001))) + (reports (compare-contents (list item) + urls))) + (return (proc (car reports)))))))))))) (test-assertm "differing-files" (call-mismatch-test From patchwork Thu Jan 20 13:08:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: M X-Patchwork-Id: 36649 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 974D927BBEA; Thu, 20 Jan 2022 19:37:46 +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 5B62527BBE9 for ; Thu, 20 Jan 2022 19:37:46 +0000 (GMT) Received: from localhost ([::1]:47442 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nAdFh-00041w-Ha for patchwork@mira.cbaines.net; Thu, 20 Jan 2022 14:37:45 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50370) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nAXBb-00042T-3F for guix-patches@gnu.org; Thu, 20 Jan 2022 08:09:09 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:35557) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nAXBW-0004Kq-O9 for guix-patches@gnu.org; Thu, 20 Jan 2022 08:09:05 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nAXBW-0004qT-KA for guix-patches@gnu.org; Thu, 20 Jan 2022 08:09:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#53389] [PATCH 2/9] tests: Generalise %local-url. Resent-From: Maxime Devos Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 20 Jan 2022 13:09:02 +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.164268413718608 (code B ref 53389); Thu, 20 Jan 2022 13:09:02 +0000 Received: (at 53389) by debbugs.gnu.org; 20 Jan 2022 13:08:57 +0000 Received: from localhost ([127.0.0.1]:56690 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nAXBR-0004q2-IG for submit@debbugs.gnu.org; Thu, 20 Jan 2022 08:08:57 -0500 Received: from baptiste.telenet-ops.be ([195.130.132.51]:41992) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nAXBM-0004oq-06 for 53389@debbugs.gnu.org; Thu, 20 Jan 2022 08:08:53 -0500 Received: from localhost.localdomain ([IPv6:2a02:1811:8c09:9d00:3c5f:2eff:feb0:ba5a]) by baptiste.telenet-ops.be with bizsmtp id l18q2600H4UW6Th0118qNC; Thu, 20 Jan 2022 14:08:51 +0100 From: Maxime Devos Date: Thu, 20 Jan 2022 13:08:42 +0000 Message-Id: <20220120130849.292178-2-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=1642684131; bh=LLNXnyxA1ztljqORkcELY3W31H0beEK/duEXvgn61Iw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=E0uoBdnbuyrhKj5k9590w7uC/piTTB2xW82ykvNLASd9MNqenjI7pB1Zt1fpyfIUh TFPAW1XTrHTfNOTl1jk7BuUQrH6pFvZqQdLBCC0cX4OYNhMVUa1pnMQAfKBP23/ypY PBc1J5V35m/QR3daA+Cj3Qyoc8muDceZWEz5sj/QeaIdK+XfYcYMV7FdTfowrPEYgX aUMCLpsVzkKmfiUhXHh0y6WQvLS4SDjDco+AZJkelp88OpRhnaCPalr3sYprf0Bp+O HKAJhgFKUDj4Lh+238ZFFRF9K23ZHDB4MrD8akLrNSVkKJ6rBhf+XcT7WjnbtTBA/3 tcM8LWdv2jRJg== 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 * guix/tests/http.scm (%local-url): Extract most functionality to ... (%local-url*): ... here and don't hardcode "/foo/bar". --- guix/tests/http.scm | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/guix/tests/http.scm b/guix/tests/http.scm index c42b4b8176..2f65df4029 100644 --- a/guix/tests/http.scm +++ b/guix/tests/http.scm @@ -31,6 +31,7 @@ call-with-http-server call-with-http-server* %http-server-port + %local-url* %local-url)) ;;; Commentary: @@ -64,12 +65,14 @@ actually listened at (in case %http-server-port was 0)." (strerror err)) (values #f #f))))) -(define* (%local-url #:optional (port (%http-server-port))) +(define* (%local-url* resource #:optional (port (%http-server-port))) + ;; The URL to the resource named RESOURCE on the current HTTP server. (when (= port 0) (error "no web server is running!")) + (string-append "http://localhost:" (number->string port) resource)) +(define* (%local-url #:optional (port (%http-server-port))) ;; URL to use for 'home-page' tests. - (string-append "http://localhost:" (number->string port) - "/foo/bar")) + (%local-url* "/foo/bar" port)) (define* (call-with-http-server* handle thunk #:key (keep-lingering? #false) (last-response? (const #false))) From patchwork Thu Jan 20 13:08:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: M X-Patchwork-Id: 36644 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 8703927BBEA; Thu, 20 Jan 2022 18:03:45 +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 E570927BBE9 for ; Thu, 20 Jan 2022 18:03:44 +0000 (GMT) Received: from localhost ([::1]:43734 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nAbmh-0008C4-Ul for patchwork@mira.cbaines.net; Thu, 20 Jan 2022 13:03:43 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50372) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nAXBb-00042U-51 for guix-patches@gnu.org; Thu, 20 Jan 2022 08:09:09 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:35556) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nAXBW-0004Kp-Bu for guix-patches@gnu.org; Thu, 20 Jan 2022 08:09:05 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nAXBW-0004qL-7Q for guix-patches@gnu.org; Thu, 20 Jan 2022 08:09:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#53389] [PATCH 3/9] tests/minetest: Run a HTTP server instead of mocking. Resent-From: Maxime Devos Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 20 Jan 2022 13:09:02 +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.164268413518597 (code B ref 53389); Thu, 20 Jan 2022 13:09:02 +0000 Received: (at 53389) by debbugs.gnu.org; 20 Jan 2022 13:08:55 +0000 Received: from localhost ([127.0.0.1]:56688 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nAXBO-0004pT-3y for submit@debbugs.gnu.org; Thu, 20 Jan 2022 08:08:55 -0500 Received: from baptiste.telenet-ops.be ([195.130.132.51]:42012) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nAXBM-0004os-2W for 53389@debbugs.gnu.org; Thu, 20 Jan 2022 08:08:52 -0500 Received: from localhost.localdomain ([IPv6:2a02:1811:8c09:9d00:3c5f:2eff:feb0:ba5a]) by baptiste.telenet-ops.be with bizsmtp id l18q2600H4UW6Th0118rNH; Thu, 20 Jan 2022 14:08:51 +0100 From: Maxime Devos Date: Thu, 20 Jan 2022 13:08:43 +0000 Message-Id: <20220120130849.292178-3-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=1642684131; bh=QPzeQ1OR9EZOc2aVtRHjROXo3bd0aTaZ2ZBGRw7ZSYs=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=NTjbY3JQB4RQt/A1eKbhb2VQCScm6SA/XOl4J4v4SoSl+jK3qeh90V+cZ2oSsKd7q v+TPEVntNyNjsLIStnAOCOQ82Nkdv3fZpMFJntbaZJdIJYa4Ffx379sm7/aJOKaQvs tE5M0swg7T3dzO+oAexyw7Ph95724HtnOIDi4kc2L5sXqChwajUAoG1EMo11HER7mV 3Qyq85saw7PtDRa967qcDFmyj0ttuDdhFC+CjrGVVdYBLmpzlWSamCtH+C76jGaUe2 5MuM+QNR+I0mT0dLGUOixSVV+Edd20QUOfLj89Cr2OsyQdK5MBLhUFiyBHKc/sAVBS BB7ZnfAKibyoQ== 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 Fixes: Unfortunately, for some unknown reason (a limitation of (guix tests http) perhaps?), parallelism causes ECONNREFUSED in tests but not in the wild, so 'par-map' has to be mocked for now. * tests/minetest.scm (call-with-packages): Avoid mocking by running an actual HTTP server. * guix/import/minetest.scm (par-map): Allow mocking the Minetest importer's use of par-map without impacting anything else. Suggested-by: Ludovic Courtès --- guix/import/minetest.scm | 5 ++- tests/minetest.scm | 82 ++++++++++++++++++++++++---------------- 2 files changed, 53 insertions(+), 34 deletions(-) diff --git a/guix/import/minetest.scm b/guix/import/minetest.scm index 3b2cdcdcac..3eab5f703f 100644 --- a/guix/import/minetest.scm +++ b/guix/import/minetest.scm @@ -19,7 +19,6 @@ (define-module (guix import minetest) #:use-module (ice-9 match) #:use-module (ice-9 receive) - #:use-module (ice-9 threads) #:use-module (ice-9 hash-table) #:use-module (srfi srfi-1) #:use-module (srfi srfi-2) @@ -69,6 +68,10 @@ (define (delete-cr text) (string-delete #\cr text)) +;; Mocked by tests. +(define par-map (@ (ice-9 threads) par-map)) +(set! par-map par-map) + ;;; diff --git a/tests/minetest.scm b/tests/minetest.scm index cbb9e83889..bdd8bd0645 100644 --- a/tests/minetest.scm +++ b/tests/minetest.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2021 Maxime Devos +;;; Copyright © 2021, 2022 Maxime Devos ;;; ;;; This file is part of GNU Guix. ;;; @@ -23,6 +23,7 @@ #:use-module (guix import minetest) #:use-module (guix import utils) #:use-module (guix tests) + #:use-module (guix tests http) #:use-module (guix packages) #:use-module (guix git-download) #:use-module ((gnu packages minetest) @@ -30,6 +31,9 @@ #:use-module ((gnu packages base) #:select (hello)) #:use-module (json) + #:use-module (web request) + #:use-module (web uri) + #:use-module (web client) #:use-module (ice-9 match) #:use-module (srfi srfi-1) #:use-module (srfi srfi-26) @@ -152,7 +156,7 @@ (invalidate-memoization! minetest->guix-package) (define (scm->json-port scm) (open-input-string (scm->json-string scm))) - (define (handle-package url requested-author requested-name . rest) + (define (handle-package subresource requested-author requested-name . rest) (define relevant-argument-list (any (lambda (argument-list) (apply (lambda* (#:key (author "Author") (name "foo") @@ -164,14 +168,15 @@ argument-lists)) (when (not relevant-argument-list) (error "the package ~a/~a should be irrelevant, but ~a is fetched" - requested-author requested-name url)) - (scm->json-port - (apply (match rest - (("") make-package-json) - (("dependencies" "") make-dependencies-json) - (("releases" "") make-releases-json) - (_ (error "TODO ~a" rest))) - relevant-argument-list))) + requested-author requested-name subresource)) + (define json (apply + (match rest + (("") make-package-json) + (("dependencies" "") make-dependencies-json) + (("releases" "") make-releases-json) + (_ (error "TODO ~a" rest))) + relevant-argument-list)) + (values '() (lambda (port) (scm->json json port)))) (define (handle-mod-search sort) ;; Produce search results, sorted by SORT in descending order. (define arguments->key @@ -191,29 +196,40 @@ ("name" . ,name) ("type" . ,type)))) (define argument-list->json (cut apply arguments->json <>)) - (scm->json-port - (list->vector (filter-map argument-list->json sorted-argument-lists)))) - (mock ((guix http-client) http-fetch - (lambda* (url #:key headers) - (unless (string-prefix? "mock://api/packages/" url) - (error "the URL ~a should not be used" url)) - (define resource - (substring url (string-length "mock://api/packages/"))) - (define components (string-split resource #\/)) - (match components - ((author name . rest) - (apply handle-package url author name rest)) - (((? (cut string-prefix? "?type=mod&q=" <>) query)) - (handle-mod-search - (cond ((string-contains query "sort=score") "score") - ((string-contains query "sort=downloads") "downloads") - (#t (error "search query ~a has unknown sort key" - query))))) - (_ - (error "the URL ~a should have an author and name component" - url))))) - (parameterize ((%contentdb-api "mock://api/")) - (thunk)))) + (define json + (list->vector (filter-map argument-list->json sorted-argument-lists))) + (values '() + (lambda (port) (scm->json json port)))) + (with-http-server* + (lambda (request _) + (unless (eq? 'GET (request-method request)) + (error "wrong HTTP method")) + (define resource (uri-path (request-uri request))) + (unless (string-prefix? "/api/packages/" resource) + (error "the resource ~a should not be used" resource)) + (define subresource + (substring resource (string-length "/api/packages/"))) + (define components (string-split subresource #\/)) + (match components + ((author name . rest) + (apply handle-package subresource author name rest)) + (("") + (let ((query (uri-query (request-uri request)))) + (handle-mod-search + (cond ((string-contains query "sort=score") "score") + ((string-contains query "sort=downloads") "downloads") + (#t (error "search query ~a has unknown sort key" + query)))))) + (_ + (error "the resource ~a should have an author and name component" + resource)))) + (parameterize ((%contentdb-api + (format #f "http://localhost:~a/api/" (%http-server-port))) + (current-http-proxy #f)) + ;; XXX: for some unknown reason, parallelism causes ECONNREFUSED in + ;; tests but not in the wild. + (mock ((guix import minetest) par-map map) + (thunk))))) (define* (minetest->guix-package* #:key (author "Author") (name "foo") (sort %default-sort-key) From patchwork Thu Jan 20 13:08:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: M X-Patchwork-Id: 36647 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 CD5DB27BBEA; Thu, 20 Jan 2022 18:06:11 +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 765C627BBE9 for ; Thu, 20 Jan 2022 18:06:11 +0000 (GMT) Received: from localhost ([::1]:46374 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nAbp4-0001ZY-C4 for patchwork@mira.cbaines.net; Thu, 20 Jan 2022 13:06:10 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50806) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nAXCX-0004EJ-8s for guix-patches@gnu.org; Thu, 20 Jan 2022 08:10:06 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:35572) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nAXCV-0006SQ-9c for guix-patches@gnu.org; Thu, 20 Jan 2022 08:10:04 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nAXCV-0004t2-3j for guix-patches@gnu.org; Thu, 20 Jan 2022 08:10:03 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#53389] [PATCH 4/9] tests/import-github: Run a HTTP server instead of mocking. Resent-From: Maxime Devos Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 20 Jan 2022 13:10:03 +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.164268415818680 (code B ref 53389); Thu, 20 Jan 2022 13:10:03 +0000 Received: (at 53389) by debbugs.gnu.org; 20 Jan 2022 13:09:18 +0000 Received: from localhost ([127.0.0.1]:56698 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nAXBi-0004r3-EG for submit@debbugs.gnu.org; Thu, 20 Jan 2022 08:09:18 -0500 Received: from baptiste.telenet-ops.be ([195.130.132.51]:42030) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nAXBM-0004ou-4a for 53389@debbugs.gnu.org; Thu, 20 Jan 2022 08:08:54 -0500 Received: from localhost.localdomain ([IPv6:2a02:1811:8c09:9d00:3c5f:2eff:feb0:ba5a]) by baptiste.telenet-ops.be with bizsmtp id l18q2600H4UW6Th0118rNS; Thu, 20 Jan 2022 14:08:51 +0100 From: Maxime Devos Date: Thu, 20 Jan 2022 13:08:44 +0000 Message-Id: <20220120130849.292178-4-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=1642684131; bh=7sjWEY1uigWnXHXrDjfkJlPOHumdUX4dZusyrLHTkZg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Ffvx/R1utHKCoKPkb6Bo1W7CJunI7QRoHPTHtaC/yk9BJC0rClG2+00uTxDx29GkQ zmWQNA5jJHvut2NsjQ+IjJOWa736HQOEj9gF/03knHSiht5Fl7Tdfj8U462zi4EXn6 74TNG/ayya7Z3mRO0jgU0lHBWG3OekyvWdb1Bx3IAIL+QNgIDAfggfNsiM3tljHNCf evCZ7B3stf5hi18HYTh3NQRQe+2U/EyZptZD2GJx5ohA+yKVlczdOcj7MNXpTRXZYV yHJoVslx+imo22r3tV/lzHsVvT5uNKNla6H2jkogObA8Q2tlBuGQkhZV28gBep5ukf cR1y4Fcim69+w== 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 Fixes: * tests/import-github.scm (call-with-releases): Run a HTTP server instead of mocking. Suggested-by: Ludovic Courtès --- tests/import-github.scm | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/tests/import-github.scm b/tests/import-github.scm index 979a0fc12b..f6985fac55 100644 --- a/tests/import-github.scm +++ b/tests/import-github.scm @@ -24,30 +24,28 @@ #:use-module (guix http-client) #:use-module (guix import github) #:use-module (guix packages) - #:use-module (guix tests) + #:use-module (guix tests http) #:use-module (guix upstream) + #:use-module (web client) + #:use-module (web request) + #:use-module (web uri) #:use-module (ice-9 match)) (test-begin "github") (define (call-with-releases thunk tags releases) - (mock ((guix http-client) http-fetch - (lambda* (uri #:key headers) - (unless (string-prefix? "mock://" uri) - (error "the URI ~a should not be used" uri)) - (define components - (string-split (substring uri 8) #\/)) - (pk 'stuff components headers) - (define (scm->json-port scm) - (open-input-string (scm->json-string scm))) - (match components - (("repos" "foo" "foomatics" "releases") - (scm->json-port releases)) - (("repos" "foo" "foomatics" "tags") - (scm->json-port tags)) - (rest (error "TODO ~a" rest))))) - (parameterize ((%github-api "mock://")) - (thunk)))) + (with-http-server* + (lambda (request _) + (define resource (uri-path (request-uri request))) + (define components (string-split resource #\/)) + (define json (match components + (("" "repos" "foo" "foomatics" "releases") releases) + (("" "repos" "foo" "foomatics" "tags") tags) + (rest (error "TODO ~a" rest)))) + (values '() (lambda (port) (scm->json json port)))) + (parameterize ((%github-api (%local-url* "")) + (current-http-proxy #false)) + (thunk)))) ;; Copied from tests/minetest.scm (define (upstream-source->sexp upstream-source) From patchwork Thu Jan 20 13:08:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: M X-Patchwork-Id: 36653 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 0B8F127BBEA; Thu, 20 Jan 2022 19:47:10 +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 C9A8E27BBE9 for ; Thu, 20 Jan 2022 19:47:09 +0000 (GMT) Received: from localhost ([::1]:57612 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nAdOm-0002p8-VQ for patchwork@mira.cbaines.net; Thu, 20 Jan 2022 14:47:08 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50808) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nAXCX-0004EK-8R for guix-patches@gnu.org; Thu, 20 Jan 2022 08:10:06 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:35571) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nAXCV-0006R9-Pf for guix-patches@gnu.org; Thu, 20 Jan 2022 08:10:04 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nAXCU-0004su-Km for guix-patches@gnu.org; Thu, 20 Jan 2022 08:10:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#53389] [PATCH 5/9] tests/cpan: Do not hard code a HTTP port. Resent-From: Maxime Devos Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 20 Jan 2022 13:10:02 +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.164268415418668 (code B ref 53389); Thu, 20 Jan 2022 13:10:02 +0000 Received: (at 53389) by debbugs.gnu.org; 20 Jan 2022 13:09:14 +0000 Received: from localhost ([127.0.0.1]:56696 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nAXBe-0004qt-Gj for submit@debbugs.gnu.org; Thu, 20 Jan 2022 08:09:14 -0500 Received: from baptiste.telenet-ops.be ([195.130.132.51]:42052) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nAXBM-0004ow-8M for 53389@debbugs.gnu.org; Thu, 20 Jan 2022 08:08:53 -0500 Received: from localhost.localdomain ([IPv6:2a02:1811:8c09:9d00:3c5f:2eff:feb0:ba5a]) by baptiste.telenet-ops.be with bizsmtp id l18q2600H4UW6Th0118rNm; Thu, 20 Jan 2022 14:08:51 +0100 From: Maxime Devos Date: Thu, 20 Jan 2022 13:08:45 +0000 Message-Id: <20220120130849.292178-5-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=1642684131; bh=SheGLTTB6ghpUvw+WSRRLoqs0Y+Ppdu6McmAZUYtXx8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=GTOCvyYXBTgGw7OoSsgp+2G2w9ZgliXlehPKgfnhPYO0+EbmzNKDPCXLvPA8kC5YR 0vh0gk64bJQYYukV3OIocbMocaQxsQwYBgw/lLbySS4s4dUvVemCOsYfSkJZMWMoUj irUih8L4cW6Zb2iUlHVhq37zugNtC1A1MQu5Za32gYKOMCl839hDYSU7N4Ns+ZeeKG zTIjITSthZ5Cm3FNhg71ndtYrREIWdZIUswpzKtfT4yKg+KzXwTBVSJMY1okkklvLI g94858awE+BVRsEAjUoRkbuqyMpu/cXY1J7FZL2NotYzx/dekS4V3m6Z2sW/9KAFpI UUik27K5TDCkQ== 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 is a follow-up to commit 4aea90b1876179aab8d603a42533a6bdf97ccd3c. * tests/cpan.scm: Don't set %http-server-port. --- tests/cpan.scm | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/cpan.scm b/tests/cpan.scm index b4db9e60e4..89e6be0b4f 100644 --- a/tests/cpan.scm +++ b/tests/cpan.scm @@ -58,9 +58,6 @@ (define test-source "foobar") -;; Avoid collisions with other tests. -(%http-server-port 10400) - (test-begin "cpan") (test-assert "cpan->guix-package" From patchwork Thu Jan 20 13:08:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: M X-Patchwork-Id: 36648 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 2831A27BBEA; Thu, 20 Jan 2022 18:26:37 +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 E69C827BBE9 for ; Thu, 20 Jan 2022 18:26:36 +0000 (GMT) Received: from localhost ([::1]:48282 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nAc8p-0005cC-3p for patchwork@mira.cbaines.net; Thu, 20 Jan 2022 13:26:36 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50744) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nAXCU-0004EE-Vp for guix-patches@gnu.org; Thu, 20 Jan 2022 08:10:06 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:35570) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nAXCU-0006Pv-A1 for guix-patches@gnu.org; Thu, 20 Jan 2022 08:10:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nAXCU-0004sm-4N for guix-patches@gnu.org; Thu, 20 Jan 2022 08:10:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#53389] [PATCH 6/9] tests/lint: Do not assume the next port is free. Resent-From: Maxime Devos Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 20 Jan 2022 13:10:02 +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.164268415018658 (code B ref 53389); Thu, 20 Jan 2022 13:10:02 +0000 Received: (at 53389) by debbugs.gnu.org; 20 Jan 2022 13:09:10 +0000 Received: from localhost ([127.0.0.1]:56692 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nAXBR-0004q4-Pk for submit@debbugs.gnu.org; Thu, 20 Jan 2022 08:09:10 -0500 Received: from baptiste.telenet-ops.be ([195.130.132.51]:42064) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nAXBM-0004ox-Ds for 53389@debbugs.gnu.org; Thu, 20 Jan 2022 08:08:53 -0500 Received: from localhost.localdomain ([IPv6:2a02:1811:8c09:9d00:3c5f:2eff:feb0:ba5a]) by baptiste.telenet-ops.be with bizsmtp id l18q2600H4UW6Th0118rNs; Thu, 20 Jan 2022 14:08:51 +0100 From: Maxime Devos Date: Thu, 20 Jan 2022 13:08:46 +0000 Message-Id: <20220120130849.292178-6-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=1642684131; bh=i9YgSMUurJM9INaaW7UyPuvAQFGVrh2kXwxrlz1kUxU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=h7750ajniiJSHdPPzjQOQ9hBgpU8hQmmziZhiKnWaevOENPMxVBmlCKqer9Nuytu9 n3d7lLupjudwm2kJtCoGL+vFVug/m+d+CeUL0P6Ne8919k6uEgOXC1BxyMlIVGDQX+ Rk3u2nU8+dp2Zu9HTLKCDLhavyNdyGQt5Pt0W6H/SIcquWjtkPZRkqdzIxLDPPjIwq x/0QrcggB4X2NEiL838YCntdvewt3WH1nsFfnbrFtb/zMQjHNvVwNjagVWC0MpXl5v ZIiXkTIX2shK/bks0SQQ/q5iMjLAZJK9/l6BLR3fJY17qRy2CXxhSyy4iw67A3RW53 dVVRvfKVAiLQw== 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 is a follow-up to commit 4aea90b1876179aab8d603a42533a6bdf97ccd3c. * tests/lint.scm ("source: 404 and 200"): Let (guix tests http) choose the ports to bind to. --- tests/lint.scm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/lint.scm b/tests/lint.scm index 76c2a70b3a..00d494bd19 100644 --- a/tests/lint.scm +++ b/tests/lint.scm @@ -987,7 +987,7 @@ '() (with-http-server `((404 ,%long-string)) (let ((bad-url (%local-url))) - (parameterize ((%http-server-port (+ 1 (%http-server-port)))) + (parameterize ((%http-server-port 0)) (with-http-server `((200 ,%long-string)) (let ((pkg (package (inherit (dummy-package "x")) From patchwork Thu Jan 20 13:08:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: M X-Patchwork-Id: 36652 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 59C2027BBEA; Thu, 20 Jan 2022 19:46:34 +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 B60FE27BBE9 for ; Thu, 20 Jan 2022 19:46:33 +0000 (GMT) Received: from localhost ([::1]:56758 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nAdOC-00029O-Pg for patchwork@mira.cbaines.net; Thu, 20 Jan 2022 14:46:32 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50802) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nAXCX-0004EH-8r for guix-patches@gnu.org; Thu, 20 Jan 2022 08:10:06 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:35574) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nAXCW-0006T3-6g for guix-patches@gnu.org; Thu, 20 Jan 2022 08:10:04 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nAXCW-0004tH-0k for guix-patches@gnu.org; Thu, 20 Jan 2022 08:10:04 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#53389] [PATCH 7/9] tests: Allow checking the URI of a HTTP request. Resent-From: Maxime Devos Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 20 Jan 2022 13:10:03 +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.164268415918695 (code B ref 53389); Thu, 20 Jan 2022 13:10:03 +0000 Received: (at 53389) by debbugs.gnu.org; 20 Jan 2022 13:09:19 +0000 Received: from localhost ([127.0.0.1]:56702 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nAXBm-0004rM-O7 for submit@debbugs.gnu.org; Thu, 20 Jan 2022 08:09:19 -0500 Received: from baptiste.telenet-ops.be ([195.130.132.51]:42074) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nAXBM-0004oy-Kt for 53389@debbugs.gnu.org; Thu, 20 Jan 2022 08:08:54 -0500 Received: from localhost.localdomain ([IPv6:2a02:1811:8c09:9d00:3c5f:2eff:feb0:ba5a]) by baptiste.telenet-ops.be with bizsmtp id l18q2600H4UW6Th0118rNy; Thu, 20 Jan 2022 14:08:52 +0100 From: Maxime Devos Date: Thu, 20 Jan 2022 13:08:47 +0000 Message-Id: <20220120130849.292178-7-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=qXHokLrX3UhbhK5gTp4pjeibyVHhQkw8mgeu4FprdvI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=iLbuSuI+tlgqAs2dSPW9TEL1ZAVxHeXW6ERMQ25+EMz0xNLPqaHzwunTKHbbVkUQZ 9YlY7WhcCTBxuLqm3TE31LjXtn4JePGVnbyOp3Nmry7b87ykxSL2xhPtpi1LN//WzA 0kL+xoMUJDjUXx/dqg/46PdDJkeiDzDrODUzfJoYFZDM5lvYeOJ45ZK9tAYpgBUG4s kCzOqEWH0DM4Xyb+RwtuOonBLr0yzNtYv6L+7YrEj78sCNqGE+uNgAAOHpniB3NZy8 GrGWOOi/QvCYdl7cdl9wTimzDIrNC3PDt+DFOB3lS3fdSo76MiR/sGX5r9/UxAgNuH Nyl5OHZWLtQSQ== 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 * guix/tests/http.scm (call-with-http-server): Thunk RESPONSES+DATA. [maybe-uri?]: New procedure. [sanitize-response+data]: New procedure extracted from the definition of 'responses', support triples containing a URI. [responses]: Thunk. [handle]: Verify the URI. Adjust for thunking. (with-http-server): Adjust for thunking. --- guix/tests/http.scm | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/guix/tests/http.scm b/guix/tests/http.scm index 2f65df4029..6af1948211 100644 --- a/guix/tests/http.scm +++ b/guix/tests/http.scm @@ -21,7 +21,9 @@ #:use-module (ice-9 threads) #:use-module (web server) #:use-module (web server http) + #:use-module (web request) #:use-module (web response) + #:use-module (web uri) #:use-module (srfi srfi-11) #:use-module (srfi srfi-39) #:use-module (ice-9 match) @@ -144,7 +146,10 @@ It will also quit if LAST-RESPONSE? returns true." (define* (call-with-http-server responses+data thunk #:key (keep-lingering? #false)) "Call THUNK with an HTTP server running and returning RESPONSES+DATA on HTTP requests. Each element of RESPONSES+DATA must be a tuple containing a -response and a string, or an HTTP response code and a string. +response and a string, or an HTTP response code and a string. Alternatively, +the elements can triples with the URI path (including the query, if any) +as the first part of the triple. In that case, the request URI is verified +against the URI in RESPONSES+DATA. The argument RESPONSES+DATA is thunked. As such, RESPONSES+DATA can use %http-server-port. %http-server-port will be set to the port listened at. @@ -152,18 +157,28 @@ It will be set for the dynamic extent of THUNK and RESPONSES+DATA. The server will exit after the last response. When KEEP-LINGERING? is false, the server will also exit after THUNK returns." + (define (maybe-uri? object) + (or (string? object) (eq? object 'any))) + (define (sanitize-response+data response+data) + (match response+data + ((response data) + (sanitize-response+data (list 'any response data))) + (((? maybe-uri? uri) (? response? response) data) + (list uri response data)) + (((? maybe-uri? uri) (? integer? code) data) + (list uri + (build-response #:code code + #:reason-phrase "Such is life") + data)))) (define (responses) - (map (match-lambda - (((? response? response) data) - (list response data)) - (((? integer? code) data) - (list (build-response #:code code - #:reason-phrase "Such is life") - data))) - (responses+data))) + (map sanitize-response+data (responses+data))) (define (handle request body) (match (responses) - (((response data) rest ...) + (((uri response data) rest ...) + (unless (or (eq? uri 'any) + (string=? uri (uri->string (request-uri request)))) + (error "this URI should not be contacted!" + (request-uri request))) (set! responses (const rest)) (values response data)))) (call-with-http-server* handle thunk #:keep-lingering? keep-lingering? 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)))))) From patchwork Thu Jan 20 13:08:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: M X-Patchwork-Id: 36645 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 D1F5427BBEA; Thu, 20 Jan 2022 18:04:03 +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 82CD227BBE9 for ; Thu, 20 Jan 2022 18:04:03 +0000 (GMT) Received: from localhost ([::1]:44618 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nAbn0-0000Lt-LZ for patchwork@mira.cbaines.net; Thu, 20 Jan 2022 13:04:02 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50810) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nAXCX-0004EL-At for guix-patches@gnu.org; Thu, 20 Jan 2022 08:10:07 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:35575) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nAXCW-0006UP-Ks for guix-patches@gnu.org; Thu, 20 Jan 2022 08:10:04 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nAXCW-0004tO-GA for guix-patches@gnu.org; Thu, 20 Jan 2022 08:10:04 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#53389] [PATCH 9/9] tests/challenge: Do not hard code HTTP ports. 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.164268415918702 (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]:56704 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nAXBn-0004rU-2u for submit@debbugs.gnu.org; Thu, 20 Jan 2022 08:09:19 -0500 Received: from baptiste.telenet-ops.be ([195.130.132.51]:42104) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nAXBN-0004p1-0b 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 l18q2600H4UW6Th0118sP7; Thu, 20 Jan 2022 14:08:52 +0100 From: Maxime Devos Date: Thu, 20 Jan 2022 13:08:49 +0000 Message-Id: <20220120130849.292178-9-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=QOnbiZkDGAC6xGcsNPZP8KQQOf8C713hLl+2UHDyN8s=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=hHzl58paTOa3m80X/OlSozvUm7INhCPR2YKK18EdRzb+nKZH9giYVNwx0eXN8ykkT PYhG4PGu/tO1aKD7s01s3TbYT0mYRcES2ThGYCelh9ev2zTKINuJNOXQh4ORrf6nAu rdd8jio+eKi+jfMsY7bjKFDgP8YzmNH4SGDcOl9QCGEMCsNFNmhoHieLxt6DJjpz6Y /DrIyh70V6896YJsPr4MLfoG2H93XyN2IK908U8yPpmwX3acCWmJbkvMwaxGKZxVLw DxWgp0Q4iYtbM/WiMkr/J52C4SiRumvu8CscOqk2vB7RgoVbv+Mt85JlmsyyPMXgFb rFpMkta8ZJJ6Q== 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 is a follow-up to commit 4aea90b1876179aab8d603a42533a6bdf97ccd3c. * tests/challenge.scm (call-mismatch-test): Set %http-server-port to 0 instead of 9001. Remove the first parametrisation of %http-server-port as it was unnecessary. Adjust calls to %local-url to use the right port number. --- tests/challenge.scm | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/challenge.scm b/tests/challenge.scm index c9de33ed34..2807b4fa00 100644 --- a/tests/challenge.scm +++ b/tests/challenge.scm @@ -198,16 +198,16 @@ value." (nar2 -> (call-with-bytevector-output-port (lambda (port) (write-file out2 port))))) - (parameterize ((%http-server-port 9000)) - (with-http-server/keep-lingering - `((200 ,(make-narinfo item size1 hash1)) - (200 ,nar1)) - (parameterize ((%http-server-port 9001)) + (with-http-server/keep-lingering + `((200 ,(make-narinfo item size1 hash1)) + (200 ,nar1)) + (let ((port1 (%http-server-port))) + (parameterize ((%http-server-port 0)) (with-http-server/keep-lingering `((200 ,(make-narinfo item size2 hash2)) (200 ,nar2)) - (mlet* %store-monad ((urls -> (list (%local-url 9000) - (%local-url 9001))) + (mlet* %store-monad ((urls -> (list (%local-url port1) + (%local-url))) (reports (compare-contents (list item) urls))) (return (proc (car reports))))))))))))