From patchwork Mon Feb 7 09:53:48 2022 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: 37053 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 D1C3A27BBEA; Mon, 7 Feb 2022 10:06:56 +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.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, SPF_HELO_PASS 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 67E6427BBE9 for ; Mon, 7 Feb 2022 10:06:56 +0000 (GMT) Received: from localhost ([::1]:49084 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nH0v9-0001EC-Do for patchwork@mira.cbaines.net; Mon, 07 Feb 2022 05:06:55 -0500 Received: from eggs.gnu.org ([209.51.188.92]:49120) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nH0ig-00018m-0R for guix-patches@gnu.org; Mon, 07 Feb 2022 04:54:03 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:47149) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nH0if-000281-N4 for guix-patches@gnu.org; Mon, 07 Feb 2022 04:54:01 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nH0if-00049h-Mo for guix-patches@gnu.org; Mon, 07 Feb 2022 04:54:01 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#53389] [PATCH 0/9] Replace some mocking with with-http-server*, avoid hardcoding ports, Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 07 Feb 2022 09:54:01 +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: Maxime Devos Cc: 53389@debbugs.gnu.org Received: via spool by 53389-submit@debbugs.gnu.org id=B53389.164422763915965 (code B ref 53389); Mon, 07 Feb 2022 09:54:01 +0000 Received: (at 53389) by debbugs.gnu.org; 7 Feb 2022 09:53:59 +0000 Received: from localhost ([127.0.0.1]:41046 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nH0ic-00049R-Rq for submit@debbugs.gnu.org; Mon, 07 Feb 2022 04:53:59 -0500 Received: from hera.aquilenet.fr ([185.233.100.1]:55960) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nH0ia-00049D-Ul for 53389@debbugs.gnu.org; Mon, 07 Feb 2022 04:53:57 -0500 Received: from localhost (localhost [127.0.0.1]) by hera.aquilenet.fr (Postfix) with ESMTP id 64C7A2C1; Mon, 7 Feb 2022 10:53:50 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at aquilenet.fr Received: from hera.aquilenet.fr ([127.0.0.1]) by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 6Qh9hEwflKRz; Mon, 7 Feb 2022 10:53:49 +0100 (CET) Received: from ribbon (91-160-117-201.subs.proxad.net [91.160.117.201]) by hera.aquilenet.fr (Postfix) with ESMTPSA id 359DB1A0; Mon, 7 Feb 2022 10:53:49 +0100 (CET) From: Ludovic =?utf-8?q?Court=C3=A8s?= References: <6b1c1d98514b2547907a81a04c1241d9b865d6fa.camel@telenet.be> <20220120130849.292178-1-maximedevos@telenet.be> <87lez7zpgf.fsf_-_@gnu.org> <687d96c300852e684422de877cd87769daae7ccd.camel@telenet.be> Date: Mon, 07 Feb 2022 10:53:48 +0100 In-Reply-To: <687d96c300852e684422de877cd87769daae7ccd.camel@telenet.be> (Maxime Devos's message of "Sat, 22 Jan 2022 19:55:30 +0100") Message-ID: <87r18fdmtv.fsf_-_@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-Spamd-Bar: / Authentication-Results: hera.aquilenet.fr; none X-Rspamd-Server: hera X-Rspamd-Queue-Id: 64C7A2C1 X-Spamd-Result: default: False [-0.10 / 15.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCPT_COUNT_TWO(0.00)[2]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[multipart/mixed,text/plain,text/x-patch]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+,1:+,2:+,3:+]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; MID_RHS_MATCH_FROM(0.00)[] 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 Hi, Maxime Devos skribis: > Ludovic Courtès schreef op za 22-01-2022 om 17:48 [+0100]: >> > +        (unless keep-lingering? >> > +          ;; exit the server thread >> > +          (system-async-mark (lambda () (throw 'quit)) server)) >> >> When do we need ‘keep-lingering?’? > > In tests/challenge.scm (call-mismatch-test), due to how the store monad > work, the thunk technically returns (*) before we are done with the > querying the server. Perhaps this can be resolved with sufficient > monadology, but I don't quite see how. > > (*) a monadic value. How about fixing it locally like this: That way we don’t need to keep the lingering variant in (guix tests http). WDYT? Ludo’. diff --git a/tests/challenge.scm b/tests/challenge.scm index fdd5fd238e..0b44ed7d21 100644 --- a/tests/challenge.scm +++ b/tests/challenge.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2015, 2017, 2019, 2020 Ludovic Courtès +;;; Copyright © 2015, 2017, 2019, 2020, 2022 Ludovic Courtès ;;; ;;; This file is part of GNU Guix. ;;; @@ -57,6 +57,17 @@ (define-syntax with-derivation-narinfo* (lambda () body ...) hash)))) +(define-syntax-rule (with-http-server* arguments body ...) + ;; Like 'with-http-server' but for use in a monadic context. + (let ((port (%http-server-port))) + (lambda (store) + (values (parameterize ((%http-server-port port)) + (call-with-http-server arguments + (lambda () + (run-with-store store + body ...)))) + store)))) + (test-begin "challenge") @@ -198,11 +209,11 @@ (define (call-mismatch-test proc) (lambda (port) (write-file out2 port))))) (parameterize ((%http-server-port 9000)) - (with-http-server `((200 ,(make-narinfo item size1 hash1)) - (200 ,nar1)) + (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)) + (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) @@ -238,4 +249,5 @@ (define (call-mismatch-test proc) ;;; Local Variables: ;;; eval: (put 'with-derivation-narinfo* 'scheme-indent-function 2) +;;; eval: (put 'with-http-server* 'scheme-indent-function 1) ;;; End: