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.
This commit is contained in:
Christian Decker
2020-02-19 17:51:55 +01:00
committed by Rusty Russell
parent 3e3b05e1b2
commit cf8c972883

View File

@@ -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:
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))