mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-12-24 05:18:07 -05:00
discovery: 'scheme-files' returns '() for a non-accessible directory.
Fixes a regression introduced in
d27cc3bfaa
.
Reported by Ricardo Wurmus <rekado@elephly.net>.
* guix/discovery.scm (scheme-files): Catch 'scandir*' system errors.
Return '() and optionally raise a warning upon 'system-error'.
* tests/discovery.scm ("scheme-modules, non-existent directory"): New
test.
This commit is contained in:
parent
3bacc655c5
commit
d46c4423f4
2 changed files with 15 additions and 2 deletions
|
@ -38,7 +38,8 @@ (define-module (guix discovery)
|
|||
|
||||
(define* (scheme-files directory)
|
||||
"Return the list of Scheme files found under DIRECTORY, recursively. The
|
||||
returned list is sorted in alphabetical order."
|
||||
returned list is sorted in alphabetical order. Return the empty list if
|
||||
DIRECTORY is not accessible."
|
||||
(define (entry-type name properties)
|
||||
(match (assoc-ref properties 'type)
|
||||
('unknown
|
||||
|
@ -67,7 +68,15 @@ (define (entry-type name properties)
|
|||
(else
|
||||
result))))))
|
||||
'()
|
||||
(scandir* directory)))
|
||||
(catch 'system-error
|
||||
(lambda ()
|
||||
(scandir* directory))
|
||||
(lambda args
|
||||
(let ((errno (system-error-errno args)))
|
||||
(unless (= errno ENOENT)
|
||||
(warning (G_ "cannot access `~a': ~a~%")
|
||||
directory (strerror errno)))
|
||||
'())))))
|
||||
|
||||
(define file-name->module-name
|
||||
(let ((not-slash (char-set-complement (char-set #\/))))
|
||||
|
|
|
@ -32,6 +32,10 @@ (define %top-srcdir
|
|||
((('guix 'import _ ...) ..1)
|
||||
#t)))
|
||||
|
||||
(test-equal "scheme-modules, non-existent directory"
|
||||
'()
|
||||
(scheme-modules "/does/not/exist"))
|
||||
|
||||
(test-assert "all-modules"
|
||||
(match (map module-name
|
||||
(all-modules `((,%top-srcdir . "guix/build-system"))))
|
||||
|
|
Loading…
Reference in a new issue