| 1 |
#!/bin/sh |
| 2 |
# |
| 3 |
# Test-opts -- test some Icon command options |
| 4 |
# |
| 5 |
# Tests a few Icon command options, and especially tests various ways |
| 6 |
# to accomplish directly executable source files. |
| 7 |
# |
| 8 |
# If this script aborts, rerun by "sh -x Test-opts" to see what's occurring. |
| 9 |
|
| 10 |
# check that Icon has been built |
| 11 |
ls ../../bin/icon >/dev/null || exit 1 |
| 12 |
ls ../../bin/icont >/dev/null || exit 1 |
| 13 |
|
| 14 |
# prepend Icon binary directory to path |
| 15 |
PATH=../../bin:$PATH |
| 16 |
export PATH |
| 17 |
|
| 18 |
# merge stdin and stderr |
| 19 |
exec 2>&1 |
| 20 |
|
| 21 |
# unprotect and remove files that might be left from a previous run |
| 22 |
test -f olleh && chmod +rw olleh |
| 23 |
test -f hello && chmod +rw hello |
| 24 |
test -f hello.u1 && chmod +rw hello.u1 |
| 25 |
test -f hello.u2 && chmod +rw hello.u2 |
| 26 |
rm -f hello hello.u? olleh |
| 27 |
|
| 28 |
# stop on subsequent errors |
| 29 |
set -e |
| 30 |
|
| 31 |
# simple compile and execute, with no arguments |
| 32 |
icont hello -x |
| 33 |
./hello north |
| 34 |
rm hello |
| 35 |
|
| 36 |
# compile and execute with options |
| 37 |
icont -u -s -o olleh hello.icn -x south |
| 38 |
./olleh east |
| 39 |
rm olleh |
| 40 |
test ! -f hello |
| 41 |
test ! -f hello.u? |
| 42 |
|
| 43 |
# profiling |
| 44 |
rm -f hello.p |
| 45 |
ICONPROFILE=hello.p icon hello.icn profiler |
| 46 |
sed 's/^ *[0-9]*/ $/' hello.p |
| 47 |
|
| 48 |
# separate compilation |
| 49 |
icont -c -t -s hello |
| 50 |
icont -u -s hello.u -x west |
| 51 |
|
| 52 |
# make sure that these files all exist |
| 53 |
# and that subsequent commands don't touch them |
| 54 |
chmod -rwx hello.u1 hello.u2 hello |
| 55 |
|
| 56 |
# icont direct execution |
| 57 |
icont -X hello.icn Tucson |
| 58 |
|
| 59 |
# icon command |
| 60 |
icon hello.icn Pima |
| 61 |
|
| 62 |
# icon command from standard input |
| 63 |
icon - <hello.icn Arizona |
| 64 |
|
| 65 |
# shell magic execution (icont) |
| 66 |
chmod +rwx hello |
| 67 |
echo '#!../../bin/icont -X' | cat - hello.icn > hello |
| 68 |
./hello world |
| 69 |
|
| 70 |
# shell magic execution (icon) |
| 71 |
echo '#!../../bin/icon' | cat - hello.icn > hello |
| 72 |
./hello galaxy |
| 73 |
|
| 74 |
# shell magic execution (/usr/bin/env icon) |
| 75 |
echo '#!/usr/bin/env icon' | cat - hello.icn > hello |
| 76 |
./hello universe |
| 77 |
|
| 78 |
# in-line program |
| 79 |
icon -P 'procedure main(); write("HOWDY!"); end' |
| 80 |
|
| 81 |
# final file cleanup |
| 82 |
chmod +rw hello.u? |
| 83 |
rm hello.u? hello |
| 84 |
: done |