GNU bug report logs - #53389
[PATCH 0/9] Replace some mocking with with-http-server*, avoid hardcoding ports,

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: guix-patches; Reported by: Maxime Devos <maximedevos@HIDDEN>; Keywords: patch; dated Thu, 20 Jan 2022 13:01:02 UTC; Maintainer for guix-patches is guix-patches@HIDDEN.

Message received at 53389 <at> debbugs.gnu.org:


Received: (at 53389) by debbugs.gnu.org; 21 Apr 2022 15:20:35 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Apr 21 11:20:35 2022
Received: from localhost ([127.0.0.1]:50765 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1nhYbj-0000r0-Bg
	for submit <at> debbugs.gnu.org; Thu, 21 Apr 2022 11:20:35 -0400
Received: from albert.telenet-ops.be ([195.130.137.90]:44258)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <maximedevos@HIDDEN>) id 1nhYbh-0000qq-03
 for 53389 <at> debbugs.gnu.org; Thu, 21 Apr 2022 11:20:33 -0400
Received: from ptr-bvsjgyhxw7psv60dyze.18120a2.ip6.access.telenet.be
 ([IPv6:2a02:1811:8c09:9d00:3c5f:2eff:feb0:ba5a])
 by albert.telenet-ops.be with bizsmtp
 id MTLX2700A4UW6Th06TLXNU; Thu, 21 Apr 2022 17:20:31 +0200
Message-ID: <e64393ed6671ccbc3176ebfdecdf9e85f0da4974.camel@HIDDEN>
Subject: [PATCH v2 0/25] Replace some mocking with with-http-server*, avoid
 harcoding ports.
From: Maxime Devos <maximedevos@HIDDEN>
To: 53389 <at> debbugs.gnu.org
Date: Thu, 21 Apr 2022 17:20:25 +0200
Content-Type: multipart/signed; micalg="pgp-sha512";
 protocol="application/pgp-signature"; boundary="=-nb+0Zunks4Cjo5g6uyF1"
User-Agent: Evolution 3.38.3-1 
MIME-Version: 1.0
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telenet.be; s=r22;
 t=1650554431; bh=wY9gepbTO+Jlj519E1HglWq3hDubICsvh/GOdqwwZa0=;
 h=Subject:From:To:Cc:Date;
 b=SH/yhPz0Bx9iiOLlCHxHTVVCbsfmHQ3gyXcsVCCFvCYEhwwIh5Mws7mvx8eolIEl1
 PRm5xx5qIYtmATf+R7+0/QNPFY6y0/56WW7yAU/7nHeAU9IT41t5bQ4gSNwMHpPrik
 z1/Fvbbyg8ZrWGajVdZgLNpQRVlxRwGaplIZZ2pKYxCDBiiqq9rpqROgdFfSKcIS3b
 vyqdIjeDtExd/WsNoHHN4lQDkEpKvrBJBFcBXJ6NzEzGYxpV/FP0n9EnBWMfIaX4OP
 15yb2S1ZcDeA+L0lXoVf4sxUXEYuvVSpzp35PmohpOKBbauiPDeaMO8NK9FXn2ZW9s
 jK+LRCk2z3hTQ==
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 53389
Cc: Ludovic =?ISO-8859-1?Q?Court=E8s?= <ludo@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)


--=-nb+0Zunks4Cjo5g6uyF1
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Hi,

Changes since the v1:

 * Simplification: keep-lingering? has been removed.  For
   tests/challenge, I have taken the proposed with-http-server*,
   renamed it to with-http-server/monadic to avoid confusion and
   removed its hardcoding of ports.

 * Simplification:=C2=A0the semantics of with-http-server*/with-http-server
   are now a bit simpler: it _always_ chooses a fresh port, regardless
   of whether %http-server-port was already set.

 * Simplification: %local-url and %local-url* have=C2=A0been unified to a
   single one-optional-argument procedure.

 * Simplification: no tests use %http-server-port anymore.  Instead,
   they directly use %local-url. =20

 * YMMV: %http-server-port is now a lexical variable instead of a dynamic
   parameter, using syntax parameters.

 * The =E2=80=98home-page: Connection refused=E2=80=99 test does not hardco=
de 9999 anymore.
   Instead, 'with-unreachable-http-server' binds a fresh port (claiming it)
   but does not listen to it (causing connections to be refused).

 * Simplification: with-http-server only supports a single form now:
   a list of (uri response-code response) triples.  The URI must now
   always be set!  Existing tests have been adjusted appropriately.

What would be preferred:

 * The 2827e9f8a5834be65f8709a595ec2d870fd39271 commit from https://notabug=
.org/maximed/scheme-gnunet/
   (https://notabug.org/maximed/guix-gnunet/commit/2827e9f8a5834be65f8709a5=
95ec2d870fd39271)
 * or a bunch of v2 mails sent with "git send-email?

Greetings,
Maxime.

--=-nb+0Zunks4Cjo5g6uyF1
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: This is a digitally signed message part
Content-Transfer-Encoding: 7bit

-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYmF2ORccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7uhUAP4uFHWZLEsKMI+YJArIBYUVWxU1
AsHIZzv9Nov1CefqzAD+OD/f4UKiI2aCnyp/JZ69WYyoCV8KpCT1HLZCageM4gM=
=cjah
-----END PGP SIGNATURE-----

--=-nb+0Zunks4Cjo5g6uyF1--





Information forwarded to guix-patches@HIDDEN:
bug#53389; Package guix-patches. Full text available.

Message received at 53389 <at> debbugs.gnu.org:


Received: (at 53389) by debbugs.gnu.org; 12 Apr 2022 19:46:55 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Apr 12 15:46:55 2022
Received: from localhost ([127.0.0.1]:50146 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1neMTX-0000GA-JE
	for submit <at> debbugs.gnu.org; Tue, 12 Apr 2022 15:46:55 -0400
Received: from albert.telenet-ops.be ([195.130.137.90]:56290)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <maximedevos@HIDDEN>) id 1neMTV-0000G0-DD
 for 53389 <at> debbugs.gnu.org; Tue, 12 Apr 2022 15:46:54 -0400
Received: from ptr-bvsjgyhxw7psv60dyze.18120a2.ip6.access.telenet.be
 ([IPv6:2a02:1811:8c09:9d00:3c5f:2eff:feb0:ba5a])
 by albert.telenet-ops.be with bizsmtp
 id Hvmr270074UW6Th06vmrrh; Tue, 12 Apr 2022 21:46:51 +0200
Message-ID: <f868253f4de7842ef74a3b5ee540ce7c49829291.camel@HIDDEN>
Subject: Re: [PATCH 0/9] Replace some mocking with with-http-server
From: Maxime Devos <maximedevos@HIDDEN>
To: 53389 <at> debbugs.gnu.org
Date: Tue, 12 Apr 2022 21:46:46 +0200
Content-Type: multipart/signed; micalg="pgp-sha512";
 protocol="application/pgp-signature"; boundary="=-yjgHpS1Ua9cL9sdBGj2c"
User-Agent: Evolution 3.38.3-1 
MIME-Version: 1.0
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telenet.be; s=r22;
 t=1649792811; bh=Q6Q223+a/Oj2gZpMFV1x4DWi0ZaXHnMLkr6acdndlwM=;
 h=Subject:From:To:Date;
 b=nR16ovm0LE/ewT8v5CoCADnCGnPHRQU4XkQiX9Z5Ukn9/O4rnfBqVL41hdhaFXJJn
 Dqp+ZRmOKXrDhqhVTyJp2ghTXtLbGGMMhFPa3u5dX0agSc+HjnWBcdsdviXuFHHkrZ
 r3YZCmV4FNsCp5S/BYY5t+K2aQUBpixs3Pvl8p43koCEBAbiU8hdaLkiq0ulG24l/o
 A9cwrkkT7jEdTQqYyh792OeuHTxUzNAo6v7sDK+AG/VjQHt4Q+YlhnEtiTAj4OSX7S
 C+ezTo0pUfiF9vPd+vkI1NW7rKWV5QpzXEWHqrMIDnap0Hamxvph4FAIU9xSAgJ+RT
 HuuUhRfxuTygQ==
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 53389
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)


--=-yjgHpS1Ua9cL9sdBGj2c
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Hi,

Status update for this patch series:

  * Rebased.
  * Fixed a typo in docstrings.
  * Worked-around a (guix import github) quasi-bug / Guile http server
    limitation / http-fetch limitation involving connection reuse.
  * keep-lingering has been been eliminated in favour of Ludo's
    with-http-server* (renamed to with-http-server/monadic to avoid
    confusion with the other with-http-server*).  Code is a bit simpler
    now!

    It has also been tweaked to automatically allocate ports.

To do:

  * Look into if further simplification is possible
  * Adjust remaining tests to use the form explicitly mentioning
    the URL
  * Maybe remove the URL-less form?

Current patch series can be found at
<https://notabug.org/maximed/guix-gnunet/src/more-precise-http-server-2>
(with some unrelated changes, commit 01d8fc1f856f1b802d359ceb1a5986bce551da=
f5).
Will send a proper patch series later, after looking into the TODOs.

Greetings,
Maxime.

--=-yjgHpS1Ua9cL9sdBGj2c
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: This is a digitally signed message part
Content-Transfer-Encoding: 7bit

-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYlXXJhccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7sW/AP0bnWXLcbE+JsIK14+7N2/REH1E
5ro6TQU0W5jh7p8VfAD/RVFG0M9AzMvRwYWNzcPwTgVM8V8ElAkEM2oYb6iQ6Q8=
=KY0G
-----END PGP SIGNATURE-----

--=-yjgHpS1Ua9cL9sdBGj2c--





Information forwarded to guix-patches@HIDDEN:
bug#53389; Package guix-patches. Full text available.

Message received at 53389 <at> debbugs.gnu.org:


Received: (at 53389) by debbugs.gnu.org; 7 Mar 2022 07:00:19 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Mar 07 02:00:19 2022
Received: from localhost ([127.0.0.1]:52303 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1nR7Lu-00073b-S1
	for submit <at> debbugs.gnu.org; Mon, 07 Mar 2022 02:00:19 -0500
Received: from andre.telenet-ops.be ([195.130.132.53]:39512)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <maximedevos@HIDDEN>) id 1nR7Ls-00073R-2d
 for 53389 <at> debbugs.gnu.org; Mon, 07 Mar 2022 02:00:17 -0500
Received: from ptr-bvsjgyhxw7psv60dyze.18120a2.ip6.access.telenet.be
 ([IPv6:2a02:1811:8c09:9d00:3c5f:2eff:feb0:ba5a])
 by andre.telenet-ops.be with bizsmtp
 id 3K0E270044UW6Th01K0E7f; Mon, 07 Mar 2022 08:00:14 +0100
Message-ID: <c99b5fcdf59cd8d15555f33e8e0b095e969ea9d8.camel@HIDDEN>
Subject: Re: bug#53389: [PATCH 0/9] Replace some mocking with
 with-http-server*, avoid hardcoding ports,
