diff options
author | Ludovic Courtès <ludo@gnu.org> | 2014-10-08 23:06:19 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2014-10-08 23:06:19 +0200 |
commit | 2e1bafb03438757c7cc34c16230b00623507ff84 (patch) | |
tree | 2f09766293395c67de7858d93a777c863e8ba20f /tests/packages.scm | |
parent | 9c814b828ae07899594ad9cd83d2e77e4cc528cc (diff) | |
download | patches-2e1bafb03438757c7cc34c16230b00623507ff84.tar patches-2e1bafb03438757c7cc34c16230b00623507ff84.tar.gz |
packages: Gracefully print packages whose 'location' is #f.
* guix/packages.scm (<package> printer): Check whether LOC is #f.
* tests/packages.scm ("printer with location", "printer without
location"): New tests.
Diffstat (limited to 'tests/packages.scm')
-rw-r--r-- | tests/packages.scm | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/tests/packages.scm b/tests/packages.scm index 2a87f3f15d..88d21e0578 100644 --- a/tests/packages.scm +++ b/tests/packages.scm @@ -19,7 +19,12 @@ (define-module (test-packages) #:use-module (guix tests) #:use-module (guix store) - #:use-module (guix utils) + #:use-module ((guix utils) + ;; Rename the 'location' binding to allow proper syntax + ;; matching when setting the 'location' field of a package. + #:renamer (lambda (name) + (cond ((eq? name 'location) 'make-location) + (else name)))) #:use-module (guix hash) #:use-module (guix derivations) #:use-module (guix packages) @@ -34,6 +39,7 @@ #:use-module (srfi srfi-34) #:use-module (srfi srfi-64) #:use-module (rnrs io ports) + #:use-module (ice-9 regex) #:use-module (ice-9 match)) ;; Test the high-level packaging layer. @@ -52,6 +58,21 @@ (home-page #f) (license #f) extra-fields ...)) +(test-assert "printer with location" + (string-match "^#<package foo-0 foo.scm:42 [[:xdigit:]]+>$" + (with-output-to-string + (lambda () + (write + (dummy-package "foo" + (location (make-location "foo.scm" 42 7)))))))) + +(test-assert "printer without location" + (string-match "^#<package foo-0 [[:xdigit:]]+>$" + (with-output-to-string + (lambda () + (write + (dummy-package "foo" (location #f))))))) + (test-assert "package-field-location" (let () (define (goto port line column) |