Fix use of "export" to work with traditional shells.
[pspp-builds.git] / tests / command / oneway-missing.sh
1 #!/bin/sh
2
3 # This program tests that the ONEWAY anova command works OK when there is missing data
4
5 TEMPDIR=/tmp/pspp-tst-$$
6 TESTFILE=$TEMPDIR/`basename $0`.sps
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 > $TESTFILE <<EOF
52 DATA LIST LIST /v1 * v2 * dep * vn *.
53 BEGIN DATA
54 . .  1  4
55 3 3  1  2
56 2 2  1  2
57 1 1  1  2
58 1 1  1  2
59 4 4  1  2
60 5 5  2  2
61 2 2  2  2
62 4 4  2  2
63 2 2  2  2
64 3 3  2  2
65 7 7  3  2
66 4 4  3  2
67 5 5  3  2
68 3 3  3  2
69 6 6  3  2
70 END DATA
71
72 ONEWAY
73         v1 v2 BY dep
74         /STATISTICS descriptives homogeneity
75         /MISSING ANALYSIS 
76         .
77 EOF
78 if [ $? -ne 0 ] ; then no_result ; fi
79
80
81 activity="run program"
82 $SUPERVISOR $here/../src/pspp -o raw-ascii $TESTFILE
83 if [ $? -ne 0 ] ; then no_result ; fi
84
85 activity="copy output"
86 cp $TEMPDIR/pspp.list $TEMPDIR/pspp.list1
87 if [ $? -ne 0 ] ; then no_result ; fi
88
89 activity="create program 2"
90 cat > $TESTFILE <<EOF
91 DATA LIST LIST /v1 * v2 * dep * vn * .
92 BEGIN DATA
93 4 .  1  2 
94 3 3  1  2
95 2 2  1  2
96 1 1  1  2
97 1 1  1  2
98 4 4  1  2
99 5 5  2  2
100 2 2  2  2
101 4 4  2  2
102 2 2  2  2
103 3 3  2  2
104 7 7  3  2
105 4 4  3  2
106 5 5  3  2
107 3 3  3  2
108 6 6  3  2
109 END DATA
110
111 ONEWAY
112         v1 v2 BY dep
113         /STATISTICS descriptives homogeneity
114         /MISSING LISTWISE
115         .
116 EOF
117 if [ $? -ne 0 ] ; then no_result ; fi
118
119 activity="run program 2"
120 $SUPERVISOR $here/../src/pspp -o raw-ascii $TESTFILE
121 if [ $? -ne 0 ] ; then no_result ; fi
122
123 activity="compare outputs"
124 diff $TEMPDIR/pspp.list $TEMPDIR/pspp.list1
125 if [ $? -ne 0 ] ; then fail ; fi
126
127 # Now try a missing dependent variable
128 # Everything depends upon it, so it should behave as if LISTWISE were set
129 activity="create program 3"
130 cat > $TESTFILE <<EOF
131 DATA LIST LIST /v1 * v2 * dep * vn * .
132 BEGIN DATA
133 4 2  .  2 
134 3 3  1  2
135 2 2  1  2
136 1 1  1  2
137 1 1  1  2
138 4 4  1  2
139 5 5  2  2
140 2 2  2  2
141 4 4  2  2
142 2 2  2  2
143 3 3  2  2
144 7 7  3  2
145 4 4  3  2
146 5 5  3  2
147 3 3  3  2
148 6 6  3  2
149 END DATA
150
151 ONEWAY
152         v1 v2 BY dep
153         /STATISTICS descriptives homogeneity
154         /MISSING ANALYSIS
155         .
156 EOF
157 if [ $? -ne 0 ] ; then no_result ; fi
158
159 activity="run program 3"
160 $SUPERVISOR $here/../src/pspp -o raw-ascii $TESTFILE
161 if [ $? -ne 0 ] ; then no_result ; fi
162
163 activity="compare outputs"
164 diff $TEMPDIR/pspp.list $TEMPDIR/pspp.list1
165 if [ $? -ne 0 ] ; then fail ; fi
166
167
168 pass