Rewrite PSPP output engine.
[pspp-builds.git] / tests / command / longvars.sh
1 #!/bin/sh
2
3 # This program tests that both long and short variable names are parsed OK.
4
5 TEMPDIR=/tmp/pspp-tst-$$
6 TESTFILE=$TEMPDIR/`basename $0`.sps
7
8 # ensure that top_builddir  are absolute
9 if [ -z "$top_builddir" ] ; then top_builddir=. ; fi
10 if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi
11 top_builddir=`cd $top_builddir; pwd`
12 PSPP=$top_builddir/src/ui/terminal/pspp
13
14 # ensure that top_srcdir is absolute
15 top_srcdir=`cd $top_srcdir; pwd`
16
17 STAT_CONFIG_PATH=$top_srcdir/config
18 export STAT_CONFIG_PATH
19
20 LANG=C
21 export LANG
22
23 cleanup()
24 {
25      if [ x"$PSPP_TEST_NO_CLEANUP" != x ] ; then 
26         echo "NOT cleaning $TEMPDIR" 
27         return ; 
28      fi
29      cd /
30      rm -rf $TEMPDIR
31 }
32
33
34 fail()
35 {
36     echo $activity
37     echo FAILED
38     cleanup;
39     exit 1;
40 }
41
42
43 no_result()
44 {
45     echo $activity
46     echo NO RESULT;
47     cleanup;
48     exit 2;
49 }
50
51 pass()
52 {
53     cleanup;
54     exit 0;
55 }
56
57 mkdir -p $TEMPDIR
58
59 cd $TEMPDIR
60
61 # Use crosstabs, since its TABLES subcommand exercises the array var set 
62 # feature.
63 activity="create program"
64 cat > $TESTFILE <<EOF
65 DATA LIST LIST /AlphaBetaGamma * B * X * Yabbadabbadoo * .
66 BEGIN DATA.
67 2 3 4 5
68 END DATA.
69
70 LIST.
71
72 CROSSTABS 
73         VARIABLES X (1,7) Yabbadabbadoo (1,7) 
74         /TABLES X BY Yabbadabbadoo.
75 EOF
76 if [ $? -ne 0 ] ; then no_result ; fi
77
78
79 activity="run program"
80 $SUPERVISOR $PSPP --testing-mode $TESTFILE
81 if [ $? -ne 0 ] ; then no_result ; fi
82
83 activity="compare output"
84 diff -c $TEMPDIR/pspp.csv - <<EOF
85 Table: Reading free-form data from INLINE.
86 Variable,Format
87 AlphaBetaGamma,F8.0
88 B,F8.0
89 X,F8.0
90 Yabbadabbadoo,F8.0
91
92 Table: Data List
93 AlphaBetaGamma,B,X,Yabbadabbadoo
94 2.00,3.00,4.00,5.00
95
96 Table: Summary.
97 ,Cases,,,,,
98 ,Valid,,Missing,,Total,
99 ,N,Percent,N,Percent,N,Percent
100 X * Yabbadabbadoo,1,100.0%,0,0.0%,1,100.0%
101
102 Table: X * Yabbadabbadoo [count].
103 ,Yabbadabbadoo,,,,,,,
104 X,1.00,2.00,3.00,4.00,5.00,6.00,7.00,Total
105 1.00,.0,.0,.0,.0,.0,.0,.0,.0
106 2.00,.0,.0,.0,.0,.0,.0,.0,.0
107 3.00,.0,.0,.0,.0,.0,.0,.0,.0
108 4.00,.0,.0,.0,.0,1.0,.0,.0,1.0
109 5.00,.0,.0,.0,.0,.0,.0,.0,.0
110 6.00,.0,.0,.0,.0,.0,.0,.0,.0
111 7.00,.0,.0,.0,.0,.0,.0,.0,.0
112 Total,.0,.0,.0,.0,1.0,.0,.0,1.0
113 EOF
114 if [ $? -ne 0 ] ; then fail ; fi
115
116
117 pass