From: Maxime Devos <maximedevos@HIDDEN>
To: Ludovic =?ISO-8859-1?Q?Court=E8s?= <ludo@HIDDEN>
Date: Mon, 07 Mar 2022 08:00:08 +0100
In-Reply-To: <878rtnkq3a.fsf_-_@HIDDEN>
References: <6b1c1d98514b2547907a81a04c1241d9b865d6fa.camel@HIDDEN>
 <20220120130849.292178-1-maximedevos@HIDDEN>
 <87lez7zpgf.fsf_-_@HIDDEN>
 <687d96c300852e684422de877cd87769daae7ccd.camel@HIDDEN>
 <87r18fdmtv.fsf_-_@HIDDEN>
 <490f1dca8f20293a931a45847018ea52eca07cd5.camel@HIDDEN>
 <878rtnkq3a.fsf_-_@HIDDEN>
Content-Type: multipart/signed; micalg="pgp-sha512";
 protocol="application/pgp-signature"; boundary="=-L+1ccARnNBqzsaojOYu/"
User-Agent: Evolution 3.38.3-1 
MIME-Version: 1.0
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telenet.be; s=r22;
 t=1646636414; bh=PNJlDHeirI53a8MB2WwSRAE3UuTqBI38KHrlG9/sjOw=;
 h=Subject:From:To:Cc:Date:In-Reply-To:References;
 b=YAjYajT5a69Umhaxtc+CQcW7mu0/8o+36Af6iKMlmmaTsVPAhwOVG3doJcP7Xu4j/
 8o8iKpu2MJsufJu1ODFnf/8sJJ/bm736dJUwupN6EhclmEHDB2KA9BIAjZHTvBsID0
 jHL0S1gP/C3Es3jzQvSrrUcvLwMYHd61BWzHXdUSDB5NHDHfWxrkT441m3qEvsEmXe
 9lVkCHEfUjJIHTLc7I77EWXQkMP+hZnOATahzGLfI5uM0RRAX97DRmyR3HoBM9k24h
 iZCqh5p06neldGRQLLlYS1Ys8+2kTW/tWeiBBtKPtT0yiLYXjVpbQHldejhJxTp/wI
 a+zvHJhpHmH4Q==
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 53389
Cc: 53389 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)


--=-L+1ccARnNBqzsaojOYu/
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Ludovic Court=C3=A8s schreef op zo 06-03-2022 om 17:23 [+0100]:
> I just remembered about this patch series.=C2=A0 Let me know when you can
> come up with v2.

Not right now, but there's another (older) patch series that should be
ready: <https://issues.guix.gnu.org/50299#91>.

Greetings,
Maxime.

--=-L+1ccARnNBqzsaojOYu/
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: This is a digitally signed message part
Content-Transfer-Encoding: 7bit

-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYiWteBccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7lEgAP93ZJMW8extc8emoEQv7odblYx5
qz1CRy7NJE8CCZZK3wEAhXn3n0ZAz1eLDfkr6o/eJV1EGa2wCtl8wGKW3Bb1lQM=
=q4az
-----END PGP SIGNATURE-----

--=-L+1ccARnNBqzsaojOYu/--





Information forwarded to guix-patches@HIDDEN:
bug#53389; Package guix-patches. Full text available.

Message received at 53389 <at> debbugs.gnu.org:


Received: (at 53389) by debbugs.gnu.org; 6 Mar 2022 16:23:15 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Mar 06 11:23:15 2022
Received: from localhost ([127.0.0.1]:51611 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1nQtf9-0003su-HT
	for submit <at> debbugs.gnu.org; Sun, 06 Mar 2022 11:23:15 -0500
Received: from eggs.gnu.org ([209.51.188.92]:42108)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1nQtf8-0003si-FP
 for 53389 <at> debbugs.gnu.org; Sun, 06 Mar 2022 11:23:15 -0500
Received: from [2001:470:142:3::e] (port=50090 helo=fencepost.gnu.org)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <ludo@HIDDEN>)
 id 1nQtf2-0007MG-Ly; Sun, 06 Mar 2022 11:23:08 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=MIME-Version:In-Reply-To:Date:References:Subject:To:
 From; bh=QP1YlljDAR26XeAg1aBhibe4Nb9O/n9xDvrqIPhCtqY=; b=oFpm1ttabJqL86Ea3hlP
 H6RrDMMN8ElmT8SIUaQBiQi7QvRqpoCi/+xxAjfyFl8yxKmywLeVkwo2AGS2vhvh6GbALRzYwi7XA
 0VIvLHrqW1J3nv6kLOntgv8zprzsvg1UHWPpS9dX64qhji4CUH0OUIIJWY9uQ2EVfsC4zjbfVp2E8
 uQCVhNDhu7+T09jo38zt9LTWx6BzKfne1p/KCjqDQ8ZRZx60FGYMePP/rnkMxQZZ25QgXp7BP0Y8f
 9/kDEvSK6dMCHTU/BaX7Q10qRQnyVdLwvYh8m0u9Ibdc8wr0ZXn7oKPxRwuMbii32FGcePkgRXAd7
 3Ydk5+QdbBNbRw==;
Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201]:50134
 helo=ribbon)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <ludo@HIDDEN>)
 id 1nQtf2-0006Dx-4c; Sun, 06 Mar 2022 11:23:08 -0500
From: =?utf-8?Q?Ludovic_Court=C3=A8s?= <ludo@HIDDEN>
To: Maxime Devos <maximedevos@HIDDEN>
Subject: Re: bug#53389: [PATCH 0/9] Replace some mocking with
 with-http-server*, avoid hardcoding ports,
References: <6b1c1d98514b2547907a81a04c1241d9b865d6fa.camel@HIDDEN>
 <20220120130849.292178-1-maximedevos@HIDDEN>
 <87lez7zpgf.fsf_-_@HIDDEN>
 <687d96c300852e684422de877cd87769daae7ccd.camel@HIDDEN>
 <87r18fdmtv.fsf_-_@HIDDEN>
 <490f1dca8f20293a931a45847018ea52eca07cd5.camel@HIDDEN>
