X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=tests%2Ffilesys.test.sh;h=28f39351846903e348b2d1e5ae2f3021da4df0d7;hb=b767eae48831153473226b985511c8f7a3ef98c5;hp=37c0e0b5d0e4c9b253ae671be2c8925a12f2dea0;hpb=1dc58ed504bd2de24fd87f9267c97c4a7d90ba3c;p=sbcl.git diff --git a/tests/filesys.test.sh b/tests/filesys.test.sh index 37c0e0b..28f3935 100644 --- a/tests/filesys.test.sh +++ b/tests/filesys.test.sh @@ -73,5 +73,118 @@ if [ $? != 52 ]; then fi rm -r $testdir +# Test DIRECTORY on a tree structure of directories. +mkdir $testdir +cd $testdir +touch water dirt +mkdir animal plant +mkdir animal/vertebrate animal/invertebrate +mkdir animal/vertebrate/mammal +mkdir animal/vertebrate/snake +mkdir animal/vertebrate/bird +mkdir animal/vertebrate/mammal/bear +mkdir animal/vertebrate/mammal/mythical +mkdir animal/vertebrate/mammal/rodent +mkdir animal/vertebrate/mammal/ruminant +touch animal/vertebrate/mammal/platypus +touch animal/vertebrate/mammal/walrus +touch animal/vertebrate/mammal/bear/grizzly +touch animal/vertebrate/mammal/mythical/mermaid +touch animal/vertebrate/mammal/mythical/unicorn +touch animal/vertebrate/mammal/rodent/beaver +touch animal/vertebrate/mammal/rodent/mouse +touch animal/vertebrate/mammal/rodent/rabbit +touch animal/vertebrate/mammal/rodent/rat +touch animal/vertebrate/mammal/ruminant/cow +touch animal/vertebrate/snake/python +touch plant/kingsfoil plant/pipeweed +$SBCL <~%" + directory-pathname) + (format t "~&~@~%" + directory-sorted-truenamestrings) + (format t "~&~@~%" + result-sorted-truenamestrings) + (error "mismatch between DIRECTORY and expected result")))) +(defun need-match (directory-pathname result-pathnames) + "Require that (DIRECTORY DIRECTORY-PATHNAME) return RESULT-PATHNAMES +(modulo TRUENAME and NAMESTRING applied to each RESULT-PATHNAME for +convenience in e.g. converting Unix filename syntax idiosyncrasies to +Lisp filename syntax idiosyncrasies)." + (let ((sorted-result-truenamestrings (sorted-truenamestrings + result-pathnames))) + ;; Relative and absolute pathnames should give the same result. + (need-match-1 directory-pathname + sorted-result-truenamestrings) + (need-match-1 (absolutify directory-pathname) + sorted-result-truenamestrings))) +(defun need-matches () + "lotso calls to NEED-MATCH" + ;; FIXME: As discussed on sbcl-devel ca. 2001-01-01, DIRECTORY should + ;; report Unix directory files contained within its output as e.g. + ;; "/usr/bin" instead of the CMU-CL-style "/usr/bin/". In that case, + ;; s:/":": in most or all the NEED-MATCHes here. + (need-match "./*.*" '("animal/" "dirt" "plant/" "water")) + (need-match "*.*" '("animal/" "dirt" "plant/" "water")) + (need-match "animal" '("animal/")) + (need-match "./animal" '("animal/")) + (need-match "animal/*.*" '("animal/invertebrate/" "animal/vertebrate/")) + (need-match "animal/*/*.*" + '("animal/vertebrate/bird/" + "animal/vertebrate/mammal/" + "animal/vertebrate/snake/")) + (need-match "plant/*.*" '("plant/kingsfoil" "plant/pipeweed")) + (need-match "plant/**/*.*" '("plant/kingsfoil" "plant/pipeweed")) + (need-match "plant/**/**/*.*" '("plant/kingsfoil" "plant/pipeweed")) + (let ((vertebrates (mapcar (lambda (stem) + (concatenate 'string + "animal/vertebrate/" + stem)) + '("bird/" + "mammal/" + "mammal/bear/" "mammal/bear/grizzly" + "mammal/mythical/" "mammal/mythical/mermaid" + "mammal/mythical/unicorn" + "mammal/platypus" + "mammal/rodent/" "mammal/rodent/beaver" + "mammal/rodent/mouse" "mammal/rodent/rabbit" + "mammal/rodent/rat" + "mammal/ruminant/" "mammal/ruminant/cow" + "mammal/walrus" + "snake/" "snake/python")))) + (need-match "animal/vertebrate/**/*.*" vertebrates) + (need-match "animal/vertebrate/mammal/../**/*.*" vertebrates) + (need-match "animal/vertebrate/mammal/../**/**/*.*" vertebrates) + (need-match "animal/vertebrate/mammal/mythical/../**/../**/*.*" + vertebrates)) + (need-match "animal/vertebrate/**/robot.*" nil) + (need-match "animal/vertebrate/mammal/../**/*.robot" nil) + (need-match "animal/vertebrate/mammal/../**/robot/*.*" nil) + (need-match "animal/vertebrate/mammal/robot/../**/../**/*.*" nil)) +(need-matches) +EOF +cd .. +rm -r $testdir + # success convention for script exit 104