1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313
|
Feature: Stop commands
After you've started a command, you might want to stop a command. To do that
you've got multiple possibilities.
On "JRuby" it's not possible to read the output of command which `echo`s a
string in a `signal`-handler - `TERM`, `HUP` etc. So please don't write
tests, which check on this, if your script needs to run on "JRuby". All other
output is logged to `STDERR` and/or `STDOUT` as normal.
Background:
Given I use a fixture named "cli-app"
Scenario: Terminate last command started
Terminating a command will send `SIGTERM` to the command.
Given an executable named "bin/cli1" with:
"""bash
#!/bin/bash
function term {
exit 100
}
trap term TERM
echo "Hello, Aruba!"
while [ true ]; do sleep 1; done
exit 1
"""
And an executable named "bin/cli2" with:
"""bash
#!/bin/bash
function term {
exit 155
}
trap term TERM
echo "Hello, Aruba!"
while [ true ]; do sleep 1; done
exit 1
"""
And a file named "features/stop.feature" with:
"""
Feature: Run it
Scenario: Run command
Given the default aruba exit timeout is 1 second
And I wait 2 seconds for a command to start up
When I run `cli1` in background
And I run `cli2` in background
And I terminate the command started last
Then the exit status should be 155
And the output should contain:
\"\"\"
Hello, Aruba!
\"\"\"
"""
When I run `cucumber`
Then the features should all pass
Scenario: Stop last command started
Stopping a command will wait n seconds for the command to stop and then
send `SIGTERM` to the command. Normally "n" is defined by the default exit
timeout of aruba.
Given an executable named "bin/cli1" with:
"""bash
#!/bin/bash
function term {
exit 100
}
trap term TERM
echo "Hello, Aruba!"
while [ true ]; do sleep 1; done
exit 1
"""
And an executable named "bin/cli2" with:
"""bash
#!/bin/bash
function term {
exit 155
}
trap term TERM
echo "Hello, Aruba!"
while [ true ]; do sleep 1; done
exit 1
"""
And a file named "features/stop.feature" with:
"""
Feature: Run it
Background:
Scenario: Run command
Given the default aruba exit timeout is 5 seconds
And I wait 2 seconds for a command to start up
When I run `cli1` in background
And I run `cli2` in background
And I stop the command started last
Then the exit status should be 155
And the output should contain:
\"\"\"
Hello, Aruba!
\"\"\"
"""
When I run `cucumber`
Then the features should all pass
Scenario: Terminate command given by commandline
Pass the commandline to the step to find the command, which should be
stopped.
Given an executable named "bin/cli1" with:
"""bash
#!/bin/bash
function term {
exit 100
}
trap term TERM
echo "Hello, Aruba!"
while [ true ]; do sleep 1; done
"""
And an executable named "bin/cli2" with:
"""bash
#!/bin/bash
function term {
exit 155
}
trap term TERM
echo "Hello, Aruba!"
while [ true ]; do sleep 1; done
exit 2
"""
And a file named "features/stop.feature" with:
"""
Feature: Run it
Background:
Given the default aruba exit timeout is 5 seconds
Scenario: Run command
Given I wait 2 seconds for a command to start up
When I run `cli1` in background
When I run `cli2` in background
And I terminate the command "cli1"
Then the exit status should be 100
And the output should contain:
\"\"\"
Hello, Aruba!
\"\"\"
"""
When I run `cucumber`
Then the features should all pass
Scenario: Stop command given by commandline
Stopping a command will wait n seconds for the command to stop and then
send `SIGTERM` to the command. Normally "n" is defined by the default exit
timeout of aruba.
Given an executable named "bin/cli1" with:
"""bash
#!/bin/bash
function term {
exit 155
}
trap term TERM
echo "Hello, Aruba!"
while [ true ]; do sleep 1; done
exit 1
"""
And an executable named "bin/cli2" with:
"""bash
#!/bin/bash
function term {
exit 100
}
trap term TERM
echo "Hello, Aruba!"
while [ true ]; do sleep 1; done
exit 1
"""
And a file named "features/stop.feature" with:
"""
Feature: Run it
Background:
Given the default aruba exit timeout is 5 seconds
Scenario: Run command
Given I wait 2 seconds for a command to start up
When I run `cli1` in background
And I run `cli2` in background
When I stop the command "cli1"
Then the exit status should be 155
And the output should contain:
\"\"\"
Hello, Aruba!
\"\"\"
"""
When I run `cucumber`
Then the features should all pass
Scenario: Stop command with configured signal
You can define a default signal which is used to stop all commands.
Given an executable named "bin/cli" with:
"""bash
#!/bin/bash
function hup {
exit 155
}
function term {
exit 100
}
trap hup HUP
trap term TERM
echo "Hello, Aruba!"
while [ true ]; do sleep 1; done
exit 1
"""
And a file named "features/run.feature" with:
"""
Feature: Run it
Scenario: Run command
Given the default aruba stop signal is "HUP"
And the default aruba exit timeout is 5 seconds
When I run `cli`
Then the exit status should be 155
"""
When I run `cucumber`
Then the features should all pass
@requires-ruby-platform-java
Scenario: STDERR/STDOUT is empty on JRUBY if output was written in "signal"-handler
Given an executable named "bin/cli1" with:
"""bash
#!/bin/bash
function term {
echo 'Hello, TERM'
exit 100
}
trap term TERM
echo "Hello, Aruba!"
while [ true ]; do sleep 1; done
exit 1
"""
And a file named "features/stop.feature" with:
"""
Feature: Run it
Scenario: Run command
Given the default aruba exit timeout is 1 second
And I wait 2 seconds for a command to start up
When I run `cli1` in background
And I terminate the command started last
Then the exit status should be 100
And the output should not contain:
\"\"\"
Hello, TERM
\"\"\"
"""
When I run `cucumber`
Then the features should all pass
@requires-ruby-platform-mri
Scenario: STDERR/STDOUT is written normally with MRI-Ruby if output was written in "signal"-handler
Given an executable named "bin/cli1" with:
"""bash
#!/bin/bash
function term {
echo 'Hello, TERM'
exit 100
}
trap term TERM
echo "Hello, Aruba!"
while [ true ]; do sleep 1; done
exit 1
"""
And a file named "features/stop.feature" with:
"""
Feature: Run it
Scenario: Run command
Given the default aruba exit timeout is 1 second
And I wait 2 seconds for a command to start up
When I run `cli1` in background
And I terminate the command started last
Then the exit status should be 100
And the output should contain:
\"\"\"
Hello, TERM
\"\"\"
"""
When I run `cucumber`
Then the features should all pass
|