Date: Sun, 06 Mar 2022 17:23:05 +0100
In-Reply-To: <490f1dca8f20293a931a45847018ea52eca07cd5.camel@HIDDEN>
 (Maxime Devos's message of "Mon, 07 Feb 2022 11:59:13 +0100")
Message-ID: <878rtnkq3a.fsf_-_@HIDDEN>
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-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 53389
Cc: 53389 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Hi Maxime,

Maxime Devos <maximedevos@HIDDEN> skribis:

> Looks nice, though it isn't ideal that port 9000/9001 is hardcoded
> here.  That can be left as an exercise for later though.  I'll do this
> in the v2 (and remove keep-lingering?) whenever I get around to writing
> the v2 (I'm mostly doing Scheme-GNUnet stuff at the moment).

I just remembered about this patch series.  Let me know when you can
come up with v2.

Ludo=E2=80=99.




Information forwarded to guix-patches@HIDDEN:
bug#53389; Package guix-patches. Full text available.

Message received at 53389 <at> debbugs.gnu.org:


Received: (at 53389) by debbugs.gnu.org; 7 Feb 2022 10:59:24 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Feb 07 05:59:24 2022
Received: from localhost ([127.0.0.1]:41137 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1nH1jv-00088T-R8
	for submit <at> debbugs.gnu.org; Mon, 07 Feb 2022 05:59:24 -0500
Received: from michel.telenet-ops.be ([195.130.137.88]:46272)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <maximedevos@HIDDEN>) id 1nH1jt-00088I-1S
 for 53389 <at> debbugs.gnu.org; Mon, 07 Feb 2022 05:59:23 -0500
Received: from [172.20.10.9] ([213.119.168.30])
 by michel.telenet-ops.be with bizsmtp
 id sAzJ260090fhH0506AzJuo; Mon, 07 Feb 2022 11:59:19 +0100
Message-ID: <490f1dca8f20293a931a45847018ea52eca07cd5.camel@HIDDEN>
Subject: Re: bug#53389: [PATCH 0/9] Replace some mocking with
 with-http-server*, avoid hardcoding ports,
From: Maxime Devos <maximedevos@HIDDEN>
To: Ludovic =?ISO-8859-1?Q?Court=E8s?= <ludo@HIDDEN>
Date: Mon, 07 Feb 2022 11:59:13 +0100
In-Reply-To: <87r18fdmtv.fsf_-_@HIDDEN>
References: <6b1c1d98514b2547907a81a04c1241d9b865d6fa.camel@HIDDEN>
 <20220120130849.292178-1-maximedevos@HIDDEN>
 <87lez7zpgf.fsf_-_@HIDDEN>
 <687d96c300852e684422de877cd87769daae7ccd.camel@HIDDEN>
 <87r18fdmtv.fsf_-_@HIDDEN>
Content-Type: multipart/signed; micalg="pgp-sha512";
 protocol="application/pgp-signature"; boundary="=-K2tsCHqSSLPIot3URSZj"
User-Agent: Evolution 3.38.3-1 
MIME-Version: 1.0
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telenet.be; s=r22;
 t=1644231559; bh=A4veEPByv1Rcq2PMaJ+lVNmfWukt7VrkvU9cp2GrMuI=;
 h=Subject:From:To:Cc:Date:In-Reply-To:References;
 b=W1I1+KZUAyRLBPvOvOaQ6i16dBAYNGnrAeTyhTUsBoPrpPLoe4FyQINzZnKf2XXKA
 PPPIzsRS5+Cg2cCzmihXXUdQ+usBkmhPpEaXGtj1sscqUcis+FfFHr3rmNEzaDRR/4
 td4R3He5I4L0eCzc41fChB7ywrjmPCIfuSsdYQIjQXsFdh1TgxdrzO10XNba583Yqc
 V1qWSyzcQI3sH1coygbi2RiaUm8w1IvUP1VZc4gl0V0EL9rKR/Zzd87qqf+i9E95SC
 7cUdyqhyRpConFtZQep3ccoybnh59GoCOEZ9vLg/zkd1eVgd+JjFr48TKUywSO+ch6
 tOm2lVBCDpeIA==
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 53389
Cc: 53389 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)


--=-K2tsCHqSSLPIot3URSZj
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Ludovic Court=C3=A8s schreef op ma 07-02-2022 om 10:53 [+0100]:
> Hi,
>=20
> Maxime Devos <maximedevos@HIDDEN> skribis:
>=20
> > 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=
 server thread
> > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (system-asy=
nc-mark (lambda () (throw 'quit)) server))
> > >=20
> > > When do we need =E2=80=98keep-lingering?=E2=80=99?
> >=20
> > 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.
> >=20
> > (*) a monadic value.
>=20
> How about fixing it locally like this:
>=20
> That way we don=E2=80=99t need to keep the lingering variant in (guix tes=
ts
> http).
>
> WDYT?

Looks nice, though it isn't ideal that port 9000/9001 is hardcoded
here.  That can be left as an exercise for later though.  I'll do this
in the v2 (and remove keep-lingering?) whenever I get around to writing
the v2 (I'm mostly doing Scheme-GNUnet stuff at the moment).

Greetings,
Maaxime.

--=-K2tsCHqSSLPIot3URSZj
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: This is a digitally signed message part
Content-Transfer-Encoding: 7bit

-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYgD7gRccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7hPIAQDkOnEYeiTRLanyOZQnIWCtzHNU
N/GFa5wpKKx5IvCM0AD+JEPxWyd7NNZzuMi6H3GY5eEq9aUq3LHcKtOoGohX8w0=
=RlSD
-----END PGP SIGNATURE-----

--=-K2tsCHqSSLPIot3URSZj--





Information forwarded to guix-patches@HIDDEN:
bug#53389; Package guix-patches. Full text available.

Message received at 53389 <at> debbugs.gnu.org:


Received: (at 53389) by debbugs.gnu.org; 7 Feb 2022 09:53:59 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Feb 07 04:53:59 2022
Received: from localhost ([127.0.0.1]:41046 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1nH0ic-00049R-Rq
	for submit <at> 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 <ludo@HIDDEN>) id 1nH0ia-00049D-Ul
 for 53389 <at> 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?= <ludo@HIDDEN>
To: Maxime Devos <maximedevos@HIDDEN>
Subject: Re: bug#53389: [PATCH 0/9] Replace some mocking with
 with-http-server*, avoid hardcoding ports,
References: <6b1c1d98514b2547907a81a04c1241d9b865d6fa.camel@HIDDEN>
 <20220120130849.292178-1-maximedevos@HIDDEN>
 <87lez7zpgf.fsf_-_@HIDDEN>
 <687d96c300852e684422de877cd87769daae7ccd.camel@HIDDEN>
Date: Mon, 07 Feb 2022 10:53:48 +0100
In-Reply-To: <687d96c300852e684422de877cd87769daae7ccd.camel@HIDDEN>
 (Maxime Devos's message of "Sat, 22 Jan 2022 19:55:30 +0100")
Message-ID: <87r18fdmtv.fsf_-_@HIDDEN>
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 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.0 (/)

--=-=-=
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

Hi,

Maxime Devos <maximedevos@HIDDEN> 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 <ludo@gnu=
.org>
+;;; Copyright =C2=A9 2015, 2017, 2019, 2020, 2022 Ludovic Court=C3=A8s <lu=
do@HIDDEN>
 ;;;
 ;;; 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.

--=-=-=--




Information forwarded to guix-patches@HIDDEN:
bug#53389; Package guix-patches. Full text available.

Message received at 53389 <at> debbugs.gnu.org:


Received: (at 53389) by debbugs.gnu.org; 25 Jan 2022 13:37:56 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Jan 25 08:37:56 2022
Received: from localhost ([127.0.0.1]:47438 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1nCM1E-0003Eo-3c
	for submit <at> debbugs.gnu.org; Tue, 25 Jan 2022 08:37:56 -0500
Received: from albert.telenet-ops.be ([195.130.137.90]:49220)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <maximedevos@HIDDEN>) id 1nCM1A-0003Ed-Qv
 for 53389 <at> debbugs.gnu.org; Tue, 25 Jan 2022 08:37:54 -0500
Received: from ptr-bvsjgyhxw7psv60dyze.18120a2.ip6.access.telenet.be
 ([IPv6:2a02:1811:8c09:9d00:3c5f:2eff:feb0:ba5a])
 by albert.telenet-ops.be with bizsmtp
 id n1dq2600E4UW6Th061dqL8; Tue, 25 Jan 2022 14:37:51 +0100
Message-ID: <6b68d02fea18699d944b92e5b0351853201ff511.camel@HIDDEN>
Subject: Re: bug#53389: [PATCH 0/9] Replace some mocking with
 with-http-server*, avoid hardcoding ports,
From: Maxime Devos <maximedevos@HIDDEN>
To: Ludovic =?ISO-8859-1?Q?Court=E8s?= <ludo@HIDDEN>
Date: Tue, 25 Jan 2022 14:37:39 +0100
In-Reply-To: <87wniop7wh.fsf@HIDDEN>
References: <6b1c1d98514b2547907a81a04c1241d9b865d6fa.camel@HIDDEN>
 <20220120130849.292178-1-maximedevos@HIDDEN>
 <87lez7zpgf.fsf_-_@HIDDEN>
 <687d96c300852e684422de877cd87769daae7ccd.camel@HIDDEN>
 <87wniop7wh.fsf@HIDDEN>
Content-Type: multipart/signed; micalg="pgp-sha512";
 protocol="application/pgp-signature"; boundary="=-u1UFmVUxIIPZXK/uFFR9"
User-Agent: Evolution 3.38.3-1 
MIME-Version: 1.0
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telenet.be; s=r22;
 t=1643117871; bh=BLGNv3t3EDK9ZskxJmTt/TuQBzD8HduV1rBhrvvcs0w=;
 h=Subject:From:To:Cc:Date:In-Reply-To:References;
 b=brpp17fcy0PQac4ksjZwj/cErflVkpnVU5shWqNAYhuhCWfsF1c4Z5hMXLZ67vw0U
 95FC6eUNWhUlYE0ezx1EB7g7uhhmDLGtFNIsaAHgb6zWHcAGcLjyUSQwNhSbYu2abN
 +ES/12VPvuZTSjzAcNykXSyiUXKFcmauvOkCKGoJRPl76vvxeJTn+bt0o+XN2rlj/s
 D4YbCPg1rlU5c/kHW1gbavT/yM7CFqvndYnSFZA9tncKrUBbvHHKcl+OYMXBVmdz1o
 pTycAFb6m6ew+nRV35R0NjS+3COaPU4iKIPGfxIDK9fBL5YR2TPvi91o1ViPyomZha
 V+CFiLlNc7/mw==
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 53389
Cc: 53389 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)


--=-u1UFmVUxIIPZXK/uFFR9
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Ludovic Court=C3=A8s schreef op di 25-01-2022 om 08:54 [+0100]:
> So tests/minetest.scm needs more than pre-programmed responses that are
> returned in a specified order?
>=20
> In ideal black-box testing, sure, you would make the test HTTP server
> completely oblivious to what=E2=80=99s being tested, in particular oblivi=
ous to
> the order in which requests might arrive.
>=20
> But in practice, you also want to keep the test infrastructure as simple
> and concise as possible, or [...]


I think the most concise test infrastructure here, with the least
potential of breakage (and hence the least need to test the test
infrastructure), would be to use mocking instead of creating a HTTP
server listening to a port:=C2=A0

  * mocking doesn't require threads, which eliminates the problem of
    deciding when to stop the thread (e.g., the current version doesn't
    stop the thread if the thunk throws an exception) and looking out
    for concurrency-related problems.

  * mocking doesn't use ports, which eliminates the problem of having
    to choose a _free_ port and eventually close it

  * somehow, when using mocking instead of threads, the
    ECONNREFUSED/par-map from [PATH 3/9] doesn't happen

'with-http-server' could then be renamed to 'with-http-mocking'
and be based on mocking.  'with-http-server*' could be removed;
tests/minetest.scm would keep mocking directly.

As such, mocking seems a lot simpler to me and 'with-http-server' could
be made simpler by implementing it on top of mocking.  Guile's
optimiser has been beginning to do some inlining for a while,
so maybe not though.

> [...] or you=E2=80=99ll need tests for that infrastructure
> too.  I guess that=E2=80=99s my main concern.

I don't think guix/tests/http.scm has become significantly more complex
and less concise, the changes seem more splitting a procedure doing
multiple somewhat unrelated things (call-with-http-server, which did
both construct a HTTP server and decide what to respond to a request)
into two separate procedures (call-with-http-server*, which constructs
a HTTP server and lets the handler procedure choose how to map requests
to responses, and call-with-http-server's handler procedure).

Additionally, it would seem to me that all tests using
call-with-http-server and call-with-http-server* are also tests of
guix/tests.scm

Still, I could write some tests for (guix tests http)?

> So I would opt for minimal changes.  There are 6 files under tests/
> that mock =E2=80=98http-fetch=E2=80=99.  Perhaps we can start converting =
them one by
> one to the (guix tests http) infrastructure as it exists, and only
> change that infrastructure when needed?

One of these files is tests/minetest.scm.  The main purpose of this
patch series was to convert tests/minetest.scm from mocking to
(guix tests http).  However, the tests in tests/minetest.scm did not
fit the original (guix tests http).  As such, some changes to the
(guix tests http) infrastructure were needed, in [PATCH 1/9].  These
changes seem rather minimal to me.

That said, there might also be other minimal changes possible.
E.g. call-with-packages could generate a map from URI -> response in
advance.  But that would require modifying both tests/minetest.scm
quite a bit and (guix tests http) (to allow optionally ignoring
ordering, adding a new flag and hence some complexity).  That doesn't
seem minimal to me?

It would also make things more complicated later, e.g. I would like to
someday teach the Minetest importer to use http-fetch/cached, If-
Modified-Since and friends to reduce network traffic and some degree of
resiliency (in case of flaky interruptions or even being offline) (*).
To test that, a static URI->response map would not suffice.  Another
tweak to the tests would be to verify the content type (for the
Minetest importer, ContentDB doesn't care currently, but for the GitHub
updater, GitHub does IIUC).

(*) Could be useful for supporting something like

(packages->manifest
  (map specification->imported-package
    '("minetest-not-in-guix-yet@HIDDEN" "minetest-mod-old-or-newer-version@9=
.0.0")))

without incurring excessive network traffic, and having a chance of
working when offline.

Greetings,
Maxime.

p.s. I'll take some time off and write a v2 for the Minetest documentation
patch later (before the v2 of this patch series).

--=-u1UFmVUxIIPZXK/uFFR9
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: This is a digitally signed message part
Content-Transfer-Encoding: 7bit

-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYe/9IxccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7kY0AP4vgU/2gv6+eAvLFf/BqjcgdA+5
O6UuD4tSWLCf8xV5KwEAvQAX05x2qWs7Yn4Um56sxs+pY1g6482zvN8c8zZzTwQ=
=Gwm/
-----END PGP SIGNATURE-----

--=-u1UFmVUxIIPZXK/uFFR9--





Information forwarded to guix-patches@HIDDEN:
bug#53389; Package guix-patches. Full text available.

Message received at 53389 <at> debbugs.gnu.org:


Received: (at 53389) by debbugs.gnu.org; 25 Jan 2022 07:54:48 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Jan 25 02:54:48 2022
Received: from localhost ([127.0.0.1]:46796 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1nCGfA-0005kT-Ch
	for submit <at> debbugs.gnu.org; Tue, 25 Jan 2022 02:54:48 -0500
Received: from hera.aquilenet.fr ([185.233.100.1]:45590)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1nCGf8-0005kB-Qi
 for 53389 <at> debbugs.gnu.org; Tue, 25 Jan 2022 02:54:47 -0500
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id E68BB188;
 Tue, 25 Jan 2022 08:54:39 +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 fdjPG7TJBUDN; Tue, 25 Jan 2022 08:54:39 +0100 (CET)
Received: from ribbon (91-160-117-201.subs.proxad.net [91.160.117.201])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id BD0C2A4;
 Tue, 25 Jan 2022 08:54:38 +0100 (CET)
From: =?utf-8?Q?Ludovic_Court=C3=A8s?= <ludo@HIDDEN>
To: Maxime Devos <maximedevos@HIDDEN>
Subject: Re: bug#53389: [PATCH 0/9] Replace some mocking with
 with-http-server*, avoid hardcoding ports,
References: <6b1c1d98514b2547907a81a04c1241d9b865d6fa.camel@HIDDEN>
 <20220120130849.292178-1-maximedevos@HIDDEN>
 <87lez7zpgf.fsf_-_@HIDDEN>
 <687d96c300852e684422de877cd87769daae7ccd.camel@HIDDEN>
X-URL: http://www.fdn.fr/~lcourtes/
X-Revolutionary-Date: 6 =?utf-8?Q?Pluvi=C3=B4se?= an 230 de la =?utf-8?Q?R?=
 =?utf-8?Q?=C3=A9volution?=
X-PGP-Key-ID: 0x090B11993D9AEBB5
X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc
X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4  0CFB 090B 1199 3D9A EBB5
X-OS: x86_64-pc-linux-gnu
Date: Tue, 25 Jan 2022 08:54:38 +0100
In-Reply-To: <687d96c300852e684422de877cd87769daae7ccd.camel@HIDDEN>
 (Maxime Devos's message of "Sat, 22 Jan 2022 19:55:30 +0100")
Message-ID: <87wniop7wh.fsf@HIDDEN>
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: /
Authentication-Results: hera.aquilenet.fr;
	none
X-Rspamd-Server: hera
X-Rspamd-Queue-Id: E68BB188
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)[text/plain];
 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-Spam-Score: 1.0 (+)
X-Debbugs-Envelope-To: 53389
Cc: 53389 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.0 (/)

Hi,

Maxime Devos <maximedevos@HIDDEN> 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.

Oh I see.

>> 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.
>
> AFAIK, they don't expect that the server quits. But they don't expect
> that the server does not quit either.  Rather, they need the server
> to keep running as long as needed -- i.e., after the last request
> has been answered.
>
> The only reason that the server quits, is to perform a form of garbage
> collection, to avoid accumulating threads and server ports.

Yes.

> There appear to be two criteria for deciding when to exit the server:
>
>  (a) Exit when the thunk returns.=20
>
>      This is similar to 'call-with-port' and 'call-with-output-file'
>      automatically closing the port when the procedure returns.
>      There don't seem to be any drawbacks with this criterium.
>
>  (b) Exit when there are no responses left.
>
>      This is problematic when there is no list of reponses but rather
>      some function mapping requests to responses without any
>      limitations on how often a resource is requested, or when there
>      are multiple resources available and the =E2=80=98client=E2=80=99 is=
 allowed to
>      query a proper subset ...
>
>      E.g., the way the tests in tests/minetest.scm are written, the
>      tests don't care in which order resources are accessed and whether
>      a resource is accessed multiple time.  Furthermore, the procedure
>      for creating a testing model of ContentDB (call-with-packages) has
>      no idea what parts of the model will be accessed.

So tests/minetest.scm needs more than pre-programmed responses that are
returned in a specified order?

In ideal black-box testing, sure, you would make the test HTTP server
completely oblivious to what=E2=80=99s being tested, in particular obliviou=
s to
the order in which requests might arrive.

But in practice, you also want to keep the test infrastructure as simple
and concise as possible, or you=E2=80=99ll need tests for that infrastructu=
re
too.  I guess that=E2=80=99s my main concern.

So I would opt for minimal changes.  There are 6 files under tests/ that
mock =E2=80=98http-fetch=E2=80=99.  Perhaps we can start converting them on=
e by one to
the (guix tests http) infrastructure as it exists, and only change that
infrastructure when needed?

Thanks,
Ludo=E2=80=99.




Information forwarded to guix-patches@HIDDEN:
bug#53389; Package guix-patches. Full text available.

Message received at 53389 <at> debbugs.gnu.org:


Received: (at 53389) by debbugs.gnu.org; 22 Jan 2022 20:43:06 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jan 22 15:43:06 2022
Received: from localhost ([127.0.0.1]:38008 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1nBNE1-000689-N3
	for submit <at> debbugs.gnu.org; Sat, 22 Jan 2022 15:43:06 -0500
Received: from albert.telenet-ops.be ([195.130.137.90]:51772)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <maximedevos@HIDDEN>) id 1nBNDy-00067l-RD
 for 53389 <at> debbugs.gnu.org; Sat, 22 Jan 2022 15:43:03 -0500
Received: from ptr-bvsjgyhxw7psv60dyze.18120a2.ip6.access.telenet.be
 ([IPv6:2a02:1811:8c09:9d00:3c5f:2eff:feb0:ba5a])
 by albert.telenet-ops.be with bizsmtp
 id lwj02601A4UW6Th06wj0yj; Sat, 22 Jan 2022 21:43:01 +0100
Message-ID: <b15ff88dd5a602365f4008baf541452876bded35.camel@HIDDEN>
Subject: Re: bug#53389: [PATCH 0/9] Replace some mocking with
 with-http-server*, avoid hardcoding ports,
From: Maxime Devos <maximedevos@HIDDEN>
To: Ludovic =?ISO-8859-1?Q?Court=E8s?= <ludo@HIDDEN>
Date: Sat, 22 Jan 2022 21:42:56 +0100
In-Reply-To: <87lez7zpgf.fsf_-_@HIDDEN>
References: <6b1c1d98514b2547907a81a04c1241d9b865d6fa.camel@HIDDEN>
 <20220120130849.292178-1-maximedevos@HIDDEN>
 <87lez7zpgf.fsf_-_@HIDDEN>
Content-Type: multipart/signed; micalg="pgp-sha512";
 protocol="application/pgp-signature"; boundary="=-FPe4W4kZiOQvf7RirXX4"
User-Agent: Evolution 3.38.3-1 
MIME-Version: 1.0
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telenet.be; s=r22;
 t=1642884181; bh=evgnQWp+2pANLW779fvUEcOf8lrmvacfrvsqaKTq7Mk=;
 h=Subject:From:To:Cc:Date:In-Reply-To:References;
 b=RufrqQWc7hYr68K3YrS9Z5DQkpjn9tERzRfVDxeAXOEmHxN9NEFKti3BafQFuKpWx
 CcfwoVh+NG/JF3v/Ky9yHAyeWhiVbrBnqUz9wp9fmAuJbPRDxBHrwrPKYfI94PINfa
 g7UDNaYCnvXJ9d+s79hN70ys3KAUK6iHw7+oOVrJOLAM4iBvoIo4/+eBV8GGPDDq6f
 aeXL1Skva1vJSFlcdwi0PtCde8TugPHok/6/1IU9YY9yJJUTPFdYVu3GN5FwBjfd2H
 AKi7YdSZO/E1hK5scEnP4sXWqfpF2cYs/C/argj+rzb+NCd+KpBmvt4sHkTbkJ+ZX0
 7Zf/rXM5rkhYg==
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 53389
Cc: 53389 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)


--=-FPe4W4kZiOQvf7RirXX4
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Ludovic Court=C3=A8s schreef op za 22-01-2022 om 17:48 [+0100]:
> My first reaction was: have we gone overboard?=C2=A0 :-)
>=20
> Since it=E2=80=99s an internal module and a test helper, I=E2=80=99m in f=
avor of keeping
> it as simple as possible.
>=20

I don't see what it matters that this module is only available from
a git checkout (or extracted tarball) and that it is only used by
tests.

Keeping things simple is good, but making it simpler in such a way
that it becomes unusable to some tests (tests/minetest.scm) somewhat
defeats the purpose of the test helper.

> =C2=A0 Can we keep a single =E2=80=98with-http-server=E2=80=99 form
> that would cover all cases?

We have a single form that covers all cases: with-http-server*.
However, the full power of the functinal with-http-server*, accepting
an arbitrary mapping from requests to responses, often isn't necessary.
For those cases, we have the declarative with-http-server, which is
quite a bit simpler to use, but much less flexible.

We could remove 'with-http-server' and keep a single macro
'with-http-server*' but I don't think that's what you were going for.

This seems a bit like trivial-build-system/copy-build-system.
trivial-build-system is rather complicated to use, but can in theory do
anything. copy-build-system is rather limited in what it can do, but
when it is suitable to the problem, it is very easy to use.
There is no attempt to somehow move everything trivial-build-system
can do into copy-build-system.

There's also the option of letting 'call-with-http-server' test
if the (responses+data) is a procedure or a list, and in the first
case behave like the old 'with-http-server*' and in the second
case like 'with-http-server'.  This overloading doesn't seem
great though, I would rather have two separate procedures for
two separate APIs -- albeit with one implemented using the other.

>=20
> We can update existing tests to include the expected URL path (or a
> wildcard, if needed), instead of keeping several forms.=C2=A0 We don=E2=
=80=99t need
> to worry about backward compatibility at all.

Always including the URL path in the declarative forms
(with-http-server) seems good to me, but it would be a lot of work
-- actually, on second though, I ran
"git grep -F with-http-server | wc -l" and there were 51 hits, which
seems doable. Let's do that in the v2.

However, the declarative form is too limiting and not sufficiently
expressive for some tests (tests/minetest.scm), tests/minetest.scm
doesn't have any use for wildcards, so with-http-server remains
unsuitable for some tests.

Greetings,
Maxime.

--=-FPe4W4kZiOQvf7RirXX4
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: This is a digitally signed message part
Content-Transfer-Encoding: 7bit

-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYexsUBccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7ssVAP93v+UNC96exqMq+RVo4YUMfFJ+
IwzP2NRQ7WQNwWD7ugD8CHO6qlnI7Gyqp5cT4isyyEHSwYdR/9mhhtgdcpw1tgU=
=O3S3
-----END PGP SIGNATURE-----

--=-FPe4W4kZiOQvf7RirXX4--





Information forwarded to guix-patches@HIDDEN:
bug#53389; Package guix-patches. Full text available.

Message received at 53389 <at> debbugs.gnu.org:


Received: (at 53389) by debbugs.gnu.org; 22 Jan 2022 19:57:43 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jan 22 14:57:43 2022
Received: from localhost ([127.0.0.1]:37989 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1nBMW7-00052L-2C
	for submit <at> debbugs.gnu.org; Sat, 22 Jan 2022 14:57:43 -0500
Received: from xavier.telenet-ops.be ([195.130.132.52]:36182)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <maximedevos@HIDDEN>) id 1nBMW5-00052C-2U
 for 53389 <at> debbugs.gnu.org; Sat, 22 Jan 2022 14:57:42 -0500
Received: from ptr-bvsjgyhxw7psv60dyze.18120a2.ip6.access.telenet.be
 ([IPv6:2a02:1811:8c09:9d00:3c5f:2eff:feb0:ba5a])
 by xavier.telenet-ops.be with bizsmtp
 id lvxe2601o4UW6Th01vxfyf; Sat, 22 Jan 2022 20:57:39 +0100
Message-ID: <729a1d056ccd32c52e45c667749f1e7f0981ae42.camel@HIDDEN>
Subject: Re: bug#53389: [PATCH 0/9] Replace some mocking with
 with-http-server*, avoid hardcoding ports,
From: Maxime Devos <maximedevos@HIDDEN>
To: Ludovic =?ISO-8859-1?Q?Court=E8s?= <ludo@HIDDEN>
Date: Sat, 22 Jan 2022 20:57:34 +0100
In-Reply-To: <87lez7zpgf.fsf_-_@HIDDEN>
References: <6b1c1d98514b2547907a81a04c1241d9b865d6fa.camel@HIDDEN>
 <20220120130849.292178-1-maximedevos@HIDDEN>
 <87lez7zpgf.fsf_-_@HIDDEN>
Content-Type: multipart/signed; micalg="pgp-sha512";
 protocol="application/pgp-signature"; boundary="=-mY+pwp5qjw6CQI30/UYy"
User-Agent: Evolution 3.38.3-1 
MIME-Version: 1.0
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telenet.be; s=r22;
 t=1642881459; bh=wNzKEPu8TodLcZOjebj495BUvYWiDuR2JHFhUub+3tA=;
 h=Subject:From:To:Cc:Date:In-Reply-To:References;
 b=f929oQtAe70vZ9EZaYWdpRUX4J05xxAERWUwSV48LvNfjDa9AFrM8/r4XNWPsqubG
 FxU/vwqfwgBZEEXGMwITvcR++3gjigYlXVhHdTSDeLR46jwXMbc4imGpBmmCCsVj5I
 JR3H4W+9jpwKcntsmx0QWn3msgnZi/ZUzU8wPYmvA6EIgqw6BCQS0+Lr9MNPyNmalR
 rDPZXcNz+wn2eP2xtzkIZ6UYXpfIXGkNCzSuBypr7vEis7yZDjRvb75phI194B5gRO
 dqpTg59yGBkcyFxPayxEkZzsI8rqv+kL6/ANnzLAQIQHVfM8JlVOlUGgcC+PlCxwP1
 4JtnVUPH6w01A==
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 53389
Cc: 53389 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)


--=-mY+pwp5qjw6CQI30/UYy
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Ludovic Court=C3=A8s schreef op za 22-01-2022 om 17:48 [+0100]:
> My first reaction was: have we gone overboard?=C2=A0 :-)
>=20
> Since it=E2=80=99s an internal module and a test helper, I=E2=80=99m in f=
avor of keeping
> it as simple as possible.
>=20

I don't see what it matters that this module is only available from
a git checkout (or extracted tarball) and that it is only used by
tests.

Keeping things simple is good, but making it simpler in such a way
that it becomes unusable to some tests (tests/minetest.scm) somewhat
defeats the purpose of the test helper.

> =C2=A0 Can we keep a single =E2=80=98with-http-server=E2=80=99 form
> that would cover all cases?

We have a single form that covers all cases: with-http-server*.
However, the full power of the functinal with-http-server*, accepting
an arbitrary mapping from requests to responses, often isn't necessary.
For those cases, we have the declarative with-http-server, which is
quite a bit simpler to use, but much less flexible.

We could remove 'with-http-server' and keep a single macro
'with-http-server*' but I don't think that's what you were going for.

This seems a bit like trivial-build-system/copy-build-system.
trivial-build-system is rather complicated to use, but can in theory do
anything.  copy-build-system is rather limited in what it can do, but
when it is suitable to the problem, it is very easy to use.
There is no attempt to somehow shove everything trivial-build-system
can do into copy-build-system.

There's also the option of letting 'call-with-http-server' test
if the (responses+data) is a procedure or a list, and in the first
case behave like the old 'with-http-server*' and in the second
case like 'with-http-server'.  This overloading doesn't seem
great though, I would rather have two separate procedures for
two separate APIs -- albeit with one implemented with the other.

> We can update existing tests to include the expected URL path (or a
> wildcard, if needed), instead of keeping several forms.=C2=A0 We don=E2=
=80=99t need
> to worry about backward compatibility at all.

Always including the URL path in the declarative forms
(with-http-server) seems good to me, but it would be a lot of work
-- actually, on second though, I ran
"git grep -F with-http-server | wc -l" and there were 51 hits, which
seems doable.  Let's do that in the v2.

However, the declarative form is too limiting and not sufficiently
expressive for some tests (tests/minetest.scm) and tests/minetest.scm
doesn't have any use for wildcards, so with-http-server remains
unsuitable for some tests.

Greetings,
Maxime.

--=-mY+pwp5qjw6CQI30/UYy
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: This is a digitally signed message part
Content-Transfer-Encoding: 7bit

-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYexhrhccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7ie9AQDQKmBJ5Ftew3o8q8NbB660J8ak
i1Z8FMzEqsZzVMp4yQEAxdDivaUzzO1SNPMC1GRLa9I8g2IAubDNmCJyu41o+Qw=
=BfMF
-----END PGP SIGNATURE-----

--=-mY+pwp5qjw6CQI30/UYy--





Information forwarded to guix-patches@HIDDEN:
bug#53389; Package guix-patches. Full text available.

Message received at 53389 <at> debbugs.gnu.org:


Received: (at 53389) by debbugs.gnu.org; 22 Jan 2022 19:21:36 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jan 22 14:21:36 2022
Received: from localhost ([127.0.0.1]:37938 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1nBLx9-00046K-P3
	for submit <at> debbugs.gnu.org; Sat, 22 Jan 2022 14:21:36 -0500
Received: from michel.telenet-ops.be ([195.130.137.88]:36380)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <maximedevos@HIDDEN>) id 1nBLx7-00046B-AL
 for 53389 <at> debbugs.gnu.org; Sat, 22 Jan 2022 14:21:34 -0500
Received: from ptr-bvsjgyhxw7psv60dyze.18120a2.ip6.access.telenet.be
 ([IPv6:2a02:1811:8c09:9d00:3c5f:2eff:feb0:ba5a])
 by michel.telenet-ops.be with bizsmtp
 id lvMX2601G4UW6Th06vMXlE; Sat, 22 Jan 2022 20:21:31 +0100
Message-ID: <aa4a48ceb1b50a108f7d560f916372e75013a818.camel@HIDDEN>
Subject: Re: bug#53389: [PATCH 0/9] Replace some mocking with
 with-http-server*, avoid hardcoding ports,
From: Maxime Devos <maximedevos@HIDDEN>
To: Ludovic =?ISO-8859-1?Q?Court=E8s?= <ludo@HIDDEN>
Date: Sat, 22 Jan 2022 20:21:26 +0100
In-Reply-To: <87lez7zpgf.fsf_-_@HIDDEN>
References: <6b1c1d98514b2547907a81a04c1241d9b865d6fa.camel@HIDDEN>
 <20220120130849.292178-1-maximedevos@HIDDEN>
 <87lez7zpgf.fsf_-_@HIDDEN>
Content-Type: multipart/signed; micalg="pgp-sha512";
 protocol="application/pgp-signature"; boundary="=-4KcSujT563+s6Em0NcGD"
User-Agent: Evolution 3.38.3-1 
MIME-Version: 1.0
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telenet.be; s=r22;
 t=1642879291; bh=NqgQbPb4gvLFLfybi1aarPEo5tzacpsVzAD/Q6+JQmk=;
 h=Subject:From:To:Cc:Date:In-Reply-To:References;
 b=k4PXcajeGmQyuw+vo5W4PtE8mcI0P3wPw/eDlovlrvDhSulCIgcuJTBqn0Kl41Id3
 TBHW3N1qu3QbyK7tV9K1+6YG3bN1caEtSxB3PFmvSajF3RISL8L1g3jWvYGjcxutxM
 d4NPRZxnPuvXbthLLk3AUIzRXRffyoIzyWAF/HMa2hutC2/v9PdnX/Z4Ier9CifSK7
 9YpJbAIIpzHehXFEsY1zmvNA13KzAmcFIAUg/DmSQUtCo+0TtHhy85IjjEwFR44MbY
 DA2wtrdGgpe5X5Ul1oKL7B7d9E208Su8WqyTkcImG1LmabxwK5olyPNGRmCmuxtZ9K
 gUiwdpjm9necQ==
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 53389
Cc: 53389 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)


--=-4KcSujT563+s6Em0NcGD
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Ludovic Court=C3=A8s schreef op za 22-01-2022 om 17:48 [+0100]:
> > +(define* (call-with-http-server responses+data thunk #:key (keep-
> > lingering? #false))
> > +=C2=A0 "Call THUNK with an HTTP server running and returning
> > RESPONSES+DATA
> > +on HTTP requests.=C2=A0 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.=C2=A0 As such, RESPONSES+DATA
> > can use
> > +%http-server-port.=C2=A0 %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.=C2=A0 When KEEP-
> > LINGERING? is false,
> > +the server will also exit after THUNK returns."
>=20
> Within tests, it would be nice if we could avoid using the =E2=80=98thunk=
=E2=80=99
> form

We can't unthunk 'thunk', otherwise the code querying the server will
be run before the server starts, which isn't very useful.  It's the
same reasn why unthunking the 'thunk' argument of 'with-output-to-file'
is not useful -- unless you only want to make a file empty I suppose.

Did you mean 'responses+data'?  For some context, consider
tests/cpan.scm:

-  (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=3Ddistribution"
+                       200 "{ \"distribution\" : \"Test-Script\" }"))
+    (parameterize ((%metacpan-base-url (%local-url* ""))
+                   (current-http-proxy #false))

(Side note: should parametrising current-http-proxy be moved into
'with-http-server', to avoid forgetting to do it in individual tests?)

This 'with-http-server' is =E2=80=98self-referrent=E2=80=99: the responses =
depend on
the port that the HTTP server bound to -- (test-json) refers to
http://localhost:THE-PORT/Foo-Bar-0.1.tar.gz.  As such, the
responses+data needs to be thunked, because this port is not known in
advance.

In principle, thunking can be avoided here by running two HTTP servers
by nesting two with-http-server forms, but why make things more
complicated by running multiple servers when a single one is
sufficient?  It can also be avoided by doing this proxy thing the
original code did, but why complicate things with proxies when
a regular server suffices?

Also, tests don't really see that thunking happens unless they actually
use the thunking to do make self-references, because all tests use
with-http-server (*) (which does thunking automatically, not unlike
'package' records).  So except for simplifying implementation details
of call-with-http-server, I don't see how unthunking would make things
nicer.

(*) Unless they use with-http-server*.

>  and instead always use the declarative form (list of URL
> path/response code/response body).

Thunking and declarative forms don't appear mutually exclusive to me;
the tests/cpan.scm example above uses a thunked declarative form.

It would be nice to always specify the paths in the declarative
form though, to make tests more precise, but there are a lot
of tests to convert.

> =C2=A0That should make the tests more concise and readable.

The declarative form is still available and isn't going away.

>=20
> Or are there new uses where the declarative form is insufficiently
> expressive?

tests/minetest.scm, see other mail.

with-http-server is still declarative, so maybe you meant the
functional with-http-server* instead?

Greetings,
Maxime

--=-4KcSujT563+s6Em0NcGD
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: This is a digitally signed message part
Content-Transfer-Encoding: 7bit

-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYexZNhccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7p59AP99NGaQ1+gmQsJm94VjJTNruOyN
7e0HSIMSmP7kAf1FsgD8C6uZqByXzp1qAHiV4b2lJixqlIK6xFbOCVdnKelpOQI=
=DKbF
-----END PGP SIGNATURE-----

--=-4KcSujT563+s6Em0NcGD--





Information forwarded to guix-patches@HIDDEN:
bug#53389; Package guix-patches. Full text available.

Message received at 53389 <at> debbugs.gnu.org:


Received: (at 53389) by debbugs.gnu.org; 22 Jan 2022 18:55:42 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jan 22 13:55:42 2022
Received: from localhost ([127.0.0.1]:37894 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1nBLY6-0003Pu-9q
	for submit <at> debbugs.gnu.org; Sat, 22 Jan 2022 13:55:42 -0500
Received: from albert.telenet-ops.be ([195.130.137.90]:41920)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <maximedevos@HIDDEN>) id 1nBLY0-0003Pi-MN
 for 53389 <at> debbugs.gnu.org; Sat, 22 Jan 2022 13:55:41 -0500
Received: from ptr-bvsjgyhxw7psv60dyze.18120a2.ip6.access.telenet.be
 ([IPv6:2a02:1811:8c09:9d00:3c5f:2eff:feb0:ba5a])
 by albert.telenet-ops.be with bizsmtp
 id luva260154UW6Th06uvaAq; Sat, 22 Jan 2022 19:55:35 +0100
Message-ID: <687d96c300852e684422de877cd87769daae7ccd.camel@HIDDEN>
Subject: Re: bug#53389: [PATCH 0/9] Replace some mocking with
 with-http-server*, avoid hardcoding ports,
From: Maxime Devos <maximedevos@HIDDEN>
To: Ludovic =?ISO-8859-1?Q?Court=E8s?= <ludo@HIDDEN>
Date: Sat, 22 Jan 2022 19:55:30 +0100
In-Reply-To: <87lez7zpgf.fsf_-_@HIDDEN>
References: <6b1c1d98514b2547907a81a04c1241d9b865d6fa.camel@HIDDEN>
 <20220120130849.292178-1-maximedevos@HIDDEN>
 <87lez7zpgf.fsf_-_@HIDDEN>
Content-Type: multipart/signed; micalg="pgp-sha512";
 protocol="application/pgp-signature"; boundary="=-t1ikULqiam0IUqcycun8"
User-Agent: Evolution 3.38.3-1 
MIME-Version: 1.0
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telenet.be; s=r22;
 t=1642877735; bh=vTNFJEHcNWUdpQTRkWdMxXbiaWBpm00AO8E6Hi/Qj5M=;
 h=Subject:From:To:Cc:Date:In-Reply-To:References;
 b=NGIIWV/rvRIamQzOf7BnQbPwgyeBSfrxL4oOEjU1jsmTM8/cnNyJPTYfWXYDnzORX
 bnA6DEo7ia9mQddDrthShbERrJakz4QHmUvLFkhtr10uAvdwKawKXpKQx5GnmcjeQ+
 HiJTAjR/AtR9fFsl958E6VNksxnDqaeqBpzMhNzy7fOAKEBAE9oNgEKSAftOBD9XpJ
 9S58vBnQgK+Ge9gIAw5BJ45MW46l3ZCTPy80wqHJqeWDmXaxcVRzaJJ0L6+6nmbmxz
 Yib8K5PpoTEfVLKyzUlL3bOFRnQxhFNTKL+pNKeVFgiPPBm4AO46tPdqyTx86GtSrI
 NrCnxUUO1h1Qg==
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 53389
Cc: 53389 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)


--=-t1ikULqiam0IUqcycun8
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Hi,

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 ser=
ver thread
> > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (system-async-m=
ark (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.

> 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.

AFAIK, they don't expect that the server quits. But they don't expect
that the server does not quit either.  Rather, they need the server
to keep running as long as needed -- i.e., after the last request
has been answered.

The only reason that the server quits, is to perform a form of garbage
collection, to avoid accumulating threads and server ports.

There appear to be two criteria for deciding when to exit the server:

 (a) Exit when the thunk returns.=20

     This is similar to 'call-with-port' and 'call-with-output-file'
     automatically closing the port when the procedure returns.
     There don't seem to be any drawbacks with this criterium.

 (b) Exit when there are no responses left.

     This is problematic when there is no list of reponses but rather
     some function mapping requests to responses without any
     limitations on how often a resource is requested, or when there
     are multiple resources available and the =E2=80=98client=E2=80=99 is a=
llowed to
     query a proper subset ...

     E.g., the way the tests in tests/minetest.scm are written, the
     tests don't care in which order resources are accessed and whether
     a resource is accessed multiple time.  Furthermore, the procedure
     for creating a testing model of ContentDB (call-with-packages) has
     no idea what parts of the model will be accessed.

     That is, the same model can be used for searches (either
     sorted by score or download), for requesting a description of a
     ContentDB =E2=80=98package=E2=80=99 and for requesting a specific rele=
ase of a
     package.

     Furthermore, the space of resources is even infinite (due to the
     search API).

     In principle, that procedure could be modified to accept a few
     arguments specifying what things will be asked and with
     which parameters, but doing that and figuring out the arguments
     for each test would be rather tedious.

     Aside from verifying that no more traffic than strictly necessary
     happens (which would be a nice property but not really required),
     I don't see the point of verifying which resources exactly are
     queried.

     Furthermore, which resources precisely are queried and how often,
     seems more of an implementation detail to me.  I would rather
     focus on the end result: verifying that the imported package
     definition is what is expected.

     Most tests in tests/minetest.scm are like that: they tell
     call-with-packages to create a ContentDB model with some data
     (using make-package-json etc.) ask (guix import minetest) to
     import some package from the model and compare the result with a
     prediction (make-package-sexp) (can this called integration
     testing?).

     These tests do not care how (guix import minetest) works -- they
     don't care about which resources are queried.  Instead, they
     simply test that the end result (the package definition) is as
     predicted.

While criterium (b) might suffice for various unit tests
(e.g. in tests/lint.scm), it is rather impractical and limiting
for the kind of tests that tests/minetest.scm does.

OTOH, criterium (a) not only suffices for tests/lint.scm-style tests,
but also for tests/minetest.scm-style tests.  It seems to work
everywhere, except for the single exception tests/challenge.scm.=20

> It would be nice if we could keep it that way.

Compare (a) and (b), then I think it will be easy to infer what I would
prefer =F0=9F=98=89.

Greetings,
Maxime.

--=-t1ikULqiam0IUqcycun8
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: This is a digitally signed message part
Content-Transfer-Encoding: 7bit

-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYexTIhccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7itTAQD1YOZJg2DKpV6zRoGJMI/YjFQ8
rnvcCyQmVDqdauZQvAEAxWD+Il+A8dyjdRcIgS5EQhFN0Xpkh85nwzpz3Tx8ZQc=
=ozOG
-----END PGP SIGNATURE-----

--=-t1ikULqiam0IUqcycun8--





Information forwarded to guix-patches@HIDDEN:
bug#53389; Package guix-patches. Full text available.

Message received at 53389 <at> debbugs.gnu.org:


Received: (at 53389) by debbugs.gnu.org; 22 Jan 2022 18:08:18 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jan 22 13:08:18 2022
Received: from localhost ([127.0.0.1]:37818 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1nBKoE-00029S-Gz
	for submit <at> debbugs.gnu.org; Sat, 22 Jan 2022 13:08:18 -0500
Received: from albert.telenet-ops.be ([195.130.137.90]:52140)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <maximedevos@HIDDEN>) id 1nBKoC-00029F-Q8
 for 53389 <at> debbugs.gnu.org; Sat, 22 Jan 2022 13:08:17 -0500
Received: from ptr-bvsjgyhxw7psv60dyze.18120a2.ip6.access.telenet.be
 ([IPv6:2a02:1811:8c09:9d00:3c5f:2eff:feb0:ba5a])
 by albert.telenet-ops.be with bizsmtp
 id lu8E2600T4UW6Th06u8Fwz; Sat, 22 Jan 2022 19:08:15 +0100
Message-ID: <e4138e11d6ec25b32792099f136ff2f1e1fc49c3.camel@HIDDEN>
Subject: Re: [PATCH 1/9] tests: Support arbitrary HTTP request handlers.
From: Maxime Devos <maximedevos@HIDDEN>
To: 53389 <at> debbugs.gnu.org
Date: Sat, 22 Jan 2022 19:08:10 +0100
In-Reply-To: <20220120130849.292178-1-maximedevos@HIDDEN>
References: <20220120130849.292178-1-maximedevos@HIDDEN>
Content-Type: multipart/signed; micalg="pgp-sha512";
 protocol="application/pgp-signature"; boundary="=-tpBHENOw4E/AhYq+rSsm"
User-Agent: Evolution 3.38.3-1 
MIME-Version: 1.0
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telenet.be; s=r22;
 t=1642874895; bh=t1ReVY4GsVsxWOY8IBoneTECMCDSv+cd4lR+fYvEW9I=;
 h=Subject:From:To:Cc:Date:In-Reply-To:References;
 b=cKuFdt06Z1zIsCX6ksHZW+s9/rSbMZWOLE6lpS43/a6TT0umwwkf5XgYll7hikDMD
 e/bAd82nHkWGHOqjNXjFPOH8KIwmooHI1lm8eb5g2mhtK2dpyI5hzT501L6JOC0vNv
 F7azryJuM6oyB7thYIHEPCVudIYxcYU3Sbb2flT5WHyT3j5cuLQireN92+Z5oUBqZ+
 mB/eLRG/QsctIk8ZVxyuwmAc4XZlm3OZMXCkA5ahWD8SGC1essDAR/j88oecuYcktg
 xDc25yolnWQxLUN81PI/5X26LuYsAo2gZ4t22MYiFB7nlGH0AnKvqtNwrzZ0mkHYHk
 AMVnWmpbBE1/g==
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 53389
Cc: ludo@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)


--=-tpBHENOw4E/AhYq+rSsm
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: base64

TWF4aW1lIERldm9zIHNjaHJlZWYgb3AgZG8gMjAtMDEtMjAyMiBvbSAxMzowOCBbKzAwMDBdOgo+
IC3CoMKgwqDCoMKgICh3aGVuIChudWxsPyByZXNwb25zZXMpCj4gLcKgwqDCoMKgwqDCoMKgIChx
dWl0ICN0KSnCoMKgwqDCoMKgwqDCoMKgwqDCoMKgwqDCoMKgwqDCoMKgwqDCoMKgwqDCoMKgwqDC
oMKgwqDCoMKgwqDCoCA7ZXhpdCB0aGUgc2VydmVyIHRocmVhZAo+ICvCoMKgwqDCoMKgICh3aGVu
IChsYXN0LXJlc3BvbnNlPykKPiArwqDCoMKgwqDCoMKgwqAgKHRocm93ICdxdWl0KSkKCihxdWl0
ICN0KSBjYW4gYmUgcHJlc2VydmVkIGhlcmUgKFRCRCBpbiB2MikK


--=-tpBHENOw4E/AhYq+rSsm
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: This is a digitally signed message part
Content-Transfer-Encoding: 7bit

-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYexIChccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7gkPAQC1wM+ujji+rYklwRCDEgKwkaas
ctlvxr9EVuLwAdbumAEA15Pt1KlSYdiETgxm/YmRnIcFGkSQuZFJf3zv5jxfEgM=
=QVq3
-----END PGP SIGNATURE-----

--=-tpBHENOw4E/AhYq+rSsm--





Information forwarded to guix-patches@HIDDEN:
bug#53389; Package guix-patches. Full text available.

Message received at 53389 <at> debbugs.gnu.org:


Received: (at 53389) by debbugs.gnu.org; 22 Jan 2022 16:48:44 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jan 22 11:48:44 2022
Received: from localhost ([127.0.0.1]:37769 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1nBJZD-0008Vd-Tp
	for submit <at> 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 <ludo@HIDDEN>) id 1nBJZB-0008VQ-EL
 for 53389 <at> 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: =?utf-8?Q?Ludovic_Court=C3=A8s?= <ludo@HIDDEN>
To: Maxime Devos <maximedevos@HIDDEN>
Subject: Re: bug#53389: [PATCH 0/9] Replace some mocking with
 with-http-server*, avoid hardcoding ports,
References: <6b1c1d98514b2547907a81a04c1241d9b865d6fa.camel@HIDDEN>
 <20220120130849.292178-1-maximedevos@HIDDEN>
Date: Sat, 22 Jan 2022 17:48:32 +0100
In-Reply-To: <20220120130849.292178-1-maximedevos@HIDDEN> (Maxime Devos's
 message of "Thu, 20 Jan 2022 13:08:41 +0000")
Message-ID: <87lez7zpgf.fsf_-_@HIDDEN>
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: /
Authentication-Results: hera.aquilenet.fr;
	none
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-Spam-Score: 1.0 (+)
X-Debbugs-Envelope-To: 53389
Cc: 53389 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.0 (/)

Hi Maxime,

Maxime Devos <maximedevos@HIDDEN> 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.




Information forwarded to guix-patches@HIDDEN:
bug#53389; Package guix-patches. Full text available.

Message received at 53389 <at> debbugs.gnu.org:


Received: (at 53389) by debbugs.gnu.org; 20 Jan 2022 15:11:28 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Jan 20 10:11:27 2022
Received: from localhost ([127.0.0.1]:58977 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1nAZ5z-00037f-HM
	for submit <at> debbugs.gnu.org; Thu, 20 Jan 2022 10:11:27 -0500
Received: from hera.aquilenet.fr ([185.233.100.1]:51326)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1nAZ5x-00037R-Vu
 for 53389 <at> debbugs.gnu.org; Thu, 20 Jan 2022 10:11:26 -0500
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id 486B54FD;
 Thu, 20 Jan 2022 16:11:19 +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 L0v2azbedg7D; Thu, 20 Jan 2022 16:11:18 +0100 (CET)
Received: from ribbon (unknown [IPv6:2a01:e0a:1d:7270:af76:b9b:ca24:c465])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id F2F10224;
 Thu, 20 Jan 2022 16:11:17 +0100 (CET)
From: =?utf-8?Q?Ludovic_Court=C3=A8s?= <ludo@HIDDEN>
To: Maxime Devos <maximedevos@HIDDEN>
Subject: Re: [bug#53389] [PATCH 0/9] Replace some mocking with
 with-http-server*, avoid hardcoding ports,
References: <6b1c1d98514b2547907a81a04c1241d9b865d6fa.camel@HIDDEN>
X-URL: http://www.fdn.fr/~lcourtes/
X-Revolutionary-Date: 1 =?utf-8?Q?Pluvi=C3=B4se?= an 230 de la =?utf-8?Q?R?=
 =?utf-8?Q?=C3=A9volution?=
X-PGP-Key-ID: 0x090B11993D9AEBB5
X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc
X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4  0CFB 090B 1199 3D9A EBB5
X-OS: x86_64-pc-linux-gnu
Date: Thu, 20 Jan 2022 16:11:17 +0100
In-Reply-To: <6b1c1d98514b2547907a81a04c1241d9b865d6fa.camel@HIDDEN>
 (Maxime Devos's message of "Thu, 20 Jan 2022 13:59:16 +0100")
Message-ID: <87czkm788a.fsf@HIDDEN>
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: /
Authentication-Results: hera.aquilenet.fr;
	none
X-Rspamd-Server: hera
X-Rspamd-Queue-Id: 486B54FD
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-Spam-Score: 1.0 (+)
X-Debbugs-Envelope-To: 53389
Cc: 53389 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.0 (/)

Hi,

Maxime Devos <maximedevos@HIDDEN> skribis:

> (see <https://issues.guix.gnu.org/53060#3>.)
>
> by extending with-http-server to with-http-server* to allow arbitrary
> request handlers and extending with-http-server to allow verifying the
> URI of a request.
>
> tests/cpan.scm has been modified to verify the URIs.
> tests/import-github.scm and tests/minetest.scm have been modified to
> avoid mocking.

Great, I=E2=80=99ll take a look.

> Somewhat unrelated, tests/lint.scm, tests/cpan.scm and
> tests/challenge.scm have been modified to avoid hard coding ports,
> as a follow-up to commit c05ceaf2b650d090cf39a048193505cb4e6bd257:
>
>  [...]
>  Previously, test cases could fail if some process was listening
>  at a hard-coded port. This patch eliminates most of these
>  potential failures, by automatically assigning an unbound port.=C2=A0
>  This should allow for building multiple guix trees in parallel
>  outside a build container, though this is currently untested.
>  [...]
>
> After this patch series, there's to my knowledge only one instance of
> hardcoded ports remaining, in tests/lint.scm ("home-page: Connection
> refused").

That=E2=80=99s a much welcome change.

Thank you!

Ludo=E2=80=99.




Information forwarded to guix-patches@HIDDEN:
bug#53389; Package guix-patches. Full text available.

Message received at 53389 <at> debbugs.gnu.org:


Received: (at 53389) by debbugs.gnu.org; 20 Jan 2022 13:09:19 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Jan 20 08:09:19 2022
Received: from localhost ([127.0.0.1]:56706 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1nAXBn-0004rb-Ie
	for submit <at> 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 <maximedevos@HIDDEN>) id 1nAXBM-0004p0-Qp
 for 53389 <at> 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 <maximedevos@HIDDEN>
To: 53389 <at> debbugs.gnu.org
Subject: [PATCH 8/9] tests/cpan: Verify URIs.
Date: Thu, 20 Jan 2022 13:08:48 +0000
Message-Id: <20220120130849.292178-8-maximedevos@HIDDEN>
X-Mailer: git-send-email 2.30.2
In-Reply-To: <20220120130849.292178-1-maximedevos@HIDDEN>
References: <20220120130849.292178-1-maximedevos@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
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-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 53389
Cc: ludo@HIDDEN, Maxime Devos <maximedevos@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)

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 <bavier@HIDDEN>
 ;;; Copyright © 2016 Alex Sassmannshausen <alex@HIDDEN>
 ;;; Copyright © 2020 Ludovic Courtès <ludo@HIDDEN>
+;;; Copyright © 2022 Maxime Devos <maximedevos@HIDDEN>
 ;;;
 ;;; 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))))))
 
-- 
2.30.2





Information forwarded to guix-patches@HIDDEN:
bug#53389; Package guix-patches. Full text available.

Message received at 53389 <at> debbugs.gnu.org:


Received: (at 53389) by debbugs.gnu.org; 20 Jan 2022 13:09:19 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Jan 20 08:09:19 2022
Received: from localhost ([127.0.0.1]:56704 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1nAXBn-0004rU-2u
	for submit <at> 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 <maximedevos@HIDDEN>) id 1nAXBN-0004p1-0b
 for 53389 <at> 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 <maximedevos@HIDDEN>
To: 53389 <at> debbugs.gnu.org
Subject: [PATCH 9/9] tests/challenge: Do not hard code HTTP ports.
Date: Thu, 20 Jan 2022 13:08:49 +0000
Message-Id: <20220120130849.292178-9-maximedevos@HIDDEN>
X-Mailer: git-send-email 2.30.2
In-Reply-To: <20220120130849.292178-1-maximedevos@HIDDEN>
References: <20220120130849.292178-1-maximedevos@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
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-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 53389
Cc: ludo@HIDDEN, Maxime Devos <maximedevos@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)

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))))))))))))
-- 
2.30.2





