Skip to content

Commit ec6a3c8

Browse files
authored
Merge pull request #229 from byexamples/Issue-228-Fix-Spurious-Timeout-After-Stop-on-Silence
Issue 228 fix spurious timeout after stop on silence
2 parents 3702682 + f33cba7 commit ec6a3c8

3 files changed

Lines changed: 25 additions & 5 deletions

File tree

byexample/modules/shell.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -206,12 +206,19 @@ def _run_impl(self, example, options):
206206
"Unexpected stop-signal '%s'" % stop_signal
207207
)
208208

209+
if stop_on_silence:
210+
options.up({'stop_on_silence': False})
211+
209212
# wait for the prompt, ignore any extra output
210-
self._expect_prompt(
211-
options,
212-
countdown=Countdown(options['x']['dfl_timeout']),
213-
prompt_re=self._PS1_re
214-
)
213+
try:
214+
self._expect_prompt(
215+
options,
216+
countdown=Countdown(options['x']['dfl_timeout']),
217+
prompt_re=self._PS1_re
218+
)
219+
finally:
220+
if stop_on_silence:
221+
options.down()
215222

216223
self._drop_output()
217224
return out

test/corner_cases.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,14 @@ $ byexample -m test/ds/submod -l python -q test/ds/one.md
184184

185185
## Shutdown
186186

187+
Ensure that if the program is slow and takes some reasonable time to
188+
shutdown, don't raise a Timeout after stopping it
189+
190+
```shell
191+
$ test/ds/sleepy/c.sh # byexample: +timeout=10 +stop-on-silence +stop-signal=interrupt
192+
Start
193+
```
194+
187195
Run three very slow tests and send `byexample` to the background
188196
as soon as possible.
189197

test/ds/sleepy/c.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
trap 'echo INT ; sleep 2 ; echo Bye' INT
3+
echo Start
4+
sleep 3
5+
echo BOOM

0 commit comments

Comments
 (0)