From: Ben Pfaff Date: Sat, 25 Sep 2010 23:20:58 +0000 (-0700) Subject: tests: Convert correlation.sh test to use Autotest. X-Git-Tag: v0.7.6~160 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bd962e8c6c0d8838e45602a8babaec91255dea76;p=pspp-builds.git tests: Convert correlation.sh test to use Autotest. --- 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/command/correlation.sh deleted file mode 100755 index d66e52c7..00000000 --- a/tests/command/correlation.sh +++ /dev/null @@ -1,206 +0,0 @@ -#!/bin/sh - -# 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 -set format = F11.3. -data list notable list /foo * bar * wiz * bang *. -begin data. -1 0 3 1 -3 9 -50 5 -3 4 3 203 -4 -9 0 -4 -98 78 104 2 -3 50 -49 200 -. 4 4 4 -5 3 0 . -end data. - -correlations - variables = foo bar wiz bang - /print nosig - /missing = listwise - . - -correlations - variables = bar wiz - /print nosig - /missing = listwise - . - -correlations - variables = foo bar wiz bang - /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 -Table: Correlations -,,foo,bar,wiz,bang -foo,Pearson Correlation,1.000,.802,.890,-.308 -,Sig. (2-tailed),,.055,.017,.553 -bar,Pearson Correlation,.802,1.000,.519,.118 -,Sig. (2-tailed),.055,,.291,.824 -wiz,Pearson Correlation,.890,.519,1.000,-.344 -,Sig. (2-tailed),.017,.291,,.505 -bang,Pearson Correlation,-.308,.118,-.344,1.000 -,Sig. (2-tailed),.553,.824,.505, - -Table: Correlations -,,bar,wiz -bar,Pearson Correlation,1.000,.497 -,Sig. (2-tailed),,.210 -wiz,Pearson Correlation,.497,1.000 -,Sig. (2-tailed),.210, - -Table: Correlations -,,foo,bar,wiz,bang -foo,Pearson Correlation,1.000,.805,.883,-.308 -,Sig. (2-tailed),,.029,.008,.553 -,N,7,7,7,6 -bar,Pearson Correlation,.805,1.000,.497,.164 -,Sig. (2-tailed),.029,,.210,.725 -,N,7,8,8,7 -wiz,Pearson Correlation,.883,.497,1.000,-.337 -,Sig. (2-tailed),.008,.210,,.460 -,N,7,8,8,7 -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 - - -# Now test that weights are properly handled. - -activity="create program 2" -cat << EOF > $TESTFILE -set format = F11.3. -data list notable list /foo * bar * wiz * bang * w *. -begin data. -1 0 3 1 1 -3 9 -50 5 2 -3 4 3 203 1 -4 -9 0 -4 1 -98 78 104 2 3 -3 50 -49 200 1 -end data. - -weight by w. - -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 -set format = F11.3. -data list notable list /foo * bar * wiz * bang * w *. -begin data. -1 0 3 1 1 -3 9 -50 5 1 -3 9 -50 5 1 -3 4 3 203 1 -4 -9 0 -4 1 -98 78 104 2 1 -98 78 104 2 1 -98 78 104 2 1 -3 50 -49 200 1 -end data. - -weight by w. - -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; diff --git a/tests/language/stats/correlations.at b/tests/language/stats/correlations.at new file mode 100644 index 00000000..f31d0593 --- /dev/null +++ b/tests/language/stats/correlations.at @@ -0,0 +1,118 @@ +AT_BANNER([CORRELATIONS]) + +AT_SETUP([CORRELATIONS -- unweighted]) +AT_DATA([correlations.sps], [dnl +set format = F11.3. +data list notable list /foo * bar * wiz * bang *. +begin data. +1 0 3 1 +3 9 -50 5 +3 4 3 203 +4 -9 0 -4 +98 78 104 2 +3 50 -49 200 +. 4 4 4 +5 3 0 . +end data. + +correlations + variables = foo bar wiz bang + /print nosig + /missing = listwise + . + +correlations + variables = bar wiz + /print nosig + /missing = listwise + . + +correlations + variables = foo bar wiz bang + /print nosig + /missing = pairwise + . +]) +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 +,Sig. (2-tailed),,.055,.017,.553 +bar,Pearson Correlation,.802,1.000,.519,.118 +,Sig. (2-tailed),.055,,.291,.824 +wiz,Pearson Correlation,.890,.519,1.000,-.344 +,Sig. (2-tailed),.017,.291,,.505 +bang,Pearson Correlation,-.308,.118,-.344,1.000 +,Sig. (2-tailed),.553,.824,.505, + +Table: Correlations +,,bar,wiz +bar,Pearson Correlation,1.000,.497 +,Sig. (2-tailed),,.210 +wiz,Pearson Correlation,.497,1.000 +,Sig. (2-tailed),.210, + +Table: Correlations +,,foo,bar,wiz,bang +foo,Pearson Correlation,1.000,.805,.883,-.308 +,Sig. (2-tailed),,.029,.008,.553 +,N,7,7,7,6 +bar,Pearson Correlation,.805,1.000,.497,.164 +,Sig. (2-tailed),.029,,.210,.725 +,N,7,8,8,7 +wiz,Pearson Correlation,.883,.497,1.000,-.337 +,Sig. (2-tailed),.008,.210,,.460 +,N,7,8,8,7 +bang,Pearson Correlation,-.308,.164,-.337,1.000 +,Sig. (2-tailed),.553,.725,.460, +,N,6,7,7,7 +]) +AT_CLEANUP + +AT_SETUP([CORRELATIONS -- weighted]) +AT_DATA([correlations1.sps], [dnl +set format = F11.3. +data list notable list /foo * bar * wiz * bang * w *. +begin data. +1 0 3 1 1 +3 9 -50 5 2 +3 4 3 203 1 +4 -9 0 -4 1 +98 78 104 2 3 +3 50 -49 200 1 +end data. + +weight by w. + +correlations + variables = foo bar wiz bang + /statistics=descriptives xprod + . +]) +AT_DATA([correlations2.sps], [dnl +set format = F11.3. +data list notable list /foo * bar * wiz * bang * w *. +begin data. +1 0 3 1 1 +3 9 -50 5 1 +3 9 -50 5 1 +3 4 3 203 1 +4 -9 0 -4 1 +98 78 104 2 1 +98 78 104 2 1 +98 78 104 2 1 +3 50 -49 200 1 +end data. + +weight by w. + +correlations + variables = foo bar wiz bang + /statistics=descriptives xprod + . +]) +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