Fixed some buglets in the tests
[pspp-builds.git] / tests / command / aggregate.sh
1 #!/bin/sh
2
3 # This program tests the aggregate procedure
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
13 export STAT_CONFIG_PATH=$top_srcdir/config
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="program create"
49 cat > $TEMPDIR/test.sps << EOF
50
51 data list notable /x y 1-2.
52 begin data.
53 13
54 27
55 30
56 12
57 26
58 11
59 10
60 28
61 29
62 14
63 15
64 end data.
65 sort cases by x.
66 aggregate /missing=columnwise /document /presorted/break=x(a) /z'label for z'=sum(y)/foo=nu.
67 list.
68 EOF
69 if [ $? -ne 0 ] ; then no_result ; fi
70
71 activity="run program"
72 $here/../src/pspp    -o raw-ascii $TEMPDIR/test.sps  
73 if [ $? -ne 0 ] ; then no_result ; fi
74
75 activity="test result"
76 diff  -b -w -B $TEMPDIR/pspp.list - << EOF
77 X        Z      FOO
78 - -------- --------
79 1    15.00     6.00 
80 2    30.00     4.00 
81 3      .00     1.00 
82 EOF
83 if [ $? -ne 0 ] ; then fail ; fi
84
85 pass;