1dnl PSPP - a program for statistical analysis.
2dnl Copyright (C) 2017 Free Software Foundation, Inc.
3dnl
4dnl This program is free software: you can redistribute it and/or modify
5dnl it under the terms of the GNU General Public License as published by
6dnl the Free Software Foundation, either version 3 of the License, or
7dnl (at your option) any later version.
8dnl
9dnl This program is distributed in the hope that it will be useful,
10dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
11dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12dnl GNU General Public License for more details.
13dnl
14dnl You should have received a copy of the GNU General Public License
15dnl along with this program.  If not, see <http://www.gnu.org/licenses/>.
16dnl
17AT_BANNER([files handling])
18
19AT_SETUP([Write error - directory exists])
20
21mkdir foobar.sav
22
23AT_DATA([file.sps], [dnl
24DATA LIST NOTABLE/x 1.
25BEGIN DATA.
265
27END DATA.
28SAVE OUTFILE='foobar.sav'.
29])
30
31AT_CHECK([pspp -O format=csv file.sps], [1], [dnl
32error: Opening foobar.sav for writing: Is a directory.
33
34error: Error opening `foobar.sav' for writing as a system file: Is a directory.
35])
36
37AT_CLEANUP
38
39
40AT_SETUP([Write error - no permission])
41
42mkdir  directory
43touch directory/foobar.sav
44chmod 000 directory
45
46AT_DATA([file.sps], [dnl
47DATA LIST NOTABLE/x 1.
48BEGIN DATA.
495
50END DATA.
51SAVE OUTFILE='directory/foobar.sav'.
52])
53
54AT_CHECK([pspp -O format=csv file.sps], [1], [dnl
55error: Creating temporary file to replace directory/foobar.sav: Permission denied.
56
57error: Error opening `directory/foobar.sav' for writing as a system file: Permission denied.
58])
59
60chmod 700 directory
61
62AT_CLEANUP
63
64
65
66AT_SETUP([Write error - temp file disappeared])
67
68AT_DATA([file.sps], [dnl
69DATA LIST NOTABLE/x 1.
70BEGIN DATA.
715
72END DATA.
73XSAVE OUTFILE='foobar.sav'.
74HOST COMMAND=[['rm foobar.savtmp*']].
75EXECUTE.
76])
77
78AT_CHECK([pspp -O format=csv file.sps], [1], [ignore])
79
80AT_CLEANUP
81
82
83
84AT_SETUP([Write fifo])
85
86dnl The Fifo feature is not available in w32 builds
87AT_SKIP_IF([$MINGW])
88
89AT_DATA([file.sps], [dnl
90DATA LIST NOTABLE/x 1.
91BEGIN DATA.
925
93END DATA.
94SAVE OUTFILE='foobar.sav'.
95])
96
97mkfifo foobar.sav
98cat foobar.sav > /dev/null &
99pid=$!
100
101AT_CHECK([pspp -O format=csv file.sps], [0], [ignore])
102
103AT_CLEANUP
104
105
106
107AT_SETUP([Reading from pipe])
108
109AT_DATA([pipe.sps], [dnl
110data list file='printf "1 2\n 3 4\n 5 6\n" |' notable list /x * y *.
111list.
112])
113
114AT_CHECK([pspp -O format=csv pipe.sps], [0], [dnl
115Table: Data List
116x,y
1171.00,2.00
1183.00,4.00
1195.00,6.00
120])
121
122AT_CLEANUP
123
124
125dnl This was seen to crash pspp
126AT_SETUP([Reusing inline file])
127
128AT_DATA([inline-reuse.sps], [dnl
129get data /type=txt /file=inline  /variables=A f7.2 .
130
131data list notable list /foo.
132begin data.
133end data.
134
135data list notable list /foo.
136])
137
138AT_CHECK([pspp inline-reuse.sps], [0], [ignore])
139
140AT_CLEANUP
141