From patchwork Mon Oct 18 15:57:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Attila Lendvai X-Patchwork-Id: 33916 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 6299727BBE3; Mon, 18 Oct 2021 16:58:36 +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 EBA4827BBE1 for ; Mon, 18 Oct 2021 16:58:35 +0100 (BST) Received: from localhost ([::1]:45948 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mcV21-0006wz-VH for patchwork@mira.cbaines.net; Mon, 18 Oct 2021 11:58:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55806) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mcV1X-0006sr-7k for guix-patches@gnu.org; Mon, 18 Oct 2021 11:58:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:36770) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mcV1W-0002FL-S0 for guix-patches@gnu.org; Mon, 18 Oct 2021 11:58:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mcV1W-0006zp-Rg for guix-patches@gnu.org; Mon, 18 Oct 2021 11:58:02 -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: Mon, 18 Oct 2021 15:58:02 +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.163457267626860 (code B ref 50814); Mon, 18 Oct 2021 15:58:02 +0000 Received: (at 50814) by debbugs.gnu.org; 18 Oct 2021 15:57:56 +0000 Received: from localhost ([127.0.0.1]:48311 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mcV1Q-0006z7-Ja for submit@debbugs.gnu.org; Mon, 18 Oct 2021 11:57:56 -0400 Received: from mail-ed1-f42.google.com ([209.85.208.42]:44804) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mcV1O-0006yr-60 for 50814@debbugs.gnu.org; Mon, 18 Oct 2021 11:57:56 -0400 Received: by mail-ed1-f42.google.com with SMTP id w14so1051501edv.11 for <50814@debbugs.gnu.org>; Mon, 18 Oct 2021 08:57:53 -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=Q1LEPb2GaMgwANKUBjTAL73fLUg/TR6v/7o6kLsZRSs=; b=A5pLJmG3KfYlHjWfBcUMi3IPYHtchncQtJlbEa9Ok+5bgFlvsH79sBQ3ZIvMM7tBwm Yy/QNDXny84Kgd8ml6TPOY67m0c9KrGyObTqVFVzb7WnmCIayzJ3GOZrTvM7bl42WLfS u2aI8RpLYFjD2AAuom2ermAEAXPL1jgAVbEmYYFqfcgtvJP4qYGeh9AefRyRJrsgpQtm kRvLkVzIZ1tNAnd27/SZcLIvaqkhtaGC0Rzb0GypO8f16CQXi4ECNTRMrsTxRtXvopnw w/WO+RwZyotjNrO3mZ3s+b8YQ4HnoCmFzLKeqrrtT8h940tR40e7TLlpSDrhLK4nowTO kRFg== 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=Q1LEPb2GaMgwANKUBjTAL73fLUg/TR6v/7o6kLsZRSs=; b=OWQmecmC43bJkeLVjIEIS+3IVmJWIK36zJaXOqpXGlDj5BF6WlWXsLDVPRgXI56RU1 UNnhA47pIZgEBnRMixDq9JVJ0F6ILhibj1CBBzxoTHwFNr8N12M6exCUzLJrAGofL3NR Z2ZRbaUzntGsImW4rcmM7jTBQeVMYCEGpt++U7f/6ouAlnST6v40hUmn9S4YqOsz4F1L PqR0MECzxxaA+kyvdGDUqVrNEZSgy6Ki1q4EpiumrPs4mm9eBaqt6oD7keTeJseh9V2N P4tze68o68FCChTloyIZLIxN9CFPfZPH8m+y7NZ+SX84LQ37I0Bn26d21+HSHGqJGUxw rZIw== X-Gm-Message-State: AOAM531tTEgoYiLBGlE/a92HG/2xx8AH+kF/65TYOK24TCaz0g/a6RP1 7fJZIDkvGNHUWRZuHW+0bfrIxUswlck= X-Google-Smtp-Source: ABdhPJyB2Lt2gJih99l5w9bmq1lCsYS+VsaE9J4bAVK+1puO0r5n0SW5lXUMIAeSqifLnWyr2JPtjQ== X-Received: by 2002:a17:906:7a50:: with SMTP id i16mr31606213ejo.507.1634572665483; Mon, 18 Oct 2021 08:57:45 -0700 (PDT) Received: from localhost.localdomain ([2a02:ab88:3710:6480:8fb4:66e9:57c0:8a0a]) by smtp.gmail.com with ESMTPSA id n22sm8762059eja.120.2021.10.18.08.57.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Oct 2021 08:57:44 -0700 (PDT) From: Attila Lendvai Date: Mon, 18 Oct 2021 17:57:30 +0200 Message-Id: <20211018155734.5175-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 @@ (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 eb8ff63a43..c7630db912 100644 --- a/guix/tests/gnupg.scm +++ b/guix/tests/gnupg.scm @@ -33,6 +33,7 @@ (define-module (guix tests gnupg) read-openpgp-packet key-fingerprint + key-fingerprint-vector key-id)) (define gpg-command @@ -76,7 +77,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))