49a7cd4c2a26c449034973e35e8f415fb7c5d0c3
[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 perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.list
85 diff  -b $TEMPDIR/pspp.list - <<EOF
86 1.1 DATA LIST.  Reading free-form data from INLINE.
87 +--------------+------+
88 |   Variable   |Format|
89 #==============#======#
90 |AlphaBetaGamma|F8.0  |
91 |B             |F8.0  |
92 |X             |F8.0  |
93 |Yabbadabbadoo |F8.0  |
94 +--------------+------+
95 AlphaBetaGamma        B        X Yabbadabbadoo
96 -------------- -------- -------- -------------
97           2.00     3.00     4.00          5.00 
98 2.1 CROSSTABS.  Summary.
99 #===============#=====================================================#
100 #               #                        Cases                        #
101 #               #-----------------+-----------------+-----------------#
102 #               #      Valid      |     Missing     |      Total      #
103 #               #--------+--------+--------+--------+--------+--------#
104 #               #       N| Percent|       N| Percent|       N| Percent#
105 #---------------#--------+--------+--------+--------+--------+--------#
106 #X *            #       1|  100.0%|       0|    0.0%|       1|  100.0%#
107 #Yabbadabbadoo  #        |        |        |        |        |        #
108 #===============#========#========#========#========#========#========#
109 2.2 CROSSTABS.  X by Yabbadabbadoo [count].
110 #===============#==============================================================#========#
111 #               #                         Yabbadabbadoo                        |        #
112 #               #--------+--------+--------+--------+--------+--------+--------+        #
113 #              X#    1.00|    2.00|    3.00|    4.00|    5.00|    6.00|    7.00|  Total #
114 #---------------#--------+--------+--------+--------+--------+--------+--------+--------#
115 #           1.00#      .0|      .0|      .0|      .0|      .0|      .0|      .0|      .0#
116 #           2.00#      .0|      .0|      .0|      .0|      .0|      .0|      .0|      .0#
117 #           3.00#      .0|      .0|      .0|      .0|      .0|      .0|      .0|      .0#
118 #           4.00#      .0|      .0|      .0|      .0|     1.0|      .0|      .0|     1.0#
119 #           5.00#      .0|      .0|      .0|      .0|      .0|      .0|      .0|      .0#
120 #           6.00#      .0|      .0|      .0|      .0|      .0|      .0|      .0|      .0#
121 #           7.00#      .0|      .0|      .0|      .0|      .0|      .0|      .0|      .0#
122 #Total          #      .0|      .0|      .0|      .0|     1.0|      .0|      .0|     1.0#
123 #===============#========#========#========#========#========#========#========#========#
124 EOF
125 if [ $? -ne 0 ] ; then fail ; fi
126
127
128 pass