From c1edead52e3b254bc305afd1d647b94bd10ca5d4 Mon Sep 17 00:00:00 2001 From: John Darrington Date: Mon, 15 Dec 2003 13:48:52 +0000 Subject: [PATCH] Started converting the make check target to aegis style tests --- config/devices | 2 + src/ascii.c | 3 +- src/output.c | 2 +- tests/Makefile.am | 8 +- tests/aggregate.stat | 20 ----- tests/autorecod.stat | 30 -------- tests/beg-data.stat | 32 -------- tests/bugs/double-frequency.sh | 13 +++- tests/bugs/html-frequency.sh | 11 ++- tests/command/aggregate.sh | 85 +++++++++++++++++++++ tests/command/autorecod.sh | 118 ++++++++++++++++++++++++++++ tests/command/beg-data.sh | 136 +++++++++++++++++++++++++++++++++ tests/syntax | 67 ---------------- tests/test_template | 58 ++++++++++++++ 14 files changed, 426 insertions(+), 159 deletions(-) delete mode 100644 tests/aggregate.stat delete mode 100644 tests/autorecod.stat delete mode 100644 tests/beg-data.stat create mode 100755 tests/command/aggregate.sh create mode 100755 tests/command/autorecod.sh create mode 100755 tests/command/beg-data.sh delete mode 100755 tests/syntax create mode 100755 tests/test_template diff --git a/config/devices b/config/devices index c1aa6c00..4f97446f 100644 --- a/config/devices +++ b/config/devices @@ -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} diff --git a/src/ascii.c b/src/ascii.c index c6f48f00..f6b39238 100644 --- a/src/ascii.c +++ b/src/ascii.c @@ -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; diff --git a/src/output.c b/src/output.c index 86e8534c..370ad591 100644 --- a/src/output.c +++ b/src/output.c @@ -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; diff --git a/tests/Makefile.am b/tests/Makefile.am index 0e633454..8de36776 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -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 index 3a95532c..00000000 --- a/tests/aggregate.stat +++ /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 index b035c336..00000000 --- a/tests/autorecod.stat +++ /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 index 6bf5a8f5..00000000 --- a/tests/beg-data.stat +++ /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. diff --git a/tests/bugs/double-frequency.sh b/tests/bugs/double-frequency.sh index 3104e36a..7509efa0 100755 --- a/tests/bugs/double-frequency.sh +++ b/tests/bugs/double-frequency.sh @@ -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 diff --git a/tests/bugs/html-frequency.sh b/tests/bugs/html-frequency.sh index 27b6f58a..dcfd4166 100755 --- a/tests/bugs/html-frequency.sh +++ b/tests/bugs/html-frequency.sh @@ -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 index 00000000..b84e63eb --- /dev/null +++ b/tests/command/aggregate.sh @@ -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 index 00000000..08428c1e --- /dev/null +++ b/tests/command/autorecod.sh @@ -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 < 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 - < $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 index 00b4b7ff..00000000 --- a/tests/syntax +++ /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 index 00000000..664549cd --- /dev/null +++ b/tests/test_template @@ -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; -- 2.30.2