packages: Catch invalid input errors for structs.
Reported by Thomas Sigurdsen <thomas.sigurdsen@gmail.com> at <https://lists.gnu.org/archive/html/help-guix/2017-04/msg00007.html>. * guix/packages.scm (expand-input): Add 'guard' form around call to 'package-source-derivation'. * tests/packages.scm (dummy): New test.
This commit is contained in:
parent
3e43166ffc
commit
76c486196f
|
@ -31,7 +31,6 @@
|
||||||
#:use-module (guix memoization)
|
#:use-module (guix memoization)
|
||||||
#:use-module (guix build-system)
|
#:use-module (guix build-system)
|
||||||
#:use-module (guix search-paths)
|
#:use-module (guix search-paths)
|
||||||
#:use-module (guix gexp)
|
|
||||||
#:use-module (guix sets)
|
#:use-module (guix sets)
|
||||||
#:use-module (ice-9 match)
|
#:use-module (ice-9 match)
|
||||||
#:use-module (ice-9 vlist)
|
#:use-module (ice-9 vlist)
|
||||||
|
@ -846,7 +845,16 @@ information in exceptions."
|
||||||
;; source.
|
;; source.
|
||||||
(list name (intern file)))
|
(list name (intern file)))
|
||||||
(((? string? name) (? struct? source))
|
(((? string? name) (? struct? source))
|
||||||
(list name (package-source-derivation store source system)))
|
;; 'package-source-derivation' calls 'lower-object', which can throw
|
||||||
|
;; '&gexp-input-error'. However '&gexp-input-error' lacks source
|
||||||
|
;; location info, so we catch and rethrow here (XXX: not optimal
|
||||||
|
;; performance-wise).
|
||||||
|
(guard (c ((gexp-input-error? c)
|
||||||
|
(raise (condition
|
||||||
|
(&package-input-error
|
||||||
|
(package package)
|
||||||
|
(input (gexp-error-invalid-input c)))))))
|
||||||
|
(list name (package-source-derivation store source system))))
|
||||||
(x
|
(x
|
||||||
(raise (condition (&package-input-error
|
(raise (condition (&package-input-error
|
||||||
(package package)
|
(package package)
|
||||||
|
|
|
@ -470,6 +470,14 @@
|
||||||
(package-derivation %store p)
|
(package-derivation %store p)
|
||||||
#f)))
|
#f)))
|
||||||
|
|
||||||
|
(let ((dummy (dummy-package "foo" (inputs `(("x" ,(current-module)))))))
|
||||||
|
(test-equal "&package-input-error"
|
||||||
|
(list dummy (current-module))
|
||||||
|
(guard (c ((package-input-error? c)
|
||||||
|
(list (package-error-package c)
|
||||||
|
(package-error-invalid-input c))))
|
||||||
|
(package-derivation %store dummy))))
|
||||||
|
|
||||||
(test-assert "reference to non-existent output"
|
(test-assert "reference to non-existent output"
|
||||||
;; See <http://bugs.gnu.org/19630>.
|
;; See <http://bugs.gnu.org/19630>.
|
||||||
(parameterize ((%graft? #f))
|
(parameterize ((%graft? #f))
|
||||||
|
|
Loading…
Reference in New Issue