Started converting the make check target to aegis style tests
authorJohn Darrington <john@darrington.wattle.id.au>
Mon, 15 Dec 2003 13:48:52 +0000 (13:48 +0000)
committerJohn Darrington <john@darrington.wattle.id.au>
Mon, 15 Dec 2003 13:48:52 +0000 (13:48 +0000)
14 files changed:
config/devices
src/ascii.c
src/output.c
tests/Makefile.am
tests/aggregate.stat [deleted file]
tests/autorecod.stat [deleted file]
tests/beg-data.stat [deleted file]
tests/bugs/double-frequency.sh
tests/bugs/html-frequency.sh
tests/command/aggregate.sh [new file with mode: 0755]
tests/command/autorecod.sh [new file with mode: 0755]
tests/command/beg-data.sh [new file with mode: 0755]
tests/syntax [deleted file]
tests/test_template [new file with mode: 0755]

index c1aa6c00494819ec0280901c2016fd77db340f91..4f97446f96ec6800ae4b31279d6a8acd0cd86523 100644 (file)
@@ -58,6 +58,8 @@ tty-ascii:ascii:screen:char-set=ascii output-file=${tty-output-file} \
   ${no-attributes}
 list-ascii:ascii:listing:length=66 width=79 char-set=ascii \
   output-file=${list-output-file} ${no-attributes}
+raw-ascii:ascii:screen:char-set=ascii \
+  output-file=${list-output-file} ${no-attributes} headers=off paginate=off
 
 # ASCII devices that support bold & underline via backspacing.
 tty-ascii-bi:ascii:screen:char-set=ascii output-file=${tty-output-file}
index c6f48f00254584f59eaab6187cc09d7ab13966bc..f6b39238ccb413181e7b9fb20eabb575537a1db7 100644 (file)
@@ -1580,7 +1580,8 @@ ascii_close_page (struct outp_driver *this)
       cp += nl_len;
     }
   memcpy (cp, ls_value (&x->ops[OPS_FORMFEED]), ff_len);
-  output_string (this, s, &s[total_len]);
+  if ( x->paginate ) 
+         output_string (this, s, &s[total_len]);
   if (line_p != line_buf && !commit_line_buf (this))
     return 0;
 
index 86e8534cedad1efcc659f7cc81346406a707887d..370ad5910cf6b2241d13bc8d1b2aa38592863c5f 100644 (file)
@@ -1148,6 +1148,7 @@ outp_get_paper_size (char *size, int *h, int *v)
   where.filename = pprsz_fn;
   where.line_number = 0;
   err_push_file_locator (&where);
+  ds_init (NULL, &line, 128);
 
   if (pprsz_fn == NULL)
     {
@@ -1163,7 +1164,6 @@ outp_get_paper_size (char *size, int *h, int *v)
       goto exit;
     }
 
