From debbugs-submit-bounces@debbugs.gnu.org Mon Feb 07 04:53:59 2022 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: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: Maxime Devos Subject: Re: bug#53389: [PATCH 0/9] Replace some mocking with with-http-server*, avoid hardcoding ports, 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 Content-Type: multipart/mixed; boundary="=-=-=" 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-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: 53389 Cc: 53389@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi, Maxime Devos skribis: > Ludovic Court=C3=A8s schreef op za 22-01-2022 om 17:48 [+0100]: >> > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (unless keep-lingering? >> > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ;; exit the se= rver thread >> > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (system-async-= mark (lambda () (throw 'quit)) server)) >>=20 >> When do we need =E2=80=98keep-lingering?=E2=80=99? > > 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: --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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 =C2=A9 2015, 2017, 2019, 2020 Ludovic Court=C3=A8s +;;; Copyright =C2=A9 2015, 2017, 2019, 2020, 2022 Ludovic Court=C3=A8s ;;; ;;; This file is part of GNU Guix. ;;; @@ -57,6 +57,17 @@ (define-syntax with-derivation-narinfo* (lambda () body ...) hash)))) =20 +(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") =20 @@ -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) =20 ;;; Local Variables: ;;; eval: (put 'with-derivation-narinfo* 'scheme-indent-function 2) +;;; eval: (put 'with-http-server* 'scheme-indent-function 1) ;;; End: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable That way we don=E2=80=99t need to keep the lingering variant in (guix tests http). WDYT? Ludo=E2=80=99. --=-=-=--