COMPUTE: Convert tests to use Autotest.
authorBen Pfaff <blp@cs.stanford.edu>
Tue, 13 Apr 2010 02:18:56 +0000 (19:18 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Tue, 13 Apr 2010 05:33:02 +0000 (22:33 -0700)
tests/automake.mk
tests/bugs/compute-fmt.sh [deleted file]
tests/bugs/compute-lv.sh [deleted file]
tests/bugs/compute-sum.sh [deleted file]
tests/bugs/computebug.sh [deleted file]
tests/language/xforms/compute.at [new file with mode: 0644]
tests/testsuite.at

index b8e891e797aca1388b962f65a1899e800a485b44..914ff86b62d93d9716aeb11a46e349b088d3f2fe 100644 (file)
@@ -105,7 +105,6 @@ dist_TESTS = \
        tests/bugs/big-input-2.sh \
        tests/bugs/case-map.sh \
        tests/bugs/comment-at-eof.sh \
-       tests/bugs/compute-fmt.sh \
        tests/bugs/compression.sh \
        tests/bugs/curtailed.sh \
        tests/bugs/data-crash.sh \
@@ -139,9 +138,6 @@ dist_TESTS = \
        tests/bugs/unwritable-dir.sh \
        tests/bugs/val-labs.sh \
        tests/bugs/val-labs-trailing-slash.sh \
-       tests/bugs/computebug.sh \
-       tests/bugs/compute-lv.sh \
-       tests/bugs/compute-sum.sh \
        tests/bugs/print-crash.sh \
        tests/bugs/keep-all.sh \
        tests/data/datasheet-test.sh \
@@ -417,6 +413,7 @@ TESTSUITE_AT = \
        tests/language/stats/autorecode.at \
        tests/language/stats/crosstabs.at \
        tests/language/stats/frequencies.at \
+       tests/language/xforms/compute.at \
        tests/language/xforms/recode.at \
        tests/output/render.at
 TESTSUITE = $(srcdir)/tests/testsuite
diff --git a/tests/bugs/compute-fmt.sh b/tests/bugs/compute-fmt.sh
deleted file mode 100755 (executable)
index 2417cca..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-#!/bin/sh
-
-# This program tests for a bug which caused a crash after SAVE FILE
-# was called on a COMPUTEd variable
-
-
-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
-
-# 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
-INPUT PROGRAM.
-       COMPUTE num = 3.
-END FILE.
-END INPUT PROGRAM.
-EXECUTE.
-
-SAVE outfile='$TEMPDIR/temp.sav'.
-EOF
-if [ $? -ne 0 ] ; then no_result ; fi
-
-$SUPERVISOR $PSPP -o pspp.csv $TESTFILE
-if [ $? -ne 0 ] ; then fail; fi
-
-
-
-pass;
diff --git a/tests/bugs/compute-lv.sh b/tests/bugs/compute-lv.sh
deleted file mode 100755 (executable)
index 5bb1321..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-#!/bin/sh
-
-# This program tests for a bug involving COMPUTE and long variable names
-
-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
-
-# 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 prog"
-cat > $TESTFILE <<EOF
-DATA LIST LIST /longVariablename * x *.
-BEGIN DATA.
-1 2
-3 4
-END DATA.
-
-
-COMPUTE longvariableName=100-longvariablename.
-
-LIST.
-
-EOF
-if [ $? -ne 0 ] ; then no_result ; fi
-
-
-activity="run prog"
-$SUPERVISOR $PSPP -o pspp.csv $TESTFILE
-if [ $? -ne 0 ] ; then fail ; fi
-
-
-activity="compare output"
-diff pspp.csv - << EOF
-Table: Reading free-form data from INLINE.
-Variable,Format
-longVariablename,F8.0
-x,F8.0
-
-Table: Data List
-longVariablename,x
-99.00,2.00
-97.00,4.00
-EOF
-if [ $? -ne 0 ] ; then fail ; fi
-
-
-pass;
diff --git a/tests/bugs/compute-sum.sh b/tests/bugs/compute-sum.sh
deleted file mode 100755 (executable)
index 455ec39..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-#!/bin/sh
-
-# This program tests for a bug in the `compute' command, in which it
-# failed to allow a newly created variable to be used as part of the
-# computation, which actually makes sense for "LEAVE" variables.
-
-TEMPDIR=/tmp/pspp-tst-$$
-
-# 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
-
-# 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="copy file"
-cat > compute-sum.stat <<EOF
-DATA LIST /ITEM 1-3.
-COMPUTE SUM=SUM+ITEM.
-PRINT OUTFILE='compute-sum.out' /ITEM SUM.
-LEAVE SUM
-BEGIN DATA.
-123
-404
-555
-999
-END DATA.
-EOF
-if [ $? -ne 0 ] ; then no_result ; fi
-
-activity="run program"
-$SUPERVISOR $PSPP -o pspp.csv $TEMPDIR/compute-sum.stat
-if [ $? -ne 0 ] ; then no_result ; fi
-
-activity="compare output"
-diff compute-sum.out - <<EOF
- 123   123.00 
- 404   527.00 
- 555  1082.00 
- 999  2081.00 
-EOF
-if [ $? -ne 0 ] ; then fail ; fi
-
-pass;
diff --git a/tests/bugs/computebug.sh b/tests/bugs/computebug.sh
deleted file mode 100755 (executable)
index 4ba6a9d..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-#!/bin/sh
-
-# This program tests for a bug in the `compute' command
-
-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
-
-# 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
-if [ $? -ne 0 ] ; then no_result ; fi
-
-activity="create input"
-cat > $TESTFILE <<EOF
-DATA LIST LIST
- /A (A161)
- B (A3).
-
-BEGIN DATA
-abc   def
-ghi   jkl
-END DATA.
-
-COMPUTE A=upcase(A).
-EXECUTE.
-LIST.
-EOF
-
-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: Reading free-form data from INLINE.
-Variable,Format
-A,A161
-B,A3
-
-Table: Data List
-A,B
-ABC                                                                                                                                                              ,def
-GHI                                                                                                                                                              ,jkl
-EOF
-if [ $? -ne 0 ] ; then fail ; fi
-
-pass;
diff --git a/tests/language/xforms/compute.at b/tests/language/xforms/compute.at
new file mode 100644 (file)
index 0000000..f992d0e
--- /dev/null
@@ -0,0 +1,100 @@
+AT_BANNER([COMPUTE transformation])
+
+AT_SETUP([COMPUTE crash with SAVE])
+AT_DATA([compute.sps],
+  [INPUT PROGRAM.
+COMPUTE num = 3.
+END FILE.
+END INPUT PROGRAM.
+EXECUTE.
+
+SAVE outfile='temp.sav'.
+])
+AT_CHECK([pspp -O format=csv compute.sps])
+AT_DATA([list.sps],
+  [GET FILE='temp.sav'.
+LIST.
+])
+AT_CHECK([pspp -O format=csv list.sps], [0], 
+  [])
+AT_CLEANUP
+
+AT_SETUP([COMPUTE bug in long string UPCASE])
+AT_DATA([compute.sps],
+  [DATA LIST LIST
+ /A (A161)
+ B (A3).
+
+BEGIN DATA
+abc   def
+ghi   jkl
+END DATA.
+
+COMPUTE A=upcase(A).
+EXECUTE.
+LIST.
+])
+AT_CHECK([pspp -O format=csv compute.sps], [0],
+  [Table: Reading free-form data from INLINE.
+Variable,Format
+A,A161
+B,A3
+
+Table: Data List
+A,B
+ABC                                                                                                                                                              ,def
+GHI                                                                                                                                                              ,jkl
+])
+AT_CLEANUP
+
+AT_SETUP([COMPUTE bug with long variable names])
+AT_DATA([compute.sps],
+  [DATA LIST LIST /longVariablename * x *.
+BEGIN DATA.
+1 2
+3 4
+END DATA.
+
+
+COMPUTE longvariableName=100-longvariablename.
+
+LIST.
+])
+AT_CHECK([pspp -O format=csv compute.sps], [0],
+  [Table: Reading free-form data from INLINE.
+Variable,Format
+longVariablename,F8.0
+x,F8.0
+
+Table: Data List
+longVariablename,x
+99.00,2.00
+97.00,4.00
+])
+AT_CLEANUP
+
+AT_SETUP([COMPUTE self-reference to new variable])
+AT_DATA([compute.sps],
+  [DATA LIST /ITEM 1-3.
+COMPUTE SUM=SUM+ITEM.
+PRINT OUTFILE='compute-sum.out' /ITEM SUM.
+LEAVE SUM
+BEGIN DATA.
+123
+404
+555
+999
+END DATA.
+])
+AT_CHECK([pspp -O format=csv compute.sps], [0],
+  [Table: Reading 1 record from INLINE.
+Variable,Record,Columns,Format
+ITEM,1,1-  3,F3.0
+])
+AT_CHECK([cat compute-sum.out], [0],
+  [ 123   123.00 @&t@
+ 404   527.00 @&t@
+ 555  1082.00 @&t@
+ 999  2081.00 @&t@
+])
+AT_CLEANUP
index c707cfff020eb2ad02559cbc40444f9c0e0b7717..7f2a7eda02770acbcf0398131626083800e2621e 100644 (file)
@@ -3,5 +3,6 @@ AT_INIT
 m4_include([tests/language/stats/autorecode.at])
 m4_include([tests/language/stats/crosstabs.at])
 m4_include([tests/language/stats/frequencies.at])
+m4_include([tests/language/xforms/compute.at])
 m4_include([tests/language/xforms/recode.at])
 m4_include([tests/output/render.at])