From 5dda55a193943200dbb77705657da238bd7ab837 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Mon, 12 Apr 2010 21:30:16 -0700 Subject: [PATCH] AGGREGATE: Convert tests to use Autotest. --- tests/automake.mk | 4 +- tests/bugs/agg-crash-2.sh | 94 ------- tests/bugs/agg_crash.sh | 83 ------- .../stats/aggregate.at} | 234 ++++++++---------- tests/testsuite.at | 1 + 5 files changed, 104 insertions(+), 312 deletions(-) delete mode 100755 tests/bugs/agg-crash-2.sh delete mode 100755 tests/bugs/agg_crash.sh rename tests/{command/aggregate.sh => language/stats/aggregate.at} (65%) mode change 100755 => 100644 diff --git a/tests/automake.mk b/tests/automake.mk index 7fb106c6..f23e3b13 100644 --- a/tests/automake.mk +++ b/tests/automake.mk @@ -10,7 +10,6 @@ TESTS_ENVIRONMENT += LC_ALL=C dist_TESTS = \ tests/command/add-files.sh \ - tests/command/aggregate.sh \ tests/command/attributes.sh \ tests/command/beg-data.sh \ tests/command/bignum.sh \ @@ -99,8 +98,6 @@ dist_TESTS = \ tests/formats/wkday-in.sh \ tests/formats/wkday-out.sh \ tests/formats/360.sh \ - tests/bugs/agg_crash.sh \ - tests/bugs/agg-crash-2.sh \ tests/bugs/big-input.sh \ tests/bugs/big-input-2.sh \ tests/bugs/case-map.sh \ @@ -407,6 +404,7 @@ EXTRA_DIST += \ $(TESTSUITE) TESTSUITE_AT = \ tests/testsuite.at \ + tests/language/stats/aggregate.at \ tests/language/stats/autorecode.at \ tests/language/stats/crosstabs.at \ tests/language/stats/descriptives.at \ diff --git a/tests/bugs/agg-crash-2.sh b/tests/bugs/agg-crash-2.sh deleted file mode 100755 index 98bd8dcf..00000000 --- a/tests/bugs/agg-crash-2.sh +++ /dev/null @@ -1,94 +0,0 @@ -#!/bin/sh - -# This program tests for a bug which caused AGGREGATE to crash when -# the MAX function was used. - -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 < $TESTFILE < aggregate.data < aggregate.data < agg-skel.pspp < agg-skel.pspp < agg-itemwise.csv < agg-columnwise.csv < $name.pspp - if [ $? -ne 0 ] ; then no_result ; fi - - activity="run $name.pspp" - $SUPERVISOR $PSPP -o pspp.csv -e /dev/null $name.pspp - if [ $? -ne 0 ] ; then no_result ; fi - - activity="check $name output" - perl -pi -e 's/^.*:\d+: //;' pspp.csv - diff -c pspp.csv agg-$missing.csv - if [ $? -ne 0 ] ; then fail ; fi - done - done -done - -pass; +4,1.00,1.00,1,1,. ,. ,. ,1.000,. ,. ,. ,.000,. ,. ,. ,.000,.,.,,4,. ,. ,. ,1.000,.,.,,4,.,.,,4,. ,. ,.,.,,4,.00,.00,.00,1.00,1.00,1.00,1.00,.00,0,0,0,1,1,1,1,0,. ,. ,. ,100.0,. ,. ,. ,.0,. ,. ,. ,.0,. ,. ,. ,100.0,. ,. ,. ,. ,. ,. @&t@ +])]) + AT_CLEANUP]) + +CHECK_AGGREGATE([scratch], [presorted], [itemwise]) +CHECK_AGGREGATE([scratch], [presorted], [columnwise]) +CHECK_AGGREGATE([scratch], [unsorted], [itemwise]) +CHECK_AGGREGATE([scratch], [unsorted], [columnwise]) +CHECK_AGGREGATE([active], [presorted], [itemwise]) +CHECK_AGGREGATE([active], [presorted], [columnwise]) +CHECK_AGGREGATE([active], [unsorted], [itemwise]) +CHECK_AGGREGATE([active], [unsorted], [columnwise]) +CHECK_AGGREGATE([external], [presorted], [itemwise]) +CHECK_AGGREGATE([external], [presorted], [columnwise]) +CHECK_AGGREGATE([external], [unsorted], [itemwise]) +CHECK_AGGREGATE([external], [unsorted], [columnwise]) + +AT_SETUP([AGGREGATE crash with MAX function]) +AT_DATA([aggregate.sps], + [DATA LIST LIST /X (F8.2) Y (a25). + +BEGIN DATA. +87.50 foo +87.34 bar +1 bar +END DATA. + +AGGREGATE OUTFILE=* /BREAK=y /X=MAX(x). +LIST /x y. +]) +AT_CHECK([pspp -O format=csv aggregate.sps], [0], + [Table: Reading free-form data from INLINE. +Variable,Format +X,F8.2 +Y,A25 + +Table: Data List +X,Y +87.34,bar @&t@ +87.50,foo @&t@ +]) +AT_CLEANUP + +AT_SETUP([AGGREGATE crash with invalid syntax]) +AT_DATA([aggregate.sps], + [INPUT PROGRAM. +LOOP c=1 TO 20. + COMPUTE x=UNIFORM(10) + END CASE. +END LOOP. +END FILE. +END INPUT PROGRAM. + +AGGREGATE /BREAK=x . +]) +AT_CHECK([pspp -O format=csv aggregate.sps], [1], [ignore], []) +AT_CLEANUP diff --git a/tests/testsuite.at b/tests/testsuite.at index 06cb6f9f..ce26a575 100644 --- a/tests/testsuite.at +++ b/tests/testsuite.at @@ -1,5 +1,6 @@ AT_INIT +m4_include([tests/language/stats/aggregate.at]) m4_include([tests/language/stats/autorecode.at]) m4_include([tests/language/stats/crosstabs.at]) m4_include([tests/language/stats/descriptives.at]) -- 2.30.2