From f3d1f9544ba67785e787ea303f81db74603780eb Mon Sep 17 00:00:00 2001 From: Matt Clay Date: Wed, 19 Sep 2018 17:58:55 -0700 Subject: [PATCH] Make ansible-test available in the bin directory. (#45876) --- bin/ansible-test | 15 +++++++++++++++ hacking/env-setup | 2 +- hacking/env-setup.fish | 2 +- test/runner/ansible-test | 9 ++++++++- test/runner/{test.py => lib/cli.py} | 8 +------- test/runner/lib/delegation.py | 6 +++--- test/sanity/pylint/ignore.txt | 1 - 7 files changed, 29 insertions(+), 14 deletions(-) create mode 100755 bin/ansible-test mode change 120000 => 100755 test/runner/ansible-test rename test/runner/{test.py => lib/cli.py} (99%) mode change 100755 => 100644 diff --git a/bin/ansible-test b/bin/ansible-test new file mode 100755 index 0000000000..aa1c3da47b --- /dev/null +++ b/bin/ansible-test @@ -0,0 +1,15 @@ +#!/usr/bin/env python +# PYTHON_ARGCOMPLETE_OK +"""Primary entry point for ansible-test.""" + +from __future__ import (absolute_import, division, print_function) + +__metaclass__ = type + +import os +import sys + +if __name__ == '__main__': + sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(os.path.dirname(__file__)), 'test', 'runner'))) + import lib.cli + lib.cli.main() diff --git a/hacking/env-setup b/hacking/env-setup index ae173454ab..d4ac830007 100644 --- a/hacking/env-setup +++ b/hacking/env-setup @@ -47,7 +47,7 @@ FULL_PATH=$($PYTHON_BIN -c "import os; print(os.path.realpath('$HACKING_DIR'))") export ANSIBLE_HOME="$(dirname "$FULL_PATH")" PREFIX_PYTHONPATH="$ANSIBLE_HOME/lib" -PREFIX_PATH="$ANSIBLE_HOME/bin:$ANSIBLE_HOME/test/runner" +PREFIX_PATH="$ANSIBLE_HOME/bin" PREFIX_MANPATH="$ANSIBLE_HOME/docs/man" expr "$PYTHONPATH" : "${PREFIX_PYTHONPATH}.*" > /dev/null || prepend_path PYTHONPATH "$PREFIX_PYTHONPATH" diff --git a/hacking/env-setup.fish b/hacking/env-setup.fish index b7b2db63b7..ee78e2ed4b 100644 --- a/hacking/env-setup.fish +++ b/hacking/env-setup.fish @@ -5,7 +5,7 @@ set HACKING_DIR (dirname (status -f)) set FULL_PATH (python -c "import os; print(os.path.realpath('$HACKING_DIR'))") set ANSIBLE_HOME (dirname $FULL_PATH) set PREFIX_PYTHONPATH $ANSIBLE_HOME/lib -set PREFIX_PATH $ANSIBLE_HOME/bin $ANSIBLE_HOME/test/runner +set PREFIX_PATH $ANSIBLE_HOME/bin set PREFIX_MANPATH $ANSIBLE_HOME/docs/man # set quiet flag diff --git a/test/runner/ansible-test b/test/runner/ansible-test deleted file mode 120000 index 9465664311..0000000000 --- a/test/runner/ansible-test +++ /dev/null @@ -1 +0,0 @@ -test.py \ No newline at end of file diff --git a/test/runner/ansible-test b/test/runner/ansible-test new file mode 100755 index 0000000000..3bc73d6238 --- /dev/null +++ b/test/runner/ansible-test @@ -0,0 +1,8 @@ +#!/usr/bin/env python +# PYTHON_ARGCOMPLETE_OK +"""Legacy entry point for ansible-test. The preferred version is in the bin directory.""" + +import lib.cli + +if __name__ == '__main__': + lib.cli.main() diff --git a/test/runner/test.py b/test/runner/lib/cli.py old mode 100755 new mode 100644 similarity index 99% rename from test/runner/test.py rename to test/runner/lib/cli.py index 1529dd3ee1..4f404fe91f --- a/test/runner/test.py +++ b/test/runner/lib/cli.py @@ -1,5 +1,3 @@ -#!/usr/bin/env python -# PYTHON_ARGCOMPLETE_OK """Test runner for all Ansible tests.""" from __future__ import absolute_import, print_function @@ -72,7 +70,7 @@ import lib.cover def main(): """Main program function.""" try: - git_root = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', '..')) + git_root = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', '..', '..')) os.chdir(git_root) initialize_cloud_plugins() sanity_init() @@ -786,7 +784,3 @@ def complete_sanity_test(prefix, parsed_args, **_): tests = sorted(t.name for t in sanity_get_tests()) return [i for i in tests if i.startswith(prefix)] - - -if __name__ == '__main__': - main() diff --git a/test/runner/lib/delegation.py b/test/runner/lib/delegation.py index e94557884d..aea242a640 100644 --- a/test/runner/lib/delegation.py +++ b/test/runner/lib/delegation.py @@ -143,7 +143,7 @@ def delegate_tox(args, exclude, require, integration_targets): tox.append('--') - cmd = generate_command(args, os.path.abspath('test/runner/test.py'), options, exclude, require) + cmd = generate_command(args, os.path.abspath('bin/ansible-test'), options, exclude, require) if not args.python: cmd += ['--python', version] @@ -195,7 +195,7 @@ def delegate_docker(args, exclude, require, integration_targets): '--docker-util': 1, } - cmd = generate_command(args, '/root/ansible/test/runner/test.py', options, exclude, require) + cmd = generate_command(args, '/root/ansible/bin/ansible-test', options, exclude, require) if isinstance(args, TestConfig): if args.coverage and not args.coverage_label: @@ -364,7 +364,7 @@ def delegate_remote(args, exclude, require, integration_targets): '--remote': 1, } - cmd = generate_command(args, 'ansible/test/runner/test.py', options, exclude, require) + cmd = generate_command(args, 'ansible/bin/ansible-test', options, exclude, require) if httptester_id: cmd += ['--inject-httptester'] diff --git a/test/sanity/pylint/ignore.txt b/test/sanity/pylint/ignore.txt index 980e625e40..69de8bcab4 100644 --- a/test/sanity/pylint/ignore.txt +++ b/test/sanity/pylint/ignore.txt @@ -106,6 +106,5 @@ test/runner/lib/thread.py missing-docstring 3.7 test/runner/lib/util.py missing-docstring 3.7 test/runner/retry.py missing-docstring 3.7 test/runner/shippable.py missing-docstring 3.7 -test/runner/test.py missing-docstring 3.7 test/runner/units/test_diff.py missing-docstring 3.7 test/sanity/import/importer.py missing-docstring 3.7