modules: Raise an error when a dependency could not be found.

* guix/modules.scm (&missing-dependency-error): New error condition.
(source-module-dependencies): Raise it when 'search-path' returns #f.
* tests/modules.scm ("&missing-dependency-error"): New test.
This commit is contained in:
Ludovic Courtès 2017-05-25 14:19:51 +02:00
parent 4862a98be4
commit bfe5264aa1
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5
2 changed files with 41 additions and 5 deletions

View file

@ -20,8 +20,13 @@
#:use-module (guix memoization)
#:use-module (guix sets)
#:use-module (srfi srfi-26)
#:use-module (srfi srfi-34)
#:use-module (srfi srfi-35)
#:use-module (ice-9 match)
#:export (source-module-closure
#:export (missing-dependency-error?
missing-dependency-module
source-module-closure
live-module-closure
guix-module-name?))
@ -35,6 +40,11 @@
;;;
;;; Code:
;; The error corresponding to a missing module.
(define-condition-type &missing-dependency-error &error
missing-dependency-error?
(module missing-dependency-module))
(define (colon-symbol? obj)
"Return true if OBJ is a symbol that starts with a colon."
(and (symbol? obj)
@ -106,9 +116,12 @@ depends on."
"Return the modules used by MODULE by looking at its source code."
(if (member module %source-less-modules)
'()
(module-file-dependencies
(search-path load-path
(module-name->file-name module)))))
(match (search-path load-path (module-name->file-name module))
((? string? file)
(module-file-dependencies file))
(#f
(raise (condition (&missing-dependency-error
(module module))))))))
(define* (module-closure modules
#:key