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