From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id 8NxLD6E17GG0BwEAgWs5BA (envelope-from ) for ; Sat, 22 Jan 2022 17:49:37 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id 8DT8C6E17GFZTwEAauVa8A (envelope-from ) for ; Sat, 22 Jan 2022 17:49:37 +0100 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id E15923A41E for ; Sat, 22 Jan 2022 17:49:36 +0100 (CET) Received: from localhost ([::1]:58220 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nBJa3-0006jN-Vc for larch@yhetil.org; Sat, 22 Jan 2022 11:49:35 -0500 Received: from eggs.gnu.org ([209.51.188.92]:46350) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nBJZc-0006jF-Oc for guix-patches@gnu.org; Sat, 22 Jan 2022 11:49:08 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:44866) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nBJZW-0004cv-GZ for guix-patches@gnu.org; Sat, 22 Jan 2022 11:49:08 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nBJZW-0008WF-Bv for guix-patches@gnu.org; Sat, 22 Jan 2022 11:49:02 -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: Sat, 22 Jan 2022 16:49: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: Maxime Devos Cc: 53389@debbugs.gnu.org Received: via spool by 53389-submit@debbugs.gnu.org id=B53389.164287012432718 (code B ref 53389); Sat, 22 Jan 2022 16:49:02 +0000 Received: (at 53389) by debbugs.gnu.org; 22 Jan 2022 16:48:44 +0000 Received: from localhost ([127.0.0.1]:37769 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nBJZD-0008Vd-Tp for submit@debbugs.gnu.org; Sat, 22 Jan 2022 11:48:44 -0500 Received: from hera.aquilenet.fr ([185.233.100.1]:56940) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nBJZB-0008VQ-EL for 53389@debbugs.gnu.org; Sat, 22 Jan 2022 11:48:42 -0500 Received: from localhost (localhost [127.0.0.1]) by hera.aquilenet.fr (Postfix) with ESMTP id F2A2E25A; Sat, 22 Jan 2022 17:48:34 +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 Mz5GYKnSM7m6; Sat, 22 Jan 2022 17:48:33 +0100 (CET) Received: from ribbon (91-160-117-201.subs.proxad.net [91.160.117.201]) by hera.aquilenet.fr (Postfix) with ESMTPSA id 5538FF8; Sat, 22 Jan 2022 17:48:33 +0100 (CET) From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: <6b1c1d98514b2547907a81a04c1241d9b865d6fa.camel@telenet.be> <20220120130849.292178-1-maximedevos@telenet.be> Date: Sat, 22 Jan 2022 17:48:32 +0100 In-Reply-To: <20220120130849.292178-1-maximedevos@telenet.be> (Maxime Devos's message of "Thu, 20 Jan 2022 13:08:41 +0000") Message-ID: <87lez7zpgf.fsf_-_@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spamd-Bar: / X-Rspamd-Server: hera X-Rspamd-Queue-Id: F2A2E25A X-Spamd-Result: default: False [-0.10 / 15.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; RCPT_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; 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+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1642870176; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post; bh=NyumDNDyIok3JU1CAMVgBFt5a26sGxdHipcmTk5t8No=; b=DXT84gKSa/ZxtotAdFSU6FiDdxE24VipwOndpSW5qBTto7zdLvs9t9rTwX3FHLe+a1BtTJ lA6sgZ/zYT0nxJS2eoA2D/zR2FuTHa+GJMmC0p9qHFAW5czdhKvpRtx2IELpQ2EGAzjg9o QJnO0OSR+uZueBiz1rqmlQlMdrQj8NtlsBkaWSCvHZPXEy3h2fE/EDYWVulhbloPrsIJjn dgQPQLXRXCQCDL44vJYS06td70Z/9QMZ4MEJSsAXxlCkNmCKwQIf2MHHwqROlEa0CBDHJd c08xlGW5LIYAclXjmdalepstpOFwtOdhclgTd0S2Y84dmHh1nXFah8p66QuM1Q== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1642870176; a=rsa-sha256; cv=none; b=oHDRVNM5ldFSGXPLK1yGnUJxDNMHjJhKuwH/Z8WLl6TrsK/s2MGD0pcFUxzn6NLk8c9Ze8 e0EzO1Qgwt2DcufzXAnn8Kg15RzI13Wl9eMIrq7QNoV7GZwUc18ksM46bBMt5126k/sDt5 zjyP0ATYKoXEzXbL7bquVJL7BnBwEcLRYVEAX4sdEAbQ2CUK9YG3ufINR9ELO3oeB2tdGb 9NcFaPQa+TfOhlwmy0ujuBvez/yBBT10Z6L8lJboWRPOhAmtiM5lmWxb4OeKj9MQFfs5U/ 9SMtqo1r9I2e2yQQdPb2qbjaBZVGg1FBj69ufmw99ADtYDiRCnDCQmtAHxoXCA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -3.13 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: E15923A41E X-Spam-Score: -3.13 X-Migadu-Scanner: scn1.migadu.com X-TUID: StZuS4ZppCDn Hi Maxime, Maxime Devos skribis: > 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'. [...] > #: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)) My first reaction was: have we gone overboard? :-) Since it=E2=80=99s an internal module and a test helper, I=E2=80=99m in fav= or of keeping it as simple as possible. Can we keep a single =E2=80=98with-http-server= =E2=80=99 form that would cover all cases? We can update existing tests to include the expected URL path (or a wildcard, if needed), instead of keeping several forms. We don=E2=80=99t n= eed to worry about backward compatibility at all. > + (unless keep-lingering? > + ;; exit the server thread > + (system-async-mark (lambda () (throw 'quit)) server)) When do we need =E2=80=98keep-lingering?=E2=80=99? So far, all uses of =E2=80=98with-http-server=E2=80=99 expected that the server would quit once= the last response has been sent. It would be nice if we could keep it that way. > + (apply values results))))) > + > + > +(define* (call-with-http-server responses+data thunk #:key (keep-lingeri= ng? #false)) > + "Call THUNK with an HTTP server running and returning RESPONSES+DATA > +on HTTP requests. Each element of RESPONSES+DATA must be a tuple contai= ning 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 a= t. > +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 f= alse, > +the server will also exit after THUNK returns." Within tests, it would be nice if we could avoid using the =E2=80=98thunk= =E2=80=99 form and instead always use the declarative form (list of URL path/response code/response body). That should make the tests more concise and readable. Or are there new uses where the declarative form is insufficiently expressive? Thanks, Ludo=E2=80=99.