0.8.10.29:
[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 expect_clean_compile () 
40 {
41     $SBCL <<EOF
42         (multiple-value-bind (pathname warnings-p failure-p)
43             (compile-file "$1")
44           (declare (ignore pathname))
45           (assert (not warnings-p))
46           (assert (not failure-p))
47           (sb-ext:quit :unix-status 52))
48 EOF
49     if [ $? != 52 ]; then
50         echo clean-compile $1 test failed: $?
51         exit 1
52     fi
53 }
54
55 expect_warned_compile ()
56 {
57     $SBCL <<EOF
58         (multiple-value-bind (pathname warnings-p failure-p)
59             (compile-file "$1")
60           (declare (ignore pathname))
61           (assert warnings-p)
62           (assert (not failure-p))
63           (sb-ext:quit :unix-status 52))
64 EOF
65     if [ $? != 52 ]; then
66         echo warn-compile $1 test failed: $?
67         exit 1
68     fi
69 }
70
71 expect_failed_compile ()
72 {
73     $SBCL <<EOF
74         (multiple-value-bind (pathname warnings-p failure-p)
75             (compile-file "$1")
76           (declare (ignore pathname warnings-p))
77           (assert failure-p)
78           (sb-ext:quit :unix-status 52))
79 EOF
80     if [ $? != 52 ]; then
81         echo fail-compile $1 test failed: $?
82         exit 1
83     fi
84 }
85
86 fail_on_compiler_note ()
87 {
88     $SBCL <<EOF
89         (handler-bind ((sb-ext:compiler-note #'error))
90           (compile-file "$1")
91           (sb-ext:quit :unix-status 52))
92 EOF
93     if [ $? != 52 ]; then
94         echo fail-on-compiler-note $1 test failed: $?
95         exit 1
96     fi
97 }
98
99 expect_compiler_note ()
100 {
101     $SBCL <<EOF
102         (handler-bind ((sb-ext:compiler-note (lambda (c)
103                                                (declare (ignore c))
104                                                (sb-ext:quit :unix-status 52))))
105           (compile-file "$1"))
106 EOF
107     if [ $? != 52 ]; then
108         echo expect-compiler-note $1 test failed: $?
109         exit 1
110     fi
111 }