Only taint casereader if case size is unknown.
[pspp] / 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      cd /
26      rm -rf $TEMPDIR
27 }
28
29
30 fail()
31 {
32     echo $activity
33     echo FAILED
34     cleanup;
35     exit 1;
36 }
37
38
39 no_result()
40 {
41     echo $activity
42     echo NO RESULT;
43     cleanup;
44     exit 2;
45 }
46
47 pass()
48 {
49     cleanup;
50     exit 0;
51 }
52
53 mkdir -p $TEMPDIR
54
55 cd $TEMPDIR
56
57 # Use crosstabs, since its TABLES subcommand exercises the array var set 
58 # feature.
59 activity="create program"
60 cat > $TESTFILE <<EOF
61 DATA LIST LIST /AlphaBetaGamma * B * X * Yabbadabbadoo * .
62 BEGIN DATA.
63 2 3 4 5
64 END DATA.
65
66 LIST.
67
68 CROSSTABS 
69         VARIABLES X (1,7) Yabbadabbadoo (1,7) 
70         /TABLES X BY Yabbadabbadoo.
71 EOF
72 if [ $? -ne 0 ] ; then no_result ; fi
73
74
75 activity="run program"
76 $SUPERVISOR $PSPP -o raw-ascii $TESTFILE
77 if [ $? -ne 0 ] ; then no_result ; fi
78
79 activity="compare output"
80 perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.list
81 diff  -b $TEMPDIR/pspp.list - <<EOF
82 1.1 DATA LIST.  Reading free-form data from INLINE.
83 +--------------+------+
84 |   Variable   |Format|
85 #==============#======#
86 |AlphaBetaGamma|F8.0  |
87 |B             |F8.0  |
88 |X             |F8.0  |
89 |Yabbadabbadoo |F8.0  |
90 +--------------+------+
91 AlphaBetaGamma        B        X Yabbadabbadoo
92 -------------- -------- -------- -------------
93           2.00     3.00     4.00          5.00 
94 2.1 CROSSTABS.  Summary.
95 #===============#=====================================================#
96 #               #                        Cases                        #
97 #               #-----------------+-----------------+-----------------#
98 #               #      Valid      |     Missing     |      Total      #
99 #               #--------+--------+--------+--------+--------+--------#
100 #               #       N| Percent|       N| Percent|       N| Percent#
101 #---------------#--------+--------+--------+--------+--------+--------#
102 #X *            #       1|  100.0%|       0|    0.0%|       1|  100.0%#
103 #Yabbadabbadoo  #        |        |        |        |        |        #
104 #===============#========#========#========#========#========#========#
105 2.2 CROSSTABS.  X by Yabbadabbadoo [count].
106 #===============#==============================================================#========#
107 #               #                         Yabbadabbadoo                        |        #
108 #               #--------+--------+--------+--------+--------+--------+--------+        #
109 #              X#    1.00|    2.00|    3.00|    4.00|    5.00|    6.00|    7.00|  Total #
110 #---------------#--------+--------+--------+--------+--------+--------+--------+--------#
111 #           1.00#      .0|      .0|      .0|      .0|      .0|      .0|      .0|      .0#
112 #           2.00#      .0|      .0|      .0|      .0|      .0|      .0|      .0|      .0#
113 #           3.00#      .0|      .0|      .0|      .0|      .0|      .0|      .0|      .0#
114 #           4.00#      .0|      .0|      .0|      .0|     1.0|      .0|      .0|     1.0#
115 #           5.00#      .0|      .0|      .0|      .0|      .0|      .0|      .0|      .0#
116 #           6.00#      .0|      .0|      .0|      .0|      .0|      .0|      .0|      .0#
117 #           7.00#      .0|      .0|      .0|      .0|      .0|      .0|      .0|      .0#
118 #Total          #     .0%|     .0%|     .0%|     .0%|    1.0%|     .0%|     .0%|    1.0%#
119 #===============#========#========#========#========#========#========#========#========#
120 EOF
121 if [ $? -ne 0 ] ; then fail ; fi
122
123
124 pass