Relocate ansible-test self tests outside package. (#61255)

* Relocate ansible-test self tests outside package.

We don't want to include the tests for verifying ansible-test within the ansible-test package.

* Add `test/ansible_test/` to classification.py.

* Fix test invocation.

* Relocate tests in MANIFEST.in.

* Improve package-data sanity test error checking.

* Only use includes for ansible-test in MANIFEST.in.

* Improve readability of MANIFEST.in.
This commit is contained in:
Matt Clay 2019-08-24 11:38:30 -07:00 committed by GitHub
parent c61dec032c
commit 02c38ed4fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 36 additions and 22 deletions

View File

@ -19,12 +19,13 @@ recursive-include lib/ansible/galaxy/data *.yml *.j2 README.md ansible.cfg inven
recursive-include lib/ansible/config *.yml
recursive-include licenses *.txt
recursive-include packaging *
recursive-include test/ansible_test *.py Makefile
recursive-include test/cache .keep
recursive-include test/integration *
recursive-include test/lib/ansible_test/config *.template
recursive-include test/lib/ansible_test/_data *
recursive-include test/lib/ansible_test/tests *
recursive-exclude test/lib/ansible_test *.pyc *.pyo *.bak *.orig *~ *.rej
recursive-include test/lib/ansible_test/_data *.cfg *.ini *.json *.ps1 *.psd1 *.py *.sh *.txt *.yml coveragerc inventory
recursive-include test/lib/ansible_test/_data/injector ansible ansible-config ansible-connection ansible-console ansible-doc ansible-galaxy ansible-playbook ansible-pull ansible-test ansible-vault pytest
recursive-include test/lib/ansible_test/_data/sanity/validate-modules validate-modules
recursive-include test/results .keep
recursive-include test/sanity *.json *.py *.txt
exclude test/sanity/code-smell/botmeta.*

View File

@ -0,0 +1,13 @@
all: sanity unit validate-modules-unit
.PHONY: sanity
sanity:
$(abspath ${CURDIR}/../../bin/ansible-test) sanity test/lib/ ${FLAGS}
.PHONY: unit
unit:
PYTHONPATH=$(abspath ${CURDIR}/../lib) pytest unit ${FLAGS}
.PHONY: validate-modules-unit
validate-modules-unit:
PYTHONPATH=$(abspath ${CURDIR}/../lib/ansible_test/_data/sanity/validate-modules):$(abspath ${CURDIR}/../../lib) pytest validate-modules-unit ${FLAGS}

View File

@ -6,12 +6,12 @@ import os
import subprocess
import pytest
from ..._internal.util import (
from ansible_test._internal.util import (
to_text,
to_bytes,
)
from ..._internal.diff import (
from ansible_test._internal.diff import (
parse_diff,
FileDiff,
)

View File

@ -617,6 +617,9 @@ class PathMapper:
return minimal
if path.startswith('test/ansible_test/'):
return minimal # these tests are not invoked from ansible-test
if path.startswith('test/cache/'):
return minimal

View File

@ -1,13 +0,0 @@
all: sanity unit validate-modules-unit
.PHONY: sanity
sanity:
ansible-test sanity test/lib/ ${FLAGS}
.PHONY: unit
unit:
PYTHONPATH=$(abspath ${CURDIR}/../..) pytest unit ${FLAGS}
.PHONY: validate-modules-unit
validate-modules-unit:
PYTHONPATH=$(abspath ${CURDIR}/../_data/sanity/validate-modules):$(abspath ${CURDIR}/../../../../lib) pytest validate-modules-unit ${FLAGS}

View File

@ -161,12 +161,17 @@ def clean_repository(file_list):
def create_sdist(tmp_dir):
"""Create an sdist in the repository"""
dummy = subprocess.Popen(
create = subprocess.Popen(
['make', 'snapshot', 'SDIST_DIR=%s' % tmp_dir],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
universal_newlines=True,
).communicate()
)
stderr = create.communicate()[1]
if create.returncode != 0:
raise Exception('make snapshot failed:\n%s' % stderr)
# Determine path to sdist
tmp_dir_files = os.listdir(tmp_dir)
@ -204,13 +209,18 @@ def extract_sdist(sdist_path, tmp_dir):
def install_sdist(tmp_dir, sdist_dir):
"""Install the extracted sdist into the temporary directory"""
stdout, _dummy = subprocess.Popen(
install = subprocess.Popen(
['python', 'setup.py', 'install', '--root=%s' % tmp_dir],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
universal_newlines=True,
cwd=os.path.join(tmp_dir, sdist_dir),
).communicate()
)
stdout, stderr = install.communicate()
if install.returncode != 0:
raise Exception('sdist install failed:\n%s' % stderr)
# Determine the prefix for the installed files
match = re.search('^creating (%s/.*?/(?:site|dist)-packages)/ansible$' %