From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:470:142:3::10]:48645) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hfO04-0002xQ-Gx for guix-patches@gnu.org; Mon, 24 Jun 2019 08:23:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hfO02-0001VE-7y for guix-patches@gnu.org; Mon, 24 Jun 2019 08:23:08 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:42188) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hfO01-0001UT-VI for guix-patches@gnu.org; Mon, 24 Jun 2019 08:23:06 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hfO01-0003o3-Mi for guix-patches@gnu.org; Mon, 24 Jun 2019 08:23:05 -0400 Subject: [bug#36351] [PATCH 08/10] packages: 'specification->package+output' distinguishes "no output specified". Resent-Message-ID: From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Date: Mon, 24 Jun 2019 14:22:10 +0200 Message-Id: <20190624122212.5932-8-ludo@gnu.org> In-Reply-To: <20190624122212.5932-1-ludo@gnu.org> References: <20190624122212.5932-1-ludo@gnu.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: 36351@debbugs.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