summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2013-02-01 13:16:27 +0100
committerLudovic Courtès <ludo@gnu.org>2013-02-01 13:16:41 +0100
commit299112d36e872d98896bf8dec281c34d9adad06e (patch)
tree5642b1b322758f1e9919c93a89e793fad181ab81 /tests
parentaa92cf980cab9f085df11c79c4b27d2b8b0d88aa (diff)
downloadguix-299112d36e872d98896bf8dec281c34d9adad06e.tar.gz
guix-package: Report `--search' matches in recutils format.
* guix/ui.scm (fill-paragraph, string->recutils, package->recutils): New
  procedures.
* guix-package.in (guix-package)[process-query]: Use `package->recutils'
  to display package meta-data.
* tests/guix-package.sh: Adjust test.
* tests/ui.scm: New file.
* Makefile.am (TESTS): Add it.
* doc/guix.texi (Invoking guix-package): Adjust `--search'
  documentation, and give an example.
Diffstat (limited to 'tests')
-rw-r--r--tests/guix-package.sh2
-rw-r--r--tests/ui.scm70
2 files changed, 71 insertions, 1 deletions
diff --git a/tests/guix-package.sh b/tests/guix-package.sh
index 0b31b55103..42a1f8da96 100644
--- a/tests/guix-package.sh
+++ b/tests/guix-package.sh
@@ -70,7 +70,7 @@ then
     test "`guix-package -p "$profile" -I 'g.*e' | cut -f1`" = "guile-bootstrap"
 
     # Search.
-    test "`guix-package -s "GNU Hello" | cut -f1`" = "hello"
+    test "`guix-package -s "GNU Hello" | grep ^name:`" = "name: hello"
     test "`guix-package -s "n0t4r341p4ck4g3"`" = ""
 
     # Remove a package.
diff --git a/tests/ui.scm b/tests/ui.scm
new file mode 100644
index 0000000000..0b6f3c5815
--- /dev/null
+++ b/tests/ui.scm
@@ -0,0 +1,70 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2013 Ludovic Courtès <ludo@gnu.org>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+
+(define-module (test-ui)
+  #:use-module (guix ui)
+  #:use-module (srfi srfi-1)
+  #:use-module (srfi srfi-64))
+
+;; Test the (guix ui) module.
+
+(define %paragraph
+  "GNU Guile is an implementation of the Scheme programming language, with
+support for many SRFIs, packaged for use in a wide variety of environments.
+In addition to implementing the R5RS Scheme standard and a large subset of
+R6RS, Guile includes a module system, full access to POSIX system calls,
+networking support, multiple threads, dynamic linking, a foreign function call
+interface, and powerful string processing.")
+
+
+(test-begin "ui")
+
+(test-assert "fill-paragraph"
+  (every (lambda (column)
+           (every (lambda (width)
+                    (every (lambda (line)
+                             (<= (string-length line) width))
+                           (string-split (fill-paragraph %paragraph
+                                                         width column)
+                                         #\newline)))
+                  '(15 30 35 40 45 50 60 70 80 90 100)))
+   '(0 5)))
+
+(test-assert "fill-paragraph, consecutive newlines"
+  (every (lambda (width)
+           (any (lambda (line)
+                  (string-prefix? "When STR" line))
+                (string-split
+                 (fill-paragraph (procedure-documentation fill-paragraph)
+                                 width)
+                 #\newline)))
+         '(15 20 25 30 40 50 60)))
+
+(test-equal "fill-paragraph, large unbreakable word"
+  '("Here is a" "very-very-long-word"
+    "and that's" "it.")
+  (string-split
+   (fill-paragraph "Here is a very-very-long-word and that's it."
+                   10)
+   #\newline))
+
+(test-end "ui")
+
+
+(exit (= (test-runner-fail-count (test-runner-current)) 0))