Fix use of "export" to work with traditional shells.
[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      rm -rf $TEMPDIR
20 }
21
22
23 fail()
24 {
25     echo $activity
26     echo FAILED
27     cleanup;
28     exit 1;
29 }
30
31
32 no_result()
33 {
34     echo $activity
35     echo NO RESULT;
36     cleanup;
37     exit 2;
38 }
39
40 pass()
41 {
42     cleanup;
43     exit 0;
44 }
45
46 mkdir -p $TEMPDIR
47
48 cd $TEMPDIR
49
50 # Use crosstabs, since its TABLES subcommand exercises the array var set 
51 # feature.
52 activity="create program"
53 cat > $TESTFILE <<EOF
54 DATA LIST LIST /AlphaBetaGamma * B * X * Yabbadabbadoo * .
55 BEGIN DATA.
56 2 3 4 5
57 END DATA.
58
59 LIST.
60
61 CROSSTABS 
62         VARIABLES X (1,7) Yabbadabbadoo (1,7) 
63         /TABLES X BY Yabbadabbadoo.
64 EOF
65 if [ $? -ne 0 ] ; then no_result ; fi
66
67
68 activity="run program"
69 $SUPERVISOR $here/../src/pspp -o raw-ascii $TESTFILE
70 if [ $? -ne 0 ] ; then no_result ; fi
71
72 activity="compare output"
73 diff -B -b $TEMPDIR/pspp.list - <<EOF
74 1.1 DATA LIST.  Reading free-form data from the command file.
75 +--------------+------+
76 |   Variable   |Format|
77 #==============#======#
78 |AlphaBetaGamma|F8.0  |
79 |B             |F8.0  |
80 |X             |F8.0  |
81 |Yabbadabbadoo |F8.0  |
82 +--------------+------+
83
84 AlphaBetaGamma        B        X Yabbadabbadoo
85 -------------- -------- -------- -------------
86           2.00     3.00     4.00          5.00 
87
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
100 2.2 CROSSTABS.  X by Yabbadabbadoo [count].
101 #===============#==============================================================#========#
102 #               #                         Yabbadabbadoo                        |        #
103 #               #--------+--------+--------+--------+--------+--------+--------+        #
104 #              X#    1.00|    2.00|    3.00|    4.00|    5.00|    6.00|    7.00|  Total #
105 #---------------#--------+--------+--------+--------+--------+--------+--------+--------#
106 #           1.00#      .0|      .0|      .0|      .0|      .0|      .0|      .0|      .0#
107 #           2.00#      .0|      .0|      .0|      .0|      .0|      .0|      .0|      .0#
108 #           3.00#      .0|      .0|      .0|      .0|      .0|      .0|      .0|      .0#
109 #           4.00#      .0|      .0|      .0|      .0|     1.0|      .0|      .0|     1.0#
110 #           5.00#      .0|      .0|      .0|      .0|      .0|      .0|      .0|      .0#
111 #           6.00#      .0|      .0|      .0|      .0|      .0|      .0|      .0|      .0#
112 #           7.00#      .0|      .0|      .0|      .0|      .0|      .0|      .0|      .0#
113 #Total          #     .0%|     .0%|     .0%|     .0%|    1.0%|     .0%|     .0%|    1.0%#
114 #===============#========#========#========#========#========#========#========#========#
115
116 EOF
117 if [ $? -ne 0 ] ; then fail ; fi
118
119
120 pass