Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions byexample/modules/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,19 @@ def _run_impl(self, example, options):
"Unexpected stop-signal '%s'" % stop_signal
)

if stop_on_silence:
options.up({'stop_on_silence': False})

# wait for the prompt, ignore any extra output
self._expect_prompt(
options,
countdown=Countdown(options['x']['dfl_timeout']),
prompt_re=self._PS1_re
)
try:
self._expect_prompt(
options,
countdown=Countdown(options['x']['dfl_timeout']),
prompt_re=self._PS1_re
)
finally:
if stop_on_silence:
options.down()

self._drop_output()
return out
Expand Down
8 changes: 8 additions & 0 deletions test/corner_cases.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,14 @@ $ byexample -m test/ds/submod -l python -q test/ds/one.md

## Shutdown

Ensure that if the program is slow and takes some reasonable time to
shutdown, don't raise a Timeout after stopping it

```shell
$ test/ds/sleepy/c.sh # byexample: +timeout=10 +stop-on-silence +stop-signal=interrupt
Start
```

Run three very slow tests and send `byexample` to the background
as soon as possible.

Expand Down
5 changes: 5 additions & 0 deletions test/ds/sleepy/c.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
trap 'echo INT ; sleep 2 ; echo Bye' INT
echo Start
sleep 3
echo BOOM