Fixed bug reporting the significance of paired value t-test.
[pspp-builds.git] / tests / command / insert.sh
1 #!/bin/sh
2
3 # This program tests the INSERT command
4
5 TEMPDIR=/tmp/pspp-tst-$$
6 TESTFILE=$TEMPDIR/`basename $0`.sps
7
8 # ensure that top_srcdir and top_builddir  are absolute
9 if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi
10 if [ -z "$top_builddir" ] ; then top_builddir=. ; fi
11 top_srcdir=`cd $top_srcdir; pwd`
12 top_builddir=`cd $top_builddir; pwd`
13
14 PSPP=$top_builddir/src/ui/terminal/pspp
15
16 STAT_CONFIG_PATH=$top_srcdir/config
17 export STAT_CONFIG_PATH
18
19 LANG=C
20 export LANG
21
22
23 cleanup()
24 {
25      if [ x"$PSPP_TEST_NO_CLEANUP" != x ] ; then 
26         echo "NOT cleaning $TEMPDIR"
27         return ; 
28      fi
29      cd /
30      rm -rf $TEMPDIR
31 }
32
33
34 fail()
35 {
36     echo $activity
37     echo FAILED
38     cleanup;
39     exit 1;
40 }
41
42
43 no_result()
44 {
45     echo $activity
46     echo NO RESULT;
47     cleanup;
48     exit 2;
49 }
50
51 pass()
52 {
53     cleanup;
54     exit 0;
55 }
56
57 mkdir -p $TEMPDIR
58
59 cd $TEMPDIR
60
61 activity="create wrapper 1"
62 cat <<EOF > $TESTFILE
63 INSERT 
64   FILE='$TEMPDIR/foo.sps'
65   SYNTAX=INTERACTIVE
66   .
67
68
69 LIST.
70
71 EOF
72 if [ $? -ne 0 ] ; then no_result ; fi
73
74 #The following syntax intentionally omits periods from some lines
75 #It's an example of "batch" syntax
76 activity="create insert"
77 cat <<EOF > $TEMPDIR/foo.sps
78 input program.
79 +  loop #i = 1 to 100.
80 +    compute z = #i
81 +    end case.
82 +  end loop
83 end file.
84 end input program.
85
86 EOF
87 if [ $? -ne 0 ] ; then no_result ; fi
88
89
90 #This command should fail
91 activity="run program 1"
92 $SUPERVISOR $PSPP --testing-mode -o raw-ascii $TESTFILE > /dev/null
93 if [ $? -eq 0 ] ; then fail ; fi
94
95
96 activity="create wrapper 2"
97 cat <<EOF > $TESTFILE
98 INSERT 
99   FILE='$TEMPDIR/foo.sps'
100   SYNTAX=BATCH
101   .
102
103
104 LIST.
105
106 EOF
107 if [ $? -ne 0 ] ; then no_result ; fi
108
109 activity="run program 2"
110 $SUPERVISOR $PSPP --testing-mode -o raw-ascii $TESTFILE
111 if [ $? -ne 0 ] ; then fail ; fi
112
113
114 # Now test the CD subcommand
115
116 activity="mkdir 1"
117 mkdir $TEMPDIR/Dir1
118 if [ $? -ne 0 ] ; then no_result ; fi
119
120 activity="create wrapper 3"
121 cat <<EOF > $TESTFILE
122 INSERT 
123   FILE='$TEMPDIR/Dir1/foo.sps'
124   CD=NO
125   .
126
127
128 LIST.
129
130 EOF
131 if [ $? -ne 0 ] ; then no_result ; fi
132
133 activity="create wrapper 4"
134 cat <<EOF > $TEMPDIR/Dir1/foo.sps
135 INSERT 
136   FILE='bar.sps'
137   CD=NO
138   .
139
140 EOF
141 if [ $? -ne 0 ] ; then no_result ; fi
142
143 activity="create wrapper 5"
144 cat <<EOF > $TEMPDIR/Dir1/bar.sps
145 DATA LIST LIST /x *.
146 BEGIN DATA.
147 1
148 2
149 3
150 END DATA.
151
152 EOF
153 if [ $? -ne 0 ] ; then no_result ; fi
154
155
156 # This command should fail
157 activity="run program 3"
158 $SUPERVISOR $PSPP --testing-mode -o raw-ascii $TESTFILE > /dev/null
159 if [ $? -eq 0 ] ; then fail ; fi
160
161 activity="create wrapper 6"
162 cat <<EOF > $TESTFILE
163 INSERT 
164   FILE='$TEMPDIR/Dir1/foo.sps'
165   CD=YES
166   .
167
168 LIST.
169
170 EOF
171 if [ $? -ne 0 ] ; then no_result ; fi
172
173 activity="run program 4"
174 $SUPERVISOR $PSPP --testing-mode -o raw-ascii $TESTFILE
175 if [ $? -ne 0 ] ; then fail ; fi
176
177
178 # Now test the ERROR= feature
179
180 activity="create wrapper 7"
181 cat <<EOF > $TESTFILE
182 INSERT 
183   FILE='$TEMPDIR/foo.sps'
184   ERROR=STOP.
185   .
186
187 LIST.
188
189 EOF
190 if [ $? -ne 0 ] ; then no_result ; fi
191
192
193 activity="create included file"
194 cat <<EOF > $TEMPDIR/foo.sps
195 DATA LIST NOTABLE LIST /x *.
196 BEGIN DATA.
197 1
198 2
199 3
200 END DATA.
201
202 * The following line is erroneous
203
204 DISPLAY AKSDJ.
205
206 EOF
207 if [ $? -ne 0 ] ; then no_result ; fi
208
209 activity="run program 5"
210 $SUPERVISOR $PSPP --testing-mode -o raw-ascii $TESTFILE > /dev/null
211 if [ $? -ne 1 ] ; then no_result ; fi
212
213 activity="examine output 1"
214 diff $TEMPDIR/pspp.list - <<EOF
215 $TEMPDIR/foo.sps:10: error: DISPLAY: AKSDJ is not a variable name.
216 warning: Error encountered while ERROR=STOP is effective.
217 $TEMPDIR/foo.sps:10: error: Stopping syntax file processing here to avoid a cascade of dependent command failures.
218
219 EOF
220 if [ $? -ne 0 ] ; then fail ; fi
221
222
223 activity="create wrapper 8"
224 cat <<EOF > $TESTFILE
225 INSERT 
226   FILE='$TEMPDIR/foo.sps'
227   ERROR=CONTINUE.
228   .
229
230 LIST.
231
232 EOF
233 if [ $? -ne 0 ] ; then no_result ; fi
234
235 activity="run program 6"
236 $SUPERVISOR $PSPP --testing-mode -o raw-ascii $TESTFILE > /dev/null
237 if [ $? -ne 1 ] ; then no_result ; fi
238
239 activity="examine output 2"
240 diff $TEMPDIR/pspp.list - <<EOF
241 $TEMPDIR/foo.sps:10: error: DISPLAY: AKSDJ is not a variable name.
242
243        x
244 --------
245     1.00 
246     2.00 
247     3.00 
248
249 EOF
250 if [ $? -ne 0 ] ; then fail ; fi
251
252
253 # Test for regression against bug #24569 in which PSPP crashed
254 # upon attempt to insert a nonexistent file.
255 activity="create wrapper 9"
256 cat <<EOF > $TESTFILE
257 INSERT 
258   FILE='$TEMPDIR/nonexistent'
259   ERROR=CONTINUE.
260   .
261
262 LIST.
263
264 EOF
265 if [ $? -ne 0 ] ; then no_result ; fi
266
267 #This command should fail
268 activity="run program 7"
269 $SUPERVISOR $PSPP --testing-mode -o raw-ascii $TESTFILE > /dev/null
270 if [ $? -eq 0 ] ; then no_result ; fi
271
272 pass;