Information forwarded to guix-patches@HIDDEN:
bug#53389; Package guix-patches. Full text available.

Message received at 53389 <at> debbugs.gnu.org:


Received: (at 53389) by debbugs.gnu.org; 20 Jan 2022 13:09:19 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Jan 20 08:09:19 2022
Received: from localhost ([127.0.0.1]:56702 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1nAXBm-0004rM-O7
	for submit <at> 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 <maximedevos@HIDDEN>) id 1nAXBM-0004oy-Kt
 for 53389 <at> 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 <maximedevos@HIDDEN>
To: 53389 <at> debbugs.gnu.org
Subject: [PATCH 7/9] tests: Allow checking the URI of a HTTP request.
Date: Thu, 20 Jan 2022 13:08:47 +0000
Message-Id: <20220120130849.292178-7-maximedevos@HIDDEN>
X-Mailer: git-send-email 2.30.2
In-Reply-To: <20220120130849.292178-1-maximedevos@HIDDEN>
References: <20220120130849.292178-1-maximedevos@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
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-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 53389
Cc: ludo@HIDDEN, Maxime Devos <maximedevos@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)

* 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?
-- 
2.30.2





Information forwarded to guix-patches@HIDDEN:
bug#53389; Package guix-patches. Full text available.

Message received at 53389 <at> debbugs.gnu.org:


