From patchwork Tue Dec 21 22:32:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Attila Lendvai X-Patchwork-Id: 35537 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 2E13E27BBEA; Tue, 21 Dec 2021 22:35:41 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id ACAA527BBE9 for ; Tue, 21 Dec 2021 22:35:40 +0000 (GMT) Received: from localhost ([::1]:59654 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mznjP-000464-Tt for patchwork@mira.cbaines.net; Tue, 21 Dec 2021 17:35:39 -0500 Received: from eggs.gnu.org ([209.51.188.92]:37570) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzniq-00045C-Kf for guix-patches@gnu.org; Tue, 21 Dec 2021 17:35:04 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:44412) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mzniq-0000GC-Ba for guix-patches@gnu.org; Tue, 21 Dec 2021 17:35:04 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mznip-0007dK-AP for guix-patches@gnu.org; Tue, 21 Dec 2021 17:35:03 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#52722] [PATCH] tests: Smarten up git repository testing framework. Resent-From: Attila Lendvai Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 21 Dec 2021 22:35:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 52722 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 52722@debbugs.gnu.org Cc: Attila Lendvai X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.164012604629254 (code B ref -1); Tue, 21 Dec 2021 22:35:03 +0000 Received: (at submit) by debbugs.gnu.org; 21 Dec 2021 22:34:06 +0000 Received: from localhost ([127.0.0.1]:55956 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mznhu-0007bm-81 for submit@debbugs.gnu.org; Tue, 21 Dec 2021 17:34:06 -0500 Received: from lists.gnu.org ([209.51.188.17]:33008) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mznhm-0007b4-MB for submit@debbugs.gnu.org; Tue, 21 Dec 2021 17:34:04 -0500 Received: from eggs.gnu.org ([209.51.188.92]:37448) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mznhm-00041U-GM for guix-patches@gnu.org; Tue, 21 Dec 2021 17:33:58 -0500 Received: from [2a00:1450:4864:20::530] (port=38911 helo=mail-ed1-x530.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mznhk-0000AC-V8 for guix-patches@gnu.org; Tue, 21 Dec 2021 17:33:58 -0500 Received: by mail-ed1-x530.google.com with SMTP id bm14so907089edb.5 for ; Tue, 21 Dec 2021 14:33:47 -0800 (PST) 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=0OcdR6vQRTSjCkc3U8/XeIuW9iwDx50UOXa8hQoarjM=; b=jd0vw19AhrQkVaDh5WfgPFMdmmJlbliZaEAER/4nQVpE7WkAsGgSD5hhlEbO16wEeA n14FOw+J4h8Mr4EDp0aVdKM9E9MiAu+QORxOT0LLPvQ4g3+CH7zpGOosCwSuaUnZwjVm ag+w0RfK76B12wlYwdfzA3j2bHD8klHvB1PCPMIW2AGbG8MVrO41o2hMmczrz3jpmJUI h4nmgvSUjNf8LUVYLbRfGo6EuH02OtuxPbGJeYNgEXNKnrhLBjVyH4031kulANCDOrlu wLRGMM+RoVKOqbDcXCV8wD67tMDyY7Sajm7joyeHHeBU9/RPMP/UDi/9JlWyCH9JlWfZ cs4A== 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=0OcdR6vQRTSjCkc3U8/XeIuW9iwDx50UOXa8hQoarjM=; b=4174SUHZisn8WBMIhX3msauVSTWF1KL9aC0VAFlZIzs2tqL/D37UVogSmHrD3YcxgG rOGe7e65k0mm7fbHGuX1clQM88MoYRpLwWiB+0CPFby/V+PjdV07GhUw8/gzheA5Tb95 WoxZcfPQaA2pwAml6T0Ngw8jEyLteKcSOUqJYClVRc/jRlDyYmuIsdp6pglZQF9qTx6I 7yzWPNvsllemaBsWFtrRKScVDo0GT681LPkiQH/DljUJR0c3cbEW2m+RoWhSRFmRalgz quErAWk+LjIhcqirxzPy35XO5nZgmCz4e907f2ro6VoWSPyeScVF7F8ZEhbfyQsoIVzr d2gQ== X-Gm-Message-State: AOAM5312ypHYKAdPeayhdXTnn447u8cqmfvq+Y3aBJO34V3qIppf1dLj /h4HXmkGonIrYCVJNpgk64oW1nbaHQgLQQ== X-Google-Smtp-Source: ABdhPJwZun8rbrlsGSzGdrkry/FbCSTeh/JT4gWvuYJP08nX+Y+EL5k9rekFIJWq7VDvi8UmYxBBOQ== X-Received: by 2002:a17:906:649c:: with SMTP id e28mr337341ejm.60.1640126025854; Tue, 21 Dec 2021 14:33:45 -0800 (PST) Received: from localhost.localdomain ([2a02:ab88:3700:b180:6072:12a9:8472:9a8f]) by smtp.gmail.com with ESMTPSA id hq29sm54462ejc.141.2021.12.21.14.33.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Dec 2021 14:33:45 -0800 (PST) From: Attila Lendvai Date: Tue, 21 Dec 2021 23:32:41 +0100 Message-Id: <20211221223244.32542-1-attila@lendvai.name> X-Mailer: git-send-email 2.34.0 MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::530 (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::530; envelope-from=attila.lendvai@gmail.com; helo=mail-ed1-x530.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action 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 These features will be used in upcoming tests. * guix/tests/git.scm (with-git-repository): New macro that can be used multiple times, inside 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 procedure. --- 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 @@ (define-module (guix tests git) #:use-module (ice-9 control) #:export (git-command with-temporary-git-repository + with-git-repository find-commit)) (define git-command @@ -59,8 +60,9 @@ (define (git command . args) (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 @@ (define (git command . args) 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 @@ (define (git command . args) ((('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 @@ (define-syntax-rule (with-temporary-git-repository directory (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 943fd66077..09f02a2b67 100644 --- a/guix/tests/gnupg.scm +++ b/guix/tests/gnupg.scm @@ -35,6 +35,7 @@ (define-module (guix tests gnupg) read-openpgp-packet key-fingerprint + key-fingerprint-vector key-id)) (define gpg-command @@ -82,7 +83,10 @@ (define (read-openpgp-packet file) (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))