diff options
author | Ludovic Courtès <ludo@gnu.org> | 2011-12-19 22:25:30 +0100 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2011-12-19 22:25:30 +0100 |
commit | a2c66014cf4b8799812e45eedbb9b1a2c61236b0 (patch) | |
tree | 585440078e0d4220e929ed0034f6f4b7744949af | |
parent | 52b680f85e84689778f10ed8f9e72adf8316fbe7 (diff) | |
download | guile-a2c66014cf4b8799812e45eedbb9b1a2c61236b0.tar.gz |
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.
-rw-r--r-- | module/ice-9/ftw.scm | 2 | ||||
-rw-r--r-- | test-suite/tests/ftw.test | 12 |
2 files changed, 13 insertions, 1 deletions
diff --git a/module/ice-9/ftw.scm b/module/ice-9/ftw.scm index eed3eeb19..5f6115427 100644 --- a/module/ice-9/ftw.scm +++ b/module/ice-9/ftw.scm @@ -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) diff --git a/test-suite/tests/ftw.test b/test-suite/tests/ftw.test index 41c731a7a..fa179d400 100644 --- a/test-suite/tests/ftw.test +++ b/test-suite/tests/ftw.test @@ -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?) |