0.6.12.7.flaky1.2:
[sbcl.git] / tests / side-effectful-pathnames.test.sh
1 #!/bin/sh
2
3 # This software is part of the SBCL system. See the README file for
4 # more information.
5 #
6 # While most of SBCL is derived from the CMU CL system, the test
7 # files (like this one) were written from scratch after the fork
8 # from CMU CL.
9
10 # This software is in the public domain and is provided with
11 # absolutely no warranty. See the COPYING and CREDITS files for
12 # more information.
13
14 original_pwd=`pwd`
15
16 # LOADing and COMPILEing files with logical pathnames
17 testdir=`pwd`"/side-effectful-pathnames-test-$$"
18 testfilestem="load-test"
19 StudlyCapsStem="Load-Test"
20 testfilename="$testdir/$testfilestem.lisp"
21 mkdir $testdir
22 cat >$testfilename <<EOF
23   (in-package :cl-user)
24   (defparameter *loaded* :yes)
25 EOF
26 $SBCL <<EOF
27   (in-package :cl-user)
28   (setf (logical-pathname-translations "TEST")
29         (list (list "**;*.*.*" "$testdir/**/*.*")))
30   (format t "/translations=~S~%" (logical-pathname-translations "TEST"))
31   (let* ((untranslated "test:$StudlyCapsStem.lisp")
32          (ignore-me (format t "untranslated=~S~%" untranslated))
33          (translation (namestring (translate-logical-pathname untranslated)))
34          (expected-translation "$testdir/$testfilestem.lisp"))
35     (format t "translation=~S~%" translation)
36     (format t "expected-translation=~S~%" expected-translation)
37     (assert (string= translation expected-translation)))
38   (load "TEST:$StudlyCapsStem")
39   (assert (eq *loaded* :yes))
40   (let ((compiled-file-name (namestring (compile-file "TEST:$StudlyCapsStem")))
41         (expected-file-name "$testdir/$testfilestem.x86f"))
42     (format t "compiled-file-name=~S~%" compiled-file-name)
43     (format t "expected-file-name=~S~%" expected-file-name)
44     (assert (string= compiled-file-name expected-file-name)))
45   (sb-ext:quit :unix-status 52)
46 EOF
47 if [ $? != 52 ]; then
48     echo LOAD/COMPILE test failed, unexpected Lisp return code=$?
49     exit 1
50 fi
51 # We don't need the test directory any more.
52 rm -r $testdir
53
54 # In the flaky1 branch, Dan Barlow pointed out that
55 # ENSURE-DIRECTORIES-EXIST failed for these relative pathname
56 # operations when the mysterious special case handling of "" pathnames
57 # was removed from UNIX-STAT. Let's make sure that it works now.
58 #
59 # Set up an empty directory to work with.
60 testfilestem=$TMPDIR/sbcl-mkdir-test-$$
61 if ! rm -rf $testfilestem ; then
62   echo "$testfilestem already exists and cannot be deleted"
63   exit 1;
64 fi
65 mkdir $testfilestem
66 cd  $testfilestem
67 #
68 # Provoke failure.
69 $SBCL <<EOF
70 (let ((rel-name #p"foo/bar/")
71       (abs-name (merge-pathnames #p"baz/quux/" (truename "."))))
72   (and
73    (ensure-directories-exist abs-name)
74    (ensure-directories-exist rel-name)
75    (sb-ext:quit :unix-status 52)))
76 EOF
77 if [ $? != 52 ]; then
78     echo ENSURE-DIRECTORIES-EXIST test failed, unexpected SBCL return code=$?
79     find $testfilestem -print
80     exit 1
81 fi
82 if [ ! -d $testfilestem/foo/bar ] ; then
83     echo test failed: $testfilestem/foo/bar is not a directory
84     find $testfilestem -print
85     exit 1
86 fi;
87 if [ ! -d $testfilestem/baz/quux ] ; then
88     echo test failed: $testfilestem/baz/quux is not a directory
89     find $testfilestem -print
90     exit 1
91 fi;
92 #
93 # We succeeded, life is good. Now we don't need the test directory
94 # any more; and come back home.
95 rm -r $testfilestem
96 cd $original_pwd
97
98 # success convention for script
99 exit 104