Add intentional coverage for an async_wrapper case (#70593) (#70630)

* Add intentional coverage for an async_wrapper case (#70593)

Change:
- Test async_wrapper when the module it runs has stderr output

Test Plan:
- CI
- Looked at coverage report and saw green for a few lines that weren't
  previously green.

Signed-off-by: Rick Elrod <rick@elrod.me>

* sigh

Signed-off-by: Rick Elrod <rick@elrod.me>
This commit is contained in:
Rick Elrod 2020-07-17 14:52:45 -05:00 committed by GitHub
parent 33e5f1d661
commit 86b24498b7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 2 deletions

View file

@ -1,3 +1,6 @@
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
import json import json
import sys import sys
@ -33,6 +36,9 @@ def main():
if 'exception' in fail_mode: if 'exception' in fail_mode:
raise Exception('failing via exception') raise Exception('failing via exception')
if 'stderr' in fail_mode:
print('printed to stderr', file=sys.stderr)
module.exit_json(**result) module.exit_json(**result)
finally: finally:

View file

@ -165,6 +165,18 @@
- async_result is successful - async_result is successful
- async_result.warnings[0] is search('trailing junk after module output') - async_result.warnings[0] is search('trailing junk after module output')
- name: test stderr handling
async_test:
fail_mode: stderr
async: 30
poll: 1
register: async_result
ignore_errors: true
- assert:
that:
- async_result.stderr == "printed to stderr\n"
# NOTE: This should report a warning that cannot be tested # NOTE: This should report a warning that cannot be tested
- name: test async properties on non-async task - name: test async properties on non-async task
command: sleep 1 command: sleep 1

View file

@ -217,8 +217,6 @@ test/integration/targets/ansible-test/ansible_collections/ns/col/tests/unit/plug
test/integration/targets/ansible-test-docker/ansible_collections/ns/col/plugins/modules/hello.py pylint:relative-beyond-top-level test/integration/targets/ansible-test-docker/ansible_collections/ns/col/plugins/modules/hello.py pylint:relative-beyond-top-level
test/integration/targets/ansible-test-docker/ansible_collections/ns/col/tests/unit/plugins/module_utils/test_my_util.py pylint:relative-beyond-top-level test/integration/targets/ansible-test-docker/ansible_collections/ns/col/tests/unit/plugins/module_utils/test_my_util.py pylint:relative-beyond-top-level
test/integration/targets/ansible-test-docker/ansible_collections/ns/col/tests/unit/plugins/modules/test_hello.py pylint:relative-beyond-top-level test/integration/targets/ansible-test-docker/ansible_collections/ns/col/tests/unit/plugins/modules/test_hello.py pylint:relative-beyond-top-level
test/integration/targets/async/library/async_test.py future-import-boilerplate
test/integration/targets/async/library/async_test.py metaclass-boilerplate
test/integration/targets/async_fail/library/async_test.py future-import-boilerplate test/integration/targets/async_fail/library/async_test.py future-import-boilerplate
test/integration/targets/async_fail/library/async_test.py metaclass-boilerplate test/integration/targets/async_fail/library/async_test.py metaclass-boilerplate
test/integration/targets/collections_plugin_namespace/collection_root/ansible_collections/my_ns/my_col/plugins/lookup/lookup_no_future_boilerplate.py future-import-boilerplate test/integration/targets/collections_plugin_namespace/collection_root/ansible_collections/my_ns/my_col/plugins/lookup/lookup_no_future_boilerplate.py future-import-boilerplate