]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Improve tempdir logging for pytest runner
authorTom Krizek <tkrizek@isc.org>
Thu, 10 Aug 2023 14:24:38 +0000 (16:24 +0200)
committerTom Krizek <tkrizek@isc.org>
Mon, 21 Aug 2023 13:54:40 +0000 (15:54 +0200)
At the end of the test, display the symlink path to the artifact
directory in case it's preserved. Log the full tempdir name in debug
log.

bin/tests/system/conftest.py

index fd7510827fbe3290b914513eea438454b86311e3..63b992eb40d26ee9dad6a5deb75928ee1668787c 100644 (file)
@@ -451,7 +451,7 @@ else:
         # System tests are meant to be executed from their directory - switch to it.
         old_cwd = os.getcwd()
         os.chdir(testdir)
-        mlogger.info("switching to tmpdir: %s", testdir)
+        mlogger.debug("switching to tmpdir: %s", testdir)
         try:
             yield testdir  # other fixtures / tests will execute here
         finally:
@@ -461,13 +461,27 @@ else:
             result = get_test_result()
 
             # Clean temporary dir unless it should be kept
+            keep = False
             if request.config.getoption("--noclean"):
-                mlogger.debug("--noclean requested, keeping temporary directory")
+                mlogger.debug(
+                    "--noclean requested, keeping temporary directory %s", testdir
+                )
+                keep = True
             elif result == "failed":
-                mlogger.debug("test failure detected, keeping temporary directory")
+                mlogger.debug(
+                    "test failure detected, keeping temporary directory %s", testdir
+                )
+                keep = True
             elif not request.node.stash[FIXTURE_OK]:
                 mlogger.debug(
-                    "test setup/teardown issue detected, keeping temporary directory"
+                    "test setup/teardown issue detected, keeping temporary directory %s",
+                    testdir,
+                )
+                keep = True
+
+            if keep:
+                mlogger.info(
+                    "test artifacts in: %s", symlink_dst.relative_to(system_test_root)
                 )
             else:
                 mlogger.debug("deleting temporary directory")