1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 03:40:34 +02:00

ftw: Include sub-directories in the result of `scandir'.

* module/ice-9/ftw.scm (scandir)[skip]: Keep NAME in the resulting list.

* test-suite/tests/ftw.test ("scandir")["top-srcdir"]: New test.
This commit is contained in:
Ludovic Courtès 2011-12-19 22:25:30 +01:00
parent 52b680f85e
commit a2c66014cf
2 changed files with 13 additions and 1 deletions

View file

@ -530,7 +530,7 @@ of file names is sorted according to ENTRY<?, which defaults to
(define (skip name stat result)
;; All the sub-directories are skipped.
result)
(cons (basename name) result))
(and=> (file-system-fold enter? leaf down up skip #f name stat)
(lambda (files)

View file

@ -169,6 +169,18 @@
(with-test-prefix "scandir"
(pass-if "top-srcdir"
(let ((valid? (negate (cut string-any #\/ <>))))
(match (scandir %top-srcdir)
(((? valid? files) ...)
;; Both subdirs and files must be included.
(let ((expected '("libguile" "README" "COPYING"
"test-suite" "Makefile.am"
"." "..")))
(lset= string=?
(lset-intersection string=? files expected)
expected))))))
(pass-if "test-suite"
(let ((select? (cut string-suffix? ".test" <>)))
(match (scandir (string-append %test-dir "/tests") select?)