X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=tests%2Fscript.test.sh;h=33483bad68b7cd0f2146308afcc5b33c70da1222;hb=1fd7c4a202a8d22c681110e49c0d396b89afc428;hp=87061f6c516253a6881dd0fb5ce8eef214c44c3e;hpb=b92e0bedf7e29a43fe4fd9141b5d658751e3bef0;p=sbcl.git diff --git a/tests/script.test.sh b/tests/script.test.sh index 87061f6..33483ba 100644 --- a/tests/script.test.sh +++ b/tests/script.test.sh @@ -18,25 +18,93 @@ use_test_subdirectory tmpscript=$TEST_FILESTEM.lisp-script +tmpout=$TEST_FILESTEM.lisp-out +tmperr=$TEST_FILESTEM.lisp-err -echo '(quit :unix-status 7)' > $tmpscript +echo '(exit :code 7)' > $tmpscript run_sbcl --script $tmpscript -check_status_maybe_lose "--script exit status from QUIT" $? 7 "(quit status good)" +check_status_maybe_lose "--script exit status from EXIT" $? 7 "(status good)" echo '(error "oops")' > $tmpscript -run_sbcl --script $tmpscript +run_sbcl --script $tmpscript 1> $tmpout 2> $tmperr check_status_maybe_lose "--script exit status from ERROR" $? 1 "(error implies 1)" +grep BACKTRACE $tmpout > /dev/null +check_status_maybe_lose "--script backtrace not to stdout" $? 1 "(ok)" +grep BACKTRACE $tmperr > /dev/null +check_status_maybe_lose "--script backtrace to stderr" $? 0 "(ok)" echo 'nil'> $tmpscript run_sbcl --script $tmpscript check_status_maybe_lose "--script exit status from normal exit" $? 0 "(everything ok)" -echo '(setf *error-output* *standard-output*) (defun foo () (bar)) (defun bar () 11) (quit :unix-status (foo))'> $tmpscript -out=`run_sbcl --script $tmpscript` -check_status_maybe_lose "--script exit status from normal exit" $? 11 "(everything ok)" -test -z "$out" -check_status_maybe_lose "--script forward-referenced functions" $? 0 "(everything ok)" +cat > $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 </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 </dev/null +check_status_maybe_lose "--script exit status from EXIT when stdout closed" $? 3 "(as given)" +run_sbcl --load $tmpscript >/dev/null +check_status_maybe_lose "--load exit status from EXIT when stdout closed" $? 3 "(as given)" + +cat > $tmpscript < $tmpout 2> $tmperr +check_status_maybe_lose "--script exit status when stdin closed" $? 0 "(as given)" +if [ -s $tmperr ] || [ "ONE" != `cat $tmpout` ] +then + echo "--script outputs wrong" + exit $EXIT_LOSE +fi + +cat > $tmpscript < $tmperr | head -n1 > $tmpout +check_status_maybe_lose "--script exit status when stdout closed" $? 0 "(as given)" +if [ -s $tmperr ] || [ "foo" != `cat $tmpout` ] +then + echo "--script unexpected error output" + exit $EXIT_LOSE +fi +echo '(write-line "Ok!")' | run_sbcl --script 1>$tmpout 2>$tmperr +check_status_maybe_lose "--script exit status script from stdin" $? 0 "(ok)" +if [ -s $tmperr ] || [ "Ok!" != `cat $tmpout` ] +then + echo "--script unexpected error output" + exit $EXIT_LOSE +fi + +# --script +cat > $tmpscript < $tmpout +if [ "`grep -c :SCRIPT-OK $tmpout`" != 1 ] ; then + echo "failed --script test using PRINT" + exit $EXIT_LOSE +fi -rm -f $tmpscript +rm -f $tmpscript $tmpout $tmperr exit $EXIT_TEST_WIN