From patchwork Tue Sep 28 00:40:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Attila Lendvai X-Patchwork-Id: 33373 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 1461A27BBE6; Tue, 28 Sep 2021 01:43:23 +0100 (BST) 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, MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,T_DKIM_INVALID 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 8FD4A27BBE1 for ; Tue, 28 Sep 2021 01:43:21 +0100 (BST) Received: from localhost ([::1]:47498 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mV1DM-0000R5-Lh for patchwork@mira.cbaines.net; Mon, 27 Sep 2021 20:43:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47106) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mV1D4-0000QL-Rn for guix-patches@gnu.org; Mon, 27 Sep 2021 20:43:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:59902) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mV1D4-0004YG-A9 for guix-patches@gnu.org; Mon, 27 Sep 2021 20:43:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mV1D4-0005rl-4R for guix-patches@gnu.org; Mon, 27 Sep 2021 20:43:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#50750] [PATCH 1/4] tests: Smarten up git repository testing framework. References: <20210923080914.6149-1-attila@lendvai.name> In-Reply-To: <20210923080914.6149-1-attila@lendvai.name> Resent-From: Attila Lendvai Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 28 Sep 2021 00:43:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 50750 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 50750@debbugs.gnu.org Cc: Attila Lendvai Received: via spool by 50750-submit@debbugs.gnu.org id=B50750.163278972522464 (code B ref 50750); Tue, 28 Sep 2021 00:43:02 +0000 Received: (at 50750) by debbugs.gnu.org; 28 Sep 2021 00:42:05 +0000 Received: from localhost ([127.0.0.1]:43209 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mV1C8-0005qF-Tf for submit@debbugs.gnu.org; Mon, 27 Sep 2021 20:42:05 -0400 Received: from mail-ed1-f43.google.com ([209.85.208.43]:36467) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mV1C4-0005p6-Ma for 50750@debbugs.gnu.org; Mon, 27 Sep 2021 20:42:01 -0400 Received: by mail-ed1-f43.google.com with SMTP id y35so25245934ede.3 for <50750@debbugs.gnu.org>; Mon, 27 Sep 2021 17:42:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=7kd0E7PC/LNXP+KlKpXFrhoFwEqqFjwgJX8oTvH5C64=; b=gErrjWE9Rju8+WkmlB8p3AsL53KN79onuSOISZcEkY3iYKcqWINrGz4CTLZlHGLDYJ mBIHY5bPMxVOn8ppxxq9qGhsWrBq/+EeNvuTF1rNGCtsqoBSuU3JXMHH3ZnXzuVLYsMS /VZBhMG269oL6YVn4m6xK24Ck7RCWCx2Vo2a1HFCyfFMhXdR3OGPZaBhP64YB2bi09fx N5wJVL9amCXSxt4Jo2vBqTcEbUr7av07jbbd0vzJ33dCW3EOhHJmF3ipuEuHIbg5VxFa zcmNIf1y5cmbrHhDEuBJ4jCKgsMitFrbSUFsWP+q09yZZArfypMWrpgSfBizN5GiqzTn qKZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; bh=7kd0E7PC/LNXP+KlKpXFrhoFwEqqFjwgJX8oTvH5C64=; b=epJyFdKCTgQNADFrSBp5dvt5JhXCNqm7xX0TbhSjV8dtAw/Gz5Uw1tZkVfk5B8u79/ N7/qNtx2tbnOqInf7T91z4vBrNKSkk1wqzIJNUuuKB2Zi37h82APoyU/tlwsxw/D4fVY 8hRp+YGdXr0hIa2wg9ImGg2R6cJEbwRxYOtMTUG744yQF8AfX1ECJShmPL6VaUSrPVzr 3O1hm2opTyU8p6SpCrFyKMVG620Di5sjtlf+V4B/vnjysjMy5sEHUaeZJ9uWCiUeo5n+ KGEavkQqbZLX8+iC6OrYztNWHWmwxwzNgubLqdFs+6DgeahvWZso0lmSKoE8qOkSIhpF tM1A== X-Gm-Message-State: AOAM5307iH1PBzN3No5aSXDsfRTjYDn0/GREM6G0DqcXFY7QP/gslNF5 tey4gFYZhRv8KcYdWKEQYyeNb34DlL4= X-Google-Smtp-Source: ABdhPJwh6FYXyhkNSCUv1Z3TIIhFy94m1UUQoINbL8rtWauxn4qyZSvvnia4bKmXYcOYx1Lo2kG9ZQ== X-Received: by 2002:a17:906:5010:: with SMTP id s16mr3550628ejj.245.1632789714789; Mon, 27 Sep 2021 17:41:54 -0700 (PDT) Received: from lelap.lan (catv-213-222-131-28.catv.broadband.hu. [213.222.131.28]) by smtp.gmail.com with ESMTPSA id u4sm9396207ejc.19.2021.09.27.17.41.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Sep 2021 17:41:54 -0700 (PDT) From: Attila Lendvai Date: Tue, 28 Sep 2021 02:40:03 +0200 Message-Id: <20210928004005.28786-1-attila@lendvai.name> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * guix/tests/git.scm (with-git-repository): New macro that can be used in a nested way under a with-temporary-git-repository. (populate-git-repository): Extend the DSL with (add "some-noise"), (reset "[commit hash]"), (checkout "branch" orphan). * guix/tests/gnupg.scm (key-fingerprint-vector): New function. --- guix/tests/git.scm | 23 +++++++++++++++++++++-- guix/tests/gnupg.scm | 8 ++++++-- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/guix/tests/git.scm b/guix/tests/git.scm index 69960284d9..76f5a8b937 100644 --- a/guix/tests/git.scm +++ b/guix/tests/git.scm @@ -26,6 +26,7 @@ #:use-module (ice-9 control) #:export (git-command with-temporary-git-repository + with-git-repository find-commit)) (define git-command @@ -59,8 +60,9 @@ Return DIRECTORY on success." (apply invoke (git-command) "-C" directory command args))))) - (mkdir-p directory) - (git "init") + (unless (directory-exists? (string-append directory "/.git")) + (mkdir-p directory) + (git "init")) (let loop ((directives directives)) (match directives @@ -78,6 +80,9 @@ Return DIRECTORY on success." port))) (git "add" file) (loop rest))) + ((('add file-name-and-content) rest ...) + (loop (cons `(add ,file-name-and-content ,file-name-and-content) + rest))) ((('remove file) rest ...) (git "rm" "-f" file) (loop rest)) @@ -99,12 +104,18 @@ Return DIRECTORY on success." ((('checkout branch) rest ...) (git "checkout" branch) (loop rest)) + ((('checkout branch 'orphan) rest ...) + (git "checkout" "--orphan" branch) + (loop rest)) ((('merge branch message) rest ...) (git "merge" branch "-m" message) (loop rest)) ((('merge branch message ('signer fingerprint)) rest ...) (git "merge" branch "-m" message (string-append "--gpg-sign=" fingerprint)) + (loop rest)) + ((('reset to) rest ...) + (git "reset" "--hard" to) (loop rest))))) (define (call-with-temporary-git-repository directives proc) @@ -121,6 +132,14 @@ per DIRECTIVES." (lambda (directory) exp ...))) +(define-syntax-rule (with-git-repository directory + directives exp ...) + "Evaluate EXP in a context where DIRECTORY is (further) populated as +per DIRECTIVES." + (begin + (populate-git-repository directory directives) + exp ...)) + (define (find-commit repository message) "Return the commit in REPOSITORY whose message includes MESSAGE, a string." (let/ec return diff --git a/guix/tests/gnupg.scm b/guix/tests/gnupg.scm index eb8ff63a43..c7630db912 100644 --- a/guix/tests/gnupg.scm +++ b/guix/tests/gnupg.scm @@ -33,6 +33,7 @@ read-openpgp-packet key-fingerprint + key-fingerprint-vector key-id)) (define gpg-command @@ -76,7 +77,10 @@ process is terminated afterwards." (open-bytevector-input-port (call-with-input-file file read-radix-64)))) +(define key-fingerprint-vector + (compose openpgp-public-key-fingerprint + read-openpgp-packet)) + (define key-fingerprint (compose openpgp-format-fingerprint - openpgp-public-key-fingerprint - read-openpgp-packet)) + key-fingerprint-vector))