From: "Ludovic Courtès" <ludo@gnu.org>
To: 36351@debbugs.gnu.org
Subject: [bug#36351] [PATCH 08/10] packages: 'specification->package+output' distinguishes "no output specified".
Date: Mon, 24 Jun 2019 14:22:10 +0200 [thread overview]
Message-ID: <20190624122212.5932-8-ludo@gnu.org> (raw)
In-Reply-To: <20190624122212.5932-1-ludo@gnu.org>
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.
---
gnu/packages.scm | 8 ++++++--
tests/packages.scm | 32 ++++++++++++++++++++++++++++++++
2 files changed, 38 insertions(+), 2 deletions(-)
diff --git a/gnu/packages.scm b/gnu/packages.scm
index 48390575ba..acb247e114 100644
--- a/gnu/packages.scm
+++ b/gnu/packages.scm
@@ -534,14 +534,18 @@ optionally contain a version number and an output name, as in these examples:
guile@2.0.9:debug
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)
(package-specification->name+version+output spec output)))
(match (%find-package spec name version)
(#f
(values #f #f))
(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)
(leave (G_ "package `~a' lacks output `~a'~%")
(package-full-name package)
diff --git a/tests/packages.scm b/tests/packages.scm
index 613b2f1221..836d446657 100644
--- a/tests/packages.scm
+++ b/tests/packages.scm
@@ -1227,6 +1227,38 @@
(lambda (key . args)
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"
(map (lambda (package)
(cons (package-version package)
--
2.22.0
next prev parent reply other threads:[~2019-06-24 12:23 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-24 12:18 [bug#36351] [PATCH 00/10] Add 'derivation-build-plan', improve (guix derivations) Ludovic Courtès
2019-06-24 12:22 ` [bug#36351] [PATCH 01/10] derivations: Add 'derivation-input' Ludovic Courtès
2019-06-24 12:22 ` [bug#36351] [PATCH 02/10] derivations: Rewrite and replace 'derivations-prerequisites-to-build' Ludovic Courtès
2019-06-24 12:22 ` [bug#36351] [PATCH 03/10] ui: 'show-what-to-build' uses 'derivation-build-plan' Ludovic Courtès
2019-06-24 12:22 ` [bug#36351] [PATCH 04/10] graph: Use 'derivation-input-derivation' Ludovic Courtès
2019-06-24 12:22 ` [bug#36351] [PATCH 05/10] derivations: <derivation-input> now aggregates a <derivation> Ludovic Courtès
2019-06-24 12:22 ` [bug#36351] [PATCH 06/10] derivations: 'derivation' preserves pointer equality Ludovic Courtès
2019-06-24 12:22 ` [bug#36351] [PATCH 07/10] derivations: 'build-derivations' can be passed derivation inputs Ludovic Courtès
2019-06-24 12:22 ` Ludovic Courtès [this message]
2019-06-24 12:22 ` [bug#36351] [PATCH 09/10] ui: 'show-what-to-build' accepts " Ludovic Courtès
2019-06-24 12:22 ` [bug#36351] [PATCH 10/10] ui: 'show-derivation-outputs' accepts <derivation-input> records Ludovic Courtès
2019-06-27 9:17 ` bug#36351: [PATCH 00/10] Add 'derivation-build-plan', improve (guix derivations) Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190624122212.5932-8-ludo@gnu.org \
--to=ludo@gnu.org \
--cc=36351@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).