Fix use of "export" to work with traditional shells.
[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      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 program"
51 cat > $TEMPDIR/descript.stat <<EOF
52 data list notable / X 1.
53 begin data.
54 0
55 1
56 2
57 3
58 4
59 5
60 end data.
61
62 descript all/stat=mean.
63
64 EOF
65 if [ $? -ne 0 ] ; then no_result ; fi
66
67
68 activity="run program"
69 $SUPERVISOR $here/../src/pspp -o raw-ascii $TEMPDIR/descript.stat
70 if [ $? -ne 0 ] ; then no_result ; fi
71
72 activity="compare output"
73 diff -B -b $TEMPDIR/pspp.list - <<EOF
74 1.1 DESCRIPTIVES.  Valid cases = 6; cases with missing value(s) = 0.
75 +--------#-+-----+
76 |Variable#N| Mean|
77 #========#=#=====#
78 |X       #6|2.500|
79 +--------#-+-----+
80 EOF
81 if [ $? -ne 0 ] ; then fail ; fi
82
83
84 pass