From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id eAnIC/tqUmEMLAEAgWs5BA (envelope-from ) for ; Tue, 28 Sep 2021 03:08:11 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id uOuBB/tqUmGWDAAA1q6Kng (envelope-from ) for ; Tue, 28 Sep 2021 01:08:11 +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 724902896C for ; Tue, 28 Sep 2021 03:08:10 +0200 (CEST) Received: from localhost ([::1]:53732 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mV1bN-00061Z-Kg for larch@yhetil.org; Mon, 27 Sep 2021 21:08:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50420) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mV1bG-000612-HE for guix-patches@gnu.org; Mon, 27 Sep 2021 21:08:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:59926) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mV1bG-0004M8-AU for guix-patches@gnu.org; Mon, 27 Sep 2021 21:08:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mV1bG-0006UJ-0Y; Mon, 27 Sep 2021 21:08:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#50814] [PATCH 1/4] 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 01:08: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.163279126824890 (code B ref 50814); Tue, 28 Sep 2021 01:08:01 +0000 Received: (at 50814) by debbugs.gnu.org; 28 Sep 2021 01:07:48 +0000 Received: from localhost ([127.0.0.1]:43231 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mV1b2-0006TM-C8 for submit@debbugs.gnu.org; Mon, 27 Sep 2021 21:07:48 -0400 Received: from mail-ed1-f49.google.com ([209.85.208.49]:35807) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mV1ay-0006Sz-Id for 50814@debbugs.gnu.org; Mon, 27 Sep 2021 21:07:47 -0400 Received: by mail-ed1-f49.google.com with SMTP id l8so28956665edw.2 for <50814@debbugs.gnu.org>; Mon, 27 Sep 2021 18:07:44 -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=4C6uXvPkgyWTKcARbKHq7ZaLxV3UyjfBBjr9wtyCgyE=; b=R1cogpYPPRAr4Ev2EvZI62NivazpiI39TYQj6/PnfluEgI2xEaDGiDSaUcr9uGdkjY vZF7a8/8AfavTMQWmBjzSZOOJfFvzx6PdU37kJ++Oxo8XGmZYYd5+6KtLrmSRY23pJT5 ETO0BE0LUjZP3Y69NxGgT4gvwyTUVuYf/p5+kI2MjlXVvw/QlXsNMvi7HYd1PsM2/IOk q+2xdq3iNXieiL7OQ+j+MyrveYZpRAoYa/Y67s5tGiIIKD0NOUmIxCYZbq18OwWGH7Mh 6Z0RLbXLs1aOjegB1+Yhmb2Ille/UPFK9Kkteda5qwxRwTDT2JjHvGTpMowZJn8lxdSc 7QtA== 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=4C6uXvPkgyWTKcARbKHq7ZaLxV3UyjfBBjr9wtyCgyE=; b=mOfBj72qeXXxanxtdqdGdye+N26AMGJ+bFonof98tSwXCnXuFrgVdCrJ/ro00wN0OB gIkt7Tqz1ntlcJj7IquwuQxx72AeexTt3nNKdC1+5iXKiG6VYe6Yv5U4Zk27ZwUv73Gq N0VnJpsxaKersGc2rusOSK73Xq7+cf9XRDnppAfCEZb4q1lRfHRV0TZZVKmm449Btl8s 5ieK4kM7URPK3PLLp78ZvO8dTEVnk17py4oc2ShIn0JQPA/aTVT6brtjWB2+h+O4v4y1 sa4iDhHA/LkoXViNa+fjIwm2/jjnHSFH9mk1rgxGtRPp+cqA/p1+vDW5knr9tidYJ9k7 ZS1Q== X-Gm-Message-State: AOAM531Ovpu7RcuoCOqoiQQLxHG5tkIGoSLYLcJYFuYRV4rN7vjxI+Nm MIXgtL2KWYqCypfN3vJHrc1qkpMUazA= X-Google-Smtp-Source: ABdhPJyZVxIbrPvx58WDmQaFMt/bkn5gwh7ikbnRyzbVaDbZuvLYh/BBpfOimsbo6S3n6xry6p5EHg== X-Received: by 2002:aa7:c2d3:: with SMTP id m19mr4137555edp.267.1632791258731; Mon, 27 Sep 2021 18:07:38 -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 c5sm11989558edx.81.2021.09.27.18.07.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Sep 2021 18:07:37 -0700 (PDT) From: Attila Lendvai Date: Tue, 28 Sep 2021 03:05:35 +0200 Message-Id: <20210928010537.4241-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=1632791290; 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=4C6uXvPkgyWTKcARbKHq7ZaLxV3UyjfBBjr9wtyCgyE=; b=a2Te2VZkJDt9oXgkt4/OGoI0MG1iG455sqJ+O6kBOQ1+tbE0fVBMAQeTAe4v3jDaGKzpKB IawHNgSL+li6a+e+cIk2KpzZLjl00OVz0Cuz6+Mn5A9veCD7KiiqQoriNamM0vk8ddj2ZB St3el47i4xBguik0kfDJ7N1bS2VvFu6PW4KI42q8UQRYCiYAwS3HQechTOCPdEM0HeoNaI a8PlOntsDAknm3U+eSfoMMl6XwfYRvRBC45PJHYATtNoWyPCi2efz4qbjkS9Ts+olue+4J Y85j3enVms7gdoJef9Zy5oECfaFv5uOOKYNVr+JirzcRapH1dnGGDABHSE35OQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1632791290; a=rsa-sha256; cv=none; b=ucpuer6EDFPdHjl9vsYJoXebENUN1b5WqOCKqcuPIvceQqr5nSlkvLrnXsScb7j5alQ57h xmxmIipdRMaZusjQj0t7M7mcbTbIVSJqcPw1pQJvs1pkB+ZaoIEpw5iUsGoxVzt2WMJFa8 gPXL1DZ36sejdb6nhblTceEhdqojpsJrBIsqIZS33vA8/ww0K/V/Rw8aVJqJ3CvJsPhE2h 8dRdRkGuSoPfw4LdIFZYjnhr53ZJbIkb0MbWAtqj57sAOOOKBvgLDudMP/YLRyKFn9EnNE CatvgwTWmZa+UteGDWBHrdCbUfsD5vbEKfQjMGJq6BQbHuG/2tdGOp0XWUI+hQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=R1cogpYP; 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.61 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=R1cogpYP; 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: 724902896C X-Spam-Score: 3.61 X-Migadu-Scanner: scn0.migadu.com X-TUID: ARA+llXeOIbu * 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. --- Ready for merging modulo possible feedback, and one TODO regarding the UI of giving feedback to the user. 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