From 8482510637fdc3ea26fdb8ef58a5084c4caf24f3 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Tue, 12 Oct 2010 21:38:30 -0700 Subject: [PATCH] format-guesser: Convert test to Autotest framework. --- tests/automake.mk | 2 +- .../format-guesser.at} | 96 ++++--------------- 2 files changed, 19 insertions(+), 79 deletions(-) rename tests/{formats/format-guesser.sh => data/format-guesser.at} (68%) mode change 100755 => 100644 diff --git a/tests/automake.mk b/tests/automake.mk index 11cd343f..c2aedb74 100644 --- a/tests/automake.mk +++ b/tests/automake.mk @@ -11,7 +11,6 @@ TESTS_ENVIRONMENT += EXEEXT=$(EXEEXT) dist_TESTS = \ tests/formats/date-in.sh \ - tests/formats/format-guesser.sh \ tests/formats/ib-in.sh \ tests/formats/legacy-in.sh \ tests/formats/month-in.sh \ @@ -261,6 +260,7 @@ TESTSUITE_AT = \ tests/data/data-in.at \ tests/data/data-out.at \ tests/data/datasheet-test.at \ + tests/data/format-guesser.at \ tests/data/por-file.at \ tests/data/sys-file.at \ tests/language/command.at \ diff --git a/tests/formats/format-guesser.sh b/tests/data/format-guesser.at old mode 100755 new mode 100644 similarity index 68% rename from tests/formats/format-guesser.sh rename to tests/data/format-guesser.at index cf7bdb74..764d0f16 --- a/tests/formats/format-guesser.sh +++ b/tests/data/format-guesser.at @@ -1,61 +1,7 @@ -#! /bin/sh +AT_BANNER([format guesser]) -# Tests guessing of data formats from data. - -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$EXEEXT - -# 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 test data" -sed -ne 's/#.*//;/^[ ]*$/!p' > $TEMPDIR/test-list <<'EOF' +AT_SETUP([format guesser]) +AT_DATA([format-guesser.txt], [dnl # No data. => F8.2 "" => F8.2 @@ -144,7 +90,7 @@ sed -ne 's/#.*//;/^[ ]*$/!p' > $TEMPDIR/test-list <<'EOF' "ix" => A2 "x" => A1 "january" => MONTH7 -"janaury" => MONTH7 +"janaury" => MONTH7 # Only first three letters are significant. "february" => MONTH8 "febraury" => MONTH8 "march" => MONTH5 @@ -175,23 +121,17 @@ sed -ne 's/#.*//;/^[ ]*$/!p' > $TEMPDIR/test-list <<'EOF' "1/1/1978" "1/2/1978" "1/3/1978" "1/13/1978" => ADATE9 # MM/DD/YY "01/01/01" "02/01/01" "03/01/01" "13/01/01" => EDATE8 # DD/MM/YY "01/01/01" "02/01/01" "03/01/01" "2013/01/01" => SDATE10 # YY/MM/DD -EOF -if [ $? -ne 0 ] ; then no_result ; fi - -activity="create syntax file" -{ - echo "SET DECIMAL=DOT." && - sed < $TEMPDIR/test-list -e 's#^\(.*\)=> \(.*\)$#DEBUG FORMAT GUESSER \1.#' -} > $TEMPDIR/test.stat -if [ $? -ne 0 ] ; then no_result ; fi - -activity="run program" -$SUPERVISOR $PSPP --testing-mode -o pspp.csv \ - $TEMPDIR/test.stat >$TEMPDIR/test.err 2> $TEMPDIR/test.out - -activity="compare output" -perl -pi -e 's/^\s*$//g' $TEMPDIR/test-list $TEMPDIR/test.out -diff -b $TEMPDIR/test-list $TEMPDIR/test.out -if [ $? -ne 0 ] ; then fail ; fi - -pass +]) +AT_CHECK([[(echo "SET DECIMAL=DOT." + sed -e 's/#.*// +s/[ ]*$// +/^$/d +s,^\(.*\)=> \(.*\)$,DEBUG FORMAT GUESSER \1.,') \ + < format-guesser.txt > format-guesser.sps]]) +AT_CHECK([pspp --testing-mode -O format=csv format-guesser.sps], + [0], [], [stderr]) +AT_CHECK([[sed -e 's/#.*// +s/[ ]*$// +/^$/d' < format-guesser.txt > expout]]) +AT_CHECK([cat stderr], [0], [expout]) +AT_CLEANUP -- 2.30.2