Received: (at 53389) by debbugs.gnu.org; 20 Jan 2022 13:09:18 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Jan 20 08:09:18 2022
Received: from localhost ([127.0.0.1]:56700 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1nAXBm-0004rF-1p
	for submit <at> 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 <maximedevos@HIDDEN>) id 1nAXBM-0004op-08
 for 53389 <at> 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 <maximedevos@HIDDEN>
To: 53389 <at> debbugs.gnu.org
Subject: [PATCH 1/9] tests: Support arbitrary HTTP request handlers.
Date: Thu, 20 Jan 2022 13:08:41 +0000
Message-Id: <20220120130849.292178-1-maximedevos@HIDDEN>
X-Mailer: git-send-email 2.30.2
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
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-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 53389
Cc: ludo@HIDDEN, Maxime Devos <maximedevos@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)

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(-)

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 <ludo@HIDDEN>
-;;; Copyright © 2021 Maxime Devos <maximedevos@HIDDEN>
+;;; Copyright © 2021, 2022 Maxime Devos <maximedevos@HIDDEN>
 ;;;
 ;;; 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 <ludo@HIDDEN>
+;;; Copyright © 2022 Maxime Devos <maximedevos@HIDDEN>
 ;;;
 ;;; 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

base-commit: 1bd250783d7118c3101dd2a6e090f3d6904b24a0
-- 
2.30.2





