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