From 984c1df3e3bf60d1624956a19e855765811e4a37 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Sat, 25 Sep 2010 16:26:49 -0700 Subject: [PATCH] tests: Convert do-if.sh test to use Autotest. --- tests/automake.mk | 2 +- tests/command/do-if.sh | 118 -------------------------------- tests/language/control/do-if.at | 50 ++++++++++++++ 3 files changed, 51 insertions(+), 119 deletions(-) delete mode 100755 tests/command/do-if.sh create mode 100644 tests/language/control/do-if.at diff --git a/tests/automake.mk b/tests/automake.mk index 684435bb..b367984e 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/do-if.sh \ tests/command/do-repeat.sh \ tests/command/erase.sh \ tests/command/examine.sh \ @@ -395,6 +394,7 @@ EXTRA_DIST += \ TESTSUITE_AT = \ tests/data/calendar.at \ tests/data/data-in.at \ + tests/language/control/do-if.at \ tests/language/data-io/add-files.at \ tests/language/data-io/data-list.at \ tests/language/data-io/data-reader.at \ diff --git a/tests/command/do-if.sh b/tests/command/do-if.sh deleted file mode 100755 index f55bcdae..00000000 --- a/tests/command/do-if.sh +++ /dev/null @@ -1,118 +0,0 @@ -#!/bin/sh - -# This program tests the DO IF command. - -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 - -LANG=C -export LANG - -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="generate input and expected output" -(for a in 0 1 ' '; do - for b in 0 1 ' '; do - for c in 0 1 ' '; do - for d in 0 1 ' '; do - abcd=$a$b$c$d - echo "$abcd" 1>&3 - if test "$a" = "1"; then - echo " $abcd A" - elif test "$a" = " "; then - : - elif test "$b" = "1"; then - echo " $abcd B" - elif test "$b" = " "; then - : - elif test "$c" = "1"; then - echo " $abcd C" - elif test "$c" = " "; then - : - elif test "$d" = "1"; then - echo " $abcd D" - elif test "$d" = " "; then - : - else - echo " $abcd E" - fi - done - done - done -done) >test1.expected 3>test1.data -if [ $? -ne 0 ] ; then no_result ; fi - -activity="create test1.pspp" -cat > test1.pspp <&3 + if test "$a" = "1"; then + echo " $abcd A" + elif test "$a" = " "; then + : + elif test "$b" = "1"; then + echo " $abcd B" + elif test "$b" = " "; then + : + elif test "$c" = "1"; then + echo " $abcd C" + elif test "$c" = " "; then + : + elif test "$d" = "1"; then + echo " $abcd D" + elif test "$d" = " "; then + : + else + echo " $abcd E" + fi + done + done + done +done) >expout 3>do-if.txt || exit 99 +AT_DATA([do-if.sps], [dnl +DATA LIST FILE="do-if.txt"/A B C D 1-4 ABCD 1-4 (A). +DO IF A. +PRINT OUTFILE="do-if.out"/ABCD 'A'. +ELSE IF B. +PRINT OUTFILE="do-if.out"/ABCD 'B'. +ELSE IF C. +PRINT OUTFILE="do-if.out"/ABCD 'C'. +ELSE IF D. +PRINT OUTFILE="do-if.out"/ABCD 'D'. +ELSE. +PRINT OUTFILE="do-if.out"/ABCD 'E'. +END IF. +EXECUTE. +]) +AT_CHECK([pspp do-if.sps], [0], [ignore]) +AT_CHECK([cat do-if.out], [0], [expout]) +AT_CLEANUP -- 2.30.2