Skip to content

Commit

Permalink
TST: try to skip tests that require nfs on CI
Browse files Browse the repository at this point in the history
  • Loading branch information
ZLLentz committed Dec 11, 2024
1 parent 3a21eaa commit 4af689c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
5 changes: 5 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
import pathlib
import sys

if pathlib.Path("/cds/group/pcds").exists():
on_cds_nfs = True
else:
on_cds_nfs = False


@contextlib.contextmanager
def cli_args(args):
Expand Down
19 changes: 18 additions & 1 deletion tests/test_expand.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from expand import main

from .conftest import cli_args
from .conftest import cli_args, on_cds_nfs


def get_release_dir(config_file: pathlib.Path) -> str:
Expand Down Expand Up @@ -134,6 +134,7 @@ def test_expand_full(tmp_path: pathlib.Path, cfg_name: str, template: str):
iocname = config_file.stem
build_dir = str(tmp_path)
for template_file in template_files:
maybe_skip(template_file=template_file)
if "ioc" in template:
target_file = tmp_path / template_file.name.replace("ioc", iocname)
else:
Expand Down Expand Up @@ -210,6 +211,22 @@ def test_expand_full(tmp_path: pathlib.Path, cfg_name: str, template: str):
assert output == expected, failure_info


def maybe_skip(template_file: pathlib.Path) -> None:
"""
Skip this test if we know it can't be done.
For example, tests that reference files from the CDS system can't be run
on CI. They need to have access to NFS.
"""
if on_cds_nfs:
return
with open(template_file, "r") as fd:
if "$$INCLUDE" in fd.read():
pytest.skip(
reason="Real test with INCLUDE macro cannot be done without NFS."
)


def full_match_ignoring_test_artifact(
text: str, test_artifact: str, expected: str
) -> bool:
Expand Down

0 comments on commit 4af689c

Please sign in to comment.