X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=tests%2Ffilesys.test.sh;h=d2082b66be5eda3a797a8dd25b21e555cd64f51f;hb=31f68584d0732dc0d17f379773e5f87f1e5a78ad;hp=d944cf22dc60ddd0e41c460a800cb893e372fc9d;hpb=83fd554b67913275d8dc06edcad8b2f065c89c49;p=sbcl.git diff --git a/tests/filesys.test.sh b/tests/filesys.test.sh index d944cf2..d2082b6 100644 --- a/tests/filesys.test.sh +++ b/tests/filesys.test.sh @@ -6,37 +6,52 @@ # While most of SBCL is derived from the CMU CL system, the test # files (like this one) were written from scratch after the fork # from CMU CL. -# +# # This software is in the public domain and is provided with # absolutely no warranty. See the COPYING and CREDITS files for # more information. +. ./subr.sh + +use_test_subdirectory +testdir="`pwd -P`" # resolve symbolic links in the directory. + +set -f # disable filename expansion in the shell. + # Test DIRECTORY and TRUENAME. -testdir=`pwd`"/filesys-test-$$" -mkdir $testdir -echo this is a test > $testdir/test-1.tmp -echo this is a test > $testdir/test-2.tmp -cd $testdir +echo this is a test > test-1.tmp +echo this is a test > test-2.tmp +echo this is a test > wild?test.tmp + +ln -s "$testdir" dirlinktest ln -s test-1.tmp link-1 -ln -s `pwd`/test-2.tmp link-2 +ln -s "$testdir/test-2.tmp" link-2 ln -s i-do-not-exist link-3 ln -s link-4 link-4 ln -s link-5 link-6 -ln -s `pwd`/link-6 link-5 -expected_truenames=\ -"'(#p\"$testdir/link-3\"\ - #p\"$testdir/link-4\"\ - #p\"$testdir/link-5\"\ - #p\"$testdir/link-6\"\ - #p\"$testdir/test-1.tmp\"\ - #p\"$testdir/test-2.tmp\")" -$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) + #+nil + (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) + #+nil + (need-match "animal/vertebrate/mammal/robot/../**/../**/*.*" nil)) +(need-matches) +(sb-ext:exit :code $EXIT_LISP_WIN) EOF -if [ $? != 52 ]; then - echo DIRECTORY/TRUENAME test part 2 failed, unexpected SBCL return code=$? - exit 1 -fi -rm -r $testdir +check_status_maybe_lose "DIRECTORY/TRUENAME part 3" $? +cleanup_test_subdirectory + +# DIRECTORY pattern matching +use_test_subdirectory + +mkdir foo +touch foo/aa.txt +touch foo/aa.tmp +mkdir foo/x + +mkdir far +touch far/ab.txt +touch far/ab.tmp +mkdir far/x +mkdir far/y +mkdir far/y/x +mkdir far/x/x + +mkdir qar +touch qar/ac.txt +touch qar/ac.tmp + +mkdir foo.moose +touch foo.bar + +mkdir -p a/z c +touch a/z/foo.bar +touch a/z/foo.dummy +ln -s ../a/z c/z + +run_sbcl <