1.0.46.43: fix sb-introspect on non-threaded builds
[sbcl.git] / tests / filesys.test.sh
index f20c4e4..6840181 100644 (file)
@@ -197,19 +197,106 @@ Lisp filename syntax idiosyncrasies)."
 (sb-ext:quit :unix-status $EXIT_LISP_WIN)
 EOF
 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
+run_sbcl <<EOF
+(defun test (pattern &rest expected)
+  (let ((wanted (sort (mapcar #'truename expected) #'string< :key #'namestring))
+        (got (sort (directory pattern) #'string< :key #'namestring)))
+    (unless (equal wanted got)
+      (format t "wanted:~%  ~Sgot:~%  ~S" wanted got)
+      (error "wanted:~%  ~Sgot:~%  ~S" wanted got))))                 
+(test "*/a*.txt" "foo/aa.txt" "far/ab.txt" "qar/ac.txt")
+(test "fo*/a*.t*" "foo/aa.txt" "foo/aa.tmp")
+(test "*/*b.*" "far/ab.txt" "far/ab.tmp")
+(test "*a*/*.txt" "far/ab.txt" "qar/ac.txt")
+(test "*ar/*.txt" "far/ab.txt" "qar/ac.txt")
+(test "f*.*" "far/" "foo/" "foo.moose/" "foo.bar")
+(test "f*" "far/" "foo/")
+(test "*r" "far/" "qar/")
+(test "*r.*" "far/" "qar/")
+(test "f*.[mb]*" "foo.moose/" "foo.bar")
+(test "f*.m*.*")
+(test "f*.b*.*")
+(test "*/x" "foo/x/" "far/x/")
+(test "far/*/x" "far/y/x/" "far/x/x/")
+(test "**/x/" "foo/x/" "far/x/" "far/x/x" "far/y/x/")
+(quit :unix-status $EXIT_LISP_WIN)
+EOF
+check_status_maybe_lose "DIRECTORY/PATTERNS" $?
 
 # Test whether ENSURE-DIRECTORIES-EXIST can create a directory whose
 # name contains a wildcard character (it used to get itself confused
 # internally).
-run_sbcl --eval '(ensure-directories-exist "foo\\*bar/baz.txt")'
+run_sbcl --eval '(ensure-directories-exist "foo\\*bar/baz.txt")' --eval '(sb-ext:quit)'
 test -d foo*bar
 check_status_maybe_lose "ENSURE-DIRECTORIES-EXIST part 1" $? \
     0 "(directory exists)"
 
-run_sbcl --eval '(ensure-directories-exist "foo\\?bar/baz.txt")'
+run_sbcl --eval '(ensure-directories-exist "foo\\?bar/baz.txt")' --eval '(sb-ext:quit)'
 test -d foo?bar
 check_status_maybe_lose "ENSURE-DIRECTORIES-EXIST part 2" $? \
     0 "(directory exists)"
 
+# DELETE-DIRECTORY
+use_test_subdirectory
+mkdir    dont_delete_me
+touch    me_neither
+mkdir    simple_test_subdir1
+mkdir    simple_test_subdir2
+mkdir -p deep/1/2/
+touch    deep/a
+touch    deep/b
+touch    deep/1/c
+touch    deep/1/d
+touch    deep/1/2/e
+touch    deep/1/2/f
+ln -s    `pwd`/dont_delete_me deep/linky
+ln -s    `pwd`/me_neither deep/1/another_linky
+
+run_sbcl --eval '(sb-ext:delete-directory "simple_test_subdir1")' \
+         --eval '(sb-ext:delete-directory "simple_test_subdir2/")' \
+         --eval '(sb-ext:delete-directory "deep" :recursive t)' \
+         --eval '(sb-ext:quit)'
+
+test -e simple_test_subdir1
+check_status_maybe_lose "delete-directory 1" $? \
+  1 "deleted"
+
+test -e simple_test_subdir2
+check_status_maybe_lose "delete-directory 2" $? \
+  1 "deleted"
+
+test -e deep
+check_status_maybe_lose "delete-directory 3" $? \
+  1 "deleted"
+
+test -e dont_delete_me
+check_status_maybe_lose "delete-directory 4" $? \
+  0 "didn't follow link"
+
+test -e me_neither
+check_status_maybe_lose "delete-directory 5" $? \
+  0 "didn't follow link"
+
 # success convention for script
 exit $EXIT_TEST_WIN