From bd962e8c6c0d8838e45602a8babaec91255dea76 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Sat, 25 Sep 2010 16:20:58 -0700 Subject: [PATCH] tests: Convert correlation.sh test to use Autotest. --- tests/automake.mk | 2 +- .../stats/correlations.at} | 122 +++--------------- 2 files changed, 18 insertions(+), 106 deletions(-) rename tests/{command/correlation.sh => language/stats/correlations.at} (52%) mode change 100755 => 100644 diff --git a/tests/automake.mk b/tests/automake.mk index 77de4a37..684435bb 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/correlation.sh \ tests/command/do-if.sh \ tests/command/do-repeat.sh \ tests/command/erase.sh \ @@ -406,6 +405,7 @@ TESTSUITE_AT = \ tests/language/expressions/evaluate.at \ tests/language/stats/aggregate.at \ tests/language/stats/autorecode.at \ + tests/language/stats/correlations.at \ tests/language/stats/crosstabs.at \ tests/language/stats/descriptives.at \ tests/language/stats/factor.at \ diff --git a/tests/command/correlation.sh b/tests/language/stats/correlations.at old mode 100755 new mode 100644 similarity index 52% rename from tests/command/correlation.sh rename to tests/language/stats/correlations.at index d66e52c7..f31d0593 --- a/tests/command/correlation.sh +++ b/tests/language/stats/correlations.at @@ -1,64 +1,7 @@ -#!/bin/sh +AT_BANNER([CORRELATIONS]) -# This program tests the CORRELATIONS command - -TEMPDIR=/tmp/pspp-tst-$$ -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 $TEMPDIR" - return ; - fi - 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 1" -cat << EOF > $TESTFILE +AT_SETUP([CORRELATIONS -- unweighted]) +AT_DATA([correlations.sps], [dnl set format = F11.3. data list notable list /foo * bar * wiz * bang *. begin data. @@ -89,16 +32,9 @@ correlations /print nosig /missing = pairwise . -EOF -if [ $? -ne 0 ] ; then no_result ; fi - - -activity="run program 1" -$SUPERVISOR $PSPP -o pspp.csv $TESTFILE -if [ $? -ne 0 ] ; then no_result ; fi - -activity="compare results 1" -diff -c $TEMPDIR/pspp.csv - << EOF +]) +AT_CHECK([pspp -o pspp.csv correlations.sps]) +AT_CHECK([cat pspp.csv], [0], [dnl Table: Correlations ,,foo,bar,wiz,bang foo,Pearson Correlation,1.000,.802,.890,-.308 @@ -131,14 +67,11 @@ wiz,Pearson Correlation,.883,.497,1.000,-.337 bang,Pearson Correlation,-.308,.164,-.337,1.000 ,Sig. (2-tailed),.553,.725,.460, ,N,6,7,7,7 -EOF -if [ $? -ne 0 ] ; then fail ; fi - +]) +AT_CLEANUP -# Now test that weights are properly handled. - -activity="create program 2" -cat << EOF > $TESTFILE +AT_SETUP([CORRELATIONS -- weighted]) +AT_DATA([correlations1.sps], [dnl set format = F11.3. data list notable list /foo * bar * wiz * bang * w *. begin data. @@ -156,21 +89,8 @@ correlations variables = foo bar wiz bang /statistics=descriptives xprod . - -EOF -if [ $? -ne 0 ] ; then no_result ; fi - - -activity="run program 2" -$SUPERVISOR $PSPP -o pspp.csv $TESTFILE -if [ $? -ne 0 ] ; then no_result ; fi - -activity="copy results" -cp $TEMPDIR/pspp.csv $TEMPDIR/weighted -if [ $? -ne 0 ] ; then no_result ; fi - -activity="create program 3" -cat << EOF > $TESTFILE +]) +AT_DATA([correlations2.sps], [dnl set format = F11.3. data list notable list /foo * bar * wiz * bang * w *. begin data. @@ -191,16 +111,8 @@ correlations variables = foo bar wiz bang /statistics=descriptives xprod . - -EOF -if [ $? -ne 0 ] ; then no_result ; fi - -activity="run program 3" -$SUPERVISOR $PSPP -o pspp.csv $TESTFILE -if [ $? -ne 0 ] ; then no_result ; fi - -activity="Compare weighted and unweighted results" -diff $TEMPDIR/pspp.csv $TEMPDIR/weighted -if [ $? -ne 0 ] ; then fail ; fi - -pass; +]) +AT_CHECK([pspp -O format=csv correlations1.sps], [0], [stdout]) +mv stdout expout +AT_CHECK([pspp -O format=csv correlations2.sps], [0], [expout]) +AT_CLEANUP -- 2.30.2