Skip to content

Commit

Permalink
Skip tests which are not supposed to run on Salt as a system service
Browse files Browse the repository at this point in the history
Signed-off-by: Pedro Algarvio <palgarvio@vmware.com>
  • Loading branch information
s0undt3ch committed Nov 25, 2023
1 parent caae371 commit 6ec3046
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ jobs:
id: run-tests
env:
SKIP_REQUIREMENTS_INSTALL: YES
SALT_FACTORIES_SYSTEM_SERVICE: "1"
run: |
sudo -E nox --force-color -e tests --no-venv -- -vv tests/
Expand Down
11 changes: 11 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,14 @@ def pytest_collection_modifyitems(items):
)
if str(item.fspath).startswith(system_service_skip_paths):
item.add_marker(skip_marker)


@pytest.hookimpl(tryfirst=True)
def pytest_runtest_setup(item):
skip_on_salt_system_service_marker = item.get_closest_marker("skip_on_salt_system_service")
if (
skip_on_salt_system_service_marker is not None
and os.environ.get("SALT_FACTORIES_SYSTEM_SERVICE", "0") == "1"
):
msg = "Salt as a system service detected, and test should skip this scenario."
raise pytest.skip.Exception(msg, _use_item_location=True)

0 comments on commit 6ec3046

Please sign in to comment.