Started converting the make check target to aegis style 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 export STAT_CONFIG_PATH=$top_srcdir/config
13
14 cleanup()
15 {
16      rm -rf $TEMPDIR
17 }
18
19
20 fail()
21 {
22     echo $activity
23     echo FAILED
24     cleanup;
25     exit 1;
26 }
27
28
29 no_result()
30 {
31     echo $activity
32     echo NO RESULT;
33     cleanup;
34     exit 2;
35 }
36
37 pass()
38 {
39     cleanup;
40     exit 0;
41 }
42
43 mkdir -p $TEMPDIR
44
45 cd $TEMPDIR
46
47 activity="program create"
48 cat > $TEMPDIR/test.sps << EOF
49
50 data list notable /x y 1-2.
51 begin data.
52 13
53 27
54 30
55 12
56 26
57 11
58 10
59 28
60 29
61 14
62 15
63 end data.
64 sort cases by x.
65 aggregate /missing=columnwise /document /presorted/break=x(a) /z'label for z'=sum(y)/foo=nu.
66 list.
67 EOF
68 if [ $? -ne 0 ] ; then no_result ; fi
69
70 activity="run program"
71 $here/../src/pspp    -o raw-ascii $TEMPDIR/test.sps  
72 if [ $? -ne 0 ] ; then no_result ; fi
73
74
75 activity="test result"
76 diff  -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;