GNU bug report logs - #52722
[PATCH] tests: Smarten up git repository testing framework.

Previous Next

Package: guix-patches;

Reported by: Attila Lendvai <attila <at> lendvai.name>

Date: Tue, 21 Dec 2021 22:35:03 UTC

Severity: normal

Tags: patch

Done: Mathieu Othacehe <othacehe <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 52722 in the body.
You can then email your comments to 52722 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#52722; Package guix-patches. (Tue, 21 Dec 2021 22:35:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to Attila Lendvai <attila <at> lendvai.name>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Tue, 21 Dec 2021 22:35:03 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Attila Lendvai <attila <at> lendvai.name>
To: guix-patches <at> gnu.org
Cc: Attila Lendvai <attila <at> lendvai.name>
Subject: [PATCH] tests: Smarten up git repository testing framework.
Date: Tue, 21 Dec 2021 23:32:41 +0100
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))
-- 
2.34.0





Information forwarded to guix-patches <at> gnu.org:
bug#52722; Package guix-patches. (Wed, 22 Dec 2021 10:31:02 GMT) Full text and rfc822 format available.

Message #8 received at 52722 <at> debbugs.gnu.org (full text, mbox):

From: Attila Lendvai <attila <at> lendvai.name>
To: 52722 <at> debbugs.gnu.org
Cc: Attila Lendvai <attila <at> lendvai.name>
Subject: [PATCH v2 1/2] tests: Smarten up git repository testing framework.
Date: Wed, 22 Dec 2021 11:28:55 +0100
* guix/tests/git.scm (with-git-repository): New macro, exported.  It can be used
repeatedly inside a WITH-TEMPORARY-GIT-REPOSITORY.
(populate-git-repository): Extend the DSL with (ADD "some-noise"), (RESET
"[commit hash]"), (CHECKOUT "branch" ORPHAN).
---

as requested on IRC, resending it as two commits.

 guix/tests/git.scm | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 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
-- 
2.34.0





Information forwarded to guix-patches <at> gnu.org:
bug#52722; Package guix-patches. (Wed, 22 Dec 2021 10:31:02 GMT) Full text and rfc822 format available.

Message #11 received at 52722 <at> debbugs.gnu.org (full text, mbox):

From: Attila Lendvai <attila <at> lendvai.name>
To: 52722 <at> debbugs.gnu.org
Cc: Attila Lendvai <attila <at> lendvai.name>
Subject: [PATCH v2 2/2] tests: gnupg: Factor out and export
 KEY-FINGERPRINT-VECTOR.
Date: Wed, 22 Dec 2021 11:28:57 +0100
* guix/tests/gnupg.scm (key-fingerprint-vector): New procedure.  Export it.
(key-fingerprint): Use it.
---
 guix/tests/gnupg.scm | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

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))
-- 
2.34.0





Reply sent to Mathieu Othacehe <othacehe <at> gnu.org>:
You have taken responsibility. (Thu, 23 Dec 2021 16:42:02 GMT) Full text and rfc822 format available.

Notification sent to Attila Lendvai <attila <at> lendvai.name>:
bug acknowledged by developer. (Thu, 23 Dec 2021 16:42:02 GMT) Full text and rfc822 format available.

Message #16 received at 52722-done <at> debbugs.gnu.org (full text, mbox):

From: Mathieu Othacehe <othacehe <at> gnu.org>
To: Attila Lendvai <attila <at> lendvai.name>
Cc: 52722-done <at> debbugs.gnu.org
Subject: Re: bug#52722: [PATCH] tests: Smarten up git repository testing
 framework.
Date: Thu, 23 Dec 2021 17:41:29 +0100
> * guix/tests/gnupg.scm (key-fingerprint-vector): New procedure.  Export it.
> (key-fingerprint): Use it.

Pushed, thanks!

Mathieu




Information forwarded to guix-patches <at> gnu.org:
bug#52722; Package guix-patches. (Thu, 23 Dec 2021 17:41:01 GMT) Full text and rfc822 format available.

Message #19 received at 52722 <at> debbugs.gnu.org (full text, mbox):

From: Leo Famulari <leo <at> famulari.name>
To: Attila Lendvai <attila <at> lendvai.name>
Cc: 52722 <at> debbugs.gnu.org
Subject: Re: [bug#52722] [PATCH v2 1/2] tests: Smarten up git repository
 testing framework.
Date: Thu, 23 Dec 2021 12:40:38 -0500
On Wed, Dec 22, 2021 at 11:28:55AM +0100, Attila Lendvai wrote:
> * guix/tests/git.scm (with-git-repository): New macro, exported.  It can be used
> repeatedly inside a WITH-TEMPORARY-GIT-REPOSITORY.
> (populate-git-repository): Extend the DSL with (ADD "some-noise"), (RESET
> "[commit hash]"), (CHECKOUT "branch" ORPHAN).

This commit introduced some ambiguity while importing the RESET
procedure:

WARNING: (guix tests git): `reset' imported from both (git) and (ice-9 control)

We need to make sure that the correct reset is imported here. Can you
take a look and make any adjustments, if necessary?




Information forwarded to guix-patches <at> gnu.org:
bug#52722; Package guix-patches. (Thu, 23 Dec 2021 21:01:01 GMT) Full text and rfc822 format available.

Message #22 received at 52722 <at> debbugs.gnu.org (full text, mbox):

From: Attila Lendvai <attila <at> lendvai.name>
To: Leo Famulari <leo <at> famulari.name>
Cc: 52722 <at> debbugs.gnu.org
Subject: Re: [bug#52722] [PATCH v2 1/2] tests: Smarten up git repository
 testing framework.
Date: Thu, 23 Dec 2021 21:00:10 +0000
> WARNING: (guix tests git): `reset' imported from both (git) and (ice-9 control)
>
> We need to make sure that the correct reset is imported here. Can you
> take a look and make any adjustments, if necessary?

i wonder why that is only a warning and not a full error.

but anyway, the fix is to only import let/ec. please change the
relevant line to:

  #:use-module ((ice-9 control) #:select (let/ec))

can you please commit this without going through the full
patch-submission cycle?

- attila





Information forwarded to guix-patches <at> gnu.org:
bug#52722; Package guix-patches. (Thu, 23 Dec 2021 23:50:01 GMT) Full text and rfc822 format available.

Message #25 received at 52722 <at> debbugs.gnu.org (full text, mbox):

From: Leo Famulari <leo <at> famulari.name>
To: Attila Lendvai <attila <at> lendvai.name>
Cc: 52722 <at> debbugs.gnu.org
Subject: Re: [bug#52722] [PATCH v2 1/2] tests: Smarten up git repository
 testing framework.
Date: Thu, 23 Dec 2021 18:49:38 -0500
On Thu, Dec 23, 2021 at 09:00:10PM +0000, Attila Lendvai wrote:
> > WARNING: (guix tests git): `reset' imported from both (git) and (ice-9 control)
> >
> > We need to make sure that the correct reset is imported here. Can you
> > take a look and make any adjustments, if necessary?
> 
> i wonder why that is only a warning and not a full error.
> 
> but anyway, the fix is to only import let/ec. please change the
> relevant line to:
> 
>   #:use-module ((ice-9 control) #:select (let/ec))
> 
> can you please commit this without going through the full
> patch-submission cycle?

Sure, done as commit ba744faeb104a1132d9f6ed04fc296b23bc09334




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 21 Jan 2022 12:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 96 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.