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 5ac5176 commit 297946e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,9 @@ 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/
sudo -E nox --force-color -e tests --no-venv -- -vv --system-service tests/
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
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 (
item.config.getoption("--system-service")
or 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 297946e

Please sign in to comment.