From patchwork Tue Sep 28 16:24: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: 33391 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 196CE27BBE3; Tue, 28 Sep 2021 17:27:13 +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 9A47327BBE1 for ; Tue, 28 Sep 2021 17:27:12 +0100 (BST) Received: from localhost ([::1]:45428 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mVFwl-0003EX-46 for patchwork@mira.cbaines.net; Tue, 28 Sep 2021 12:27:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35486) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVFwc-0003E2-7k for guix-patches@gnu.org; Tue, 28 Sep 2021 12:27:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:35241) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mVFwc-0006yl-0S for guix-patches@gnu.org; Tue, 28 Sep 2021 12:27:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mVFwb-0005aN-TV; Tue, 28 Sep 2021 12:27:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#50814] [PATCH 1/5] tests: Smarten up git repository testing framework. References: <20210926101928.3877-1-attila@lendvai.name> In-Reply-To: <20210926101928.3877-1-attila@lendvai.name> Resent-From: Attila Lendvai Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 28 Sep 2021 16:27:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 50814 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 50814@debbugs.gnu.org Cc: Attila Lendvai Received: via spool by 50814-submit@debbugs.gnu.org id=B50814.163284636821348 (code B ref 50814); Tue, 28 Sep 2021 16:27:01 +0000 Received: (at 50814) by debbugs.gnu.org; 28 Sep 2021 16:26:08 +0000 Received: from localhost ([127.0.0.1]:46778 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mVFvj-0005YF-KJ for submit@debbugs.gnu.org; Tue, 28 Sep 2021 12:26:07 -0400 Received: from mail-ed1-f49.google.com ([209.85.208.49]:40789) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mVFvf-0005Xh-Qh for 50814@debbugs.gnu.org; Tue, 28 Sep 2021 12:26:06 -0400 Received: by mail-ed1-f49.google.com with SMTP id g8so85609665edt.7 for <50814@debbugs.gnu.org>; Tue, 28 Sep 2021 09:26:03 -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=Ih2wHg8CHn1lhLlWDj4wv35zanKpD5kefzDPZch+y/5g4cGcp16z6Qkno8Xvpq5At/ u/yk1k4pmg59tcz6GUrVbOkp58WTLgm1wIPmMnB24551CbNMzMoBneXqZwIhAD2xWyog Y29wqsespsBKm5Lh2FXbKhTdekxgvTB9PGv8luRcqfp9tsNQ2PgEdPCXoISvNoNu10RQ lBAjvGWU07t/zHEs0ZD/h0j5/XfvPxQ73g36TCqNzFxiVW58+MXhlgtN3dzocovxpKC/ X3PkAi8529q1Ga7Lis+CDG76PDByqzy5FgnQz3xe12hJAK/Y1s6OqqILTMCcsbSZN0TN VHMA== 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=x//0CgCRE8HYs5v/uiPGTOi1mYvZxwnxFZSLVRzSu/z7kLbOlpkMG/Tk6V4OZHt0JJ oiBmi/yNLszkkxlh2IvpnaQRufOA2qyumUG/sBu7ZSLvcprgaPRUYHnCRq/KHqbXnYnv Aj7moPy2OEVLv6ZlW2tCBoV7aaNI1Znl31xQSI9NcV6qBMr7EfXg29IwDGL6gjacqacL X0HIqkf+WoKq08YxIfiI1DmAlloh9KPST7BeYvbVCJ2Fp0QaPp5IqyENgKSaqcxuGPBN 16xpMTfeRSeKb3apfkSp8q8ODjz2yyQLYnb8Bj4q3TlTdHuciQ3+aHuyghVf1OVMTiBV pg8Q== X-Gm-Message-State: AOAM532u+iXkwtkqpFnoQlcq0qZT9coZ8YUQmD80LvDHgaIfTWPs2AgE /rS2Iznb5W7eRjMIYL1HOSyI6z52oXI= X-Google-Smtp-Source: ABdhPJzk6fMCtMSz4Ae3hjL+ui28Rud1Do1YtMuW0C/f3f1ZXfwd0UJDf8p/xHu1XX6Rzyq/wR0Nvg== X-Received: by 2002:a17:906:308d:: with SMTP id 13mr7747940ejv.570.1632846356871; Tue, 28 Sep 2021 09:25:56 -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 f4sm3147720ejq.125.2021.09.28.09.25.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Sep 2021 09:25:56 -0700 (PDT) From: Attila Lendvai Date: Tue, 28 Sep 2021 18:24:03 +0200 Message-Id: <20210928162406.27205-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))