diff options
Diffstat (limited to 'tests/general/Test-opts')
-rwxr-xr-x | tests/general/Test-opts | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/tests/general/Test-opts b/tests/general/Test-opts new file mode 100755 index 0000000..ac81ebc --- /dev/null +++ b/tests/general/Test-opts @@ -0,0 +1,79 @@ +#!/bin/sh +# +# Test-opts -- test some Icon command options +# +# Tests a few Icon command options, and especially tests various ways +# to accomplish directly executable source files. +# +# If this script aborts, rerun by "sh -x Test-opts" to see what's occurring. + +# check that Icon has been built +ls ../../bin/icon >/dev/null || exit 1 +ls ../../bin/icont >/dev/null || exit 1 + +# prepend Icon binary directory to path +PATH=../../bin:$PATH +export PATH + +# merge stdin and stderr +exec 2>&1 + +# unprotect and remove files that might be left from a previous run +test -f olleh && chmod +rw olleh +test -f hello && chmod +rw hello +test -f hello.u1 && chmod +rw hello.u1 +test -f hello.u2 && chmod +rw hello.u2 +rm -f hello hello.u? olleh + +# stop on subsequent errors +set -e + +# simple compile and execute, with no arguments +icont hello -x +./hello north +rm hello + +# compile and execute with options +icont -u -s -o olleh hello.icn -x south +./olleh east +rm olleh +test ! -f hello +test ! -f hello.u? + +# separate compilation +icont -c -t -s hello +icont -u -s hello.u -x west + +# make sure that these files all exist +# and that subsequent commands don't touch them +chmod -rwx hello.u1 hello.u2 hello + +# icont direct execution +icont -X hello.icn Tucson + +# icon command +icon hello.icn Pima + +# icon command from standard input +icon - <hello.icn Arizona + +# shell magic execution (icont) +chmod +rwx hello +echo '#!../../bin/icont -X' | cat - hello.icn > hello +./hello world + +# shell magic execution (icon) +echo '#!../../bin/icon' | cat - hello.icn > hello +./hello galaxy + +# shell magic execution (/usr/bin/env icon) +echo '#!/usr/bin/env icon' | cat - hello.icn > hello +./hello universe + +# in-line program +icon -P 'procedure main(); write("HOWDY!"); end' + +# final file cleanup +chmod +rw hello.u? +rm hello.u? hello +: done |