From 2b6d94c4c85a4fffeb592f058dcdd37bb05893cc Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Fri, 6 Dec 2019 08:48:17 -0800 Subject: [PATCH] Change the check_pyyaml() function to return the features of pyyaml that we check --- test/lib/ansible_test/_internal/ansible_util.py | 14 ++++++++------ test/lib/ansible_test/_internal/sanity/yamllint.py | 4 ++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/test/lib/ansible_test/_internal/ansible_util.py b/test/lib/ansible_test/_internal/ansible_util.py index f26b983594e..309f2678b87 100644 --- a/test/lib/ansible_test/_internal/ansible_util.py +++ b/test/lib/ansible_test/_internal/ansible_util.py @@ -123,14 +123,14 @@ def check_pyyaml(args, version): :type args: EnvironmentConfig :type version: str """ - if version in CHECK_YAML_VERSIONS: - return + try: + return CHECK_YAML_VERSIONS[version] + except KeyError: + pass python = find_python(version) - stdout, _dummy = run_command(args, [python, os.path.join(ANSIBLE_TEST_DATA_ROOT, 'yamlcheck.py')], capture=True) - - if args.explain: - return + stdout, _dummy = run_command(args, [python, os.path.join(ANSIBLE_TEST_DATA_ROOT, 'yamlcheck.py')], + capture=True, always=True) CHECK_YAML_VERSIONS[version] = result = json.loads(stdout) @@ -141,3 +141,5 @@ def check_pyyaml(args, version): display.warning('PyYAML is not installed for interpreter: %s' % python) elif not cloader: display.warning('PyYAML will be slow due to installation without libyaml support for interpreter: %s' % python) + + return result diff --git a/test/lib/ansible_test/_internal/sanity/yamllint.py b/test/lib/ansible_test/_internal/sanity/yamllint.py index 38fc68c704a..4bb9ce8d448 100644 --- a/test/lib/ansible_test/_internal/sanity/yamllint.py +++ b/test/lib/ansible_test/_internal/sanity/yamllint.py @@ -71,8 +71,8 @@ class YamllintTest(SanitySingleVersion): :type python_version: str :rtype: TestResult """ - ansible_util.check_pyyaml(args, python_version) - if not ansible_util.CHECK_YAML_VERSIONS[python_version]['cloader']: + pyyaml_presence = ansible_util.check_pyyaml(args, python_version) + if not pyyaml_presence['cloader']: display.warning("Skipping sanity test '%s' due to missing libyaml support in PyYAML." % self.name) return SanitySkipped(self.name)