M guix/discovery.scm => guix/discovery.scm +11 -2
@@ 38,7 38,8 @@
(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 @@ returned list is sorted in alphabetical order."
(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 #\/))))
M tests/discovery.scm => tests/discovery.scm +4 -0
@@ 32,6 32,10 @@
((('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"))))