mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-31 14:35:26 +00:00
Add --noclean option to pytest runner
Support the --noclean option to allow the user to keep the artifacts from any test run.
This commit is contained in:
@@ -108,6 +108,14 @@ if os.getenv("LEGACY_TEST_RUNNER", "0") == "0":
|
|||||||
|
|
||||||
# --------------------------- pytest hooks -------------------------------
|
# --------------------------- pytest hooks -------------------------------
|
||||||
|
|
||||||
|
def pytest_addoption(parser):
|
||||||
|
parser.addoption(
|
||||||
|
"--noclean",
|
||||||
|
action="store_true",
|
||||||
|
default=False,
|
||||||
|
help="don't remove the temporary test directories with artifacts",
|
||||||
|
)
|
||||||
|
|
||||||
def pytest_configure():
|
def pytest_configure():
|
||||||
# Ensure this hook only runs on the main pytest instance if xdist is
|
# Ensure this hook only runs on the main pytest instance if xdist is
|
||||||
# used to spawn other workers.
|
# used to spawn other workers.
|
||||||
@@ -258,7 +266,10 @@ if os.getenv("LEGACY_TEST_RUNNER", "0") == "0":
|
|||||||
os.chdir(old_cwd)
|
os.chdir(old_cwd)
|
||||||
logger.debug("changed workdir to: %s", old_cwd)
|
logger.debug("changed workdir to: %s", old_cwd)
|
||||||
|
|
||||||
# cases when tempdir should be kept are handled in follow-up commits
|
# Clean temporary dir unless it should be kept
|
||||||
|
if request.config.getoption("--noclean"):
|
||||||
|
logger.debug("--noclean requested, keeping temporary directory")
|
||||||
|
else:
|
||||||
logger.debug("deleting temporary directory")
|
logger.debug("deleting temporary directory")
|
||||||
shutil.rmtree(testdir)
|
shutil.rmtree(testdir)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user