From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id QMwbDyNlUmEuIAEAgWs5BA (envelope-from ) for ; Tue, 28 Sep 2021 02:43:15 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id wBTfCiNlUmHdeQAA1q6Kng (envelope-from ) for ; Tue, 28 Sep 2021 00:43:15 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id D4E7F2F931 for ; Tue, 28 Sep 2021 02:43:14 +0200 (CEST) Received: from localhost ([::1]:47498 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mV1DF-0000R5-G8 for larch@yhetil.org; Mon, 27 Sep 2021 20:43:13 -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 Content-Transfer-Encoding: 8bit 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+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1632789795; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=7kd0E7PC/LNXP+KlKpXFrhoFwEqqFjwgJX8oTvH5C64=; b=Lqf1sCOU82DYbwJ75fkjUXERbT1oIqXAW1tYtTU1KswVjCJOiv951lWuWy4fERlnVoMCt7 WgQF8dyCH4b+pLUTDs2pOdhjNrF2fKcA8qZGt8N/9ZwEEnYEnjE++KrD+VM2ghzF208/HB 60W5LNZtR1WB5wLwCjKXhugGMbAuSgRqStXRYGYxGy55dzxl2BeD+/+KXHJ50NkJ0JLtgp +E987mcI9J8Qr4hWw6H2cVSlTv8t8vcP/i2nJd+UD+9CZiiAVG9RTbfBDBwNa6CdrFN3Z1 R6bX7xA7eUpaNOxd5YxKX+MBm4fqbSFTqydGqCn6zEf6eLfw60OKJgtp/966Sg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1632789795; a=rsa-sha256; cv=none; b=eoauKzK0OFvKc5o0IzZ5jm2p9CAOOjOxVndseKbhRy3wnokOJ4tOoO27RAxjQS5Q1zEpq9 rBQJ4YFWSpFYMjg0MoUqGjZYVPUKhHmOeZq/QvVUkUMXbytuddaCMeuPHLfmLbPtbyLuqg 8j38vTv4KETFRVsShb3KJasw881aMk787rm9LA9ctMjwO9JbDiSQFwiWP+lRG6TxvjRInM ECvBQLWNY3vDphi0yMSAyXq9lfDrHIbxyD/YmvB/dXYR9Dg1zzpCT5EUlQay1kWasjtvXb fIQcWvCgtlPJWn+QhQ7CUC/KCMoLDZek19pup9dMe+/zvXa6KQ5E1rV4/4XXnQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=gErrjWE9; dmarc=none; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Spam-Score: 3.21 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=gErrjWE9; dmarc=none; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Queue-Id: D4E7F2F931 X-Spam-Score: 3.21 X-Migadu-Scanner: scn1.migadu.com X-TUID: E/yL59jy8aVX * 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)) -- 2.33.0