-  ds_init (NULL, &line, 128);
   for (;;)
     {
       char *cp, *bp, *ep;
index 0e6334547b107ef119a30a493dd4a23e4d840ad4..8de36776f59988cb72b3db14bda11a8d6ef56fb1 100644 (file)
@@ -4,7 +4,11 @@ bench:
        make BENCHMARK=1 check
 
 TESTS_ENVIRONMENT=top_srcdir=${top_srcdir}
-TESTS = syntax bugs/double-frequency.sh bugs/html-frequency.sh
+TESTS = command/aggregate.sh \
+       command/autorecod.sh \
+       command/beg-data.sh \
+       bugs/double-frequency.sh \
+       bugs/html-frequency.sh
 
 noinst_PROGRAMS = gengarbage
 
@@ -12,7 +16,7 @@ noinst_DATA = sort.data
 sort.data: gengarbage
        ./gengarbage | head -1000 > $@
 
-EXTRA_DIST = aggregate.stat autorecod.stat beg-data.stat bignum.data   \
+EXTRA_DIST = bignum.data       \
 bignum.stat compute.stat count.stat crosstabs.stat data-fmts.stat      \
 data-list.data data-list.stat descript.stat do-if.stat do-repeat.stat  \
 expr.stat file-lab.stat filter.stat flip.stat gengarbage.c             \
diff --git a/tests/aggregate.stat b/tests/aggregate.stat
deleted file mode 100644 (file)
index 3a95532..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-title 'Test for AGGREGATE procedure'.
-
-data list /x y 1-2.
-begin data.
-13
-27
-30
-12
-26
-11
-10
-28
-29
-14
-15
-end data.
-sort cases by x.
-list.
-aggregate outfile='aggregate.save'/missing=columnwise /document /presorted/break=x(a) /z'label for z'=sum(y)/foo=nu.
-list.
diff --git a/tests/autorecod.stat b/tests/autorecod.stat
deleted file mode 100644 (file)
index b035c33..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-title 'Test for AUTORECODE procedure'.
-
-/* Tries AUTORECODE on some random but similar strings of characters.
-data list /x 1-5(a) y 7.
-begin data.
-lasdj 1 1                                                           3
-asdfk 0 3 <---- These are the numbers that should be produced for a 4
-asdfj 2 4                                                           2
-asdfj 1 4                                                           3
-asdfk 2 3                                                           2
-asdfj 9 4                                                           1
-lajks 9 2                                                           1
-asdfk 0 3 These are the numbers that should be produced for b ----> 4
-asdfk 1 3                                                           3
-end data.
-list.
-autorecode x y into a b/descend.
-
-/* This should produce the values indicated in the data above.
-list.
-
-/* Just to make sure it works on second & subsequent executions,
-/* try it again.
-compute z=trunc(y/2).
-autorecode z into w.
-
-/* This should display:
-/*   z 0 0 1 0 1 4 4 0 0
-/*   w 1 1 2 1 2 3 3 1 1
-list z w.
diff --git a/tests/beg-data.stat b/tests/beg-data.stat
deleted file mode 100644 (file)
index 6bf5a8f..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-title 'Test BEGIN DATA ... END DATA'.
-
-remark EOF
-----------------------------------------------------------------------
-First we show that we can input data with BEGIN DATA/END DATA after
-a procedure.
-----------------------------------------------------------------------
-EOF
-data list /A B 1-2.
-list.
-begin data.
-12
-34
-56
-78
-90
-end data.
-
-remark EOF
-----------------------------------------------------------------------
-Next we show that BEGIN DATA/END DATA work fine on their own as well.
-----------------------------------------------------------------------
-EOF
-data list /A B 1-2.
-begin data.
-09
-87
-65
-43
-21
-end data.
-list.
index 3104e36abff5da1b7ccb7973033bac2f6bf5580d..7509efa0f309fb49ea4d9d63202608e136a12ad5 100755 (executable)
@@ -5,6 +5,15 @@
 
 TEMPDIR=/tmp/pspp-tst-$$
 
+here=`pwd`;
+
+# ensure that top_srcdir is absolute
+cd $top_srcdir; top_srcdir=`pwd`
+
+
+export STAT_CONFIG_PATH=$top_srcdir/config
+
+
 cleanup()
 {
      rm -rf $TEMPDIR
@@ -36,7 +45,6 @@ pass()
 
 mkdir -p $TEMPDIR
 
-here=`pwd`;
 
 activity="create data"
 cat << EOF > $TEMPDIR/ff.stat 
@@ -54,12 +62,11 @@ frequencies v1 v2.
 EOF
 if [ $? -ne 0 ] ; then no_result ; fi
 
-cd $top_srcdir; top_srcdir=`pwd`
 
 cd $TEMPDIR
 
 activity="run data"
-$here/../src/pspp -B $top_srcdir/config $TEMPDIR/ff.stat
+$here/../src/pspp  $TEMPDIR/ff.stat
 if [ $? -ne 0 ] ; then fail ; fi
 
 
index 27b6f58a81547c42295c163e50d16b57ba30f6fe..dcfd41662ca9bd5caeb7b1329dc0ccad261185be 100755 (executable)
@@ -7,6 +7,13 @@
 
 TEMPDIR=/tmp/pspp-tst-$$
 
+here=`pwd`
+
+# ensure that top_srcdir is absolute
+cd $top_srcdir ; top_srcdir=`pwd`
+
+STAT_CONFIG_PATH=$top_srcdir/config
+
 cleanup()
 {
      rm -rf $TEMPDIR
@@ -38,7 +45,6 @@ pass()
 
 mkdir -p $TEMPDIR
 
-here=`pwd`;
 
 activity="create data"
 cat << EOF > $TEMPDIR/ff.stat 
@@ -55,11 +61,10 @@ frequencies v1 v2.
 EOF
 if [ $? -ne 0 ] ; then no_result ; fi
 
-cd $top_srcdir ; top_srcdir=`pwd`
 cd $TEMPDIR
 
 activity="run data"
-$here/../src/pspp -B $top_srcdir/config -o html $TEMPDIR/ff.stat
+$here/../src/pspp -o html $TEMPDIR/ff.stat
 if [ $? -ne 0 ] ; then fail ; fi
 
 
diff --git a/tests/command/aggregate.sh b/tests/command/aggregate.sh
new file mode 100755 (executable)
index 0000000..b84e63e
--- /dev/null
@@ -0,0 +1,85 @@
+#!/bin/sh
+
+# This program tests the aggregate procedure
+
+TEMPDIR=/tmp/pspp-tst-$$
+
+here=`pwd`;
+
+# ensure that top_srcdir is absolute
+cd $top_srcdir; top_srcdir=`pwd`
+
+export STAT_CONFIG_PATH=$top_srcdir/config
+
+cleanup()
+{
+     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="program create"
+cat > $TEMPDIR/test.sps << EOF
+
+data list notable /x y 1-2.
+begin data.
+13
+27
+30
+12
+26
+11
+10
+28
+29
+14
+15
+end data.
+sort cases by x.
+aggregate /missing=columnwise /document /presorted/break=x(a) /z'label for z'=sum(y)/foo=nu.
+list.
+EOF
+if [ $? -ne 0 ] ; then no_result ; fi
+
+activity="run program"
+$here/../src/pspp    -o raw-ascii $TEMPDIR/test.sps  
+if [ $? -ne 0 ] ; then no_result ; fi
+
+
+activity="test result"
+diff  -B $TEMPDIR/pspp.list - << EOF
+X        Z      FOO
+- -------- --------
+1    15.00     6.00 
+2    30.00     4.00 
+3      .00     1.00 
+EOF
+if [ $? -ne 0 ] ; then fail ; fi
+
+pass;
diff --git a/tests/command/autorecod.sh b/tests/command/autorecod.sh
new file mode 100755 (executable)
index 0000000..08428c1
--- /dev/null
@@ -0,0 +1,118 @@
+#!/bin/sh
+
+# This program tests the autorecode command
+
+TEMPDIR=/tmp/pspp-tst-$$
+
+here=`pwd`;
+
+# ensure that top_srcdir is absolute
+cd $top_srcdir; top_srcdir=`pwd`
+
+export STAT_CONFIG_PATH=$top_srcdir/config
+
+
+cleanup()
+{
+     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"
+cat > $TEMPDIR/prog.sps <<EOF
+/* Tries AUTORECODE on some random but similar strings of characters.
+data list /x 1-5(a) y 7.
+begin data.
+lasdj 1 1                                                           3
+asdfk 0 3 <---- These are the numbers that should be produced for a 4
+asdfj 2 4                                                           2
+asdfj 1 4                                                           3
+asdfk 2 3                                                           2
+asdfj 9 4                                                           1
+lajks 9 2                                                           1
+asdfk 0 3 These are the numbers that should be produced for b ----> 4
+asdfk 1 3                                                           3
+end data.
+
+autorecode x y into a b/descend.
+
+list.
+/* Just to make sure it works on second & subsequent executions,
+/* try it again.
+compute z=trunc(y/2).
+autorecode z into w.
+list.
+EOF
+if [ $? -ne 0 ] ; then no_result ; fi
+
+activity="run program"
+$here/../src/pspp    -o raw-ascii $TEMPDIR/prog.sps  
+if [ $? -ne 0 ] ; then no_result ; fi
+
+activity="test output"
+diff -B $TEMPDIR/pspp.list - <<EOF
+1.1 DATA LIST.  Reading 1 record from the command file.
++--------+------+-------+------+
+|Variable|Record|Columns|Format|
+#========#======#=======#======#
+|X       |     1|  1-  5|A5    |
+|Y       |     1|  7-  7|F1.0  |
++--------+------+-------+------+
+
+    X Y        A        B
+----- - -------- --------
+lasdj 1     1.00     3.00 
+asdfk 0     3.00     4.00 
+asdfj 2     4.00     2.00 
+asdfj 1     4.00     3.00 
+asdfk 2     3.00     2.00 
+asdfj 9     4.00     1.00 
+lajks 9     2.00     1.00 
+asdfk 0     3.00     4.00 
+asdfk 1     3.00     3.00 
+
+    X Y        A        B        Z        W
+----- - -------- -------- -------- --------
+lasdj 1     1.00     3.00      .00     1.00 
+asdfk 0     3.00     4.00      .00     1.00 
+asdfj 2     4.00     2.00     1.00     2.00 
+asdfj 1     4.00     3.00      .00     1.00 
+asdfk 2     3.00     2.00     1.00     2.00 
+asdfj 9     4.00     1.00     4.00     3.00 
+lajks 9     2.00     1.00     4.00     3.00 
+asdfk 0     3.00     4.00      .00     1.00 
+asdfk 1     3.00     3.00      .00     1.00 
+EOF
+if [ $? -ne 0 ] ; then fail ; fi
+
+pass
+
+
+
diff --git a/tests/command/beg-data.sh b/tests/command/beg-data.sh
new file mode 100755 (executable)
index 0000000..dc044bc
--- /dev/null
@@ -0,0 +1,136 @@
+#!/bin/sh
+
+# This program tests the BEGIN DATA / END DATA commands
+
+TEMPDIR=/tmp/pspp-tst-$$
+
+here=`pwd`;
+
+# ensure that top_srcdir is absolute
+cd $top_srcdir; top_srcdir=`pwd`
+
+export STAT_CONFIG_PATH=$top_srcdir/config
+
+
+cleanup()
+{
+     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"
+cat > $TEMPDIR/prog.sps << EOF_foobar
+title 'Test BEGIN DATA ... END DATA'.
+
+remark EOF
+----------------------------------------------------------------------
+First we show that we can input data with BEGIN DATA/END DATA after
+a procedure.
+----------------------------------------------------------------------
+EOF
+data list /A B 1-2.
+list.
+begin data.
+12
+34
+56
+78
+90
+end data.
+
+remark EOF
+----------------------------------------------------------------------
+Next we show that BEGIN DATA/END DATA work fine on their own as well.
+----------------------------------------------------------------------
+EOF
+data list /A B 1-2.
+begin data.
+09
+87
+65
+43
+21
+end data.
+list.
+EOF_foobar
+if [ $? -ne 0 ] ; then no_result ; fi
+
+
+activity="run program"
+$here/../src/pspp -o raw-ascii $TEMPDIR/prog.sps
+if [ $? -ne 0 ] ; then no_result ; fi
+
+activity="compare data"
+diff -B $TEMPDIR/pspp.list - << foobar
+----------------------------------------------------------------------
+First we show that we can input data with BEGIN DATA/END DATA after
+a procedure.
+----------------------------------------------------------------------
+
+1.1 DATA LIST.  Reading 1 record from the command file.
++--------+------+-------+------+
+|Variable|Record|Columns|Format|
+#========#======#=======#======#
+|A       |     1|  1-  1|F1.0  |
+|B       |     1|  2-  2|F1.0  |
++--------+------+-------+------+
+
+A B
+- -
+1 2 
+3 4 
+5 6 
+7 8 
+9 0 
+
+----------------------------------------------------------------------
+Next we show that BEGIN DATA/END DATA work fine on their own as well.
+----------------------------------------------------------------------
+
+2.1 DATA LIST.  Reading 1 record from the command file.
++--------+------+-------+------+
+|Variable|Record|Columns|Format|
+#========#======#=======#======#
+|A       |     1|  1-  1|F1.0  |
+|B       |     1|  2-  2|F1.0  |
++--------+------+-------+------+
+
+A B
+- -
+0 9 
+8 7 
+6 5 
+4 3 
+2 1 
+foobar
+if [ $? -ne 0 ] ; then fail ; fi
+
+
+pass;
diff --git a/tests/syntax b/tests/syntax
deleted file mode 100755 (executable)
index 00b4b7f..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-#!/bin/sh
-
-build_dir=`pwd`
-
-
-# This script tests that incorrect syntax on various commands produces the 
-# appropriate error messages
-
-set -e
-RESULT=pass
-
-
-#for x in `cd $srcdir; echo *.stat *.data`; do 
-#    if [ ! -e $x ]; then
-#      ln -s $srcdir/$x .
-#    fi
-#done
-
-rm -f *.actual
-if [ -z "$BENCHMARK" ]; then
-    for t in $top_srcdir/tests/*.stat; do
-       x=`basename $t`
-       echo -n "$x ... "
-#      if [ $x = bignum.stat ] ; then continue ; fi
-#      if [ $x = data-list.stat ] ; then continue ; fi
-#      if [ $x = do-repeat.stat ] ; then continue ; fi
-#      if [ $x = list.stat ] ; then continue ; fi
-#      if [ $x = print.stat ] ; then continue ; fi
-#      if [ $x = reread.stat ] ; then continue ; fi
-#      if [ $x = weighting.stat ] ; then continue ; fi
-       cat $t | ../src/pspp -B $top_srcdir/config --testing-mode - > $build_dir/$x.actual 
-       if [ -f $top_srcdir/tests/expect/$x ]; then
-           if diff -u $top_srcdir/tests/expect/$x $build_dir/$x.actual; then 
-               echo "pass"; rm $build_dir/$x.actual
-           else 
-               echo "FAIL"; RESULT=fail ; exit 1
-           fi
-       else
-           if [ -s $build_dir/$x.actual ]; then 
-               diff -u /dev/null $build_dir/$x.actual || true
-               echo "FAIL"; RESULT=fail ; exit 1
-           else 
-               echo "pass"; rm $build_dir/$x.actual
-           fi
-       fi
-    done
-else
-    mkdir $build_dir/benchmark || true
-    rm -f $build_dir/benchmark/*
-    for x in $top_srcdir/tests/*.stat; do
-       echo -n "$x ... "
-       ../src/pspp -B $top_srcdir/config --testing-mode $x > $build_dir/benchmark/$x
-       if [ ! -s $build_dirbenchmark/$x ]; then
-           rm $build_dir/benchmark/$x
-       fi
-       echo
-    done
-fi
-
-# for x in *.stat *.data; do
-#   if [ -h $x ]; then
-#      rm $x
-#    fi
-#done
-
-if [ $RESULT = fail ]; then exit 1; fi
-
diff --git a/tests/test_template b/tests/test_template
new file mode 100755 (executable)
index 0000000..664549c
--- /dev/null
@@ -0,0 +1,58 @@
+#!/bin/sh
+
+# This program tests ....
+
+TEMPDIR=/tmp/pspp-tst-$$
+
+here=`pwd`;
+
+# ensure that top_srcdir is absolute
+cd $top_srcdir; top_srcdir=`pwd`
+
+export STAT_CONFIG_PATH=$top_srcdir/config
+
+
+cleanup()
+{
+     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
+
+put test set up here ...
+
+if [ $? -ne 0 ] ; then no_result ; fi
+
+
+put test here
+
+if [ $? -ne 0 ] ; then fail ; fi
+
+
+pass;