Remove unneeded #includes.
[pspp] / tests / language / utilities / host.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([HOST - portable tests])
18
19 AT_SETUP([HOST - one command])
20 AT_DATA([host.sps], [dnl
21 HOST COMMAND=[['echo "hi there" > file']].
22 ])
23 AT_CHECK([pspp -O format=csv host.sps])
24 AT_CHECK([cat file], [0], [hi there
25 ])
26 AT_CLEANUP
27
28 AT_SETUP([HOST - two commands])
29 AT_DATA([host.sps], [dnl
30 HOST COMMAND=[['echo a > a' 'echo b > b']].
31 ])
32 AT_CHECK([pspp -O format=csv host.sps])
33 AT_CHECK([cat a], [0], [a
34 ])
35 AT_CHECK([cat b], [0], [b
36 ])
37 AT_CLEANUP
38
39 AT_SETUP([HOST - time limit])
40 AT_DATA([host.sps], [dnl
41 HOST COMMAND=[['sleep 10']] TIMELIMIT=0.1.
42 ])
43 if $MINGW; then
44     AT_CHECK([pspp -O format=csv host.sps], [1], [dnl
45 host.sps:1: error: HOST: Time limit not supported on this platform.
46 ])
47 else
48     AT_CHECK([pspp -O format=csv host.sps], [0], [dnl
49 "host.sps:1: warning: HOST: Command ""sleep 10"" timed out."
50 ])
51 fi
52 AT_CLEANUP
53
54 AT_BANNER([HOST - Unix-like OSes only])
55
56 AT_SETUP([HOST - command failure])
57 AT_SKIP_IF([$MINGW])
58 AT_DATA([host.sps], [dnl
59 HOST COMMAND=[['exit 1' 'echo "Not reached"']].
60 ])
61 AT_CHECK([pspp -O format=csv host.sps], [0], [dnl
62 "host.sps:1: warning: HOST: Command ""exit 1"" exited with status 1."
63 ])
64 AT_CLEANUP
65
66 AT_SETUP([HOST - nonexistent shell])
67 AT_SKIP_IF([$MINGW])
68 AT_DATA([host.sps], [dnl
69 HOST COMMAND=[['echo hi']].
70 ])
71 AT_CHECK([SHELL=/nonexistent pspp -O format=csv host.sps], [0], [dnl
72 "host.sps:1: warning: HOST: Command ""echo hi"" exited with status 127 (Command or shell not found)."
73 ])
74 AT_CLEANUP
75
76 AT_SETUP([HOST - nonexistent command])
77 AT_SKIP_IF([$MINGW])
78 AT_DATA([host.sps], [dnl
79 HOST COMMAND=[['/nonexistent']].
80 ])
81 AT_CHECK([pspp -O format=csv host.sps | head -1], [0], [dnl
82 "host.sps:1: warning: HOST: Command ""/nonexistent"" exited with status 127 (Command or shell not found)."
83 ])
84 AT_CLEANUP
85
86 AT_SETUP([HOST - output to stdout])
87 AT_SKIP_IF([$MINGW])
88 AT_DATA([host.sps], [dnl
89 HOST COMMAND=[['echo hi']].
90 ])
91 AT_CHECK([pspp -O format=csv host.sps], [0], [hi
92 ])
93 AT_CLEANUP
94
95 AT_SETUP([HOST - output to stderr])
96 AT_SKIP_IF([$MINGW])
97 AT_DATA([host.sps], [dnl
98 HOST COMMAND=[['echo hi 2>&1']].
99 ])
100 AT_CHECK([pspp -O format=csv host.sps], [0], [hi
101 ])
102 AT_CLEANUP
103
104 AT_SETUP([HOST - input from stdin])
105 AT_SKIP_IF([$MINGW])
106 AT_DATA([host.sps], [dnl
107 HOST COMMAND=[['cat && echo ok || echo fail']] TIMELIMIT=5.
108 ])
109 AT_CHECK([pspp -O format=csv host.sps], [0], [ok
110 ])
111 AT_CLEANUP
112
113 dnl This is a special case inside run_command().
114 AT_SETUP([HOST - zero time limit])
115 AT_SKIP_IF([$MINGW])
116 AT_DATA([host.sps], [dnl
117 HOST COMMAND=[['sleep 10']] TIMELIMIT=0.
118 ])
119 AT_CHECK([pspp -O format=csv host.sps], [0], [dnl
120 "host.sps:1: warning: HOST: Command ""sleep 10"" timed out."
121 ])
122 AT_CLEANUP
123
124 AT_SETUP([HOST - signal termination])
125 AT_SKIP_IF([$MINGW])
126 AT_DATA([host.sps], [dnl
127 HOST COMMAND=[['kill -ABRT $$' 'echo "Not reached"']].
128 ])
129 AT_CHECK([pspp -O format=csv host.sps], [0], [dnl
130 "host.sps:1: warning: HOST: Command ""kill -ABRT $$"" terminated by signal 6."
131 ])
132 AT_CLEANUP
133
134 AT_SETUP([HOST - SAFER])
135 AT_SKIP_IF([$MINGW])
136 AT_DATA([host.sps], [dnl
137 SET SAFER=ON.
138 HOST COMMAND=[['sleep 10']] TIMELIMIT=0.1.
139 ])
140 AT_CHECK([pspp -O format=csv host.sps], [1], [dnl
141 "host.sps:2.1-2.4: error: HOST: This command not allowed when the SAFER option is set.
142     2 | HOST COMMAND=[['sleep 10']] TIMELIMIT=0.1.
143       | ^~~~"
144 ])
145 AT_CLEANUP