Rewrite PSPP output engine.
[pspp-builds.git] / tests / command / print.sh
1 #!/bin/sh
2
3 # This program tests unusual aspects of the PRINT and WRITE
4 # transformations:
5 #
6 #   - PRINT puts spaces between variables, unless a format 
7 #     is specified explicitly.
8 #
9 #   - WRITE doesn't put space between variables.
10 #
11 #   - PRINT to an external file prefixes each line with a space.
12 #
13 #   - PRINT EJECT to an external file indicates a formfeed by a "1"
14 #     in the first column.
15 #
16 #   - WRITE writes out spaces for system-missing values, not a period.
17 #
18 #   - When no output is specified, an empty record is output.
19
20 TEMPDIR=/tmp/pspp-tst-$$
21 TESTFILE=$TEMPDIR/`basename $0`.sps
22
23 # ensure that top_builddir  are absolute
24 if [ -z "$top_builddir" ] ; then top_builddir=. ; fi
25 if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi
26 top_builddir=`cd $top_builddir; pwd`
27 PSPP=$top_builddir/src/ui/terminal/pspp
28
29 # ensure that top_srcdir is absolute
30 top_srcdir=`cd $top_srcdir; pwd`
31
32 STAT_CONFIG_PATH=$top_srcdir/config
33 export STAT_CONFIG_PATH
34
35 LANG=C
36 export LANG
37
38 cleanup()
39 {
40      if [ x"$PSPP_TEST_NO_CLEANUP" != x ] ; then 
41         echo "NOT cleaning $TEMPDIR" 
42         return ; 
43      fi
44      cd /
45      rm -rf $TEMPDIR
46 }
47
48
49 fail()
50 {
51     echo $activity
52     echo FAILED
53     cleanup;
54     exit 1;
55 }
56
57
58 no_result()
59 {
60     echo $activity
61     echo NO RESULT;
62     cleanup;
63     exit 2;
64 }
65
66 pass()
67 {
68     cleanup;
69     exit 0;
70 }
71
72 mkdir -p $TEMPDIR
73
74 cd $TEMPDIR
75
76 activity="create program"
77 cat > $TEMPDIR/print.stat << foobar
78 data list notable /x y 1-2.
79 begin data.
80 12
81 34
82  6 
83
84 90
85 end data.
86
87 print /x y.
88 print eject /x y 1-2.
89 print /x '-' y.
90 print.
91
92 print outfile='print.out' /x y.
93 print eject outfile='print.out' /x y (f1,f1).
94 print outfile='print.out' /x '-' y.
95 print outfile='print.out'.
96
97 write outfile='write.out' /x y.
98 write outfile='write.out' /x y (2(f1)).
99 write outfile='write.out' /x '-' y.
100 write outfile='write.out'.
101
102 execute.
103 foobar
104 if [ $? -ne 0 ] ; then no_result ; fi
105
106
107 activity="run program"
108 $SUPERVISOR $PSPP --testing-mode --error-file=$TEMPDIR/errs $TEMPDIR/print.stat 
109 if [ $? -ne 0 ] ; then fail ; fi
110
111 activity="compare print.out"
112 diff $TEMPDIR/print.out - <<EOF
113  1 2 
114 112
115  1 -2 
116  
117  3 4 
118 134
119  3 -4 
120  
121  . 6 
122 1.6
123  . -6 
124  
125  7 . 
126 17.
127  7 -. 
128  
129  9 0 
130 190
131  9 -0 
132  
133 EOF
134 if [ $? -ne 0 ] ; then fail ; fi
135
136 activity="compare write.out"
137 diff $TEMPDIR/write.out - <<EOF
138 12
139 12
140 1-2
141
142 34
143 34
144 3-4
145
146  6
147  6
148  -6
149
150
151
152 7- 
153
154 90
155 90
156 9-0
157
158 EOF
159 if [ $? -ne 0 ] ; then fail ; fi
160
161 activity="compare output"
162 diff $TEMPDIR/pspp.csv - << EOF
163 1 2 
164
165
166
167 12
168
169 1 -2 
170
171
172
173 3 4 
174
175
176
177 34
178
179 3 -4 
180
181
182
183 . 6 
184
185
186
187 .6
188
189 . -6 
190
191
192
193 7 . 
194
195
196
197 7.
198
199 7 -. 
200
201
202
203 9 0 
204
205
206
207 90
208
209 9 -0 
210
211
212 EOF
213 if [ $? -ne 0 ] ; then fail ; fi
214
215 pass;