Fix make-array transforms.
[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 . ./subr.sh
15
16 use_test_subdirectory
17 testdir="`pwd -P`" # resolve symbolic links in the directory.
18
19 # LOADing and COMPILEing files with logical pathnames
20 testfilestem="load-test"
21 StudlyCapsStem="Load-Test"
22 testfilename="$testfilestem.lisp"
23 cat >$testfilename <<EOF
24   (in-package :cl-user)
25   (defparameter *loaded* :yes)
26 EOF
27 run_sbcl <<EOF
28   (in-package :cl-user)
29   (setf (logical-pathname-translations "TEST")
30         (list (list "**;*.*.*" "$testdir/**/*.*")))
31   (format t "/translations=~S~%" (logical-pathname-translations "TEST"))
32   (let* ((untranslated "test:$StudlyCapsStem.lisp")
33          (ignore-me (format t "untranslated=~S~%" untranslated))
34          (translation (namestring (translate-logical-pathname untranslated)))
35          (expected-translation "$testdir/$testfilestem.lisp"))
36     (format t "translation=~S~%" translation)
37     (format t "expected-translation=~S~%" expected-translation)
38     (assert (string= translation expected-translation)))
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.fasl"))
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   (sb-ext:quit :unix-status $EXIT_LISP_WIN)
48 EOF
49 check_status_maybe_lose "LOAD/COMPILE" $?
50
51 # In the flaky1 branch, Dan Barlow pointed out that
52 # ENSURE-DIRECTORIES-EXIST failed for these relative pathname
53 # operations when the mysterious special case handling of "" pathnames
54 # was removed from UNIX-STAT. Let's make sure that it works now.
55 #
56 # Set up an empty directory to work with.
57 testdir="${TMPDIR:-/tmp}/sbcl-mkdir-test-$$"
58 if ! rm -rf "$testdir" ; then
59   echo "$testdir already exists and could not be deleted"
60   exit 1;
61 fi
62 mkdir "$testdir"
63 cd "$testdir"
64 #
65 # Provoke failure.
66 run_sbcl <<EOF
67 (let ((rel-name #p"foo/bar/")
68       (abs-name (merge-pathnames #p"baz/quux/" (truename "."))))
69   (and
70    (equalp (ensure-directories-exist abs-name) abs-name)
71    (equalp (ensure-directories-exist rel-name) rel-name)
72    (sb-ext:quit :unix-status 52)))
73 EOF
74 check_status_maybe_lose "ENSURE-DIRECTORIES-EXIST" $?
75 if [ ! -d "$testdir/foo/bar" ] ; then
76     echo test failed: "$testdir/foo/bar" is not a directory
77     find "$testdir" -print
78     exit 1
79 fi;
80 if [ ! -d "$testdir/baz/quux" ] ; then
81     echo test failed: "$testdir/baz/quux" is not a directory
82     find "$testdir" -print
83     exit 1
84 fi;
85 #
86 # We succeeded, life is good. Now we don't need the test directory
87 # any more; and come back home.
88 cd "$SBCL_PWD"
89 rm -r "$testdir"
90
91 exit $EXIT_TEST_WIN