BEGIN DATA: Convert tests to use Autotest.
authorBen Pfaff <blp@cs.stanford.edu>
Mon, 9 Aug 2010 05:34:48 +0000 (22:34 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Mon, 9 Aug 2010 17:59:05 +0000 (10:59 -0700)
tests/automake.mk
tests/command/beg-data.sh [deleted file]
tests/language/data-io/data-reader.at [new file with mode: 0644]

index fd50986421a2873f28cb3dabce1250e0e2f07301..98fafb739a4b72164bd3f271b5e19e0c0fce5277 100644 (file)
@@ -10,7 +10,6 @@ TESTS_ENVIRONMENT += LC_ALL=C
 TESTS_ENVIRONMENT += EXEEXT=$(EXEEXT)
 
 dist_TESTS = \
-       tests/command/beg-data.sh \
        tests/command/bignum.sh \
        tests/command/count.sh \
        tests/command/correlation.sh \
@@ -418,6 +417,7 @@ TESTSUITE_AT = \
        tests/data/calendar.at \
        tests/language/data-io/add-files.at \
        tests/language/data-io/data-list.at \
+       tests/language/data-io/data-reader.at \
        tests/language/data-io/save.at \
        tests/language/data-io/save-translate.at \
        tests/language/dictionary/attributes.at \
diff --git a/tests/command/beg-data.sh b/tests/command/beg-data.sh
deleted file mode 100755 (executable)
index 972b990..0000000
+++ /dev/null
@@ -1,125 +0,0 @@
-#!/bin/sh
-
-# This program tests the BEGIN DATA / END DATA commands
-
-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
-
-LANG=C
-export LANG
-
-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_foobar
-title 'Test BEGIN DATA ... END DATA'.
-
-data list /A B 1-2.
-list.
-begin data.
-12
-34
-56
-78
-90
-end data.
-
-data list /A B 1-2.
-begin data.
-09
-87
-65
-43
-21
-end data.
-list.
-EOF_foobar
-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 data"
-diff -c $TEMPDIR/pspp.csv - << foobar
-Title: Test BEGIN DATA ... END DATA
-
-Table: Reading 1 record from INLINE.
-Variable,Record,Columns,Format
-A,1,1-  1,F1.0
-B,1,2-  2,F1.0
-
-Table: Data List
-A,B
-1,2
-3,4
-5,6
-7,8
-9,0
-
-Table: Reading 1 record from INLINE.
-Variable,Record,Columns,Format
-A,1,1-  1,F1.0
-B,1,2-  2,F1.0
-
-Table: Data List
-A,B
-0,9
-8,7
-6,5
-4,3
-2,1
-foobar
-if [ $? -ne 0 ] ; then fail ; fi
-
-
-pass;
diff --git a/tests/language/data-io/data-reader.at b/tests/language/data-io/data-reader.at
new file mode 100644 (file)
index 0000000..281ca2a
--- /dev/null
@@ -0,0 +1,64 @@
+AT_BANNER([BEGIN DATA])
+
+# BEGIN DATA can run as a command in itself, or it can appear as part
+# of the first procedure.  First, test it after a procedure.
+AT_SETUP([BEGIN DATA as part of a procedure])
+AT_DATA([begin-data.sps], [dnl
+TITLE 'Test BEGIN DATA ... END DATA'.
+
+DATA LIST /a b 1-2.
+LIST.
+BEGIN DATA.
+12
+34
+56
+78
+90
+END DATA.
+])
+AT_CHECK([pspp -O format=csv begin-data.sps], [0], [dnl
+Title: Test BEGIN DATA ... END DATA
+
+Table: Reading 1 record from INLINE.
+Variable,Record,Columns,Format
+a,1,1-  1,F1.0
+b,1,2-  2,F1.0
+
+Table: Data List
+a,b
+1,2
+3,4
+5,6
+7,8
+9,0
+])
+AT_CLEANUP
+
+# Also test BEGIN DATA as an independent command.
+AT_SETUP([BEGIN DATA as an independent command])
+AT_DATA([begin-data.sps], [dnl
+data list /A B 1-2.
+begin data.
+09
+87
+65
+43
+21
+end data.
+list.
+])
+AT_CHECK([pspp -O format=csv begin-data.sps], [0], [dnl
+Table: Reading 1 record from INLINE.
+Variable,Record,Columns,Format
+A,1,1-  1,F1.0
+B,1,2-  2,F1.0
+
+Table: Data List
+A,B
+0,9
+8,7
+6,5
+4,3
+2,1
+])
+AT_CLEANUP