guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

01/02: guix gc: '--verify=foo' is reported as an error.


From: Ludovic Courtès
Subject: 01/02: guix gc: '--verify=foo' is reported as an error.
Date: Mon, 18 Dec 2017 17:17:36 -0500 (EST)

civodul pushed a commit to branch master
in repository guix.

commit 3caab236c49012643ab46afd7e82a287ec413ee8
Author: Ludovic Courtès <address@hidden>
Date:   Mon Dec 18 22:33:51 2017 +0100

    guix gc: '--verify=foo' is reported as an error.
    
    Fixes <https://bugs.gnu.org/29761>.
    Reported by Martin Castillo <address@hidden>.
    
    * guix/scripts/gc.scm (argument->verify-options): New procedure.
    (%options) ["verify"]: Adjust to use it.
    * tests/guix-gc.sh: Add test.
---
 guix/scripts/gc.scm | 31 +++++++++++++++++++++----------
 tests/guix-gc.sh    |  3 +++
 2 files changed, 24 insertions(+), 10 deletions(-)

diff --git a/guix/scripts/gc.scm b/guix/scripts/gc.scm
index 378a47d..a31d223 100644
--- a/guix/scripts/gc.scm
+++ b/guix/scripts/gc.scm
@@ -78,6 +78,21 @@ Invoke the garbage collector.\n"))
   (newline)
   (show-bug-report-information))
 
+(define argument->verify-options
+  (let ((not-comma (char-set-complement (char-set #\,)))
+        (validate  (lambda (option)
+                     (unless (memq option '(repair contents))
+                       (leave (G_ "~a: invalid '--verify' option~%")
+                              option)))))
+    (lambda (arg)
+      "Turn ARG into a list of symbols denoting '--verify' options."
+      (if arg
+          (let ((lst (map string->symbol
+                          (string-tokenize arg not-comma))))
+            (for-each validate lst)
+            lst)
+          '()))))
+
 (define %options
   ;; Specification of the command-line options.
   (list (option '(#\h "help") #f #f
@@ -112,16 +127,12 @@ Invoke the garbage collector.\n"))
                   (alist-cons 'action 'optimize
                               (alist-delete 'action result))))
         (option '("verify") #f #t
-                (let ((not-comma (char-set-complement (char-set #\,))))
-                  (lambda (opt name arg result)
-                    (let ((options (if arg
-                                       (map string->symbol
-                                            (string-tokenize arg not-comma))
-                                       '())))
-                      (alist-cons 'action 'verify
-                                  (alist-cons 'verify-options options
-                                              (alist-delete 'action
-                                                            result)))))))
+                (lambda (opt name arg result)
+                  (let ((options (argument->verify-options arg)))
+                    (alist-cons 'action 'verify
+                                (alist-cons 'verify-options options
+                                            (alist-delete 'action
+                                                          result))))))
         (option '("list-dead") #f #f
                 (lambda (opt name arg result)
                   (alist-cons 'action 'list-dead
diff --git a/tests/guix-gc.sh b/tests/guix-gc.sh
index 57c5e7d..efbc7e7 100644
--- a/tests/guix-gc.sh
+++ b/tests/guix-gc.sh
@@ -39,6 +39,9 @@ do
     if guix gc $option whatever; then false; else true; fi
 done
 
+# This should fail.
+if guix gc --verify=foo; then false; else true; fi
+
 # Check the references of a .drv.
 drv="`guix build guile-bootstrap -d`"
 out="`guix build guile-bootstrap`"



reply via email to

[Prev in Thread] Current Thread [Next in Thread]