GET: Convert some more tests to Autotest.
authorBen Pfaff <blp@cs.stanford.edu>
Sun, 10 Oct 2010 04:39:43 +0000 (21:39 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Sun, 10 Oct 2010 04:39:43 +0000 (21:39 -0700)
tests/automake.mk
tests/bugs/get-no-file.sh [deleted file]
tests/bugs/get.sh [deleted file]
tests/language/data-io/get.at [new file with mode: 0644]

index e9c78ae1e0c7d31c1d407791896ef898976671f1..a60b344bb3706799be2b512589e934afaae48b2c 100644 (file)
@@ -31,8 +31,6 @@ dist_TESTS = \
        tests/bugs/compression.sh \
        tests/bugs/curtailed.sh \
        tests/bugs/data-crash.sh \
-       tests/bugs/get.sh \
-       tests/bugs/get-no-file.sh \
        tests/bugs/if_crash.sh \
        tests/bugs/input-crash.sh \
        tests/bugs/multipass.sh \
@@ -317,6 +315,7 @@ TESTSUITE_AT = \
        tests/language/data-io/get-data-gnm.at \
        tests/language/data-io/get-data-psql.at \
        tests/language/data-io/get-data-txt.at \
+       tests/language/data-io/get.at \
        tests/language/data-io/list.at \
        tests/language/data-io/match-files.at \
        tests/language/data-io/print.at \
diff --git a/tests/bugs/get-no-file.sh b/tests/bugs/get-no-file.sh
deleted file mode 100755 (executable)
index 97fd7b6..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-#!/bin/sh
-
-# This program tests for a bug which caused a crash when 
-# GET specified a non-existent file
-
-TEMPDIR=/tmp/pspp-tst-$$
-TESTFILE=$TEMPDIR/`basename $0`.sps
-
-# ensure that top_builddir  are absolute
-if [ -z "$top_builddir" ] ; then top_builddir=. ; fi
-if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi
-top_builddir=`cd $top_builddir; pwd`
-PSPP=$top_builddir/src/ui/terminal/pspp$EXEEXT
-
-# ensure that top_srcdir is absolute
-top_srcdir=`cd $top_srcdir; pwd`
-
-STAT_CONFIG_PATH=$top_srcdir/config
-export STAT_CONFIG_PATH
-
-
-cleanup()
-{
-     if [ x"$PSPP_TEST_NO_CLEANUP" != x ] ; then 
-       echo "NOT cleaning $TEMPDIR" 
-       return ; 
-     fi
-     cd /
-     rm -rf $TEMPDIR
-}
-
-
-fail()
-{
-    echo $activity
-    echo FAILED
-    cleanup;
-    exit 1;
-}
-
-
-no_result()
-{
-    echo $activity
-    echo NO RESULT;
-    cleanup;
-    exit 2;
-}
-
-pass()
-{
-    cleanup;
-    exit 0;
-}
-
-mkdir -p $TEMPDIR
-
-cd $TEMPDIR
-
-activity="create program"
-cat > $TESTFILE <<EOF
-GET /FILE='$TEMPDIR/no-file.xx'.
-EOF
-if [ $? -ne 0 ] ; then no_result ; fi
-
-
-# The command should produce a warning.  Not an error.
-# We use the stdinput here, because the bug seems to manifest itself only in 
-# interactive mode.
-activity="run program"
-cat $TESTFILE | $SUPERVISOR $PSPP -o pspp.csv  > /dev/null
-if [ $? -ne 1 ] ; then fail ; fi
-
-pass
diff --git a/tests/bugs/get.sh b/tests/bugs/get.sh
deleted file mode 100755 (executable)
index 3fd6d56..0000000
+++ /dev/null
@@ -1,122 +0,0 @@
-#!/bin/sh
-
-# This program tests for a bug which caused
-# the second procedure after GET FILE to corrupt its output
-
-
-TEMPDIR=/tmp/pspp-tst-$$
-TESTFILE=$TEMPDIR/`basename $0`.sps
-
-# ensure that top_builddir  are absolute
-if [ -z "$top_builddir" ] ; then top_builddir=. ; fi
-if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi
-top_builddir=`cd $top_builddir; pwd`
-PSPP=$top_builddir/src/ui/terminal/pspp$EXEEXT
-
-# ensure that top_srcdir is absolute
-top_srcdir=`cd $top_srcdir; pwd`
-
-STAT_CONFIG_PATH=$top_srcdir/config
-export STAT_CONFIG_PATH
-
-
-cleanup()
-{
-     if [ x"$PSPP_TEST_NO_CLEANUP" != x ] ; then 
-       echo "NOT cleaning $TEMPDIR" 
-       return ; 
-     fi
-     cd /
-     rm -rf $TEMPDIR
-}
-
-
-fail()
-{
-    echo $activity
-    echo FAILED
-    cleanup;
-    exit 1;
-}
-
-
-no_result()
-{
-    echo $activity
-    echo NO RESULT;
-    cleanup;
-    exit 2;
-}
-
-pass()
-{
-    cleanup;
-    exit 0;
-}
-
-mkdir -p $TEMPDIR
-
-cd $TEMPDIR
-
-activity="create program"
-cat > $TESTFILE <<EOF
-DATA LIST LIST NOTABLE /LOCATION * EDITOR * SHELL * FREQ * .
-BEGIN DATA.
-    1.00     1.00    1.0     2.00
-    1.00     1.00    2.0    30.00
-    1.00     2.00    1.0     8.00
-    1.00     2.00    2.0    20.00
-    2.00     1.00    1.0     2.00
-    2.00     1.00    2.0    22.00
-    2.00     2.00    1.0     1.00
-    2.00     2.00    2.0     3.00
-END DATA.
-
-SAVE /OUTFILE='$TEMPDIR/foo.sav'.
-
-GET /FILE='$TEMPDIR/foo.sav'.
-
-* This one's ok
-LIST.
-
-* But this one get rubbish
-LIST.
-
-EOF
-if [ $? -ne 0 ] ; then no_result ; fi
-
-
-activity="run program"
-$SUPERVISOR $PSPP -o pspp.csv $TESTFILE
-if [ $? -ne 0 ] ; then no_result ; fi
-
-
-
-
-activity="compare output"
-diff -c $TEMPDIR/pspp.csv - << EOF
-Table: Data List
-LOCATION,EDITOR,SHELL,FREQ
-1.00,1.00,1.00,2.00
-1.00,1.00,2.00,30.00
-1.00,2.00,1.00,8.00
-1.00,2.00,2.00,20.00
-2.00,1.00,1.00,2.00
-2.00,1.00,2.00,22.00
-2.00,2.00,1.00,1.00
-2.00,2.00,2.00,3.00
-
-Table: Data List
-LOCATION,EDITOR,SHELL,FREQ
-1.00,1.00,1.00,2.00
-1.00,1.00,2.00,30.00
-1.00,2.00,1.00,8.00
-1.00,2.00,2.00,20.00
-2.00,1.00,1.00,2.00
-2.00,1.00,2.00,22.00
-2.00,2.00,1.00,1.00
-2.00,2.00,2.00,3.00
-EOF
-if [ $? -ne 0 ] ; then fail ; fi
-
-pass;
diff --git a/tests/language/data-io/get.at b/tests/language/data-io/get.at
new file mode 100644 (file)
index 0000000..e9f2e2e
--- /dev/null
@@ -0,0 +1,64 @@
+AT_BANNER([GET])
+
+dnl Tests for a bug which caused the second procedure
+dnl after GET to have corrupt input.
+AT_SETUP([GET data works in multiple procedures])
+AT_DATA([get.sps], [dnl
+DATA LIST LIST NOTABLE /LOCATION * EDITOR * SHELL * FREQ * .
+BEGIN DATA.
+    1.00     1.00    1.0     2.00
+    1.00     1.00    2.0    30.00
+    1.00     2.00    1.0     8.00
+    1.00     2.00    2.0    20.00
+    2.00     1.00    1.0     2.00
+    2.00     1.00    2.0    22.00
+    2.00     2.00    1.0     1.00
+    2.00     2.00    2.0     3.00
+END DATA.
+
+SAVE /OUTFILE='foo.sav'.
+
+GET /FILE='foo.sav'.
+
+* This one's ok
+LIST.
+
+* But this one get rubbish
+LIST.
+])
+AT_CHECK([pspp -o pspp.csv get.sps])
+AT_CHECK([cat pspp.csv], [0], [dnl
+Table: Data List
+LOCATION,EDITOR,SHELL,FREQ
+1.00,1.00,1.00,2.00
+1.00,1.00,2.00,30.00
+1.00,2.00,1.00,8.00
+1.00,2.00,2.00,20.00
+2.00,1.00,1.00,2.00
+2.00,1.00,2.00,22.00
+2.00,2.00,1.00,1.00
+2.00,2.00,2.00,3.00
+
+Table: Data List
+LOCATION,EDITOR,SHELL,FREQ
+1.00,1.00,1.00,2.00
+1.00,1.00,2.00,30.00
+1.00,2.00,1.00,8.00
+1.00,2.00,2.00,20.00
+2.00,1.00,1.00,2.00
+2.00,1.00,2.00,22.00
+2.00,2.00,1.00,1.00
+2.00,2.00,2.00,3.00
+])
+AT_CLEANUP
+
+dnl Tests for a bug that crashed when GET specified a nonexistent file.
+AT_SETUP([GET nonexistent file doesn't crash])
+dnl We use stdin here, because the bug seems to manifest itself only in 
+dnl interactive mode.
+AT_CHECK([echo "GET /FILE='nonexistent.sav'." | pspp -O format=csv], [1], [dnl
+error: An error occurred while opening `nonexistent.sav': No such file or directory.
+
+-:1: error: Stopping syntax file processing here to avoid a cascade of dependent command failures.
+])
+AT_CLEANUP