mirror of
https://github.com/aljazceru/lightning.git
synced 2026-01-09 00:54:22 +01:00
pyln-testing: try harder if cleaning directory fails.
This happens under CI, but it's not informative. Sleep and retry. Also, "except (OSError, Exception)" does not seem to do what you'd think: this clause never gets run. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -14,6 +14,7 @@ import shutil
|
||||
import string
|
||||
import sys
|
||||
import tempfile
|
||||
import time
|
||||
|
||||
|
||||
# A dict in which we count how often a particular test has run so far. Used to
|
||||
@@ -94,10 +95,14 @@ def directory(request, test_base_dir, test_name):
|
||||
if not failed:
|
||||
try:
|
||||
shutil.rmtree(directory)
|
||||
except (OSError, Exception):
|
||||
except OSError:
|
||||
# Usually, this means that e.g. valgrind is still running. Wait
|
||||
# a little and retry.
|
||||
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
|
||||
print("Directory still contains files: ", files)
|
||||
print("... sleeping then retrying")
|
||||
time.sleep(10)
|
||||
shutil.rmtree(directory)
|
||||
else:
|
||||
logging.debug("Test execution failed, leaving the test directory {} intact.".format(directory))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user