unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: "Ludovic Courtès" <ludo@gnu.org>
To: Maxime Devos <maximedevos@telenet.be>
Cc: 46668@debbugs.gnu.org
Subject: [bug#46668] [PATCH]: tests: do not hard code HTTP ports
Date: Tue, 02 Mar 2021 22:29:18 +0100	[thread overview]
Message-ID: <87eegxtfbl.fsf_-_@gnu.org> (raw)
In-Reply-To: <a9549150450e97d5f02ae789af24a320b5315749.camel@telenet.be> (Maxime Devos's message of "Tue, 02 Mar 2021 09:15:57 +0100")

Hi,

Maxime Devos <maximedevos@telenet.be> skribis:

> From 933cb85de0f50c54190e7c60420bef5245a3f2ed Mon Sep 17 00:00:00 2001
> From: Maxime Devos <maximedevos@telenet.be>
> Date: Sat, 20 Feb 2021 22:04:59 +0100
> Subject: [PATCH] tests: do not hard code HTTP ports
>
> 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.  This should
> allow for building multiple guix trees in parallel outside a build
> container, though this is currently untested.
>
> The test "home-page: Connection refused" in tests/lint.scm still
> hardcodes port 9999, however.
>
> * guix/tests/http.scm
>   (http-server-can-listen?): remove now unused procedure.
>   (%http-server-port): default to port 0, meaning the OS
>   will automatically choose a port.
>   (open-http-server-socket): remove the false statement claiming
>   this procedure is exported and also return the allocated port
>   number.
>   (%local-url): raise an error if the port is obviously unbound.
>   (call-with-http-server): set %http-server-port to the allocated
>   port while the thunk is called.
> * tests/derivations.scm: adjust test cases to use automatically
>   assign a port.  As there is no risk of a port conflict now,
>   do not make any tests conditional upon 'http-server-can-listen?'
>   anymore.
> * tests/elpa.scm: likewise.
> * tests/lint.scm: likewise, and add a TODO comment about a port
>   that is still hard-coded.
> * tests/texlive.scm: likewise.

Minor comment but nothing blocking:

> +  (let* ((text (random-text)))
> +    (with-http-server `((200 ,text))
> +      (let ((drv (derivation %store "world"
> +                             "builtin:download" '()
> +                             #:env-vars `(("url"
> +                                           . ,(object->string (%local-url))))
> +                             #:hash-algo 'sha256
> +                             #:hash (gcrypt:sha256 (string->utf8 text)))))
> +        (and drv (build-derivations %store (list drv))
> +             (with-http-server `((200 ,text))
> +               (build-derivations %store (list drv)
> +                                  (build-mode check)))
> +             (string=? (call-with-input-file (derivation->output-path drv)
> +                         get-string-all)
> +                       text))))))

It’s a tad confusing that the second ‘with-http-server’ is now nested;
it shouldn’t change the semantics though, so it’s okay.

Anyway, you’re welcome to push to ‘master’ if “make check” agrees.  :-)

Thanks again!

Ludo’.




  reply	other threads:[~2021-03-02 21:34 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-20 22:00 [bug#46668] [PATCH]: tests: do not hard code HTTP ports Maxime Devos
2021-03-01 15:46 ` Ludovic Courtès
2021-03-01 17:23   ` Maxime Devos
2021-03-01 21:40     ` Ludovic Courtès
2021-03-02  8:15       ` Maxime Devos
2021-03-02 21:29         ` Ludovic Courtès [this message]
2021-03-02 21:49           ` Maxime Devos
2021-03-06 10:23             ` bug#46668: " Ludovic Courtès

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

  List information: https://guix.gnu.org/

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

  git send-email \
    --in-reply-to=87eegxtfbl.fsf_-_@gnu.org \
    --to=ludo@gnu.org \
    --cc=46668@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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).