Information forwarded to guix-patches@HIDDEN:
bug#53389; Package guix-patches. Full text available.

Message received at 53389 <at> debbugs.gnu.org:


Received: (at 53389) by debbugs.gnu.org; 20 Jan 2022 13:09:18 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Jan 20 08:09:18 2022
Received: from localhost ([127.0.0.1]:56698 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1nAXBi-0004r3-EG
	for submit <at> 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 <maximedevos@HIDDEN>) id 1nAXBM-0004ou-4a
 for 53389 <at> 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 <maximedevos@HIDDEN>
To: 53389 <at> debbugs.gnu.org
Subject: [PATCH 4/9] tests/import-github: Run a HTTP server instead of mocking.
Date: Thu, 20 Jan 2022 13:08:44 +0000
Message-Id: <20220120130849.292178-4-maximedevos@HIDDEN>
X-Mailer: git-send-email 2.30.2
In-Reply-To: <20220120130849.292178-1-maximedevos@HIDDEN>
References: <20220120130849.292178-1-maximedevos@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
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-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 53389
Cc: ludo@HIDDEN, Maxime Devos <maximedevos@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)

Fixes: <https://issues.guix.gnu.org/53060#3>

* tests/import-github.scm (call-with-releases): Run a HTTP server instead of
  mocking.

