1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00
community.general/test/integration/targets/pause/runme.sh
Sam Doran 1c20029694
Fix ctrl+c in pause module and add tests (#40134)
* Fix all cases with pause and ctrl+c
 - naked:
	- pause:
 - with prompt
	- pause: prompt=hi
 - time wait
	- pause: seconds=60
 - time wait with prompt
	- pause: seconds=60 prompt=hi


Fixes #35372

* Use curses to control stdout
* Use curses to clear lines on interactive input
* Validate input for echo parameter and fail nicely if invalid
* Add integration tests for pause module using pexpect
* Use try except when trying to determine erase sequence to account for lack of TTY in containers in tests
* Improve output validation for regular paus test
* Accept two digit precision for pause length in test
* Check for seconds when seconds is specificed, minutes when minutes is specified
* Add test for no TTY mode

Co-authored by: Toshio Kuratomi <a.badger@gmail.com>
Co-authored by: Brian Coca <brian.coca+git@gmail.com>
2018-05-21 10:04:43 -04:00

23 lines
693 B
Bash
Executable file

#!/usr/bin/env bash
set -eux
# Test pause module when no tty and non-interactive. This is to prevent playbooks
# from hanging in cron and Tower jobs.
/usr/bin/env bash << EOF
ansible-playbook test-pause-no-tty.yml -i ../../inventory 2>&1 | \
grep '\[WARNING\]: Not waiting for response to prompt as stdin is not interactive' && {
echo 'Successfully skipped pause in no TTY mode' >&2
exit 0
} || {
echo 'Failed to skip pause module' >&2
exit 1
}
EOF
# Test pause with seconds and minutes specified
ansible-playbook test-pause.yml -i ../../inventory "$@"
# Interactively test pause
pip install pexpect
python test-pause.py -i ../../inventory "$@"