tests: Convert do-if.sh test to use Autotest.
authorBen Pfaff <blp@cs.stanford.edu>
Sat, 25 Sep 2010 23:26:49 +0000 (16:26 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Sat, 25 Sep 2010 23:26:49 +0000 (16:26 -0700)
tests/automake.mk
tests/command/do-if.sh [deleted file]
tests/language/control/do-if.at [new file with mode: 0644]

index 684435bb27252a2dee327d2cc5d894bd6685053e..b367984eae982b10a17cdbbc3f121c449de98135 100644 (file)
@@ -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 (executable)
index f55bcda..0000000
+++ /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 <<EOF
-DATA LIST FILE="test1.data"/A B C D 1-4 ABCD 1-4 (A).
-DO IF A.
-PRINT OUTFILE="test1.out"/ABCD 'A'.
-ELSE IF B.
-PRINT OUTFILE="test1.out"/ABCD 'B'.
-ELSE IF C.
-PRINT OUTFILE="test1.out"/ABCD 'C'.
-ELSE IF D.
-PRINT OUTFILE="test1.out"/ABCD 'D'.
-ELSE.
-PRINT OUTFILE="test1.out"/ABCD 'E'.
-END IF.
-EXECUTE.
-EOF
-if [ $? -ne 0 ] ; then no_result ; fi
-
-activity="run test1"
-$SUPERVISOR $PSPP -o pspp.csv test1.pspp
-if [ $? -ne 0 ] ; then no_result ; fi
-
-activity="compare test1 results"
-diff -u $TEMPDIR/test1.out $TEMPDIR/test1.expected
-if [ $? -ne 0 ] ; then fail ; fi
-
-pass
diff --git a/tests/language/control/do-if.at b/tests/language/control/do-if.at
new file mode 100644 (file)
index 0000000..45f696a
--- /dev/null
@@ -0,0 +1,50 @@
+AT_BANNER([DO IF])
+
+AT_SETUP([DO IF])
+(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) >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