twiddle script.test.sh
[sbcl.git] / tests / script.test.sh
index e17761a..87a2e08 100644 (file)
@@ -38,13 +38,31 @@ run_sbcl --script $tmpscript
 check_status_maybe_lose "--script exit status from normal exit" $? 0 "(everything ok)"
 
 cat > $tmpscript <<EOF
-(setf *standard-output* (open "/dev/stdout"))
+(setf *standard-output* (make-broadcast-stream))
 (close *standard-output*)
 (sb-ext:quit :unix-status 3)
 EOF
-run_sbcl --script $tmpscript
+run_sbcl --script $tmpscript >/dev/null
+check_status_maybe_lose "--script exit status from QUIT when standard-output closed" $? 3 "(as given)"
+run_sbcl --load $tmpscript >/dev/null
+check_status_maybe_lose "--load exit status from QUIT when standard-output closed" $? 3 "(as given)"
+
+cat > $tmpscript <<EOF
+(close *standard-output*)
+(sb-ext:quit :unix-status 3)
+EOF
+run_sbcl --script $tmpscript >/dev/null
+check_status_maybe_lose "--script exit status from QUIT when original standard-output closed" $? 3 "(as given)"
+run_sbcl --load $tmpscript >/dev/null
+check_status_maybe_lose "--load exit status from QUIT when original standard-output closed" $? 3 "(as given)"
+
+cat > $tmpscript <<EOF
+(close sb-sys:*stdout*)
+(sb-ext:quit :unix-status 3)
+EOF
+run_sbcl --script $tmpscript >/dev/null
 check_status_maybe_lose "--script exit status from QUIT when stdout closed" $? 3 "(as given)"
-run_sbcl --load $tmpscript
+run_sbcl --load $tmpscript >/dev/null
 check_status_maybe_lose "--load exit status from QUIT when stdout closed" $? 3 "(as given)"
 
 cat > $tmpscript <<EOF
@@ -76,6 +94,17 @@ then
     exit $EXIT_LOSE
 fi
 
+# --script
+cat > $tmpscript <<EOF
+(print :script-ok)
+EOF
+run_sbcl --script $tmpscript --eval foo \
+  < /dev/null > $tmpout
+if [ "`grep -c :SCRIPT-OK $tmpout`" != 1 ] ; then
+   echo "failed --script test using PRINT"
+   exit $EXIT_LOSE
+fi
+
 rm -f $tmpscript $tmpout $tmperr
 
 exit $EXIT_TEST_WIN