0.6.12.21.flaky2.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   #| ; REMOVEME: These should be uncommented-out after flaky2_branch is merged.
39   (format t "about to LOAD ~S~%" "TEST:$StudlyCapsStem")
40   (load "TEST:$StudlyCapsStem")
41   (assert (eq *loaded* :yes))
42   (let ((compiled-file-name (namestring (compile-file "TEST:$StudlyCapsStem")))
43         (expected-file-name "$testdir/$testfilestem.x86f"))
44     (format t "compiled-file-name=~S~%" compiled-file-name)
45     (format t "expected-file-name=~S~%" expected-file-name)
46     (assert (string= compiled-file-name expected-file-name)))
47   |#
48   (sb-ext:quit :unix-status 52)
49 EOF
50 if [ $? != 52 ]; then
51     echo LOAD/COMPILE test failed, unexpected Lisp return code=$?
52     exit 1
53 fi
54 # We don't need the test directory any more.
55 rm -r $testdir
56
57 # In the flaky1 branch, Dan Barlow pointed out that
58 # ENSURE-DIRECTORIES-EXIST failed for these relative pathname
59 # operations when the mysterious special case handling of "" pathnames
60 # was removed from UNIX-STAT. Let's make sure that it works now.
61 #
62 # Set up an empty directory to work with.
63 testdir=$TMPDIR/sbcl-mkdir-test-$$
64 if ! rm -rf $testdir ; then
65   echo "$testdir already exists and could not be deleted"
66   exit 1;
67 fi
68 mkdir $testdir
69 cd $testdir
70 #
71 # Provoke failure.
72 $SBCL <<EOF
73 (let ((rel-name #p"foo/bar/")
74       (abs-name (merge-pathnames #p"baz/quux/" (truename "."))))
75   (and
76    (ensure-directories-exist abs-name)
77    (ensure-directories-exist rel-name)
78    (sb-ext:quit :unix-status 52)))
79 EOF
80 if [ $? != 52 ]; then
81     echo ENSURE-DIRECTORIES-EXIST test failed, unexpected SBCL return code=$?
82     find $testdir -print
83     exit 1
84 fi
85 if [ ! -d $testdir/foo/bar ] ; then
86     echo test failed: $testdir/foo/bar is not a directory
87     find $testdir -print
88     exit 1
89 fi;
90 if [ ! -d $testdir/baz/quux ] ; then
91     echo test failed: $testdir/baz/quux is not a directory
92     find $testdir -print
93     exit 1
94 fi;
95 #
96 # We succeeded, life is good. Now we don't need the test directory
97 # any more; and come back home.
98 rm -r $testdir
99 cd $original_pwd
100
101 # success convention for script
102 exit 104