3 # This program tests the INSERT command
5 BASETEMPDIR=/tmp/pspp-tst-$$
6 TEMPDIR=$BASETEMPDIR/link
7 TESTFILE=$TEMPDIR/`basename $0`.sps
9 # ensure that top_srcdir and top_builddir are absolute
10 if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi
11 if [ -z "$top_builddir" ] ; then top_builddir=. ; fi
12 top_srcdir=`cd $top_srcdir; pwd`
13 top_builddir=`cd $top_builddir; pwd`
15 PSPP=$top_builddir/src/ui/terminal/pspp
17 STAT_CONFIG_PATH=$top_srcdir/config
18 export STAT_CONFIG_PATH
26 if [ x"$PSPP_TEST_NO_CLEANUP" != x ] ; then
27 echo "NOT cleaning $BASETEMPDIR"
58 mkdir -p $BASETEMPDIR/target
60 ln -s $BASETEMPDIR/target $TEMPDIR
64 activity="create wrapper 1"
67 FILE='$TEMPDIR/foo.sps'
75 if [ $? -ne 0 ] ; then no_result ; fi
77 #The following syntax intentionally omits periods from some lines
78 #It's an example of "batch" syntax
79 activity="create insert"
80 cat <<EOF > $TEMPDIR/foo.sps
90 if [ $? -ne 0 ] ; then no_result ; fi
93 #This command should fail
94 activity="run program 1"
95 $SUPERVISOR $PSPP -o pspp.csv $TESTFILE > /dev/null
96 if [ $? -eq 0 ] ; then fail ; fi
99 activity="create wrapper 2"
100 cat <<EOF > $TESTFILE
102 FILE='$TEMPDIR/foo.sps'
110 if [ $? -ne 0 ] ; then no_result ; fi
112 activity="run program 2"
113 $SUPERVISOR $PSPP -o pspp.csv $TESTFILE
114 if [ $? -ne 0 ] ; then fail ; fi
117 # Now test the CD subcommand
121 if [ $? -ne 0 ] ; then no_result ; fi
123 activity="create wrapper 3"
124 cat <<EOF > $TESTFILE
126 FILE='$TEMPDIR/Dir1/foo.sps'
134 if [ $? -ne 0 ] ; then no_result ; fi
136 activity="create wrapper 4"
137 cat <<EOF > $TEMPDIR/Dir1/foo.sps
144 if [ $? -ne 0 ] ; then no_result ; fi
146 activity="create wrapper 5"
147 cat <<EOF > $TEMPDIR/Dir1/bar.sps
156 if [ $? -ne 0 ] ; then no_result ; fi
159 # This command should fail
160 activity="run program 3"
161 $SUPERVISOR $PSPP -o pspp.csv $TESTFILE > /dev/null
162 if [ $? -eq 0 ] ; then fail ; fi
164 activity="create wrapper 6"
165 cat <<EOF > $TESTFILE
167 FILE='$TEMPDIR/Dir1/foo.sps'
174 if [ $? -ne 0 ] ; then no_result ; fi
176 activity="run program 4"
177 $SUPERVISOR $PSPP -o pspp.csv $TESTFILE
178 if [ $? -ne 0 ] ; then fail ; fi
181 # Now test the ERROR= feature
183 activity="create wrapper 7"
184 cat <<EOF > $TESTFILE
186 FILE='$TEMPDIR/foo.sps'
193 if [ $? -ne 0 ] ; then no_result ; fi
196 activity="create included file"
197 cat <<EOF > $TEMPDIR/foo.sps
198 DATA LIST NOTABLE LIST /x *.
205 * The following line is erroneous
210 if [ $? -ne 0 ] ; then no_result ; fi
212 activity="run program 5"
213 $SUPERVISOR $PSPP -o pspp.csv $TESTFILE > /dev/null
214 if [ $? -ne 1 ] ; then no_result ; fi
216 activity="examine output 1"
217 diff -c $TEMPDIR/pspp.csv - <<EOF
218 $TEMPDIR/foo.sps:10: error: DISPLAY: AKSDJ is not a variable name.
220 warning: Error encountered while ERROR=STOP is effective.
222 $TEMPDIR/foo.sps:10: error: Stopping syntax file processing here to avoid a cascade of dependent command failures.
224 if [ $? -ne 0 ] ; then fail ; fi
227 activity="create wrapper 8"
228 cat <<EOF > $TESTFILE
230 FILE='$TEMPDIR/foo.sps'
237 if [ $? -ne 0 ] ; then no_result ; fi
239 activity="run program 6"
240 $SUPERVISOR $PSPP -o pspp.csv $TESTFILE > /dev/null
241 if [ $? -ne 1 ] ; then no_result ; fi
243 activity="examine output 2"
244 diff $TEMPDIR/pspp.csv - <<EOF
245 $TEMPDIR/foo.sps:10: error: DISPLAY: AKSDJ is not a variable name.
253 if [ $? -ne 0 ] ; then fail ; fi
255 # Test for regression against bug #24569 in which PSPP crashed
256 # upon attempt to insert a nonexistent file.
257 activity="create wrapper 9"
258 cat <<EOF > $TESTFILE
260 FILE='$TEMPDIR/nonexistent'
267 if [ $? -ne 0 ] ; then no_result ; fi
269 #This command should fail
270 activity="run program 7"
271 $SUPERVISOR $PSPP -o pspp.csv $TESTFILE > /dev/null
272 if [ $? -eq 0 ] ; then no_result ; fi