Fix use of "export" to work with traditional shells.
[pspp-builds.git] / tests / command / print.sh
1 #!/bin/sh
2
3 # This program tests the PRINT transformation
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 # Copy this file --- it's shared with another test
51 activity="create data"
52 cp $top_srcdir/tests/data-list.data $TEMPDIR
53 if [ $? -ne 0 ] ; then no_result ; fi
54
55
56 activity="create program"
57 cat > $TEMPDIR/print.stat << foobar
58 title 'Test PRINT transformation'.
59
60 data list free table file='$TEMPDIR/data-list.data'/A B C D.
61 print outfile="foo" table/A(f8.2) '/' B(e8.2) '/' C(n10) '/'.
62 print space a.
63 print outfile="foo" /a b c d.
64 list.
65
66 data list list table file='$TEMPDIR/data-list.data'/A B C D.
67 print table/A B C D.
68 list.
69
70 foobar
71 if [ $? -ne 0 ] ; then no_result ; fi
72
73
74 activity="run program"
75 $SUPERVISOR $here/../src/pspp --testing-mode -o raw-ascii --testing-mode $TEMPDIR/print.stat > $TEMPDIR/errs
76 # Note   vv   --- there are errors in input.  Therefore, the  command must FAIL
77 if [ $? -eq 0 ] ; then fail ; fi
78
79 activity="compare error messages"
80 diff -w $TEMPDIR/errs - <<EOF
81 $TEMPDIR/data-list.data:1: error: (columns 1-5, field type F8.0) Field does not form a valid floating-point constant.
82 $TEMPDIR/data-list.data:1: warning: LIST: The expression on PRINT SPACE evaluated to the system-missing value.
83 $TEMPDIR/data-list.data:2: error: (columns 1-8, field type F8.0) Field does not form a valid floating-point constant.
84 $TEMPDIR/data-list.data:4: warning: LIST: The expression on PRINT SPACE evaluated to the system-missing value.
85 $TEMPDIR/data-list.data:4: error: (columns 3-12, field type F8.0) Field does not form a valid floating-point constant.
86 $TEMPDIR/data-list.data:6: warning: LIST: The expression on PRINT SPACE evaluated to the system-missing value.
87 $TEMPDIR/data-list.data:1: error: (columns 1-5, field type F8.0) Field does not form a valid floating-point constant.
88 $TEMPDIR/data-list.data:2: error: (columns 1-8, field type F8.0) Field does not form a valid floating-point constant.
89 $TEMPDIR/data-list.data:2: warning: LIST: Missing value(s) for all variables from C onward.  These will be filled with the system-missing value or blanks, as appropriate.
90 $TEMPDIR/data-list.data:3: warning: LIST: Missing value(s) for all variables from B onward.  These will be filled with the system-missing value or blanks, as appropriate.
91 $TEMPDIR/data-list.data:4: error: (columns 3-12, field type F8.0) Field does not form a valid floating-point constant.
92 $TEMPDIR/data-list.data:4: warning: LIST: Missing value(s) for all variables from C onward.  These will be filled with the system-missing value or blanks, as appropriate.
93 $TEMPDIR/data-list.data:5: warning: LIST: Missing value(s) for all variables from C onward.  These will be filled with the system-missing value or blanks, as appropriate.
94 $TEMPDIR/data-list.data:6: warning: LIST: Missing value(s) for all variables from B onward.  These will be filled with the system-missing value or blanks, as appropriate.
95 EOF
96 if [ $? -ne 0 ] ; then fail ; fi
97
98
99 activity="compare output"
100 diff -b -B $TEMPDIR/pspp.list - << EOF
101 1.1 DATA LIST.  Reading free-form data from file $TEMPDIR/data-list.data.
102 +--------+------+
103 |Variable|Format|
104 #========#======#
105 |A       |F8.0  |
106 |B       |F8.0  |
107 |C       |F8.0  |
108 |D       |F8.0  |
109 +--------+------+
110
111 2.1 PRINT.  Writing 1 record(s) to file foo.
112 +--------+------+-------+------+
113 |Variable|Record|Columns|Format|
114 #========#======#=======#======#
115 |A       |     1|  1-  8|F8.2  |
116 |"/"     |     1|  9-  9|A1    |
117 |B       |     1| 10- 17|E8.2  |
118 |"/"     |     1| 18- 18|A1    |
119 |C       |     1| 19- 28|N10.0 |
120 |"/"     |     1| 29- 29|A1    |
121 +--------+------+-------+------+
122
123
124        A        B        C        D
125 -------- -------- -------- --------
126      .       2.00     3.00     4.00 
127
128      .       6.00     7.00     8.00 
129
130      .      10.00    11.00    12.00 
131
132 3.1 DATA LIST.  Reading free-form data from file $TEMPDIR/data-list.data.
133 +--------+------+
134 |Variable|Format|
135 #========#======#
136 |A       |F8.0  |
137 |B       |F8.0  |
138 |C       |F8.0  |
139 |D       |F8.0  |
140 +--------+------+
141
142 4.1 PRINT.  Writing 1 record(s) to the listing file.
143 +--------+------+-------+------+
144 |Variable|Record|Columns|Format|
145 #========#======#=======#======#
146 |A       |     1|  1-  8|F8.2  |
147 |B       |     1| 10- 17|F8.2  |
148 |C       |     1| 19- 26|F8.2  |
149 |D       |     1| 28- 35|F8.2  |
150 +--------+------+-------+------+
151      .       2.00     3.00     4.00 
152
153        A        B        C        D
154 -------- -------- -------- --------
155      .       2.00     3.00     4.00 
156      .       6.00      .        .   
157      .       6.00      .        .   
158     7.00      .        .        .   
159     7.00      .        .        .   
160     8.00      .        .        .   
161     8.00      .        .        .   
162    10.00    11.00      .        .   
163    10.00    11.00      .        .   
164    12.00      .        .        .   
165    12.00      .        .        .   
166
167 EOF
168 if [ $? -ne 0 ] ; then fail ; fi
169
170
171 activity="compare print out"
172 diff $TEMPDIR/foo - << EOF
173      .  /2.00E+00/0000000003/
174      .       2.00     3.00     4.00 
175      .  /6.00E+00/0000000007/
176      .       6.00     7.00     8.00 
177      .  /1.00E+01/0000000011/
178      .      10.00    11.00    12.00 
179 EOF
180 if [ $? -ne 0 ] ; then fail ; fi
181
182 pass;