|
|
|
@ -17,9 +17,14 @@ from . import (
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
from ...constants import (
|
|
|
|
|
CONTROLLER_MIN_PYTHON_VERSION,
|
|
|
|
|
REMOTE_ONLY_PYTHON_VERSIONS,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
from ...io import (
|
|
|
|
|
write_text_file,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
from ...test import (
|
|
|
|
|
TestResult,
|
|
|
|
|
)
|
|
|
|
@ -29,15 +34,18 @@ from ...target import (
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
from ...util import (
|
|
|
|
|
cache,
|
|
|
|
|
SubprocessError,
|
|
|
|
|
display,
|
|
|
|
|
parse_to_list_of_dict,
|
|
|
|
|
is_subdir,
|
|
|
|
|
ANSIBLE_TEST_TOOLS_ROOT,
|
|
|
|
|
ANSIBLE_TEST_TARGET_ROOT,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
from ...util_common import (
|
|
|
|
|
ResultType,
|
|
|
|
|
create_temp_dir,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
from ...ansible_util import (
|
|
|
|
@ -144,6 +152,8 @@ class ImportTest(SanityMultipleVersion):
|
|
|
|
|
SANITY_COLLECTION_FULL_NAME=data_context().content.collection.full_name,
|
|
|
|
|
SANITY_EXTERNAL_PYTHON=external_python.path,
|
|
|
|
|
SANITY_YAML_TO_JSON=os.path.join(ANSIBLE_TEST_TOOLS_ROOT, 'yaml_to_json.py'),
|
|
|
|
|
ANSIBLE_CONTROLLER_MIN_PYTHON_VERSION=CONTROLLER_MIN_PYTHON_VERSION,
|
|
|
|
|
PYTHONPATH=':'.join((get_ansible_test_python_path(), env["PYTHONPATH"])),
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
display.info(import_type + ': ' + data, verbosity=4)
|
|
|
|
@ -186,3 +196,20 @@ class ImportTest(SanityMultipleVersion):
|
|
|
|
|
return SanityFailure(self.name, messages=results, python_version=python.version)
|
|
|
|
|
|
|
|
|
|
return SanitySuccess(self.name, python_version=python.version)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@cache
|
|
|
|
|
def get_ansible_test_python_path(): # type: () -> str
|
|
|
|
|
"""
|
|
|
|
|
Return a directory usable for PYTHONPATH, containing only the ansible-test collection loader.
|
|
|
|
|
The temporary directory created will be cached for the lifetime of the process and cleaned up at exit.
|
|
|
|
|
"""
|
|
|
|
|
python_path = create_temp_dir(prefix='ansible-test-')
|
|
|
|
|
ansible_test_path = os.path.join(python_path, 'ansible_test')
|
|
|
|
|
|
|
|
|
|
# legacy collection loader required by all python versions not supported by the controller
|
|
|
|
|
write_text_file(os.path.join(ansible_test_path, '__init__.py'), '', True)
|
|
|
|
|
write_text_file(os.path.join(ansible_test_path, '_internal', '__init__.py'), '', True)
|
|
|
|
|
os.symlink(os.path.join(ANSIBLE_TEST_TARGET_ROOT, 'legacy_collection_loader'), os.path.join(ansible_test_path, '_internal', 'legacy_collection_loader'))
|
|
|
|
|
|
|
|
|
|
return python_path
|
|
|
|
|