Fix use of "export" to work with traditional shells.
[pspp-builds.git] / tests / command / loop.sh
1 #!/bin/sh
2
3 # This program tests the LOOP command
4
5 TEMPDIR=/tmp/pspp-tst-$$
6 TESTFILE=$TEMPDIR/`basename $0`.sps
7
8 here=`pwd`;
9
10 # ensure that top_srcdir is absolute
11 cd $top_srcdir; top_srcdir=`pwd`
12
13 STAT_CONFIG_PATH=$top_srcdir/config
14 export STAT_CONFIG_PATH
15
16
17 cleanup()
18 {
19      rm -rf $TEMPDIR
20 }
21
22
23 fail()
24 {
25     echo $activity
26     echo FAILED
27     cleanup;
28     exit 1;
29 }
30
31
32 no_result()
33 {
34     echo $activity
35     echo NO RESULT;
36     cleanup;
37     exit 2;
38 }
39
40 pass()
41 {
42     cleanup;
43     exit 0;
44 }
45
46 mkdir -p $TEMPDIR
47
48 cd $TEMPDIR
49
50 activity="create prog"
51 cat > $TEMPDIR/loop.stat <<EOF
52 data list /X 1 Y 2 ZOOLOGICAL 3.
53 begin data.
54 125
55 256
56 397
57 401
58 end data.
59 loop iterative_Variable=y to zoological by abs(zoological-y)/(zoological-y).
60 print /x iterative_Variable.
61 break.          /* Generates warning.
62 end loop.
63 execute.
64 EOF
65 if [ $? -ne 0 ] ; then no_result ; fi
66
67 activity="run program"
68 $SUPERVISOR $here/../src/pspp --testing-mode -o raw-ascii $TEMPDIR/loop.stat > $TEMPDIR/stdout
69 if [ $? -ne 0 ] ; then no_result ; fi
70
71 activity="compare stdout"
72 diff -B -b $TEMPDIR/stdout  - <<EOF
73 $TEMPDIR/loop.stat:10: warning: BREAK: BREAK not enclosed in DO IF structure.
74 EOF
75 if [ $? -ne 0 ] ; then fail ; fi
76
77 activity="compare results"
78 diff -B -b $TEMPDIR/pspp.list  - <<EOF
79 1.1 DATA LIST.  Reading 1 record from the command file.
80 +----------+------+-------+------+
81 | Variable |Record|Columns|Format|
82 #==========#======#=======#======#
83 |X         |     1|  1-  1|F1.0  |
84 |Y         |     1|  2-  2|F1.0  |
85 |ZOOLOGICAL|     1|  3-  3|F1.0  |
86 +----------+------+-------+------+
87 1     2.00 
88 2     5.00 
89 3     9.00 
90 4      .00 
91 EOF
92 if [ $? -ne 0 ] ; then fail ; fi
93
94
95 pass;