9024f89ba29665edb4d4a630f64885e6ac9c01c4
[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 Table: Variables
108 Name,Position,Measurement Level,Role,Width,Alignment,Print Format,Write Format
109 VAR1,1,Scale,Input,8,Right,F1.0,F1.0
110 VAR2,2,Scale,Input,8,Right,F1.0,F1.0
111 VAR3,3,Scale,Input,8,Right,F1.0,F1.0
112 VAR4,4,Scale,Input,8,Right,F1.0,F1.0
113 VAR5,5,Scale,Input,8,Right,F1.0,F1.0
114
115 Table: Value Labels
116 Variable Value,,Label
117 VAR1,1,one
118 VAR2,2,two
119 VAR3,3,three
120 VAR4,4,four
121 VAR5,5,five
122
123 Table: Data List
124 VAR1,VAR2,VAR3,VAR4,VAR5
125 1,2,3,4,5
126 ])
127 AT_DATA([sys-file-info.sps], [SYSFILE INFO FILE='data.por'
128 ])
129 AT_CHECK([pspp -O format=csv sys-file-info.sps | sed '/Encoding/d
130 /Integer Format/d
131 /Real Format/d
132 /Created/d
133 /Product/d
134 '], [0], [dnl
135 Table: File Information
136 File,data.por
137 Variables,5
138 Cases,Unknown
139 Type,SPSS Portable File
140 Weight,Not weighted
141 Compression,None
142
143 Table: Variables
144 Name,Position,Measurement Level,Role,Width,Alignment,Print Format,Write Format
145 VAR1,1,Scale,Input,8,Right,F1.0,F1.0
146 VAR2,2,Scale,Input,8,Right,F1.0,F1.0
147 VAR3,3,Scale,Input,8,Right,F1.0,F1.0
148 VAR4,4,Scale,Input,8,Right,F1.0,F1.0
149 VAR5,5,Scale,Input,8,Right,F1.0,F1.0
150
151 Table: Value Labels
152 Variable Value,,Label
153 VAR1,1,one
154 VAR2,2,two
155 VAR3,3,three
156 VAR4,4,four
157 VAR5,5,five
158 ])
159 AT_CLEANUP