c5de1e9fe6f40992fc9c8d0d23b4249c0d242464
[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      cd /
41      rm -rf $TEMPDIR
42 }
43
44
45 fail()
46 {
47     echo $activity
48     echo FAILED
49     cleanup;
50     exit 1;
51 }
52
53
54 no_result()
55 {
56     echo $activity
57     echo NO RESULT;
58     cleanup;
59     exit 2;
60 }
61
62 pass()
63 {
64     cleanup;
65     exit 0;
66 }
67
68 mkdir -p $TEMPDIR
69
70 cd $TEMPDIR
71
72 activity="create program"
73 cat > $TEMPDIR/print.stat << foobar
74 data list notable /x y 1-2.
75 begin data.
76 12
77 34
78  6 
79
80 90
81 end data.
82
83 print /x y.
84 print eject /x y 1-2.
85 print /x '-' y.
86 print.
87
88 print outfile='print.out' /x y.
89 print eject outfile='print.out' /x y (f1,f1).
90 print outfile='print.out' /x '-' y.
91 print outfile='print.out'.
92
93 write outfile='write.out' /x y.
94 write outfile='write.out' /x y (2(f1)).
95 write outfile='write.out' /x '-' y.
96 write outfile='write.out'.
97
98 execute.
99 foobar
100 if [ $? -ne 0 ] ; then no_result ; fi
101
102
103 activity="run program"
104 $SUPERVISOR $PSPP --testing-mode --error-file=$TEMPDIR/errs $TEMPDIR/print.stat 
105 if [ $? -ne 0 ] ; then fail ; fi
106
107 activity="compare print.out"
108 diff $TEMPDIR/print.out - <<EOF
109  1 2 
110 112
111  1 -2 
112  
113  3 4 
114 134
115  3 -4 
116  
117  . 6 
118 1.6
119  . -6 
120  
121  7 . 
122 17.
123  7 -. 
124  
125  9 0 
126 190
127  9 -0 
128  
129 EOF
130 if [ $? -ne 0 ] ; then fail ; fi
131
132 activity="compare write.out"
133 diff $TEMPDIR/write.out - <<EOF
134 12
135 12
136 1-2
137
138 34
139 34
140 3-4
141
142  6
143  6
144  -6
145
146
147
148 7- 
149
150 90
151 90
152 9-0
153
154 EOF
155 if [ $? -ne 0 ] ; then fail ; fi
156
157 activity="compare output"
158 diff $TEMPDIR/pspp.list - << EOF
159 1 2 
160
161 12
162 1 -2 
163
164 3 4 
165
166 34
167 3 -4 
168
169 . 6 
170
171 .6
172 . -6 
173
174 7 . 
175
176 7.
177 7 -. 
178
179 9 0 
180
181 90
182 9 -0 
183
184 EOF
185 if [ $? -ne 0 ] ; then fail ; fi
186
187 pass;