mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-30 14:07:59 +00:00
fix: test: Make system tests compatible with pytest 8.0.0+
Make system tests symlinks and logged test names consistent across pytest versions. Merge branch 'nicki/pytest-v8-compat' into 'main' See merge request isc-projects/bind9!9071
This commit is contained in:
1
bin/tests/system/.gitignore
vendored
1
bin/tests/system/.gitignore
vendored
@@ -16,6 +16,7 @@ named.run
|
|||||||
/*.trs
|
/*.trs
|
||||||
/*.xml
|
/*.xml
|
||||||
/resolve
|
/resolve
|
||||||
|
/legacy.run.sh
|
||||||
/run.log
|
/run.log
|
||||||
/start.sh
|
/start.sh
|
||||||
/stop.sh
|
/stop.sh
|
||||||
|
@@ -355,7 +355,7 @@ def system_test_dir(request, system_test_name):
|
|||||||
isctest.vars.dirs.set_system_test_name(testdir.name)
|
isctest.vars.dirs.set_system_test_name(testdir.name)
|
||||||
|
|
||||||
# Create a convenience symlink with a stable and predictable name
|
# Create a convenience symlink with a stable and predictable name
|
||||||
module_name = SYMLINK_REPLACEMENT_RE.sub(r"\1", request.node.name)
|
module_name = SYMLINK_REPLACEMENT_RE.sub(r"\1", str(_get_node_path(request.node)))
|
||||||
symlink_dst = system_test_root / module_name
|
symlink_dst = system_test_root / module_name
|
||||||
unlink(symlink_dst)
|
unlink(symlink_dst)
|
||||||
symlink_dst.symlink_to(os.path.relpath(testdir, start=system_test_root))
|
symlink_dst.symlink_to(os.path.relpath(testdir, start=system_test_root))
|
||||||
@@ -446,6 +446,15 @@ def _run_script(
|
|||||||
isctest.log.debug(" exited with %d", returncode)
|
isctest.log.debug(" exited with %d", returncode)
|
||||||
|
|
||||||
|
|
||||||
|
def _get_node_path(node) -> Path:
|
||||||
|
if isinstance(node.parent, pytest.Session):
|
||||||
|
if _pytest_major_ver >= 8:
|
||||||
|
return Path()
|
||||||
|
return Path(node.name)
|
||||||
|
assert node.parent is not None
|
||||||
|
return _get_node_path(node.parent) / node.name
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope="module")
|
@pytest.fixture(scope="module")
|
||||||
def shell(system_test_dir):
|
def shell(system_test_dir):
|
||||||
"""Function to call a shell script with arguments."""
|
"""Function to call a shell script with arguments."""
|
||||||
@@ -543,7 +552,7 @@ def system_test(
|
|||||||
isctest.log.error("Found core dumps or sanitizer reports")
|
isctest.log.error("Found core dumps or sanitizer reports")
|
||||||
pytest.fail(f"get_core_dumps.sh exited with {exc.returncode}")
|
pytest.fail(f"get_core_dumps.sh exited with {exc.returncode}")
|
||||||
|
|
||||||
isctest.log.info(f"test started: {request.node.name}")
|
isctest.log.info(f"test started: {_get_node_path(request.node)}")
|
||||||
port = int(os.environ["PORT"])
|
port = int(os.environ["PORT"])
|
||||||
isctest.log.info(
|
isctest.log.info(
|
||||||
"using port range: <%d, %d>", port, port + isctest.vars.ports.PORTS_PER_TEST - 1
|
"using port range: <%d, %d>", port, port + isctest.vars.ports.PORTS_PER_TEST - 1
|
||||||
|
Reference in New Issue
Block a user