-
Notifications
You must be signed in to change notification settings - Fork 0
/
expect.sh
143 lines (130 loc) · 3.77 KB
/
expect.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# file to be sourced by scripts wanting to test the compiler
. ./subr.sh
# Check that compiling and loading the file $1 generates an error
# at load time; also that just loading it directly (into the
# interpreter) generates an error.
# In bash,
#
# function callee() { cat }
# function caller() { callee bar <<EOF \n $1 \n EOF \n }
# caller foo
#
# will print "foo". In certain versions of sh, however, it will print
# "bar" instead. Hence variables f and c in the following code.
expect_load_error ()
{
# Test compiling and loading.
f="$1"
run_sbcl <<EOF
(compile-file "$f")
;;; But loading the file should fail.
(multiple-value-bind (value0 value1) (ignore-errors (load *))
(assert (null value0))
(format t "VALUE1=~S (~A)~%" value1 value1)
(assert (typep value1 'error)))
(sb-ext:exit :code $EXIT_LISP_WIN)
EOF
check_status_maybe_lose compile-and-load $?
# Test loading into the interpreter.
f="$1"
run_sbcl <<EOF
(multiple-value-bind (value0 value1) (ignore-errors (load "$f"))
(assert (null value0))
(format t "VALUE1=~S (~A)~%" value1 value1)
(assert (typep value1 'error)))
(sb-ext:exit :code $EXIT_LISP_WIN)
EOF
check_status_maybe_lose load-into-interpreter $?
}
expect_clean_cload ()
{
expect_clean_compile $1
f="$1"
run_sbcl <<EOF
(multiple-value-bind (value0 value1)
(ignore-errors (load (compile-file-pathname "$f")))
(assert value0)
(assert (null value1)))
(sb-ext:exit :code $EXIT_LISP_WIN)
EOF
check_status_maybe_lose load-compiled $?
}
# Test that a file compiles cleanly, with no ERRORs, WARNINGs or
# STYLE-WARNINGs.
expect_clean_compile ()
{
f="$1"
run_sbcl <<EOF
(multiple-value-bind (pathname warnings-p failure-p)
(compile-file "$f")
(declare (ignore pathname))
(assert (not warnings-p))
(assert (not failure-p))
(sb-ext:exit :code $EXIT_LISP_WIN))
EOF
check_status_maybe_lose clean-compile $?
}
expect_warned_compile ()
{
f="$1"
run_sbcl <<EOF
(multiple-value-bind (pathname warnings-p failure-p)
(compile-file "$f")
(declare (ignore pathname))
(assert warnings-p)
(assert (not failure-p))
(sb-ext:exit :code $EXIT_LISP_WIN))
EOF
check_status_maybe_lose warn-compile $?
}
expect_failed_compile ()
{
f="$1"
run_sbcl <<EOF
(multiple-value-bind (pathname warnings-p failure-p)
(compile-file "$f")
(declare (ignore pathname warnings-p))
(assert failure-p)
(sb-ext:exit :code $EXIT_LISP_WIN))
EOF
check_status_maybe_lose fail-compile $?
}
expect_aborted_compile ()
{
f="$1"
run_sbcl <<EOF
(let* ((lisp "$f")
(fasl (compile-file-pathname lisp)))
(multiple-value-bind (pathname warnings-p failure-p)
(compile-file "$f" :print t)
(assert (not pathname))
(assert failure-p)
(assert warnings-p)
(assert (not (probe-file fasl))))
(sb-ext:exit :code $EXIT_LISP_WIN))
EOF
check_status_maybe_lose abort-compile $?
}
fail_on_condition_during_compile ()
{
c="$1"
f="$2"
run_sbcl <<EOF
(handler-bind (($c #'error))
(compile-file "$f")
(sb-ext:exit :code $EXIT_LISP_WIN))
EOF
check_status_maybe_lose "fail-on-condition_$1" $?
}
expect_condition_during_compile ()
{
c="$1"
f="$2"
run_sbcl <<EOF
(handler-bind (($c (lambda (c)
(declare (ignore c))
(sb-ext:exit :code $EXIT_LISP_WIN))))
(compile-file "$f"))
EOF
check_status_maybe_lose "expect-condition_$1" $?
}