0.8.3.28:
[sbcl.git] / tests / expect.sh
1 # file to be sourced by scripts wanting to test the compiler
2
3 # Check that compiling and loading the file $1 generates an error
4 # at load time; also that just loading it directly (into the
5 # interpreter) generates an error.
6 expect_load_error ()
7 {
8     # Test compiling and loading.
9     $SBCL <<EOF
10         (compile-file "$1")
11         ;;; But loading the file should fail.
12         (multiple-value-bind (value0 value1) (ignore-errors (load *))
13             (assert (null value0))
14             (format t "VALUE1=~S (~A)~%" value1 value1)
15             (assert (typep value1 'error)))
16         (sb-ext:quit :unix-status 52)
17 EOF
18     if [ $? != 52 ]; then
19         echo compile-and-load $1 test failed: $?
20         exit 1
21     fi
22
23     # Test loading into the interpreter.
24     $SBCL <<EOF
25         (multiple-value-bind (value0 value1) (ignore-errors (load "$1"))
26             (assert (null value0))
27             (format t "VALUE1=~S (~A)~%" value1 value1)
28             (assert (typep value1 'error)))
29         (sb-ext:quit :unix-status 52)
30 EOF
31     if [ $? != 52 ]; then
32         echo load-into-interpreter $1 test failed: $?
33         exit 1
34     fi
35 }
36
37 # Test that a file compiles cleanly, with no ERRORs, WARNINGs or
38 # STYLE-WARNINGs.
39 #
40 # Maybe this wants to be in a compiler.test.sh script?  This function
41 # was originally written to test APD's patch for slot readers and
42 # writers not being known to the compiler. -- CSR, 2002-08-14
43 expect_clean_compile () 
44 {
45     $SBCL <<EOF
46         (multiple-value-bind (pathname warnings-p failure-p)
47             (compile-file "$1")
48           (declare (ignore pathname))
49           (assert (not warnings-p))
50           (assert (not failure-p))
51           (sb-ext:quit :unix-status 52))
52 EOF
53     if [ $? != 52 ]; then
54         echo clean-compile $1 test failed: $?
55         exit 1
56     fi
57 }
58
59 expect_warned_compile ()
60 {
61     $SBCL <<EOF
62         (multiple-value-bind (pathname warnings-p failure-p)
63             (compile-file "$1")
64           (declare (ignore pathname))
65           (assert warnings-p)
66           (assert (not failure-p))
67           (sb-ext:quit :unix-status 52))
68 EOF
69     if [ $? != 52 ]; then
70         echo warn-compile $1 test failed: $?
71         exit 1
72     fi
73 }
74
75 expect_failed_compile ()
76 {
77     $SBCL <<EOF
78         (multiple-value-bind (pathname warnings-p failure-p)
79             (compile-file "$1")
80           (declare (ignore pathname warnings-p))
81           (assert failure-p)
82           (sb-ext:quit :unix-status 52))
83 EOF
84     if [ $? != 52 ]; then
85         echo fail-compile $1 test failed: $?
86         exit 1
87     fi
88 }
89
90 fail_on_compiler_note ()
91 {
92     $SBCL <<EOF
93         (handler-bind ((sb-ext:compiler-note #'error))
94           (compile-file "$1")
95           (sb-ext:quit :unix-status 52))
96 EOF
97     if [ $? != 52 ]; then
98         echo compiler-note $1 test failed: $?
99         exit 1
100     fi
101 }
102