Suggested-by: Ludovic Courtès <ludo@HIDDEN>
---
 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)
-- 
2.30.2





Information forwarded to guix-patches@HIDDEN:
bug#53389; Package guix-patches. Full text available.

Message received at 53389 <at> debbugs.gnu.org:


Received: (at 53389) by debbugs.gnu.org; 20 Jan 2022 13:09:14 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Jan 20 08:09:14 2022
Received: from localhost ([127.0.0.1]:56696 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1nAXBe-0004qt-Gj
	for submit <at> 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 <maximedevos@HIDDEN>) id 1nAXBM-0004ow-8M
 for 53389 <at> 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 <maximedevos@HIDDEN>
To: 53389 <at> debbugs.gnu.org
Subject: [PATCH 5/9] tests/cpan: Do not hard code a HTTP port.
Date: Thu, 20 Jan 2022 13:08:45 +0000
Message-Id: <20220120130849.292178-5-maximedevos@HIDDEN>
X-Mailer: git-send-email 2.30.2
In-Reply-To: <20220120130849.292178-1-maximedevos@HIDDEN>
References: <20220120130849.292178-1-maximedevos@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
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-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 53389
Cc: ludo@HIDDEN, Maxime Devos <maximedevos@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)

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"
-- 
2.30.2





Information forwarded to guix-patches@HIDDEN:
bug#53389; Package guix-patches. Full text available.

