+++ /dev/null
-#!/bin/sh
-
-# This program tests the INSERT command
-
-BASETEMPDIR=/tmp/pspp-tst-$$
-TEMPDIR=$BASETEMPDIR/link
-TESTFILE=$TEMPDIR/`basename $0`.sps
-
-# ensure that top_srcdir and top_builddir are absolute
-if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi
-if [ -z "$top_builddir" ] ; then top_builddir=. ; fi
-top_srcdir=`cd $top_srcdir; pwd`
-top_builddir=`cd $top_builddir; pwd`
-
-PSPP=$top_builddir/src/ui/terminal/pspp$EXEEXT
-
-STAT_CONFIG_PATH=$top_srcdir/config
-export STAT_CONFIG_PATH
-
-LANG=C
-export LANG
-
-
-cleanup()
-{
- if [ x"$PSPP_TEST_NO_CLEANUP" != x ] ; then
- echo "NOT cleaning $BASETEMPDIR"
- return ;
- fi
- cd /
- rm -rf $BASETEMPDIR
-}
-
-
-fail()
-{
- echo $activity
- echo FAILED
- cleanup;
- exit 1;
-}
-
-
-no_result()
-{
- echo $activity
- echo NO RESULT;
- cleanup;
- exit 2;
-}
-
-pass()
-{
- cleanup;
- exit 0;
-}
-
-mkdir -p $BASETEMPDIR/target
-
-ln -s $BASETEMPDIR/target $TEMPDIR
-
-cd $TEMPDIR
-
-activity="create wrapper 1"
-cat <<EOF > $TESTFILE
-INSERT
- FILE='$TEMPDIR/foo.sps'
- SYNTAX=INTERACTIVE
- .
-
-
-LIST.
-
-EOF
-if [ $? -ne 0 ] ; then no_result ; fi
-
-#The following syntax intentionally omits periods from some lines
-#It's an example of "batch" syntax
-activity="create insert"
-cat <<EOF > $TEMPDIR/foo.sps
-input program.
-+ loop #i = 1 to 100.
-+ compute z = #i
-+ end case.
-+ end loop
-end file.
-end input program.
-
-EOF
-if [ $? -ne 0 ] ; then no_result ; fi
-
-
-#This command should fail
-activity="run program 1"
-$SUPERVISOR $PSPP -o pspp.csv $TESTFILE > /dev/null
-if [ $? -eq 0 ] ; then fail ; fi
-
-
-activity="create wrapper 2"
-cat <<EOF > $TESTFILE
-INSERT
- FILE='$TEMPDIR/foo.sps'
- SYNTAX=BATCH
- .
-
-
-LIST.
-
-EOF
-if [ $? -ne 0 ] ; then no_result ; fi
-
-activity="run program 2"
-$SUPERVISOR $PSPP -o pspp.csv $TESTFILE
-if [ $? -ne 0 ] ; then fail ; fi
-
-
-# Now test the CD subcommand
-
-activity="mkdir 1"
-mkdir $TEMPDIR/Dir1
-if [ $? -ne 0 ] ; then no_result ; fi
-
-activity="create wrapper 3"
-cat <<EOF > $TESTFILE
-INSERT
- FILE='$TEMPDIR/Dir1/foo.sps'
- CD=NO
- .
-
-
-LIST.
-
-EOF
-if [ $? -ne 0 ] ; then no_result ; fi
-
-activity="create wrapper 4"
-cat <<EOF > $TEMPDIR/Dir1/foo.sps
-INSERT
- FILE='bar.sps'
- CD=NO
- .
-
-EOF
-if [ $? -ne 0 ] ; then no_result ; fi
-
-activity="create wrapper 5"
-cat <<EOF > $TEMPDIR/Dir1/bar.sps
-DATA LIST LIST /x *.
-BEGIN DATA.
-1
-2
-3
-END DATA.
-
-EOF
-if [ $? -ne 0 ] ; then no_result ; fi
-
-
-# This command should fail
-activity="run program 3"
-$SUPERVISOR $PSPP -o pspp.csv $TESTFILE > /dev/null
-if [ $? -eq 0 ] ; then fail ; fi
-
-activity="create wrapper 6"
-cat <<EOF > $TESTFILE
-INSERT
- FILE='$TEMPDIR/Dir1/foo.sps'
- CD=YES
- .
-
-LIST.
-
-EOF
-if [ $? -ne 0 ] ; then no_result ; fi
-
-activity="run program 4"
-$SUPERVISOR $PSPP -o pspp.csv $TESTFILE
-if [ $? -ne 0 ] ; then fail ; fi
-
-
-# Now test the ERROR= feature
-
-activity="create wrapper 7"
-cat <<EOF > $TESTFILE
-INSERT
- FILE='$TEMPDIR/foo.sps'
- ERROR=STOP.
- .
-
-LIST.
-
-EOF
-if [ $? -ne 0 ] ; then no_result ; fi
-
-
-activity="create included file"
-cat <<EOF > $TEMPDIR/foo.sps
-DATA LIST NOTABLE LIST /x *.
-BEGIN DATA.
-1
-2
-3
-END DATA.
-
-* The following line is erroneous
-
-DISPLAY AKSDJ.
-
-EOF
-if [ $? -ne 0 ] ; then no_result ; fi
-
-activity="run program 5"
-$SUPERVISOR $PSPP -o pspp.csv $TESTFILE > /dev/null
-if [ $? -ne 1 ] ; then no_result ; fi
-
-activity="examine output 1"
-diff -c $TEMPDIR/pspp.csv - <<EOF
-$TEMPDIR/foo.sps:10: error: DISPLAY: AKSDJ is not a variable name.
-
-warning: Error encountered while ERROR=STOP is effective.
-
-$TEMPDIR/foo.sps:10: error: Stopping syntax file processing here to avoid a cascade of dependent command failures.
-EOF
-if [ $? -ne 0 ] ; then fail ; fi
-
-
-activity="create wrapper 8"
-cat <<EOF > $TESTFILE
-INSERT
- FILE='$TEMPDIR/foo.sps'
- ERROR=CONTINUE.
- .
-
-LIST.
-
-EOF
-if [ $? -ne 0 ] ; then no_result ; fi
-
-activity="run program 6"
-$SUPERVISOR $PSPP -o pspp.csv $TESTFILE > /dev/null
-if [ $? -ne 1 ] ; then no_result ; fi
-
-activity="examine output 2"
-diff $TEMPDIR/pspp.csv - <<EOF
-$TEMPDIR/foo.sps:10: error: DISPLAY: AKSDJ is not a variable name.
-
-Table: Data List
-x
-1.00
-2.00
-3.00
-EOF
-if [ $? -ne 0 ] ; then fail ; fi
-
-# Test for regression against bug #24569 in which PSPP crashed
-# upon attempt to insert a nonexistent file.
-activity="create wrapper 9"
-cat <<EOF > $TESTFILE
-INSERT
- FILE='$TEMPDIR/nonexistent'
- ERROR=CONTINUE.
- .
-
-LIST.
-
-EOF
-if [ $? -ne 0 ] ; then no_result ; fi
-
-#This command should fail
-activity="run program 7"
-$SUPERVISOR $PSPP -o pspp.csv $TESTFILE > /dev/null
-if [ $? -eq 0 ] ; then no_result ; fi
-
-pass;
--- /dev/null
+AT_BANNER([INSERT])
+
+dnl Create a file "batch.sps" that is valid syntax only in batch mode.
+m4_define([CREATE_BATCH_SPS],
+ [AT_DATA([batch.sps], [dnl
+input program.
++ loop #i = 1 to 5.
++ compute z = #i
++ end case.
++ end loop
+end file.
+end input program.
+])])
+
+AT_SETUP([INSERT SYNTAX=INTERACTIVE])
+CREATE_BATCH_SPS
+AT_DATA([insert.sps], [dnl
+INSERT
+ FILE='batch.sps'
+ SYNTAX=INTERACTIVE.
+LIST.
+])
+AT_CHECK([pspp -o pspp.csv insert.sps], [1], [dnl
+batch.sps:2: error: INPUT PROGRAM: Syntax error at `+': expecting command name.
+batch.sps:3: error: INPUT PROGRAM: Syntax error at `+': expecting command name.
+batch.sps:5: error: INPUT PROGRAM: Syntax error at `+': expecting command name.
+batch.sps:7: error: Input program did not create any variables.
+insert.sps:4: error: LIST: LIST is allowed only after the active file has been defined.
+])
+AT_CLEANUP
+
+AT_SETUP([INSERT SYNTAX=BATCH])
+CREATE_BATCH_SPS
+AT_DATA([insert.sps], [dnl
+INSERT
+ FILE='batch.sps'
+ SYNTAX=BATCH.
+LIST.
+])
+AT_CHECK([pspp -o pspp.csv insert.sps])
+AT_CHECK([cat pspp.csv], [0], [dnl
+Table: Data List
+z
+1.00
+2.00
+3.00
+4.00
+5.00
+])
+AT_CLEANUP
+
+AT_SETUP([INSERT CD=NO])
+AT_DATA([insert.sps], [INSERT FILE='Dir1/foo.sps'.
+LIST.
+])
+mkdir Dir1
+AT_DATA([Dir1/foo.sps], [INSERT FILE='bar.sps' CD=NO.
+])
+AT_DATA([Dir1/bar.sps],
+ [DATA LIST LIST /x *.
+BEGIN DATA.
+1
+2
+3
+END DATA.
+])
+AT_CHECK([pspp -o pspp.csv insert.sps], [1], [dnl
+Dir1/foo.sps:1: error: INSERT: Can't find `bar.sps' in include file search path.
+insert.sps:2: error: LIST: LIST is allowed only after the active file has been defined.
+])
+AT_CLEANUP
+
+AT_SETUP([INSERT CD=YES])
+AT_DATA([insert.sps], [INSERT FILE='Dir1/foo.sps' CD=YES.
+LIST.
+])
+mkdir Dir1
+AT_DATA([Dir1/foo.sps], [INSERT FILE='bar.sps'.
+])
+AT_DATA([Dir1/bar.sps],
+ [DATA LIST LIST /x *.
+BEGIN DATA.
+1
+2
+3
+END DATA.
+])
+AT_CHECK([pspp -o pspp.csv insert.sps])
+AT_CHECK([cat pspp.csv], [0], [dnl
+Table: Reading free-form data from INLINE.
+Variable,Format
+x,F8.0
+
+Table: Data List
+x
+1.00
+2.00
+3.00
+])
+AT_CLEANUP
+
+m4_define([CREATE_ERROR_SPS],
+ [AT_DATA([error.sps], [dnl
+DATA LIST NOTABLE LIST /x *.
+BEGIN DATA.
+1
+2
+3
+END DATA.
+
+* The following line is erroneous
+
+DISPLAY AKSDJ.
+])])
+
+AT_SETUP([INSERT ERROR=STOP])
+CREATE_ERROR_SPS
+AT_DATA([insert.sps], [INSERT FILE='error.sps' ERROR=STOP.
+LIST.
+])
+AT_CHECK([pspp -o pspp.csv insert.sps], [1], [dnl
+error.sps:10: error: DISPLAY: AKSDJ is not a variable name.
+warning: Error encountered while ERROR=STOP is effective.
+error.sps:10: error: Stopping syntax file processing here to avoid a cascade of dependent command failures.
+])
+AT_CLEANUP
+
+AT_SETUP([INSERT ERROR=CONTINUE])
+CREATE_ERROR_SPS
+AT_DATA([insert.sps], [INSERT FILE='error.sps' ERROR=CONTINUE.
+LIST.
+])
+AT_CHECK([pspp -o pspp.csv insert.sps], [1], [dnl
+error.sps:10: error: DISPLAY: AKSDJ is not a variable name.
+])
+AT_CHECK([cat pspp.csv], [0], [dnl
+error.sps:10: error: DISPLAY: AKSDJ is not a variable name.
+
+Table: Data List
+x
+1.00
+2.00
+3.00
+])
+AT_CLEANUP
+
+dnl Test for regression against bug #24569 in which PSPP crashed
+dnl upon attempt to insert a nonexistent file.
+AT_SETUP([INSERT nonexistent file])
+AT_DATA([insert.sps], [dnl
+INSERT
+ FILE='nonexistent'
+ ERROR=CONTINUE.
+ .
+
+LIST.
+])
+AT_CHECK([pspp -O format=csv insert.sps], [1], [dnl
+insert.sps:3: error: INSERT: Can't find `nonexistent' in include file search path.
+
+insert.sps:6: error: LIST: LIST is allowed only after the active file has been defined.
+])
+AT_CLEANUP