From cf8c9728835fa7806af353a619a9c6c89f07159a Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Wed, 19 Feb 2020 17:51:55 +0100 Subject: [PATCH] pyln-testing: Print a list of files if we can't remove the test dir For some reason we fail to remove the test directory in some cases. My hypothesis is that it is a daemon that is not completely shut down yet, and still writes to the directory. This commit intercepts the error, prints any files in the directory and re-raises the error. This should allow us to debug the reappears. --- contrib/pyln-testing/pyln/testing/fixtures.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/contrib/pyln-testing/pyln/testing/fixtures.py b/contrib/pyln-testing/pyln/testing/fixtures.py index cda03c263..a5e888322 100644 --- a/contrib/pyln-testing/pyln/testing/fixtures.py +++ b/contrib/pyln-testing/pyln/testing/fixtures.py @@ -55,7 +55,12 @@ def directory(request, test_base_dir, test_name): failed = not outcome or request.node.has_errors or outcome != 'passed' if not failed: - shutil.rmtree(directory) + try: + shutil.rmtree(directory) + except Exception: + files = [os.path.join(dp, f) for dp, dn, fn in os.walk(directory) for f in fn] + print("Directory still contains files:", files) + raise else: logging.debug("Test execution failed, leaving the test directory {} intact.".format(directory))