all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Ludovic Courtès" <ludo@gnu.org>
To: Maxime Devos <maximedevos@telenet.be>
Cc: 53389@debbugs.gnu.org
Subject: [bug#53389] [PATCH 0/9] Replace some mocking with with-http-server*, avoid hardcoding ports,
Date: Mon, 07 Feb 2022 10:53:48 +0100	[thread overview]
Message-ID: <87r18fdmtv.fsf_-_@gnu.org> (raw)
In-Reply-To: <687d96c300852e684422de877cd87769daae7ccd.camel@telenet.be> (Maxime Devos's message of "Sat, 22 Jan 2022 19:55:30 +0100")

[-- Attachment #1: Type: text/plain, Size: 678 bytes --]

Hi,

Maxime Devos <maximedevos@telenet.be> skribis:

> Ludovic Courtès schreef op za 22-01-2022 om 17:48 [+0100]:
>> > +        (unless keep-lingering?
>> > +          ;; exit the server thread
>> > +          (system-async-mark (lambda () (throw 'quit)) server))
>> 
>> When do we need ‘keep-lingering?’?
>
> In tests/challenge.scm (call-mismatch-test), due to how the store monad
> work, the thunk technically returns (*) before we are done with the
> querying the server.  Perhaps this can be resolved with sufficient
> monadology, but I don't quite see how.
>
> (*) a monadic value.

How about fixing it locally like this:


[-- Attachment #2: Type: text/x-patch, Size: 2285 bytes --]

diff --git a/tests/challenge.scm b/tests/challenge.scm
index fdd5fd238e..0b44ed7d21 100644
--- a/tests/challenge.scm
+++ b/tests/challenge.scm
@@ -1,5 +1,5 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2015, 2017, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2015, 2017, 2019, 2020, 2022 Ludovic Courtès <ludo@gnu.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -57,6 +57,17 @@ (define-syntax with-derivation-narinfo*
        (lambda () body ...)
        hash))))
 
+(define-syntax-rule (with-http-server* arguments body ...)
+  ;; Like 'with-http-server' but for use in a monadic context.
+  (let ((port (%http-server-port)))
+    (lambda (store)
+      (values (parameterize ((%http-server-port port))
+                (call-with-http-server arguments
+                                       (lambda ()
+                                         (run-with-store store
+                                           body ...))))
+              store))))
+
 \f
 (test-begin "challenge")
 
@@ -198,11 +209,11 @@ (define (call-mismatch-test proc)
                                      (lambda (port)
                                        (write-file out2 port)))))
         (parameterize ((%http-server-port 9000))
-          (with-http-server `((200 ,(make-narinfo item size1 hash1))
-                              (200 ,nar1))
+          (with-http-server* `((200 ,(make-narinfo item size1 hash1))
+                               (200 ,nar1))
             (parameterize ((%http-server-port 9001))
-              (with-http-server `((200 ,(make-narinfo item size2 hash2))
-                                  (200 ,nar2))
+              (with-http-server* `((200 ,(make-narinfo item size2 hash2))
+                                   (200 ,nar2))
                 (mlet* %store-monad ((urls -> (list (%local-url 9000)
                                                     (%local-url 9001)))
                                      (reports (compare-contents (list item)
@@ -238,4 +249,5 @@ (define (call-mismatch-test proc)
 
 ;;; Local Variables:
 ;;; eval: (put 'with-derivation-narinfo* 'scheme-indent-function 2)
+;;; eval: (put 'with-http-server* 'scheme-indent-function 1)
 ;;; End:

[-- Attachment #3: Type: text/plain, Size: 102 bytes --]


That way we don’t need to keep the lingering variant in (guix tests
http).

WDYT?

Ludo’.

  parent reply	other threads:[~2022-02-07 10:06 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-20 12:59 [bug#53389] [PATCH 0/9] Replace some mocking with with-http-server*, avoid hardcoding ports, Maxime Devos
2022-01-20 13:08 ` [bug#53389] [PATCH 1/9] tests: Support arbitrary HTTP request handlers Maxime Devos
2022-01-20 13:08   ` [bug#53389] [PATCH 2/9] tests: Generalise %local-url Maxime Devos
2022-01-20 13:08   ` [bug#53389] [PATCH 3/9] tests/minetest: Run a HTTP server instead of mocking Maxime Devos
2022-01-20 13:08   ` [bug#53389] [PATCH 4/9] tests/import-github: " Maxime Devos
2022-01-20 13:08   ` [bug#53389] [PATCH 5/9] tests/cpan: Do not hard code a HTTP port Maxime Devos
2022-01-20 13:08   ` [bug#53389] [PATCH 6/9] tests/lint: Do not assume the next port is free Maxime Devos
2022-01-20 13:08   ` [bug#53389] [PATCH 7/9] tests: Allow checking the URI of a HTTP request Maxime Devos
2022-01-20 13:08   ` [bug#53389] [PATCH 8/9] tests/cpan: Verify URIs Maxime Devos
2022-01-20 13:08   ` [bug#53389] [PATCH 9/9] tests/challenge: Do not hard code HTTP ports Maxime Devos
2022-01-22 16:48   ` [bug#53389] [PATCH 0/9] Replace some mocking with with-http-server*, avoid hardcoding ports, Ludovic Courtès
2022-01-22 18:55     ` Maxime Devos
2022-01-25  7:54       ` Ludovic Courtès
2022-01-25 13:37         ` Maxime Devos
2022-02-07  9:53       ` Ludovic Courtès [this message]
2022-02-07 10:59         ` Maxime Devos
2022-03-06 16:23           ` Ludovic Courtès
2022-03-07  7:00             ` Maxime Devos
2022-01-22 19:21     ` Maxime Devos
2022-01-22 19:57     ` Maxime Devos
2022-01-22 20:42     ` Maxime Devos
2022-01-22 18:08   ` [bug#53389] [PATCH 1/9] tests: Support arbitrary HTTP request handlers Maxime Devos
2022-01-20 15:11 ` [bug#53389] [PATCH 0/9] Replace some mocking with with-http-server*, avoid hardcoding ports, Ludovic Courtès
2022-04-12 19:46 ` [bug#53389] [PATCH 0/9] Replace some mocking with with-http-server Maxime Devos
2022-04-21 15:20 ` [bug#53389] [PATCH v2 0/25] Replace some mocking with with-http-server*, avoid harcoding ports Maxime Devos

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87r18fdmtv.fsf_-_@gnu.org \
    --to=ludo@gnu.org \
    --cc=53389@debbugs.gnu.org \
    --cc=maximedevos@telenet.be \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.