packages: 'specification->package+output' distinguishes "no output specified".
Until now the caller couldn't tell the different between a spec like "foo:out" and one like "foo". This change allows users to distinguish between these two cases. * gnu/packages.scm (specification->package+output): Disable output membership test when OUTPUT = #f and SUB-DRV = #f. * tests/packages.scm ("specification->package+output") ("specification->package+output invalid output") ("specification->package+output no default output") ("specification->package+output invalid output, no default"): New tests.
This commit is contained in:
parent
7c690a4738
commit
066eeae1a1
@ -534,14 +534,18 @@ optionally contain a version number and an output name, as in these examples:
|
|||||||
guile@2.0.9:debug
|
guile@2.0.9:debug
|
||||||
|
|
||||||
If SPEC does not specify a version number, return the preferred newest
|
If SPEC does not specify a version number, return the preferred newest
|
||||||
version; if SPEC does not specify an output, return OUTPUT."
|
version; if SPEC does not specify an output, return OUTPUT.
|
||||||
|
|
||||||
|
When OUTPUT is false and SPEC does not specify any output, return #f as the
|
||||||
|
output."
|
||||||
(let-values (((name version sub-drv)
|
(let-values (((name version sub-drv)
|
||||||
(package-specification->name+version+output spec output)))
|
(package-specification->name+version+output spec output)))
|
||||||
(match (%find-package spec name version)
|
(match (%find-package spec name version)
|
||||||
(#f
|
(#f
|
||||||
(values #f #f))
|
(values #f #f))
|
||||||
(package
|
(package
|
||||||
(if (member sub-drv (package-outputs package))
|
(if (or (and (not output) (not sub-drv))
|
||||||
|
(member sub-drv (package-outputs package)))
|
||||||
(values package sub-drv)
|
(values package sub-drv)
|
||||||
(leave (G_ "package `~a' lacks output `~a'~%")
|
(leave (G_ "package `~a' lacks output `~a'~%")
|
||||||
(package-full-name package)
|
(package-full-name package)
|
||||||
|
@ -1227,6 +1227,38 @@
|
|||||||
(lambda (key . args)
|
(lambda (key . args)
|
||||||
key)))
|
key)))
|
||||||
|
|
||||||
|
(test-equal "specification->package+output"
|
||||||
|
`((,coreutils "out") (,coreutils "debug"))
|
||||||
|
(list (call-with-values (lambda ()
|
||||||
|
(specification->package+output "coreutils"))
|
||||||
|
list)
|
||||||
|
(call-with-values (lambda ()
|
||||||
|
(specification->package+output "coreutils:debug"))
|
||||||
|
list)))
|
||||||
|
|
||||||
|
(test-equal "specification->package+output invalid output"
|
||||||
|
'error
|
||||||
|
(catch 'quit
|
||||||
|
(lambda ()
|
||||||
|
(specification->package+output "coreutils:does-not-exist"))
|
||||||
|
(lambda _
|
||||||
|
'error)))
|
||||||
|
|
||||||
|
(test-equal "specification->package+output no default output"
|
||||||
|
`(,coreutils #f)
|
||||||
|
(call-with-values
|
||||||
|
(lambda ()
|
||||||
|
(specification->package+output "coreutils" #f))
|
||||||
|
list))
|
||||||
|
|
||||||
|
(test-equal "specification->package+output invalid output, no default"
|
||||||
|
'error
|
||||||
|
(catch 'quit
|
||||||
|
(lambda ()
|
||||||
|
(specification->package+output "coreutils:does-not-exist" #f))
|
||||||
|
(lambda _
|
||||||
|
'error)))
|
||||||
|
|
||||||
(test-equal "find-package-locations"
|
(test-equal "find-package-locations"
|
||||||
(map (lambda (package)
|
(map (lambda (package)
|
||||||
(cons (package-version package)
|
(cons (package-version package)
|
||||||
|
Loading…
Reference in New Issue
Block a user