From fa7f84217b865350ee518a9af3a6d33c0b8527b4 Mon Sep 17 00:00:00 2001 From: Matt Clay Date: Tue, 24 Jan 2017 10:31:39 -0800 Subject: [PATCH] Add startup checks to ansible-test. --- test/runner/lib/executor.py | 18 ++++++++++++++++++ test/runner/test.py | 2 ++ 2 files changed, 20 insertions(+) diff --git a/test/runner/lib/executor.py b/test/runner/lib/executor.py index 57efbe2bb08..742585cc77e 100644 --- a/test/runner/lib/executor.py +++ b/test/runner/lib/executor.py @@ -2,6 +2,7 @@ from __future__ import absolute_import, print_function +import errno import glob import os import tempfile @@ -84,6 +85,23 @@ COMPILE_PYTHON_VERSIONS = tuple(sorted(SUPPORTED_PYTHON_VERSIONS + ('2.4',))) coverage_path = '' # pylint: disable=locally-disabled, invalid-name +def check_startup(): + """Checks to perform at startup before running commands.""" + check_legacy_modules() + + +def check_legacy_modules(): + """Detect conflicts with legacy core/extras module directories to avoid problems later.""" + for directory in 'core', 'extras': + path = 'lib/ansible/modules/%s' % directory + + for root, _, file_names in os.walk(path): + if file_names: + # the directory shouldn't exist, but if it does, it must contain no files + raise ApplicationError('Files prohibited in "%s". ' + 'These are most likely legacy modules from version 2.2 or earlier.' % root) + + def create_shell_command(command): """ :type command: list[str] diff --git a/test/runner/test.py b/test/runner/test.py index ecb165875ef..c604258ed4a 100755 --- a/test/runner/test.py +++ b/test/runner/test.py @@ -39,6 +39,7 @@ from lib.executor import ( ApplicationWarning, Delegate, generate_pip_install, + check_startup, ) from lib.target import ( @@ -67,6 +68,7 @@ def main(): config = args.config(args) display.verbosity = config.verbosity display.color = config.color + check_startup() try: args.func(config)