DATA LIST: Convert tests for line-ends compatibility to use Autotest.
authorBen Pfaff <blp@cs.stanford.edu>
Thu, 30 Sep 2010 03:34:28 +0000 (20:34 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Thu, 30 Sep 2010 04:41:52 +0000 (21:41 -0700)
tests/automake.mk
tests/command/line-ends.sh [deleted file]
tests/language/data-io/data-list.at

index 986e9ec2190cc25a0c1e26ca0182eabbf3e2988e..19a2798ea86e5aaada24e223e322e32ffb4035f1 100644 (file)
@@ -10,7 +10,6 @@ TESTS_ENVIRONMENT += LC_ALL=C
 TESTS_ENVIRONMENT += EXEEXT=$(EXEEXT)
 
 dist_TESTS = \
-       tests/command/line-ends.sh \
        tests/command/list.sh \
        tests/command/loop.sh \
        tests/command/longvars.sh \
diff --git a/tests/command/line-ends.sh b/tests/command/line-ends.sh
deleted file mode 100755 (executable)
index 7649962..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-#!/bin/sh
-
-# This program tests that DATA LIST can be used to read input files
-# with varying line ends (LF only, CR LF, CR only).
-
-TEMPDIR=/tmp/pspp-tst-$$
-TESTFILE=$TEMPDIR/`basename $0`.sps
-
-# 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
-
-# Create command file.
-activity="create program"
-cat > $TESTFILE << EOF
-data list list notable file='input.txt'/a b c.
-list.
-EOF
-if [ $? -ne 0 ] ; then no_result ; fi
-
-
-activity="create input.txt"
-printf '1 2 3\n4 5 6\r\n7\r8\r9\r\n10 11 12\n13 14 15 \r\n16\r\r17\r18\n' > input.txt
-if [ $? -ne 0 ] ; then no_result ; fi
-
-
-# Make sure that input.txt actually received the data that we expect.
-# It might not have, if we're running on a system that translates \n
-# into some other sequence.
-activity="check input.txt"
-cksum input.txt > input.cksum
-diff input.cksum - <<EOF
-1732021750 50 input.txt
-EOF
-if [ $? -ne 0 ] ; then no_result ; fi
-
-
-activity="run program"
-$SUPERVISOR $PSPP -o pspp.csv $TESTFILE
-if [ $? -ne 0 ] ; then fail ; fi
-
-
-activity="compare output"
-diff -c $TEMPDIR/pspp.csv - << EOF
-Table: Data List
-a,b,c
-1.00,2.00,3.00
-4.00,5.00,6.00
-7.00,8.00,9.00
-10.00,11.00,12.00
-13.00,14.00,15.00
-16.00,17.00,18.00
-EOF
-if [ $? -ne 0 ] ; then fail ; fi
-
-pass;
index 544b020a244b36e1dde5ad363ba027bbe509111a..64a918df9e3d6688f86ad25aec9c806055319f55 100644 (file)
@@ -199,3 +199,29 @@ x,y
 9,0
 ])
 AT_CLEANUP
+
+dnl Test that PSPP accepts LF and CR LF as line ends, but
+dnl treats isolated CR as linear whitespace.
+AT_SETUP([DATA LIST with various line-ends])
+AT_DATA([data-list.sps], [dnl
+data list list notable file='input.txt'/a b c.
+list.
+])
+printf '1 2 3\n4 5 6\r\n7\r8\r9\r\n10 11 12\n13 14 15 \r\n16\r\r17\r18\n' > input.txt
+dnl Make sure that input.txt actually received the data that we expect.
+dnl It might not have, if we're running on a system that translates \n
+dnl into some other sequence.
+AT_CHECK([cksum input.txt], [0], [1732021750 50 input.txt
+])
+AT_CHECK([pspp -o pspp.csv data-list.sps])
+AT_CHECK([cat pspp.csv], [0], [dnl
+Table: Data List
+a,b,c
+1.00,2.00,3.00
+4.00,5.00,6.00
+7.00,8.00,9.00
+10.00,11.00,12.00
+13.00,14.00,15.00
+16.00,17.00,18.00
+])
+AT_CLEANUP