Rewrite PSPP output engine.
[pspp-builds.git] / tests / command / n_of_cases.sh
1 #!/bin/sh
2
3 # This program tests the N OF CASES command to make sure
4 # that it actually works.
5
6 TEMPDIR=/tmp/pspp-tst-$$
7 TESTFILE=$TEMPDIR/`basename $0`.sps
8
9 # ensure that top_srcdir and top_builddir  are absolute
10 if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi
11 if [ -z "$top_builddir" ] ; then top_builddir=. ; fi
12 top_srcdir=`cd $top_srcdir; pwd`
13 top_builddir=`cd $top_builddir; pwd`
14
15 PSPP=$top_builddir/src/ui/terminal/pspp
16
17 STAT_CONFIG_PATH=$top_srcdir/config
18 export STAT_CONFIG_PATH
19
20 LANG=C
21 export LANG
22
23
24 cleanup()
25 {
26      if [ x"$PSPP_TEST_NO_CLEANUP" != x ] ; then 
27         echo "NOT cleaning $TEMPDIR"
28         return ; 
29      fi
30      cd /
31      rm -rf $TEMPDIR
32 }
33
34
35 fail()
36 {
37     echo $activity
38     echo FAILED
39     cleanup;
40     exit 1;
41 }
42
43
44 no_result()
45 {
46     echo $activity
47     echo NO RESULT;
48     cleanup;
49     exit 2;
50 }
51
52 pass()
53 {
54     cleanup;
55     exit 0;
56 }
57
58 mkdir -p $TEMPDIR
59
60 cd $TEMPDIR
61
62 cat > $TESTFILE <<EOF
63 INPUT PROGRAM.
64 LOOP #I = 1 TO 100.
65 COMPUTE X=#I.
66 END CASE.
67 END LOOP.
68 END FILE.
69 END INPUT PROGRAM.
70
71 N OF CASES 15.
72
73 LIST.
74 EOF
75 if [ $? -ne 0 ] ; then no_result ; fi
76
77
78 activity="run program"
79 $SUPERVISOR $PSPP --testing-mode $TESTFILE
80 if [ $? -ne 0 ] ; then no_result ; fi
81
82
83 activity="compare output"
84 diff -c $TEMPDIR/pspp.csv - <<EOF
85 Table: Data List
86 X
87 1.00
88 2.00
89 3.00
90 4.00
91 5.00
92 6.00
93 7.00
94 8.00
95 9.00
96 10.00
97 11.00
98 12.00
99 13.00
100 14.00
101 15.00
102 EOF
103 if [ $? -ne 0 ] ; then fail ; fi
104
105
106 pass;