Merge remote-tracking branch 'origin/master' into sheet
[pspp] / tests / data / por-file.at
1 dnl PSPP - a program for statistical analysis.
2 dnl Copyright (C) 2017 Free Software Foundation, Inc.
3 dnl 
4 dnl This program is free software: you can redistribute it and/or modify
5 dnl it under the terms of the GNU General Public License as published by
6 dnl the Free Software Foundation, either version 3 of the License, or
7 dnl (at your option) any later version.
8 dnl 
9 dnl This program is distributed in the hope that it will be useful,
10 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
11 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 dnl GNU General Public License for more details.
13 dnl 
14 dnl You should have received a copy of the GNU General Public License
15 dnl along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 dnl
17 AT_BANNER([portable files])
18
19 AT_SETUP([overwriting portable file])
20 AT_DATA([output.por], [abcdef
21 ])
22 cp output.por output.por.backup
23 AT_DATA([porfile.sps], [dnl
24 DATA LIST NOTABLE/x 1.
25 BEGIN DATA.
26 5
27 END DATA.
28 EXPORT OUTFILE='output.por'.
29 ])
30 AT_CHECK([pspp -O format=csv porfile.sps])
31 AT_CHECK([cmp output.por output.por.backup], [1], [ignore])
32 AT_CLEANUP
33
34 AT_SETUP([overwriting portable file atomically])
35 AT_DATA([output.por], [abcdef
36 ])
37 cp output.por output.por.backup
38 AT_DATA([porfile.sps],
39 [[DATA LIST NOTABLE/x 1.
40 BEGIN DATA.
41 5
42 END DATA.
43 XEXPORT OUTFILE='output.por'.
44 HOST COMMAND=['kill -TERM $PPID'].
45 ]])
46 AT_CHECK([pspp -O format=csv porfile.sps], [143], [], [ignore])
47 AT_CHECK([cmp output.por output.por.backup])
48 AT_CHECK(
49   [for file in *.tmp*; do if test -e $file; then echo $file; exit 1; fi; done])
50 AT_CLEANUP
51
52 AT_SETUP([write to same portable file being read])
53 AT_DATA([export.sps], [dnl
54 DATA LIST NOTABLE/x 1.
55 BEGIN DATA.
56 2
57 END DATA.
58 EXPORT OUTFILE='data.por'.
59 ])
60 AT_CHECK([pspp -O format=csv export.sps])
61 AT_CHECK([test -s data.por])
62 AT_CHECK(
63   [for file in *.tmp*; do if test -e $file; then echo $file; exit 1; fi; done])
64 AT_DATA([export2.sps], [dnl
65 IMPORT FILE='data.por'.
66 COMPUTE y = x * 2.
67 EXPORT OUTFILE='data.por'.
68 ])
69 AT_CHECK([pspp -O format=csv export2.sps])
70 AT_CHECK(
71   [for file in *.tmp*; do if test -e $file; then echo $file; exit 1; fi; done])
72 AT_DATA([export3.sps], [dnl
73 IMPORT FILE='data.por'.
74 LIST.
75 ])
76 AT_CHECK([pspp -O format=csv export3.sps], [0], [dnl
77 Table: Data List
78 X,Y
79 2,4.00
80 ])
81 AT_CLEANUP
82
83 dnl This checks for a bug in the portable file writer that caused an infinite
84 dnl loop in some cases, and other problems in other cases, when a variable
85 dnl had value labels.
86 AT_SETUP([write portable file with value labels])
87 AT_DATA([export.sps], [dnl
88 DATA LIST NOTABLE/var1 TO var5 1-5.
89 VALUE LABELS
90         /var1 1 'one'
91         /var2 2 'two'
92         /var3 3 'three'
93         /var4 4 'four'
94         /var5 5 'five'.
95 BEGIN DATA.
96 12345
97 END DATA.
98 EXPORT OUTFILE='data.por'.
99 ])
100 AT_CHECK([pspp -O format=csv export.sps])
101 AT_DATA([import.sps], [dnl
102 IMPORT FILE='data.por'.
103 DISPLAY DICTIONARY.
104 LIST.
105 ])
106 AT_CHECK([pspp -O format=csv import.sps], [0], [dnl
107 Variable,Description,Position
108 VAR1,"Format: F1.0
109
110 Value,Label
111 1,one",1
112 VAR2,"Format: F1.0
113
114 Value,Label
115 2,two",2
116 VAR3,"Format: F1.0
117
118 Value,Label
119 3,three",3
120 VAR4,"Format: F1.0
121
122 Value,Label
123 4,four",4
124 VAR5,"Format: F1.0
125
126 Value,Label
127 5,five",5
128
129 Table: Data List
130 VAR1,VAR2,VAR3,VAR4,VAR5
131 1,2,3,4,5
132 ])
133 AT_DATA([sys-file-info.sps], [SYSFILE INFO FILE='data.por'
134 ])
135 AT_CHECK([pspp -O format=csv sys-file-info.sps | sed '/Encoding/d
136 /Integer Format/d
137 /Real Format/d
138 /Created/d
139 /Product/d
140 '], [0], [dnl
141 File:,data.por
142 Label:,No label.
143 Variables:,5
144 Cases:,Unknown
145 Type:,SPSS Portable File
146 Weight:,Not weighted.
147 Compression:,None
148
149 Variable,Description,Position
150 VAR1,"Format: F1.0
151 Measure: Scale
152 Role: Input
153 Display Alignment: Right
154 Display Width: 8
155
156 Value,Label
157 1,one",1
158 VAR2,"Format: F1.0
159 Measure: Scale
160 Role: Input
161 Display Alignment: Right
162 Display Width: 8
163
164 Value,Label
165 2,two",2
166 VAR3,"Format: F1.0
167 Measure: Scale
168 Role: Input
169 Display Alignment: Right
170 Display Width: 8
171
172 Value,Label
173 3,three",3
174 VAR4,"Format: F1.0
175 Measure: Scale
176 Role: Input
177 Display Alignment: Right
178 Display Width: 8
179
180 Value,Label
181 4,four",4
182 VAR5,"Format: F1.0
183 Measure: Scale
184 Role: Input
185 Display Alignment: Right
186 Display Width: 8
187
188 Value,Label
189 5,five",5
190 ])
191 AT_CLEANUP