mirror of
https://github.com/saltstack/salt.git
synced 2025-04-16 17:50:20 +00:00
Instead of skipping tests, don't even select them
This commit is contained in:
parent
1c64b277cc
commit
19cba10fa2
5 changed files with 73 additions and 11 deletions
|
@ -200,7 +200,7 @@ jobs:
|
|||
run: |
|
||||
tools --timestamps --no-output-timeout-secs=1800 --timeout-secs=14400 vm test --skip-requirements-install ${{ matrix.fips && '--fips ' || '' }}\
|
||||
--nox-session=${{ inputs.nox-session }}-pkgs --rerun-failures ${{ inputs.distro-slug }} -- ${{ matrix.tests-chunk }} \
|
||||
${{ matrix.version && format('--prev-version {0}', matrix.version) || ''}}
|
||||
${{ matrix.version && format('--prev-version={0}', matrix.version) || ''}}
|
||||
|
||||
- name: Download Test Run Artifacts
|
||||
id: download-artifacts-from-vm
|
||||
|
|
|
@ -185,7 +185,7 @@ jobs:
|
|||
COVERAGE_CONTEXT: ${{ inputs.distro-slug }}
|
||||
run: |
|
||||
sudo -E nox --force-color -e ${{ inputs.nox-session }}-pkgs -- ${{ matrix.tests-chunk }} \
|
||||
${{ matrix.version && format('--prev-version {0}', matrix.version) || ''}}
|
||||
${{ matrix.version && format('--prev-version={0}', matrix.version) || ''}}
|
||||
|
||||
- name: Fix file ownership
|
||||
run: |
|
||||
|
|
|
@ -199,7 +199,7 @@ jobs:
|
|||
run: |
|
||||
tools --timestamps --no-output-timeout-secs=1800 --timeout-secs=14400 vm test --skip-requirements-install ${{ matrix.fips && '--fips ' || '' }}\
|
||||
--nox-session=${{ inputs.nox-session }}-pkgs --rerun-failures ${{ inputs.distro-slug }} -- ${{ matrix.tests-chunk }} \
|
||||
${{ matrix.version && format('--prev-version {0}', matrix.version) || ''}}
|
||||
${{ matrix.version && format('--prev-version={0}', matrix.version) || ''}}
|
||||
|
||||
- name: Download Test Run Artifacts
|
||||
id: download-artifacts-from-vm
|
||||
|
|
26
noxfile.py
26
noxfile.py
|
@ -1828,32 +1828,25 @@ def ci_test_onedir_pkgs(session):
|
|||
]
|
||||
|
||||
chunks = {
|
||||
"install": [
|
||||
"tests/pytests/pkg/",
|
||||
],
|
||||
"install": [],
|
||||
"upgrade": [
|
||||
"--upgrade",
|
||||
"--no-uninstall",
|
||||
"tests/pytests/pkg/upgrade/",
|
||||
],
|
||||
"upgrade-classic": [
|
||||
"--upgrade",
|
||||
"--no-uninstall",
|
||||
"tests/pytests/pkg/upgrade/",
|
||||
],
|
||||
"downgrade": [
|
||||
"--downgrade",
|
||||
"--no-uninstall",
|
||||
"tests/pytests/pkg/downgrade/",
|
||||
],
|
||||
"downgrade-classic": [
|
||||
"--downgrade",
|
||||
"--no-uninstall",
|
||||
"tests/pytests/pkg/downgrade/",
|
||||
],
|
||||
"download-pkgs": [
|
||||
"--download-pkgs",
|
||||
"tests/pytests/pkg/download/",
|
||||
],
|
||||
}
|
||||
|
||||
|
@ -1894,6 +1887,17 @@ def ci_test_onedir_pkgs(session):
|
|||
]
|
||||
+ session.posargs
|
||||
)
|
||||
append_tests_path = True
|
||||
test_paths = (
|
||||
"tests/pytests/pkg/",
|
||||
str(REPO_ROOT / "tests" / "pytests" / "pkg"),
|
||||
)
|
||||
for arg in session.posargs:
|
||||
if arg.startswith(test_paths):
|
||||
append_tests_path = False
|
||||
break
|
||||
if append_tests_path:
|
||||
pytest_args.append("tests/pytests/pkg/")
|
||||
try:
|
||||
_pytest(session, coverage=False, cmd_args=pytest_args, env=env)
|
||||
except CommandFailed:
|
||||
|
@ -1917,6 +1921,8 @@ def ci_test_onedir_pkgs(session):
|
|||
]
|
||||
+ session.posargs
|
||||
)
|
||||
if append_tests_path:
|
||||
pytest_args.append("tests/pytests/pkg/")
|
||||
_pytest(
|
||||
session,
|
||||
coverage=False,
|
||||
|
@ -1941,6 +1947,8 @@ def ci_test_onedir_pkgs(session):
|
|||
pytest_args.append("--use-prev-version")
|
||||
if chunk in ("upgrade-classic", "downgrade-classic"):
|
||||
pytest_args.append("--classic")
|
||||
if append_tests_path:
|
||||
pytest_args.append("tests/pytests/pkg/")
|
||||
try:
|
||||
_pytest(session, coverage=False, cmd_args=pytest_args, env=env)
|
||||
except CommandFailed:
|
||||
|
@ -1963,6 +1971,8 @@ def ci_test_onedir_pkgs(session):
|
|||
pytest_args.append("--use-prev-version")
|
||||
if chunk in ("upgrade-classic", "downgrade-classic"):
|
||||
pytest_args.append("--classic")
|
||||
if append_tests_path:
|
||||
pytest_args.append("tests/pytests/pkg/")
|
||||
_pytest(
|
||||
session,
|
||||
coverage=False,
|
||||
|
|
|
@ -114,6 +114,58 @@ def pytest_addoption(parser):
|
|||
)
|
||||
|
||||
|
||||
@pytest.hookimpl(hookwrapper=True, trylast=True)
|
||||
def pytest_collection_modifyitems(config, items):
|
||||
"""
|
||||
called after collection has been performed, may filter or re-order
|
||||
the items in-place.
|
||||
|
||||
:param _pytest.main.Session session: the pytest session object
|
||||
:param _pytest.config.Config config: pytest config object
|
||||
:param List[_pytest.nodes.Item] items: list of item objects
|
||||
"""
|
||||
# Let PyTest or other plugins handle the initial collection
|
||||
yield
|
||||
selected = []
|
||||
deselected = []
|
||||
pkg_tests_path = pathlib.Path(__file__).parent
|
||||
|
||||
if config.getoption("--upgrade"):
|
||||
for item in items:
|
||||
if str(item.fspath).startswith(str(pkg_tests_path / "upgrade")):
|
||||
selected.append(item)
|
||||
else:
|
||||
deselected.append(item)
|
||||
elif config.getoption("--downgrade"):
|
||||
for item in items:
|
||||
if str(item.fspath).startswith(str(pkg_tests_path / "downgrade")):
|
||||
selected.append(item)
|
||||
else:
|
||||
deselected.append(item)
|
||||
elif config.getoption("--download-pkgs"):
|
||||
for item in items:
|
||||
if str(item.fspath).startswith(str(pkg_tests_path / "download")):
|
||||
selected.append(item)
|
||||
else:
|
||||
deselected.append(item)
|
||||
else:
|
||||
exclude_paths = (
|
||||
str(pkg_tests_path / "upgrade"),
|
||||
str(pkg_tests_path / "downgrade"),
|
||||
str(pkg_tests_path / "download"),
|
||||
)
|
||||
for item in items:
|
||||
if str(item.fspath).startswith(exclude_paths):
|
||||
deselected.append(item)
|
||||
else:
|
||||
selected.append(item)
|
||||
|
||||
if deselected:
|
||||
# Selection changed
|
||||
items[:] = selected
|
||||
config.hook.pytest_deselected(items=deselected)
|
||||
|
||||
|
||||
@pytest.hookimpl(tryfirst=True)
|
||||
def pytest_runtest_setup(item):
|
||||
"""
|
||||
|
|
Loading…
Add table
Reference in a new issue