From cfd313bced3e998fe77e6719b75a4597843d33ec Mon Sep 17 00:00:00 2001 From: Matt Clay Date: Wed, 8 Mar 2017 11:45:38 -0800 Subject: [PATCH] Disable ansible color output on sanity tests. --- test/runner/lib/ansible_util.py | 5 +++-- test/runner/lib/sanity.py | 9 +++------ 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/test/runner/lib/ansible_util.py b/test/runner/lib/ansible_util.py index f0f558d1d2d..6eb3608eecd 100644 --- a/test/runner/lib/ansible_util.py +++ b/test/runner/lib/ansible_util.py @@ -7,9 +7,10 @@ import os from lib.util import common_environment -def ansible_environment(args): +def ansible_environment(args, color=True): """ :type args: CommonConfig + :type color: bool :rtype: dict[str, str] """ env = common_environment() @@ -21,7 +22,7 @@ def ansible_environment(args): path = ansible_path + os.pathsep + path ansible = dict( - ANSIBLE_FORCE_COLOR='%s' % 'true' if args.color else 'false', + ANSIBLE_FORCE_COLOR='%s' % 'true' if args.color and color else 'false', ANSIBLE_DEPRECATION_WARNINGS='false', ANSIBLE_CONFIG='/dev/null', ANSIBLE_HOST_KEY_CHECKING='false', diff --git a/test/runner/lib/sanity.py b/test/runner/lib/sanity.py index 1ef62c56aa5..6c2e33a6f05 100644 --- a/test/runner/lib/sanity.py +++ b/test/runner/lib/sanity.py @@ -128,10 +128,7 @@ def command_sanity_code_smell(args, _, script): test = os.path.splitext(os.path.basename(script))[0] cmd = [script] - env = ansible_environment(args) - - # Since the output from scripts end up in other places besides the console, we don't want color here. - env.pop('ANSIBLE_FORCE_COLOR') + env = ansible_environment(args, color=False) try: stdout, stderr = run_command(args, cmd, env=env, capture=True) @@ -155,7 +152,7 @@ def command_sanity_validate_modules(args, targets): :rtype: SanityResult """ test = 'validate-modules' - env = ansible_environment(args) + env = ansible_environment(args, color=False) paths = [deepest_path(i.path, 'lib/ansible/modules/') for i in targets.include_external] paths = sorted(set(p for p in paths if p)) @@ -494,7 +491,7 @@ def command_sanity_ansible_doc(args, targets, python_version): if not modules: return SanitySkipped(test, python_version=python_version) - env = ansible_environment(args) + env = ansible_environment(args, color=False) cmd = ['ansible-doc'] + modules try: