#!/bin/sh
#
# This is a simple script that tests pspp
#
# install as: /usr/lib/debian-test/tests/pspp
# or else as: /usr/lib/debian-test/tests/pspp/test-1
# In the latter case, /usr/lib/debian-test/tests/pspp/ can contain
# other file with test data and/or other scripts named test-2, test-3, etc.
#
# You can run this script with the command
#       sh debian/tests
# After installation, you can run it with the commands
#       /usr/lib/debian-test/tests/pspp
# or
#       debian-test -v pspp
# see debian-test(1)

. ${DEBIANTEST_LIB:-/usr/lib/debian-test/lib}/functions.sh

if [ -f my-data-file ]; then
    TESTDIR=`pwd`;
else
    TESTDIR=/usr/lib/debian-test/tests/pspp;
fi


## We need a scratch directory in which to execute

TMP=/tmp/pspp-test.$$
test -e $TMP && rm -rf $TMP
mkdir $TMP
cd $TMP
trap "rm -rf $TMP" EXIT

test1(){
    RESULT=0
# This is one of the examples shipped with pspp
    cat >descript.stat <<EOF
title 'Test DESCRIPTIVES procedure'.

data list / v0 to v16 1-17.
begin data.
12128989012389023
34128080123890128
56127781237893217
78127378123793112
90913781237892318
37978547878935789
52878237892378279
12377912789378932
26787654347894348
29137178947891888
end data.

descript all/stat=all/format=serial.

EOF
    pspp descript.stat
    if grep -q "V4.*-2.51" pspp.list; then true; else RESULT=1; fi
    return $RESULT
}

runtest "descriptive statistics" test1

