3 # tests related to --script
5 # This software is part of the SBCL system. See the README file for
8 # While most of SBCL is derived from the CMU CL system, the test
9 # files (like this one) were written from scratch after the fork
12 # This software is in the public domain and is provided with
13 # absolutely no warranty. See the COPYING and CREDITS files for
20 tmpscript=$TEST_FILESTEM.lisp-script
21 tmpout=$TEST_FILESTEM.lisp-out
22 tmperr=$TEST_FILESTEM.lisp-err
24 echo '(quit :unix-status 7)' > $tmpscript
25 run_sbcl --script $tmpscript
26 check_status_maybe_lose "--script exit status from QUIT" $? 7 "(quit status good)"
28 echo '(error "oops")' > $tmpscript
29 run_sbcl --script $tmpscript 1> $tmpout 2> $tmperr
30 check_status_maybe_lose "--script exit status from ERROR" $? 1 "(error implies 1)"
31 grep BACKTRACE $tmpout > /dev/null
32 check_status_maybe_lose "--script backtrace not to stdout" $? 1 "(ok)"
33 grep BACKTRACE $tmperr > /dev/null
34 check_status_maybe_lose "--script backtrace to stderr" $? 0 "(ok)"
36 echo 'nil'> $tmpscript
37 run_sbcl --script $tmpscript
38 check_status_maybe_lose "--script exit status from normal exit" $? 0 "(everything ok)"
40 cat > $tmpscript <<EOF
41 (setf *standard-output* (open "/dev/stdout"))
42 (close *standard-output*)
43 (sb-ext:quit :unix-status 3)
45 run_sbcl --script $tmpscript
46 check_status_maybe_lose "--script exit status from QUIT when stdout closed" $? 3 "(as given)"
47 run_sbcl --load $tmpscript
48 check_status_maybe_lose "--load exit status from QUIT when stdout closed" $? 3 "(as given)"
50 cat > $tmpscript <<EOF
51 (loop (write-line (read-line)))
53 echo ONE | run_sbcl --script $tmpscript 1> $tmpout 2> $tmperr
54 check_status_maybe_lose "--script exit status when stdin closed" $? 0 "(as given)"
55 if [ -s $tmperr ] || [ "ONE" != `cat $tmpout` ]
57 echo "--script outputs wrong"
61 cat > $tmpscript <<EOF
62 (loop (write-line "foo"))
64 run_sbcl --script $tmpscript 2> $tmperr | head -n1 > $tmpout
65 check_status_maybe_lose "--script exit status when stdout closed" $? 0 "(as given)"
66 if [ -s $tmperr ] || [ "foo" != `cat $tmpout` ]
68 echo "--script unexpected error output"
71 echo '(write-line "Ok!")' | run_sbcl --script 1>$tmpout 2>$tmperr
72 check_status_maybe_lose "--script exit status script from stdin" $? 0 "(ok)"
73 if [ -s $tmperr ] || [ "Ok!" != `cat $tmpout` ]
75 echo "--script unexpected error output"
79 rm -f $tmpscript $tmpout $tmperr