Rewrite PSPP output engine.
[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 # ensure that top_builddir  are absolute
9 if [ -z "$top_builddir" ] ; then top_builddir=. ; fi
10 if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi
11 top_builddir=`cd $top_builddir; pwd`
12 PSPP=$top_builddir/src/ui/terminal/pspp
13
14 # ensure that top_srcdir is absolute
15 top_srcdir=`cd $top_srcdir; pwd`
16
17 STAT_CONFIG_PATH=$top_srcdir/config
18 export STAT_CONFIG_PATH
19
20
21 cleanup()
22 {
23      if [ x"$PSPP_TEST_NO_CLEANUP" != x ] ; then 
24         echo "NOT cleaning $TEMPDIR" 
25         return ; 
26      fi
27      cd /
28      rm -rf $TEMPDIR
29 }
30
31
32 fail()
33 {
34     echo $activity
35     echo FAILED
36     cleanup;
37     exit 1;
38 }
39
40
41 no_result()
42 {
43     echo $activity
44     echo NO RESULT;
45     cleanup;
46     exit 2;
47 }
48
49 pass()
50 {
51     cleanup;
52     exit 0;
53 }
54
55 mkdir -p $TEMPDIR
56
57 cd $TEMPDIR
58
59 activity="create program"
60 cat > $TESTFILE <<EOF
61 DATA LIST LIST /v1 * v2 * dep * vn *.
62 BEGIN DATA
63 . .  1  4
64 3 3  1  2
65 2 2  1  2
66 1 1  1  2
67 1 1  1  2
68 4 4  1  2
69 5 5  2  2
70 2 2  2  2
71 4 4  2  2
72 2 2  2  2
73 3 3  2  2
74 7 7  3  2
75 4 4  3  2
76 5 5  3  2
77 3 3  3  2
78 6 6  3  2
79 END DATA
80
81 ONEWAY
82         v1 v2 BY dep
83         /STATISTICS descriptives homogeneity
84         /MISSING ANALYSIS 
85         .
86 EOF
87 if [ $? -ne 0 ] ; then no_result ; fi
88
89
90 activity="run program"
91 $SUPERVISOR $PSPP --testing-mode $TESTFILE
92 if [ $? -ne 0 ] ; then no_result ; fi
93
94 activity="copy output"
95 cp $TEMPDIR/pspp.csv $TEMPDIR/pspp.csv1
96 if [ $? -ne 0 ] ; then no_result ; fi
97
98 activity="create program 2"
99 cat > $TESTFILE <<EOF
100 DATA LIST LIST /v1 * v2 * dep * vn * .
101 BEGIN DATA
102 4 .  1  2 
103 3 3  1  2
104 2 2  1  2
105 1 1  1  2
106 1 1  1  2
107 4 4  1  2
108 5 5  2  2
109 2 2  2  2
110 4 4  2  2
111 2 2  2  2
112 3 3  2  2
113 7 7  3  2
114 4 4  3  2
115 5 5  3  2
116 3 3  3  2
117 6 6  3  2
118 END DATA
119
120 ONEWAY
121         v1 v2 BY dep
122         /STATISTICS descriptives homogeneity
123         /MISSING LISTWISE
124         .
125 EOF
126 if [ $? -ne 0 ] ; then no_result ; fi
127
128 activity="run program 2"
129 $SUPERVISOR $PSPP --testing-mode $TESTFILE
130 if [ $? -ne 0 ] ; then no_result ; fi
131
132 activity="compare outputs"
133 diff $TEMPDIR/pspp.csv $TEMPDIR/pspp.csv1
134 if [ $? -ne 0 ] ; then fail ; fi
135
136 # Now try a missing dependent variable
137 # Everything depends upon it, so it should behave as if LISTWISE were set
138 activity="create program 3"
139 cat > $TESTFILE <<EOF
140 DATA LIST LIST /v1 * v2 * dep * vn * .
141 BEGIN DATA
142 4 2  .  2 
143 3 3  1  2
144 2 2  1  2
145 1 1  1  2
146 1 1  1  2
147 4 4  1  2
148 5 5  2  2
149 2 2  2  2
150 4 4  2  2
151 2 2  2  2
152 3 3  2  2
153 7 7  3  2
154 4 4  3  2
155 5 5  3  2
156 3 3  3  2
157 6 6  3  2
158 END DATA
159
160 ONEWAY
161         v1 v2 BY dep
162         /STATISTICS descriptives homogeneity
163         /MISSING ANALYSIS
164         .
165 EOF
166 if [ $? -ne 0 ] ; then no_result ; fi
167
168 activity="run program 3"
169 $SUPERVISOR $PSPP --testing-mode $TESTFILE
170 if [ $? -ne 0 ] ; then no_result ; fi
171
172 activity="compare outputs"
173 diff $TEMPDIR/pspp.csv $TEMPDIR/pspp.csv1
174 if [ $? -ne 0 ] ; then fail ; fi
175
176
177 pass