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