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