Merge commit 'c8da65a' into new-open
[sbcl/kreuter.git] / tests / expect.sh
blob637960d1f232d23cfdf325d09df75e6c8ac0cd3a
1 # file to be sourced by scripts wanting to test the compiler
3 . ./subr.sh
5 # In theory, each of these should delete the fasls they produce, so
6 # that the various tests don't interact in odd ways.
7 delete_fasl ()
9 run_sbcl <<EOF
10 (delete-file (compile-file-pathname "$1"))
11 (sb-ext:quit :unix-status 0)
12 EOF
13 # If the above is too principled, we can try this:
14 # rm "${1%.lisp}.fasl"
17 # Check that compiling and loading the file $1 generates an error
18 # at load time; also that just loading it directly (into the
19 # interpreter) generates an error.
20 expect_load_error ()
22 # Test compiling and loading.
23 run_sbcl <<EOF
24 (compile-file "$1")
25 ;;; But loading the file should fail.
26 (multiple-value-bind (value0 value1) (ignore-errors (load *))
27 (assert (null value0))
28 (format t "VALUE1=~S (~A)~%" value1 value1)
29 (assert (typep value1 'error)))
30 (sb-ext:quit :unix-status $EXIT_LISP_WIN)
31 EOF
32 check_status_maybe_lose compile-and-load $?
34 # Test loading into the interpreter.
35 run_sbcl <<EOF
36 (multiple-value-bind (value0 value1) (ignore-errors (load "$1"))
37 (assert (null value0))
38 (format t "VALUE1=~S (~A)~%" value1 value1)
39 (assert (typep value1 'error)))
40 (sb-ext:quit :unix-status $EXIT_LISP_WIN)
41 EOF
42 check_status_maybe_lose load-into-interpreter $?
45 # Test that a file compiles cleanly, with no ERRORs, WARNINGs or
46 # STYLE-WARNINGs.
47 expect_clean_compile ()
49 run_sbcl <<EOF
50 (multiple-value-bind (pathname warnings-p failure-p)
51 (compile-file "$1")
52 (declare (ignore pathname))
53 (assert (not warnings-p))
54 (assert (not failure-p))
55 (sb-ext:quit :unix-status $EXIT_LISP_WIN))
56 EOF
57 check_status_maybe_lose clean-compile $?
60 expect_warned_compile ()
62 run_sbcl <<EOF
63 (multiple-value-bind (pathname warnings-p failure-p)
64 (compile-file "$1")
65 (declare (ignore pathname))
66 (assert warnings-p)
67 (assert (not failure-p))
68 (sb-ext:quit :unix-status $EXIT_LISP_WIN))
69 EOF
70 check_status_maybe_lose warn-compile $?
73 expect_failed_compile ()
75 run_sbcl <<EOF
76 (multiple-value-bind (pathname warnings-p failure-p)
77 (compile-file "$1")
78 (declare (ignore pathname warnings-p))
79 (assert failure-p)
80 (sb-ext:quit :unix-status $EXIT_LISP_WIN))
81 EOF
82 check_status_maybe_lose fail-compile $?
85 expect_aborted_compile ()
87 delete_fasl "$1"
88 run_sbcl <<EOF
89 (let* ((lisp "$1")
90 (fasl (compile-file-pathname lisp)))
91 (multiple-value-bind (pathname warnings-p failure-p)
92 (compile-file "$1" :print t)
93 (assert (not pathname))
94 (assert failure-p)
95 (assert warnings-p)
96 (assert (not (probe-file fasl))))
97 (sb-ext:quit :unix-status $EXIT_LISP_WIN))
98 EOF
99 check_status_maybe_lose abort-compile $?
102 fail_on_compiler_note ()
104 run_sbcl <<EOF
105 (handler-bind ((sb-ext:compiler-note #'error))
106 (compile-file "$1")
107 (sb-ext:quit :unix-status $EXIT_LISP_WIN))
109 check_status_maybe_lose fail-on-compiler-note $?
112 expect_compiler_note ()
114 run_sbcl <<EOF
115 (handler-bind ((sb-ext:compiler-note (lambda (c)
116 (declare (ignore c))
117 (sb-ext:quit :unix-status
118 $EXIT_LISP_WIN))))
119 (compile-file "$1"))
121 check_status_maybe_lose expect-compiler-note $?