summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2018-09-04 17:22:55 +0200
committerLudovic Courtès <ludo@gnu.org>2018-09-04 17:22:55 +0200
commit7e1d229019c1924a2748e5daec2a619e7efbd7d7 (patch)
tree13a9ee538f851ec4ab28d173d75f13d241dc4b85
parent1bf758767d1553594b6d7534ca8c38a2171b5afe (diff)
inferior: Add home-page and location package accessors.
* guix/inferior.scm (inferior-package-home-page) (inferior-package-location): New procedures. * tests/inferior.scm ("inferior-packages"): Test them.
-rw-r--r--guix/inferior.scm20
-rw-r--r--tests/inferior.scm26
2 files changed, 35 insertions, 11 deletions
diff --git a/guix/inferior.scm b/guix/inferior.scm
index 05c8d65debd..af37233a037 100644
--- a/guix/inferior.scm
+++ b/guix/inferior.scm
@@ -19,6 +19,7 @@
19(define-module (guix inferior) 19(define-module (guix inferior)
20 #:use-module (srfi srfi-9) 20 #:use-module (srfi srfi-9)
21 #:use-module (srfi srfi-9 gnu) 21 #:use-module (srfi srfi-9 gnu)
22 #:use-module ((guix utils) #:select (source-properties->location))
22 #:use-module (ice-9 match) 23 #:use-module (ice-9 match)
23 #:use-module (ice-9 popen) 24 #:use-module (ice-9 popen)
24 #:export (inferior? 25 #:export (inferior?
@@ -33,7 +34,9 @@
33 34
34 inferior-packages 35 inferior-packages
35 inferior-package-synopsis 36 inferior-package-synopsis
36 inferior-package-description)) 37 inferior-package-description
38 inferior-package-home-page
39 inferior-package-location))
37 40
38;;; Commentary: 41;;; Commentary:
39;;; 42;;;
@@ -198,3 +201,18 @@ TRANSLATE? is true, translate it to the current locale's language."
198 (if translate? 201 (if translate?
199 '(compose (@ (guix ui) P_) package-description) 202 '(compose (@ (guix ui) P_) package-description)
200 'package-description))) 203 'package-description)))
204
205(define (inferior-package-home-page package)
206 "Return the home page of PACKAGE."
207 (inferior-package-field package 'package-home-page))
208
209(define (inferior-package-location package)
210 "Return the source code location of PACKAGE, either #f or a <location>
211record."
212 (source-properties->location
213 (inferior-package-field package
214 '(compose (lambda (loc)
215 (and loc
216 (location->source-properties
217 loc)))
218 package-location))))
diff --git a/tests/inferior.scm b/tests/inferior.scm
index 5e0f8ae66e0..ff5cad4210a 100644
--- a/tests/inferior.scm
+++ b/tests/inferior.scm
@@ -45,9 +45,11 @@
45 45
46(test-equal "inferior-packages" 46(test-equal "inferior-packages"
47 (take (sort (fold-packages (lambda (package lst) 47 (take (sort (fold-packages (lambda (package lst)
48 (alist-cons (package-name package) 48 (cons (list (package-name package)
49 (package-version package) 49 (package-version package)
50 lst)) 50 (package-home-page package)
51 (package-location package))
52 lst))
51 '()) 53 '())
52 (lambda (x y) 54 (lambda (x y)
53 (string<? (car x) (car y)))) 55 (string<? (car x) (car y))))
@@ -56,14 +58,18 @@
56 #:command "scripts/guix")) 58 #:command "scripts/guix"))
57 (packages (inferior-packages inferior))) 59 (packages (inferior-packages inferior)))
58 (and (every string? (map inferior-package-synopsis packages)) 60 (and (every string? (map inferior-package-synopsis packages))
59 (begin 61 (let ()
62 (define result
63 (take (sort (map (lambda (package)
64 (list (inferior-package-name package)
65 (inferior-package-version package)
66 (inferior-package-home-page package)
67 (inferior-package-location package)))
68 packages)
69 (lambda (x y)
70 (string<? (car x) (car y))))
71 10))
60 (close-inferior inferior) 72 (close-inferior inferior)
61 (take (sort (map (lambda (package) 73 result))))
62 (cons (inferior-package-name package)
63 (inferior-package-version package)))
64 packages)
65 (lambda (x y)
66 (string<? (car x) (car y))))
67 10)))))
68 74
69(test-end "inferior") 75(test-end "inferior")