Message received at 53389 <at> debbugs.gnu.org:


Received: (at 53389) by debbugs.gnu.org; 20 Jan 2022 13:09:10 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Jan 20 08:09:10 2022
Received: from localhost ([127.0.0.1]:56692 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1nAXBR-0004q4-Pk
	for submit <at> 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 <maximedevos@HIDDEN>) id 1nAXBM-0004ox-Ds
 for 53389 <at> 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 <maximedevos@HIDDEN>
To: 53389 <at> debbugs.gnu.org
Subject: [PATCH 6/9] tests/lint: Do not assume the next port is free.
Date: Thu, 20 Jan 2022 13:08:46 +0000
Message-Id: <20220120130849.292178-6-maximedevos@HIDDEN>
X-Mailer: git-send-email 2.30.2
In-Reply-To: <20220120130849.292178-1-maximedevos@HIDDEN>
References: <20220120130849.292178-1-maximedevos@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
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-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 53389
Cc: ludo@HIDDEN, Maxime Devos <maximedevos@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

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"))
-- 
2.30.2





Information forwarded to guix-patches@HIDDEN:
bug#53389; Package guix-patches. Full text available.

Message received at 53389 <at> debbugs.gnu.org:


Received: (at 53389) by debbugs.gnu.org; 20 Jan 2022 13:08:57 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Jan 20 08:08:57 2022
Received: from localhost ([127.0.0.1]:56690 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1nAXBR-0004q2-IG
	for submit <at> 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 <maximedevos@HIDDEN>) id 1nAXBM-0004oq-06
 for 53389 <at> 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 <maximedevos@HIDDEN>
To: 53389 <at> debbugs.gnu.org
Subject: [PATCH 2/9] tests: Generalise %local-url.
Date: Thu, 20 Jan 2022 13:08:42 +0000
Message-Id: <20220120130849.292178-2-maximedevos@HIDDEN>
X-Mailer: git-send-email 2.30.2
In-Reply-To: <20220120130849.292178-1-maximedevos@HIDDEN>
References: <20220120130849.292178-1-maximedevos@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
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-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 53389
Cc: ludo@HIDDEN, Maxime Devos <maximedevos@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)

* 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)))
-- 
2.30.2





Information forwarded to guix-patches@HIDDEN:
bug#53389; Package guix-patches. Full text available.

Message received at 53389 <at> debbugs.gnu.org:


Received: (at 53389) by debbugs.gnu.org; 20 Jan 2022 13:08:55 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Jan 20 08:08:55 2022
Received: from localhost ([127.0.0.1]:56688 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1nAXBO-0004pT-3y
	for submit <at> 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 <maximedevos@HIDDEN>) id 1nAXBM-0004os-2W
 for 53389 <at> 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 <maximedevos@HIDDEN>
To: 53389 <at> debbugs.gnu.org
Subject: [PATCH 3/9] tests/minetest: Run a HTTP server instead of mocking.
Date: Thu, 20 Jan 2022 13:08:43 +0000
Message-Id: <20220120130849.292178-3-maximedevos@HIDDEN>
X-Mailer: git-send-email 2.30.2
In-Reply-To: <20220120130849.292178-1-maximedevos@HIDDEN>
References: <20220120130849.292178-1-maximedevos@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
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-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 53389
Cc: ludo@HIDDEN, Maxime Devos <maximedevos@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)

Fixes: <https://issues.guix.gnu.org/53060#3>

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 <ludo@HIDDEN>
---
 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 <maximedevos@HIDDEN>
+;;; Copyright © 2021, 2022 Maxime Devos <maximedevos@HIDDEN>
 ;;;
 ;;; 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)
-- 
2.30.2





Information forwarded to guix-patches@HIDDEN:
bug#53389; Package guix-patches. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 20 Jan 2022 13:00:58 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Jan 20 08:00:58 2022
Received: from localhost ([127.0.0.1]:56645 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1nAX3h-0003Gi-J4
	for submit <at> debbugs.gnu.org; Thu, 20 Jan 2022 08:00:58 -0500
Received: from lists.gnu.org ([209.51.188.17]:43974)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <maximedevos@HIDDEN>) id 1nAX3f-0003EC-88
 for submit <at> debbugs.gnu.org; Thu, 20 Jan 2022 08:00:55 -0500
Received: from eggs.gnu.org ([209.51.188.92]:47914)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <maximedevos@HIDDEN>)
 id 1nAX3Q-0001WR-45
 for guix-patches@HIDDEN; Thu, 20 Jan 2022 08:00:50 -0500
Received: from [2a02:1800:120:4::f00:15] (port=44032 helo=andre.telenet-ops.be)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <maximedevos@HIDDEN>)
 id 1nAX3G-0005cn-2k
 for guix-patches@HIDDEN; Thu, 20 Jan 2022 08:00:34 -0500
Received: from ptr-bvsjgyhxw7psv60dyze.18120a2.ip6.access.telenet.be
 ([IPv6:2a02:1811:8c09:9d00:3c5f:2eff:feb0:ba5a])
 by andre.telenet-ops.be with bizsmtp
 id l0zS260044UW6Th010zSBi; Thu, 20 Jan 2022 13:59:28 +0100
Message-ID: <6b1c1d98514b2547907a81a04c1241d9b865d6fa.camel@HIDDEN>
Subject: [PATCH 0/9] Replace some mocking with with-http-server*, avoid
 hardcoding ports,
From: Maxime Devos <maximedevos@HIDDEN>
To: guix-patches@HIDDEN
Date: Thu, 20 Jan 2022 13:59:16 +0100
Content-Type: multipart/signed; micalg="pgp-sha512";
 protocol="application/pgp-signature"; boundary="=-QJCuQ6NNc7AgRWJOGoB8"
User-Agent: Evolution 3.38.3-1 
MIME-Version: 1.0
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telenet.be; s=r22;
 t=1642683568; bh=T2BWXZYp6DRhEBP93gCQ7XG/jZyoBX1+6RBN0nZWKdM=;
 h=Subject:From:To:Date;
 b=M7pUWf78fuxaIPUo1gc+dzyfirGXFI9ffzjr+AQndvqiRB47+rBSIi6Ibvd004GS+
 es03QBJzV2gSgmteMCEr+hPEGmFqxoITc1e+bT36OjbnKptj9AJjqjaP5SjT/10b5W
 TBn4725DFZjTtWRnpcToIy1i/G1VXvh8u2LNaTeFsudvQCXVDXMFbAUZcDlUNA6JcS
 8WDfme2KlzD2bpGgOCkBueHBL+xK1Vm8CCic4D/byyPVQpKmMA3Fi2jrxv6NAHceAR
 Bzf77ojijxg/GgD0k6Rm5fe7o0sk5GfUJQkraew2DUay55uKHVGV5yBnL5FrJwz7fn
 zYV1QhPonnyKQ==
X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a02:1800:120:4::f00:15
 (failed)
Received-SPF: pass client-ip=2a02:1800:120:4::f00:15;
 envelope-from=maximedevos@HIDDEN; helo=andre.telenet-ops.be
X-Spam_score_int: -19
X-Spam_score: -2.0
X-Spam_bar: --
X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001,
 RCVD_IN_DNSWL_LOW=-0.7, RDNS_NONE=0.793, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001 autolearn=no autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -0.1 (/)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.3 (--)


--=-QJCuQ6NNc7AgRWJOGoB8
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

X-Debbugs-CC: ludo@HIDDEN

Hi,

This patch series addresses:

Ludovic Court=C3=A8s schreef op zo 16-01-2022 om 23:19 [+0100]:
> I think the whole point of having the =E2=80=98%github-api=E2=80=99 param=
eter is that
> it allows us to mock the HTTP server instead of having to override
> bindings such as =E2=80=98http-fetch=E2=80=99.
>=20
> I=E2=80=99d have a slight preference for doing that, similar to what is d=
one
> in tests/cpan.scm for instance.  WDYT?

(see <https://issues.guix.gnu.org/53060#3>.)

by extending with-http-server to with-http-server* to allow arbitrary
request handlers and extending with-http-server to allow verifying the
URI of a request.

tests/cpan.scm has been modified to verify the URIs.
tests/import-github.scm and tests/minetest.scm have been modified to
avoid mocking.

Somewhat unrelated, tests/lint.scm, tests/cpan.scm and
tests/challenge.scm have been modified to avoid hard coding ports,
as a follow-up to commit c05ceaf2b650d090cf39a048193505cb4e6bd257:

 [...]
 Previously, test cases could fail if some process was listening
 at a hard-coded port. This patch eliminates most of these
 potential failures, by automatically assigning an unbound port.=C2=A0
 This should allow for building multiple guix trees in parallel
 outside a build container, though this is currently untested.
 [...]

After this patch series, there's to my knowledge only one instance of
hardcoded ports remaining, in tests/lint.scm ("home-page: Connection
refused").

This patch series is also available at
https://notabug.org/maximed/guix-gnunet (branch
more-precise-http-tests, commit
f0a0303c17b5aa92493aea5a6d28183421b7cf44).

Greetings,
Maxime.

--=-QJCuQ6NNc7AgRWJOGoB8
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: This is a digitally signed message part
Content-Transfer-Encoding: 7bit

-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYelcpBccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7irMAPwNeTw/NNF7cXaGMZlTV+D1k3p6
xFhNYna2mBtbycMXDwEAkcl04r0yhSxeFWzFd39Wtq0MbnlmB1iBu48nwDIQoA4=
=56SL
-----END PGP SIGNATURE-----

--=-QJCuQ6NNc7AgRWJOGoB8--





Acknowledgement sent to Maxime Devos <maximedevos@HIDDEN>:
New bug report received and forwarded. Copy sent to ludo@HIDDEN, guix-patches@HIDDEN. Full text available.
Report forwarded to ludo@HIDDEN, guix-patches@HIDDEN:
bug#53389; Package guix-patches. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Thu, 21 Apr 2022 15:30:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.