summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorNikita Karetnikov <nikita@karetnikov.org>2013-09-19 11:07:39 +0000
committerNikita Karetnikov <nikita@karetnikov.org>2013-09-19 11:22:31 +0000
commit2cd09108c9b316c9c8aa1c1b87b85a1c32cef089 (patch)
tree9cce8929f1da78d7b7a9324129829cf3d9ab5238 /tests
parent72d9148fbf6e097cd8838b51c49f107c5176287a (diff)
downloadguix-2cd09108c9b316c9c8aa1c1b87b85a1c32cef089.tar.gz
guix package: Add '--list-generations'.
* guix/scripts/package.scm: Import (srfi srfi-19).
  (generation-time, matching-generations): New functions.
  (show-help): Add '--list-generations'.
  (%options): Likewise.
  (guix-package)[process-query]: Add support for '--list-generations'.
* guix/ui.scm: Import (srfi srfi-19) and (ice-9 regex).
  (string->generations, string->duration): New functions.
* tests/guix-package.sh: Test '--list-generations'.
* tests/ui.scm: Import (srfi srfi-19).
  Test 'string->generations' and 'string->duration'.
* doc/guix.texi (Invoking guix-package): Document '--list-generations'.
Diffstat (limited to 'tests')
-rw-r--r--tests/guix-package.sh4
-rw-r--r--tests/ui.scm85
2 files changed, 89 insertions, 0 deletions
diff --git a/tests/guix-package.sh b/tests/guix-package.sh
index 60b42907a8..b09a9c0173 100644
--- a/tests/guix-package.sh
+++ b/tests/guix-package.sh
@@ -81,6 +81,10 @@ then
         "name: hello"
     test "`guix package -s "n0t4r341p4ck4g3"`" = ""
 
+    # List generations.
+    test "`guix package -p "$profile" -l | cut -f1 | grep guile | head -n1`" \
+        = "  guile-bootstrap"
+
     # Remove a package.
     guix package --bootstrap -p "$profile" -r "guile-bootstrap"
     test -L "$profile-3-link"
diff --git a/tests/ui.scm b/tests/ui.scm
index 0b6f3c5815..3d5c3e7969 100644
--- a/tests/ui.scm
+++ b/tests/ui.scm
@@ -20,6 +20,7 @@
 (define-module (test-ui)
   #:use-module (guix ui)
   #:use-module (srfi srfi-1)
+  #:use-module (srfi srfi-19)
   #:use-module (srfi srfi-64))
 
 ;; Test the (guix ui) module.
@@ -64,6 +65,90 @@ interface, and powerful string processing.")
                    10)
    #\newline))
 
+(test-equal "integer"
+  '(1)
+  (string->generations "1"))
+
+(test-equal "comma-separated integers"
+  '(3 7 1 4 6)
+  (string->generations "3,7,1,4,6"))
+
+(test-equal "closed range"
+  '(4 5 6 7 8 9 10 11 12)
+  (string->generations "4..12"))
+
+(test-equal "closed range, equal endpoints"
+  '(3)
+  (string->generations "3..3"))
+
+(test-equal "indefinite end range"
+  '(>= 7)
+  (string->generations "7.."))
+
+(test-equal "indefinite start range"
+  '(<= 42)
+  (string->generations "..42"))
+
+(test-equal "integer, char"
+  #f
+  (string->generations "a"))
+
+(test-equal "comma-separated integers, consecutive comma"
+  #f
+  (string->generations "1,,2"))
+
+(test-equal "comma-separated integers, trailing comma"
+  #f
+  (string->generations "1,2,"))
+
+(test-equal "comma-separated integers, chars"
+  #f
+  (string->generations "a,b"))
+
+(test-equal "closed range, start > end"
+  #f
+  (string->generations "9..2"))
+
+(test-equal "closed range, chars"
+  #f
+  (string->generations "a..b"))
+
+(test-equal "indefinite end range, char"
+  #f
+  (string->generations "a.."))
+
+(test-equal "indefinite start range, char"
+  #f
+  (string->generations "..a"))
+
+(test-equal "duration, 1 day"
+  (make-time time-duration 0 (* 3600 24))
+  (string->duration "1d"))
+
+(test-equal "duration, 1 week"
+  (make-time time-duration 0 (* 3600 24 7))
+  (string->duration "1w"))
+
+(test-equal "duration, 1 month"
+  (make-time time-duration 0 (* 3600 24 30))
+  (string->duration "1m"))
+
+(test-equal "duration, 1 week == 7 days"
+  (string->duration "1w")
+  (string->duration "7d"))
+
+(test-equal "duration, 1 month == 30 days"
+  (string->duration "1m")
+  (string->duration "30d"))
+
+(test-equal "duration, integer"
+  #f
+  (string->duration "1"))
+
+(test-equal "duration, char"
+  #f
+  (string->duration "d"))
+
 (test-end "ui")