From 4f6ea4fa1bd1da3059195055b83e950b70fc497f Mon Sep 17 00:00:00 2001 From: Tom Krizek Date: Thu, 10 Aug 2023 16:24:38 +0200 Subject: [PATCH] Improve tempdir logging for pytest runner 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. (cherry picked from commit f91d0b13e882f2b265412eadb958d2faa64974f8) --- bin/tests/system/conftest.py | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/bin/tests/system/conftest.py b/bin/tests/system/conftest.py index 326a02ef30..ad08ab9ead 100644 --- a/bin/tests/system/conftest.py +++ b/bin/tests/system/conftest.py @@ -452,7 +452,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: @@ -462,13 +462,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")