File: expect.sh

package info (click to toggle)
sbcl 1%3A0.9.16.0-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 19,960 kB
  • ctags: 16,537
  • sloc: lisp: 231,164; ansic: 19,558; asm: 2,539; sh: 1,925; makefile: 308
file content (111 lines) | stat: -rw-r--r-- 2,995 bytes parent folder | download
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
# file to be sourced by scripts wanting to test the compiler

# 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.
expect_load_error ()
{
    # Test compiling and loading.
    $SBCL <<EOF
        (compile-file "$1")
        ;;; 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:quit :unix-status 52)
EOF
    if [ $? != 52 ]; then
        echo compile-and-load $1 test failed: $?
        exit 1
    fi

    # Test loading into the interpreter.
    $SBCL <<EOF
        (multiple-value-bind (value0 value1) (ignore-errors (load "$1"))
            (assert (null value0))
            (format t "VALUE1=~S (~A)~%" value1 value1)
            (assert (typep value1 'error)))
        (sb-ext:quit :unix-status 52)
EOF
    if [ $? != 52 ]; then
        echo load-into-interpreter $1 test failed: $?
        exit 1
    fi
}

# Test that a file compiles cleanly, with no ERRORs, WARNINGs or
# STYLE-WARNINGs.
expect_clean_compile ()
{
    $SBCL <<EOF
        (multiple-value-bind (pathname warnings-p failure-p)
            (compile-file "$1")
          (declare (ignore pathname))
          (assert (not warnings-p))
          (assert (not failure-p))
          (sb-ext:quit :unix-status 52))
EOF
    if [ $? != 52 ]; then
        echo clean-compile $1 test failed: $?
        exit 1
    fi
}

expect_warned_compile ()
{
    $SBCL <<EOF
        (multiple-value-bind (pathname warnings-p failure-p)
            (compile-file "$1")
          (declare (ignore pathname))
          (assert warnings-p)
          (assert (not failure-p))
          (sb-ext:quit :unix-status 52))
EOF
    if [ $? != 52 ]; then
        echo warn-compile $1 test failed: $?
        exit 1
    fi
}

expect_failed_compile ()
{
    $SBCL <<EOF
        (multiple-value-bind (pathname warnings-p failure-p)
            (compile-file "$1")
          (declare (ignore pathname warnings-p))
          (assert failure-p)
          (sb-ext:quit :unix-status 52))
EOF
    if [ $? != 52 ]; then
        echo fail-compile $1 test failed: $?
        exit 1
    fi
}

fail_on_compiler_note ()
{
    $SBCL <<EOF
        (handler-bind ((sb-ext:compiler-note #'error))
          (compile-file "$1")
          (sb-ext:quit :unix-status 52))
EOF
    if [ $? != 52 ]; then
        echo fail-on-compiler-note $1 test failed: $?
        exit 1
    fi
}

expect_compiler_note ()
{
    $SBCL <<EOF
        (handler-bind ((sb-ext:compiler-note (lambda (c)
                                               (declare (ignore c))
                                               (sb-ext:quit :unix-status 52))))
          (compile-file "$1"))
EOF
    if [ $? != 52 ]; then
        echo expect-compiler-note $1 test failed: $?
        exit 1
    fi
}