Consolidate quoting style in printed strings.
[pspp] / tests / command / get-data-gnm.sh
1 #!/bin/sh
2
3 # This program tests that pspp can read Gnumeric files
4
5 TEMPDIR=/tmp/pspp-tst-$$
6 TESTFILE=$TEMPDIR/`basename $0`.sps
7
8 # ensure that top_srcdir and top_builddir  are absolute
9 if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi
10 if [ -z "$top_builddir" ] ; then top_builddir=. ; fi
11 top_srcdir=`cd $top_srcdir; pwd`
12 top_builddir=`cd $top_builddir; pwd`
13
14 PSPP=$top_builddir/src/ui/terminal/pspp$EXEEXT
15
16 STAT_CONFIG_PATH=$top_srcdir/config
17 export STAT_CONFIG_PATH
18
19 LANG=C
20 export LANG
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 activity="zip the gnm file and place it in the test directory"
62 gzip -c $top_srcdir/tests/Book1.gnm.unzipped > $TEMPDIR/Book1.gnumeric
63 if [ $? -ne 0 ] ; then no_result ; fi
64
65 activity="create program 1"
66 cat > $TESTFILE <<EOF
67 GET DATA /TYPE=gnm /FILE='$TEMPDIR/Book1.gnumeric'  /READNAMES=off /SHEET=name 'This' /CELLRANGE=range 'g9:i13' .
68 DISPLAY VARIABLES.
69 LIST.
70
71
72 GET DATA /TYPE=gnm /FILE='$TEMPDIR/Book1.gnumeric'  /READNAMES=on /SHEET=name 'This' /CELLRANGE=range 'g8:i13' .
73 DISPLAY VARIABLES.
74 LIST.
75
76
77 GET DATA /TYPE=gnm /FILE='$TEMPDIR/Book1.gnumeric' /SHEET=index 3.
78 DISPLAY VARIABLES.
79 LIST.
80
81 * This sheet has no data in one of its variables
82 GET DATA /TYPE=gnm /FILE='$TEMPDIR/Book1.gnumeric' /READNAMES=on /SHEET=index 5.
83 DISPLAY VARIABLES.
84 LIST.
85
86 EOF
87 if [ $? -ne 0 ] ; then no_result ; fi
88
89 activity="run program 1"
90 $SUPERVISOR $PSPP -o pspp.csv $TESTFILE
91 if [ $? -ne 0 ] ; then no_result ; fi
92
93
94 activity="compare output 1"
95 diff -c $TEMPDIR/pspp.csv - <<EOF
96 Variable,Description,,Position
97 VAR001,Format: F8.2,,1
98 ,Measure: Scale,,
99 ,Display Alignment: Right,,
100 ,Display Width: 8,,
101 VAR002,Format: A8,,2
102 ,Measure: Nominal,,
103 ,Display Alignment: Left,,
104 ,Display Width: 8,,
105 VAR003,Format: F8.2,,3
106 ,Measure: Scale,,
107 ,Display Alignment: Right,,
108 ,Display Width: 8,,
109
110 Table: Data List
111 VAR001,VAR002,VAR003
112 .00,fred    ,20.00
113 1.00,11      ,21.00
114 2.00,twelve  ,22.00
115 3.00,13      ,23.00
116 4.00,14      ,24.00
117
118 Variable,Description,,Position
119 V1,Format: F8.2,,1
120 ,Measure: Scale,,
121 ,Display Alignment: Right,,
122 ,Display Width: 8,,
123 V2,Format: A8,,2
124 ,Measure: Nominal,,
125 ,Display Alignment: Left,,
126 ,Display Width: 8,,
127 VAR001,Format: F8.2,,3
128 ,Measure: Scale,,
129 ,Display Alignment: Right,,
130 ,Display Width: 8,,
131
132 Table: Data List
133 V1,V2,VAR001
134 .00,fred    ,20.00
135 1.00,11      ,21.00
136 2.00,twelve  ,22.00
137 3.00,13      ,23.00
138 4.00,14      ,24.00
139
140 Variable,Description,,Position
141 name,Format: A8,,1
142 ,Measure: Nominal,,
143 ,Display Alignment: Left,,
144 ,Display Width: 8,,
145 id,Format: F8.2,,2
146 ,Measure: Scale,,
147 ,Display Alignment: Right,,
148 ,Display Width: 8,,
149 height,Format: F8.2,,3
150 ,Measure: Scale,,
151 ,Display Alignment: Right,,
152 ,Display Width: 8,,
153
154 Table: Data List
155 name,id,height
156 fred    ,.00,23.40
157 bert    ,1.00,.56
158 charlie ,2.00,.  
159 dick    ,3.00,-34.09
160
161 Variable,Description,,Position
162 vone,Format: F8.2,,1
163 ,Measure: Scale,,
164 ,Display Alignment: Right,,
165 ,Display Width: 8,,
166 vtwo,Format: F8.2,,2
167 ,Measure: Scale,,
168 ,Display Alignment: Right,,
169 ,Display Width: 8,,
170 vthree,Format: A8,,3
171 ,Measure: Nominal,,
172 ,Display Alignment: Left,,
173 ,Display Width: 8,,
174 v4,Format: F8.2,,4
175 ,Measure: Scale,,
176 ,Display Alignment: Right,,
177 ,Display Width: 8,,
178
179 Table: Data List
180 vone,vtwo,vthree,v4
181 1.00,3.00,,5.00
182 2.00,4.00,,6.00
183 EOF
184 if [ $? -ne 0 ] ; then fail ; fi
185
186
187 activity="create program 2"
188 cat > $TESTFILE <<EOF
189 * This sheet is empty
190 GET DATA /TYPE=gnm /FILE='$TEMPDIR/Book1.gnumeric' /SHEET=name 'Empty'.
191
192
193 * This sheet doesnt exist
194 GET DATA /TYPE=gnm /FILE='$TEMPDIR/Book1.gnumeric' /SHEET=name 'foobarxx'.
195
196 EOF
197 if [ $? -ne 0 ] ; then no_result ; fi
198
199 activity="run program 2"
200 $SUPERVISOR $PSPP -o pspp.csv $TESTFILE > /dev/null
201 if [ $? -ne 0 ] ; then fail ; fi
202
203 activity="compare output 2"
204 diff -c $TEMPDIR/pspp.csv - <<EOF
205 warning: Selected sheet or range of spreadsheet \`$TEMPDIR/Book1.gnumeric' is empty.
206
207 warning: Selected sheet or range of spreadsheet \`$TEMPDIR/Book1.gnumeric' is empty.
208 EOF
209 if [ $? -ne 0 ] ; then fail ; fi
210
211 pass;