8571ab5b71a0392897b048f2a1e2de659a0a6701
[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 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 | perl -e 's/^\s*$//g'
76 1.1 DATA LIST.  Reading free-form data from the command file.
77 +--------------+------+
78 |   Variable   |Format|
79 #==============#======#
80 |AlphaBetaGamma|F8.0  |
81 |B             |F8.0  |
82 |X             |F8.0  |
83 |Yabbadabbadoo |F8.0  |
84 +--------------+------+
85
86 AlphaBetaGamma        B        X Yabbadabbadoo
87 -------------- -------- -------- -------------
88           2.00     3.00     4.00          5.00 
89
90 2.1 CROSSTABS.  Summary.
91 #===============#=====================================================#
92 #               #                        Cases                        #
93 #               #-----------------+-----------------+-----------------#
94 #               #      Valid      |     Missing     |      Total      #
95 #               #--------+--------+--------+--------+--------+--------#
96 #               #       N| Percent|       N| Percent|       N| Percent#
97 #---------------#--------+--------+--------+--------+--------+--------#
98 #X *            #       1|  100.0%|       0|    0.0%|       1|  100.0%#
99 #Yabbadabbadoo  #        |        |        |        |        |        #
100 #===============#========#========#========#========#========#========#
101
102 2.2 CROSSTABS.  X by Yabbadabbadoo [count].
103 #===============#==============================================================#========#
104 #               #                         Yabbadabbadoo                        |        #
105 #               #--------+--------+--------+--------+--------+--------+--------+        #
106 #              X#    1.00|    2.00|    3.00|    4.00|    5.00|    6.00|    7.00|  Total #
107 #---------------#--------+--------+--------+--------+--------+--------+--------+--------#
108 #           1.00#      .0|      .0|      .0|      .0|      .0|      .0|      .0|      .0#
109 #           2.00#      .0|      .0|      .0|      .0|      .0|      .0|      .0|      .0#
110 #           3.00#      .0|      .0|      .0|      .0|      .0|      .0|      .0|      .0#
111 #           4.00#      .0|      .0|      .0|      .0|     1.0|      .0|      .0|     1.0#
112 #           5.00#      .0|      .0|      .0|      .0|      .0|      .0|      .0|      .0#
113 #           6.00#      .0|      .0|      .0|      .0|      .0|      .0|      .0|      .0#
114 #           7.00#      .0|      .0|      .0|      .0|      .0|      .0|      .0|      .0#
115 #Total          #     .0%|     .0%|     .0%|     .0%|    1.0%|     .0%|     .0%|    1.0%#
116 #===============#========#========#========#========#========#========#========#========#
117
118 EOF
119 if [ $? -ne 0 ] ; then fail ; fi
120
121
122 pass