Merge remote-tracking branch 'origin/master' into sheet
[pspp] / tests / data / 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([files handling])
18
19 AT_SETUP([Write error - directory exists])
20
21 mkdir foobar.sav
22
23 AT_DATA([file.sps], [dnl
24 DATA LIST NOTABLE/x 1.
25 BEGIN DATA.
26 5
27 END DATA.
28 SAVE OUTFILE='foobar.sav'.
29 ])
30
31 AT_CHECK([pspp -O format=csv file.sps], [1], [dnl
32 error: Opening foobar.sav for writing: Is a directory.
33
34 error: Error opening `foobar.sav' for writing as a system file: Is a directory.
35 ])
36
37 AT_CLEANUP
38
39
40 AT_SETUP([Write error - no permission])
41
42 mkdir  directory
43 touch directory/foobar.sav
44 chmod 000 directory
45
46 AT_DATA([file.sps], [dnl
47 DATA LIST NOTABLE/x 1.
48 BEGIN DATA.
49 5
50 END DATA.
51 SAVE OUTFILE='directory/foobar.sav'.
52 ])
53
54 AT_CHECK([pspp -O format=csv file.sps], [1], [dnl
55 error: Creating temporary file to replace directory/foobar.sav: Permission denied.
56
57 error: Error opening `directory/foobar.sav' for writing as a system file: Permission denied.
58 ])
59
60 chmod 700 directory
61
62 AT_CLEANUP
63
64
65
66 AT_SETUP([Write error - temp file disappeared])
67
68 AT_DATA([file.sps], [dnl
69 DATA LIST NOTABLE/x 1.
70 BEGIN DATA.
71 5
72 END DATA.
73 XSAVE OUTFILE='foobar.sav'.
74 HOST COMMAND=[['rm foobar.savtmp*']].
75 EXECUTE.
76 ])
77
78 AT_CHECK([pspp -O format=csv file.sps], [1], [ignore])
79
80 AT_CLEANUP
81
82
83
84 AT_SETUP([Write fifo])
85
86 dnl The Fifo feature is not available in w32 builds
87 AT_SKIP_IF([case $host in *-*-mingw*) true ;; *) false ;; esac])
88
89 AT_DATA([file.sps], [dnl
90 DATA LIST NOTABLE/x 1.
91 BEGIN DATA.
92 5
93 END DATA.
94 SAVE OUTFILE='foobar.sav'.
95 ])
96
97 mkfifo foobar.sav
98 cat foobar.sav > /dev/null & 
99 pid=$!
100
101 AT_CHECK([pspp -O format=csv file.sps], [0], [ignore])
102
103 AT_CLEANUP
104
105
106
107 AT_SETUP([Reading from pipe])
108
109 AT_DATA([pipe.sps], [dnl
110 data list file='printf "1 2\n 3 4\n 5 6\n" |' notable list /x * y *.
111 list.
112 ])
113
114 AT_CHECK([pspp -O format=csv pipe.sps], [0], [dnl
115 Table: Data List
116 x,y
117 1.00,2.00
118 3.00,4.00
119 5.00,6.00
120 ])
121
122 AT_CLEANUP