[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
03/03: packages: Gracefully report packages not found.
From: |
Ludovic Courtès |
Subject: |
03/03: packages: Gracefully report packages not found. |
Date: |
Tue, 08 Mar 2016 10:51:54 +0000 |
civodul pushed a commit to branch master
in repository guix.
commit efb107e0cd34fa0ed656441bf6e2414253c0344a
Author: Ludovic Courtès <address@hidden>
Date: Tue Mar 8 11:48:21 2016 +0100
packages: Gracefully report packages not found.
Fixes a thinko introduced in 1b846da8c372bee78851439fd9e72b2499115e5a
that would lead to a backtrace when looking for an unknown package.
* gnu/packages.scm (%find-package): Correct logic when checking for
FALLBACK?.
---
gnu/packages.scm | 4 +++-
tests/packages.scm | 9 +++++++++
2 files changed, 12 insertions(+), 1 deletions(-)
diff --git a/gnu/packages.scm b/gnu/packages.scm
index 5a76e9b..bbd460a 100644
--- a/gnu/packages.scm
+++ b/gnu/packages.scm
@@ -300,13 +300,15 @@ use address@hidden instead~%")))
(_
(if version
(leave (_ "~A: package not found for version ~a~%") name version)
- (or fallback?
+ (if (not fallback?)
;; XXX: Fallback to the older specification style with an hyphen
;; between NAME and VERSION, for backward compatibility.
(call-with-values
(lambda ()
(hyphen-separated-name->name+version name))
(cut %find-package spec <> <> #:fallback? #t))
+
+ ;; The fallback case didn't find anything either, so bail out.
(leave (_ "~A: unknown package~%") name))))))
(define (specification->package spec)
diff --git a/tests/packages.scm b/tests/packages.scm
index 9a2dbee..823ede1 100644
--- a/tests/packages.scm
+++ b/tests/packages.scm
@@ -788,6 +788,15 @@
(guix-package "-p" (derivation->output-path prof)
"--search-paths"))))))
+(test-equal "specification->package when not found"
+ 'quit
+ (catch 'quit
+ (lambda ()
+ ;; This should call 'leave', producing an error message.
+ (specification->package "this-package-does-not-exist"))
+ (lambda (key . args)
+ key)))
+
(test-end "packages")