all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [bug#52722] [PATCH] tests: Smarten up git repository testing framework.
@ 2021-12-21 22:32 Attila Lendvai
  2021-12-22 10:28 ` [bug#52722] [PATCH v2 1/2] " Attila Lendvai
  0 siblings, 1 reply; 7+ messages in thread
From: Attila Lendvai @ 2021-12-21 22:32 UTC (permalink / raw)
  To: 52722; +Cc: Attila Lendvai

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





^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [bug#52722] [PATCH v2 1/2] tests: Smarten up git repository testing framework.
  2021-12-21 22:32 [bug#52722] [PATCH] tests: Smarten up git repository testing framework Attila Lendvai
@ 2021-12-22 10:28 ` Attila Lendvai
  2021-12-22 10:28   ` [bug#52722] [PATCH v2 2/2] tests: gnupg: Factor out and export KEY-FINGERPRINT-VECTOR Attila Lendvai
  2021-12-23 17:40   ` [bug#52722] [PATCH v2 1/2] " Leo Famulari
  0 siblings, 2 replies; 7+ messages in thread
From: Attila Lendvai @ 2021-12-22 10:28 UTC (permalink / raw)
  To: 52722; +Cc: Attila Lendvai

* 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





^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [bug#52722] [PATCH v2 2/2] tests: gnupg: Factor out and export KEY-FINGERPRINT-VECTOR.
  2021-12-22 10:28 ` [bug#52722] [PATCH v2 1/2] " Attila Lendvai
@ 2021-12-22 10:28   ` Attila Lendvai
  2021-12-23 16:41     ` bug#52722: [PATCH] tests: Smarten up git repository testing framework Mathieu Othacehe
  2021-12-23 17:40   ` [bug#52722] [PATCH v2 1/2] " Leo Famulari
  1 sibling, 1 reply; 7+ messages in thread
From: Attila Lendvai @ 2021-12-22 10:28 UTC (permalink / raw)
  To: 52722; +Cc: Attila Lendvai

* 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





^ permalink raw reply related	[flat|nested] 7+ messages in thread

* bug#52722: [PATCH] tests: Smarten up git repository testing framework.
  2021-12-22 10:28   ` [bug#52722] [PATCH v2 2/2] tests: gnupg: Factor out and export KEY-FINGERPRINT-VECTOR Attila Lendvai
@ 2021-12-23 16:41     ` Mathieu Othacehe
  0 siblings, 0 replies; 7+ messages in thread
From: Mathieu Othacehe @ 2021-12-23 16:41 UTC (permalink / raw)
  To: Attila Lendvai; +Cc: 52722-done


> * guix/tests/gnupg.scm (key-fingerprint-vector): New procedure.  Export it.
> (key-fingerprint): Use it.

Pushed, thanks!

Mathieu




^ permalink raw reply	[flat|nested] 7+ messages in thread

* [bug#52722] [PATCH v2 1/2] tests: Smarten up git repository testing framework.
  2021-12-22 10:28 ` [bug#52722] [PATCH v2 1/2] " Attila Lendvai
  2021-12-22 10:28   ` [bug#52722] [PATCH v2 2/2] tests: gnupg: Factor out and export KEY-FINGERPRINT-VECTOR Attila Lendvai
@ 2021-12-23 17:40   ` Leo Famulari
  2021-12-23 21:00     ` Attila Lendvai
  1 sibling, 1 reply; 7+ messages in thread
From: Leo Famulari @ 2021-12-23 17:40 UTC (permalink / raw)
  To: Attila Lendvai; +Cc: 52722

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?




^ permalink raw reply	[flat|nested] 7+ messages in thread

* [bug#52722] [PATCH v2 1/2] tests: Smarten up git repository testing framework.
  2021-12-23 17:40   ` [bug#52722] [PATCH v2 1/2] " Leo Famulari
@ 2021-12-23 21:00     ` Attila Lendvai
  2021-12-23 23:49       ` Leo Famulari
  0 siblings, 1 reply; 7+ messages in thread
From: Attila Lendvai @ 2021-12-23 21:00 UTC (permalink / raw)
  To: Leo Famulari; +Cc: 52722

> 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





^ permalink raw reply	[flat|nested] 7+ messages in thread

* [bug#52722] [PATCH v2 1/2] tests: Smarten up git repository testing framework.
  2021-12-23 21:00     ` Attila Lendvai
@ 2021-12-23 23:49       ` Leo Famulari
  0 siblings, 0 replies; 7+ messages in thread
From: Leo Famulari @ 2021-12-23 23:49 UTC (permalink / raw)
  To: Attila Lendvai; +Cc: 52722

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




^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-12-23 23:50 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-21 22:32 [bug#52722] [PATCH] tests: Smarten up git repository testing framework Attila Lendvai
2021-12-22 10:28 ` [bug#52722] [PATCH v2 1/2] " Attila Lendvai
2021-12-22 10:28   ` [bug#52722] [PATCH v2 2/2] tests: gnupg: Factor out and export KEY-FINGERPRINT-VECTOR Attila Lendvai
2021-12-23 16:41     ` bug#52722: [PATCH] tests: Smarten up git repository testing framework Mathieu Othacehe
2021-12-23 17:40   ` [bug#52722] [PATCH v2 1/2] " Leo Famulari
2021-12-23 21:00     ` Attila Lendvai
2021-12-23 23:49       ` Leo Famulari

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.