89693ff11150ccac3aafd059e9f436b6183d9aa2
[sbcl.git] / tests / script.test.sh
1 #!/bin/sh
2
3 # tests related to --script
4
5 # This software is part of the SBCL system. See the README file for
6 # more information.
7 #
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
10 # from CMU CL.
11 #
12 # This software is in the public domain and is provided with
13 # absolutely no warranty. See the COPYING and CREDITS files for
14 # more information.
15
16 . ./subr.sh
17
18 use_test_subdirectory
19
20 tmpscript=$TEST_FILESTEM.lisp-script
21
22 echo '(quit :unix-status 7)' > $tmpscript
23 run_sbcl --script $tmpscript
24 check_status_maybe_lose "--script exit status from QUIT" $? 7 "(quit status good)"
25
26 echo '(error "oops")' > $tmpscript
27 run_sbcl --script $tmpscript 2> /dev/null
28 check_status_maybe_lose "--script exit status from ERROR" $? 1 "(error implies 1)"
29
30 echo 'nil'> $tmpscript
31 run_sbcl --script $tmpscript
32 check_status_maybe_lose "--script exit status from normal exit" $? 0 "(everything ok)"
33
34 cat > $tmpscript <<EOF
35 (setf *standard-output* (open "/dev/stdout"))
36 (close *standard-output*)
37 (sb-ext:quit :unix-status 3)
38 EOF
39 cat $tmpscript
40 run_sbcl --script $tmpscript
41 check_status_maybe_lose "--script exit status from QUIT when stdout closed" $? 3 "(as given)"
42 run_sbcl --load $tmpscript
43 check_status_maybe_lose "--load exit status from QUIT when stdout closed" $? 3 "(as given)"
44
45 rm -f $tmpscript
46
47 exit $EXIT_TEST_WIN