Rewrite and improve formatted output routines.
[pspp-builds.git] / tests / formats / num-out.sh
1 #! /bin/sh
2
3 TEMPDIR=/tmp/pspp-tst-$$
4 mkdir -p $TEMPDIR
5 trap 'cd /; rm -rf $TEMPDIR' 0
6
7 # ensure that top_builddir  are absolute
8 if [ -z "$top_builddir" ] ; then top_builddir=. ; fi
9 if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi
10 top_builddir=`cd $top_builddir; pwd`
11 PSPP=$top_builddir/src/ui/terminal/pspp
12
13 # ensure that top_srcdir is absolute
14 top_srcdir=`cd $top_srcdir; pwd`
15
16 STAT_CONFIG_PATH=$top_srcdir/config
17 export STAT_CONFIG_PATH
18
19 fail()
20 {
21     echo $activity
22     echo FAILED
23     exit 1;
24 }
25
26
27 no_result()
28 {
29     echo $activity
30     echo NO RESULT;
31     exit 2;
32 }
33
34 pass()
35 {
36     exit 0;
37 }
38
39 cd $TEMPDIR
40
41 activity="generate pspp syntax"
42 $PERL $top_srcdir/tests/formats/num-out.pl > num-out.pspp
43 if [ $? -ne 0 ] ; then no_result ; fi
44 echo -n .
45
46 activity="run program"
47 $SUPERVISOR $PSPP --testing-mode num-out.pspp
48 if [ $? -ne 0 ] ; then no_result ; fi
49 echo -n .
50
51 activity="inexactify results"
52 $top_builddir/tests/formats/inexactify < output.txt > output.inexact
53 if [ $? -ne 0 ] ; then no_result ; fi
54 echo -n .
55
56 activity="gunzip expected results"
57 gzip -cd < $top_srcdir/tests/formats/num-out.expected.cmp.gz > expected.txt.cmp
58 if [ $? -ne 0 ] ; then no_result ; fi
59 echo -n .
60
61 activity="decompress expected results"
62 $PERL $top_srcdir/tests/formats/num-out-decmp.pl < expected.txt.cmp > expected.txt
63 if [ $? -ne 0 ] ; then no_result ; fi
64 echo -n .
65
66 activity="inexactify expected results"
67 $top_builddir/tests/formats/inexactify < expected.txt > expected.inexact
68 if [ $? -ne 0 ] ; then no_result ; fi
69 echo -n .
70
71 activity="compare output"
72 $PERL $top_srcdir/tests/formats/num-out-compare.pl \
73         $PSPP_NUM_OUT_COMPARE_FLAGS expected.inexact output.inexact
74 if [ $? -ne 0 ] ; then fail ; fi
75
76 echo .
77
78 pass