Fix missing @clicksequence problem with older Texinfo versions.
[pspp-builds.git] / tests / command / get-data-txt.sh
1 #!/bin/sh
2
3 # This program tests features of GET DATA /TYPE=TXT input program that
4 # it has in common with DATA LIST, using tests drawn from
5 # data-list.sh.
6
7 TEMPDIR=/tmp/pspp-tst-$$
8 TESTFILE=$TEMPDIR/`basename $0`.sps
9
10 # ensure that top_builddir  are absolute
11 if [ -z "$top_builddir" ] ; then top_builddir=. ; fi
12 if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi
13 top_builddir=`cd $top_builddir; pwd`
14 PSPP=$top_builddir/src/ui/terminal/pspp
15
16 # ensure that top_srcdir is absolute
17 top_srcdir=`cd $top_srcdir; pwd`
18
19 STAT_CONFIG_PATH=$top_srcdir/config
20 export STAT_CONFIG_PATH
21
22
23 cleanup()
24 {
25      if [ x"$PSPP_TEST_NO_CLEANUP" != x ] ; then 
26         echo "NOT cleaning $TEMPDIR" 
27         return ; 
28      fi
29      cd /
30      rm -rf $TEMPDIR
31 }
32
33
34 fail()
35 {
36     echo $activity
37     echo FAILED
38     cleanup;
39     exit 1;
40 }
41
42
43 no_result()
44 {
45     echo $activity
46     echo NO RESULT;
47     cleanup;
48     exit 2;
49 }
50
51 pass()
52 {
53     cleanup;
54     exit 0;
55 }
56
57 mkdir -p $TEMPDIR
58
59 cd $TEMPDIR
60
61 # Create command file.
62 activity="create program"
63 cat > $TESTFILE << EOF
64 get data /type=txt /file=inline /delimiters="|X"
65  /variables=A f7.2 B f7.2 C f7.2 D f7.2.
66 begin data.
67 1|23X45|2.03
68 2X22|34|23|
69 3|34|34X34
70 end data.
71
72 list.
73
74 get data /type=txt /file=inline /delimiters=', ' /delcase=variables 4
75  /firstcase=2 /variables=A f7.2 B f7.2 C f7.2 D f7.2.
76 begin data.
77 # This record is ignored.
78 ,1,2,3
79 ,4,,5
80 6
81 7,
82 8 9
83 0,1,,,
84 ,,,,
85 2
86
87 3
88 4
89 5
90 end data.
91 list.
92
93 get data /type=txt /file=inline /delimiters='\t' /delcase=variables 4
94  /firstcase=3 /variables=A f7.2 B f7.2 C f7.2 D f7.2.
95 begin data.
96 # These records
97 # are skipped.
98 1       2       3       4
99 1       2       3       
100 1       2               4
101 1       2               
102 1               3       4
103 1               3       
104 1                       4
105 1                       
106         2       3       4
107         2       3       
108         2               4
109         2               
110                 3       4
111                 3       
112                         4
113                         
114 end data.
115 list.
116
117 get data /type=txt /file=inline /arrangement=fixed /fixcase=3 /variables=
118         /1 start 0-19 adate
119         /2 end 0-19 adate
120         /3 count 0-2 f.
121 begin data.
122 07-22-2007
123 10-06-2007
124 321
125 07-14-1789
126 08-26-1789
127 4
128 01-01-1972
129 12-31-1999
130 682
131 end data.
132 list.
133
134 get data /type=txt /file=inline /arrangement=fixed /fixcase=2 /variables=
135         /1 x 0 f 
136            y 1 f.
137 begin data.
138 12
139
140 34
141
142 56
143
144 78
145
146 90
147
148 end data.
149 list.
150 EOF
151 if [ $? -ne 0 ] ; then no_result ; fi
152
153
154 activity="run program"
155 $SUPERVISOR $PSPP --testing-mode $TESTFILE
156 if [ $? -ne 0 ] ; then fail ; fi
157
158 activity="compare output"
159 perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.list
160 diff -b  $TEMPDIR/pspp.list - << EOF
161        A        B        C        D
162 -------- -------- -------- --------
163     1.00    23.00    45.00     2.03
164     2.00    22.00    34.00    23.00
165     3.00    34.00    34.00    34.00
166        A        B        C        D
167 -------- -------- -------- --------
168      .       1.00     2.00     3.00
169      .       4.00      .       5.00
170     6.00     7.00      .       8.00
171     9.00      .00     1.00      .
172      .        .        .        .
173      .        .        .       2.00
174      .       3.00     4.00     5.00
175        A        B        C        D
176 -------- -------- -------- --------
177     1.00     2.00     3.00     4.00
178     1.00     2.00     3.00      .
179     1.00     2.00      .       4.00
180     1.00     2.00      .        .
181     1.00      .       3.00     4.00
182     1.00      .       3.00      .
183     1.00      .        .       4.00
184     1.00      .        .        .
185      .       2.00     3.00     4.00
186      .       2.00     3.00      .
187      .       2.00      .       4.00
188      .       2.00      .        .
189      .        .       3.00     4.00
190      .        .       3.00      .
191      .        .        .       4.00
192      .        .        .        .
193                start                  end count
194 -------------------- -------------------- -----
195           07/22/2007           10/06/2007   321
196           07/14/1789           08/26/1789     4
197           01/01/1972           12/31/1999   682
198 x y
199 - -
200 1 2
201 3 4
202 5 6
203 7 8
204 9 0
205 EOF
206 if [ $? -ne 0 ] ; then fail ; fi
207
208 pass;