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