9bb2f76289258fcd199f55602ca170fd36e95108
[pspp-builds.git] / tests / stats / descript-mean-bug.sh
1 #!/bin/sh
2
3 # This program tests that DESCRIPTIVES asking for a mean only works,
4 # which didn't at one point.
5
6 TEMPDIR=/tmp/pspp-tst-$$
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      cd /
20      rm -rf $TEMPDIR
21 }
22
23
24 fail()
25 {
26     echo $activity
27     echo FAILED
28     cleanup;
29     exit 1;
30 }
31
32
33 no_result()
34 {
35     echo $activity
36     echo NO RESULT;
37     cleanup;
38     exit 2;
39 }
40
41 pass()
42 {
43     cleanup;
44     exit 0;
45 }
46
47 mkdir -p $TEMPDIR
48
49 cd $TEMPDIR
50
51 activity="create program"
52 cat > $TEMPDIR/descript.stat <<EOF
53 data list notable / X 1.
54 begin data.
55 0
56 1
57 2
58 3
59 4
60 5
61 end data.
62
63 descript all/stat=mean.
64
65 EOF
66 if [ $? -ne 0 ] ; then no_result ; fi
67
68
69 activity="run program"
70 $SUPERVISOR $here/../src/pspp -o raw-ascii $TEMPDIR/descript.stat
71 if [ $? -ne 0 ] ; then no_result ; fi
72
73 activity="compare output"
74 perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.list
75 diff  -b $TEMPDIR/pspp.list - <<EOF
76 1.1 DESCRIPTIVES.  Valid cases = 6; cases with missing value(s) = 0.
77 +--------#-+-----+
78 |Variable#N| Mean|
79 #========#=#=====#
80 |X       #6|2.500|
81 +--------#-+-----+
82 EOF
83 if [ $? -ne 0 ] ; then fail ; fi
84
85
86 pass