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 | |
| parent | 9c814b828ae07899594ad9cd83d2e77e4cc528cc (diff) | |
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')
| -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 2a87f3f15d1..88d21e05784 100644 --- a/tests/packages.scm +++ b/tests/packages.scm | |||
| @@ -19,7 +19,12 @@ | |||
| 19 | (define-module (test-packages) | 19 | (define-module (test-packages) |
| 20 | #:use-module (guix tests) | 20 | #:use-module (guix tests) |
| 21 | #:use-module (guix store) | 21 | #:use-module (guix store) |
| 22 | #:use-module (guix utils) | 22 | #:use-module ((guix utils) |
| 23 | ;; Rename the 'location' binding to allow proper syntax | ||
| 24 | ;; matching when setting the 'location' field of a package. | ||
| 25 | #:renamer (lambda (name) | ||
| 26 | (cond ((eq? name 'location) 'make-location) | ||
| 27 | (else name)))) | ||
| 23 | #:use-module (guix hash) | 28 | #:use-module (guix hash) |
| 24 | #:use-module (guix derivations) | 29 | #:use-module (guix derivations) |
| 25 | #:use-module (guix packages) | 30 | #:use-module (guix packages) |
| @@ -34,6 +39,7 @@ | |||
| 34 | #:use-module (srfi srfi-34) | 39 | #:use-module (srfi srfi-34) |
| 35 | #:use-module (srfi srfi-64) | 40 | #:use-module (srfi srfi-64) |
| 36 | #:use-module (rnrs io ports) | 41 | #:use-module (rnrs io ports) |
| 42 | #:use-module (ice-9 regex) | ||
| 37 | #:use-module (ice-9 match)) | 43 | #:use-module (ice-9 match)) |
| 38 | 44 | ||
| 39 | ;; Test the high-level packaging layer. | 45 | ;; Test the high-level packaging layer. |
| @@ -52,6 +58,21 @@ | |||
| 52 | (home-page #f) (license #f) | 58 | (home-page #f) (license #f) |
| 53 | extra-fields ...)) | 59 | extra-fields ...)) |
| 54 | 60 | ||
| 61 | (test-assert "printer with location" | ||
| 62 | (string-match "^#<package foo-0 foo.scm:42 [[:xdigit:]]+>$" | ||
| 63 | (with-output-to-string | ||
| 64 | (lambda () | ||
| 65 | (write | ||
| 66 | (dummy-package "foo" | ||
| 67 | (location (make-location "foo.scm" 42 7)))))))) | ||
| 68 | |||
| 69 | (test-assert "printer without location" | ||
| 70 | (string-match "^#<package foo-0 [[:xdigit:]]+>$" | ||
| 71 | (with-output-to-string | ||
| 72 | (lambda () | ||
| 73 | (write | ||
| 74 | (dummy-package "foo" (location #f))))))) | ||
| 75 | |||
| 55 | (test-assert "package-field-location" | 76 | (test-assert "package-field-location" |
| 56 | (let () | 77 | (let () |
| 57 | (define (goto port line column) | 78 | (define (goto port line column) |
