From patchwork Sun Jan 31 20:04:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: M X-Patchwork-Id: 26794 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 5F0EC27BC1D; Sun, 31 Jan 2021 20:05:11 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS,T_DKIM_INVALID,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 121C727BC1E for ; Sun, 31 Jan 2021 20:05:10 +0000 (GMT) Received: from localhost ([::1]:42532 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l6Iy5-00065c-91 for patchwork@mira.cbaines.net; Sun, 31 Jan 2021 15:05:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36426) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l6Ixy-00065U-Rt for guix-patches@gnu.org; Sun, 31 Jan 2021 15:05:02 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:46556) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l6Ixy-0006BX-Ku for guix-patches@gnu.org; Sun, 31 Jan 2021 15:05:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1l6Ixy-0004mu-GQ for guix-patches@gnu.org; Sun, 31 Jan 2021 15:05:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#46216] [PATCH] Remove duplication in tests/publish.scm Resent-From: Maxime Devos Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 31 Jan 2021 20:05:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 46216 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 46216@debbugs.gnu.org Received: via spool by 46216-submit@debbugs.gnu.org id=B46216.161212349618385 (code B ref 46216); Sun, 31 Jan 2021 20:05:02 +0000 Received: (at 46216) by debbugs.gnu.org; 31 Jan 2021 20:04:56 +0000 Received: from localhost ([127.0.0.1]:58102 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l6Ixl-0004mN-64 for submit@debbugs.gnu.org; Sun, 31 Jan 2021 15:04:56 -0500 Received: from baptiste.telenet-ops.be ([195.130.132.51]:49058) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l6Ixj-0004mD-CG for 46216@debbugs.gnu.org; Sun, 31 Jan 2021 15:04:48 -0500 Received: from ptr-bvsjgyjmffd7q9timvx.18120a2.ip6.access.telenet.be ([IPv6:2a02:1811:8c09:9d00:aaf1:9810:a0b8:a55d]) by baptiste.telenet-ops.be with bizsmtp id PY4l2400D0mfAB401Y4lD7; Sun, 31 Jan 2021 21:04:45 +0100 Message-ID: <22d53945012c235334fb1b37262c000fcb666838.camel@telenet.be> From: Maxime Devos Date: Sun, 31 Jan 2021 21:04:39 +0100 In-Reply-To: References: User-Agent: Evolution 3.34.2 MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telenet.be; s=r21; t=1612123485; bh=rvXm+iMA2en9+gmA8Cf05ddh/Ei5bkpGR3mljGmVYYs=; h=Subject:From:Reply-To:To:Date:In-Reply-To:References; b=eivnwZKeR7pvbHzPpsVtTffexSAffknYNoDWrDtmb8oV2xrXHJ3oRVqZZYo8gPFFq rMtiSqg7++5evHQhb0s/p+6XTycn5DU7uQawYEWagXwYYsr4FK9Kt22pF9gGh7yXvN wrPNUKTm6dIFCMd+aK44VkbeGLS5/USpWMSJuKclqFUK8+aecnxVtdr2vBBPzlpmgt dBBquAUiLlcS/eYvMNjQngJ/UIFHE4uJhg6Ol8NSXo0bG1231WZAyuOAzaBb+tQJbc v/BRGN++5zUoiln9eqyUbawYloyCLg7FqVIi5Mr1GdpIZbKmtzxfNXZv8sFhUAO1oi KXYrNRttZ4/cw== X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: 46216@debbugs.gnu.org Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches This is the second patch in the series. Description from commit message: * tests/publish.scm (call-with-guix-publish, with-guix-publish): introduce combination of spawn-guix-publish and wait-until-ready, and adjust tests to use the macro. Maxime From dc166f96da951ed045ddc87441428a44693035cd Mon Sep 17 00:00:00 2001 From: Maxime Devos Date: Sun, 31 Jan 2021 20:58:46 +0100 Subject: [PATCH] tests: publish: remove duplicated use of wait-until-ready * tests/publish.scm (call-with-guix-publish, with-guix-publish): introduce combination of spawn-guix-publish and wait-until-ready, and adjust tests to use the macro. --- tests/publish.scm | 68 +++++++++++++++++++++++------------------------ 1 file changed, 33 insertions(+), 35 deletions(-) diff --git a/tests/publish.scm b/tests/publish.scm index 7c90332bda..e24b0feb00 100644 --- a/tests/publish.scm +++ b/tests/publish.scm @@ -106,6 +106,18 @@ The resulting thread is returned." (lambda () (apply guix-publish (format #f "--port=~a" port) extra-arguments))))) +(define (call-with-guix-publish port extra-arguments thunk) + "Call THUNK in an environment where a local publishing service +is running in a separate thread, listening at PORT. EXTRA-ARGUMENTS +are passed as-is as extra command-line arguments." + (let ((thread (apply spawn-guix-publish port extra-arguments))) + (wait-until-ready port) + (thunk))) + +(define-syntax-rule (with-guix-publish port extra-arguments exp ...) + (call-with-guix-publish port extra-arguments + (lambda () exp ...))) + (spawn-guix-publish 6789 "-C0") (define (wait-until-ready port) @@ -267,8 +279,7 @@ References: ~%" `(("StorePath" . ,%item) ("URL" . ,(string-append "nar/gzip/" (basename %item))) ("Compression" . "gzip")) - (let ((thread (spawn-guix-publish 6799 "-C5"))) - (wait-until-ready 6799) + (with-guix-publish 6799 '("-C5") (let* ((url (string-append "http://localhost:6799/" (store-path-hash-part %item) ".narinfo")) (body (http-get-port url))) @@ -284,8 +295,7 @@ References: ~%" `(("StorePath" . ,%item) ("URL" . ,(string-append "nar/lzip/" (basename %item))) ("Compression" . "lzip")) - (let ((thread (spawn-guix-publish 6790 "-Clzip"))) - (wait-until-ready 6790) + (with-guix-publish 6790 '("-Clzip") (let* ((url (string-append "http://localhost:6790/" (store-path-hash-part %item) ".narinfo")) (body (http-get-port url))) @@ -319,8 +329,7 @@ References: ~%" 200) (call-with-temporary-directory (lambda (cache) - (let ((thread (spawn-guix-publish 6793 "-Cgzip:2" "-Clzip:2"))) - (wait-until-ready 6793) + (with-guix-publish 6793 '("-Cgzip:2" "-Clzip:2") (let* ((base "http://localhost:6793/") (part (store-path-hash-part %item)) (url (string-append base part ".narinfo")) @@ -340,9 +349,7 @@ References: ~%" ("Compression" . "none")) 200 404) - (let ((thread (spawn-guix-publish 6798 "-C0" - "--nar-path=///foo/bar//chbouib/"))) - (wait-until-ready 6798) + (with-guix-publish 6798 '("-C0" "--nar-path=///foo/bar//chbouib/") (let* ((base "http://localhost:6798/") (part (store-path-hash-part %item)) (url (string-append base part ".narinfo")) @@ -423,10 +430,8 @@ References: ~%" 404) ;nar/… (call-with-temporary-directory (lambda (cache) - (let ((thread (spawn-guix-publish 6797 "-C2" - (string-append "--cache=" cache) - "--cache-bypass-threshold=0"))) - (wait-until-ready 6797) + (with-guix-publish 6797 `("-C2" ,(string-append "--cache=" cache) + "--cache-bypass-threshold=0") (let* ((base "http://localhost:6797/") (part (store-path-hash-part %item)) (url (string-append base part ".narinfo")) @@ -475,10 +480,9 @@ References: ~%" '(200 200 404) (call-with-temporary-directory (lambda (cache) - (let ((thread (spawn-guix-publish 6794 "-Cgzip:2" "-Clzip:2" - (string-append "--cache=" cache) - "--cache-bypass-threshold=0"))) - (wait-until-ready 6794) + (with-guix-publish 6794 `("-Cgzip:2" "-Clzip:2" + ,(string-append "--cache=" cache) + "--cache-bypass-threshold=0") (let* ((base "http://localhost:6794/") (part (store-path-hash-part %item)) (url (string-append base part ".narinfo")) @@ -528,13 +532,9 @@ References: ~%" 404) ;nar/gzip/… (call-with-temporary-directory (lambda (cache) - (let ((thread (with-separate-output-ports - (call-with-new-thread - (lambda () - (guix-publish "--port=6796" "-C2" "--ttl=42h" - (string-append "--cache=" cache) - "--cache-bypass-threshold=0")))))) - (wait-until-ready 6796) + (with-guix-publish 6796 `("-C2" "--ttl=42h" + ,(string-append "--cache=" cache) + "--cache-bypass-threshold=0") (let* ((base "http://localhost:6796/") (part (store-path-hash-part item)) (url (string-append base part ".narinfo")) @@ -580,9 +580,7 @@ References: ~%" 200 (call-with-temporary-directory (lambda (cache) - (let ((thread (spawn-guix-publish 6795 - (string-append "--cache=" cache)))) - (wait-until-ready 6795) + (with-guix-publish 6795 (list (string-append "--cache=" cache)) ;; Make sure that, even if ITEM disappears, we're still able to fetch ;; it. @@ -604,11 +602,8 @@ References: ~%" 200 (call-with-temporary-directory (lambda (cache) - (let ((thread (spawn-guix-publish 6788 "-C" "gzip" - "--port=6788" "-C" "gzip" - (string-append "--cache=" cache)))) - (wait-until-ready 6788) - + (with-guix-publish 6788 `("-C" "gzip" "-C" "gzip" + ,(string-append "--cache=" cache)) (let* ((base "http://localhost:6788/") (item (add-text-to-store %store "random" (random-text))) (part (store-path-hash-part item)) @@ -638,9 +633,7 @@ References: ~%" ;; for a non-existing file name. (call-with-temporary-directory (lambda (cache) - (let ((thread (spawn-guix-publish 6787 "-C" "gzip" - (string-append "--cache=" cache)))) - (wait-until-ready 6787) + (with-guix-publish 6787 `("-C" "gzip" ,(string-append "--cache=" cache)) (let* ((base "http://localhost:6787/") (item (add-text-to-store %store "random" (random-text))) @@ -702,3 +695,8 @@ References: ~%" (http-post (publish-uri path)))))) (test-end "publish") + +;; Local Variables: +;; eval: (put 'with-guix-publish 'scheme-indent-function 2) +;; eval: (put 'call-with-guix-publish 'scheme-indent-function 2) +;; End: -- 2.30.0