From: Ben Pfaff Date: Wed, 29 Sep 2010 04:30:20 +0000 (-0700) Subject: INSERT: Convert tests to use Autotest. X-Git-Tag: v0.7.6~142 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e25c57860682ec882157b87603f8103957e840bc;p=pspp-builds.git INSERT: Convert tests to use Autotest. --- diff --git a/tests/automake.mk b/tests/automake.mk index a0a1d7b0..125b0b79 100644 --- a/tests/automake.mk +++ b/tests/automake.mk @@ -10,7 +10,6 @@ TESTS_ENVIRONMENT += LC_ALL=C TESTS_ENVIRONMENT += EXEEXT=$(EXEEXT) dist_TESTS = \ - tests/command/insert.sh \ tests/command/lag.sh \ tests/command/line-ends.sh \ tests/command/list.sh \ @@ -393,6 +392,7 @@ TESTSUITE_AT = \ tests/language/stats/flip.at \ tests/language/stats/frequencies.at \ tests/language/stats/oneway.at \ + tests/language/utilities/insert.at \ tests/language/utilities/set.at \ tests/language/utilities/title.at \ tests/language/xforms/compute.at \ diff --git a/tests/command/insert.sh b/tests/command/insert.sh deleted file mode 100755 index 4bcb96fe..00000000 --- a/tests/command/insert.sh +++ /dev/null @@ -1,274 +0,0 @@ -#!/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 < $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 < $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 < $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 < $TESTFILE -INSERT - FILE='$TEMPDIR/Dir1/foo.sps' - CD=NO - . - - -LIST. - -EOF -if [ $? -ne 0 ] ; then no_result ; fi - -activity="create wrapper 4" -cat < $TEMPDIR/Dir1/foo.sps -INSERT - FILE='bar.sps' - CD=NO - . - -EOF -if [ $? -ne 0 ] ; then no_result ; fi - -activity="create wrapper 5" -cat < $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 < $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 < $TESTFILE -INSERT - FILE='$TEMPDIR/foo.sps' - ERROR=STOP. - . - -LIST. - -EOF -if [ $? -ne 0 ] ; then no_result ; fi - - -activity="create included file" -cat < $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 - < $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 - < $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; diff --git a/tests/language/utilities/insert.at b/tests/language/utilities/insert.at new file mode 100644 index 00000000..e119f103 --- /dev/null +++ b/tests/language/utilities/insert.at @@ -0,0 +1,163 @@ +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