summaryrefslogtreecommitdiff
path: root/tests/general/Test-opts
blob: ac81ebc99f8739c2e56beaf311c9e6f298ae3324 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
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