Commit 6f9f5ff1 authored by Ben Gamari's avatar Ben Gamari Committed by Ben Gamari

testsuite/driver: Fix deletion retry logic on Windows

Previously rmtree's error callback would throw an exception, breaking
out of the retry loop.

Test Plan: Validate on Windows

Reviewers: Phyx, austin

Reviewed By: Phyx

Subscribers: rwbarton, thomie

Differential Revision:
parent b68697e5
......@@ -767,7 +767,10 @@ def test_common_work(watcher, name, opts, func, args):
t.n_tests_skipped += len(set(all_ways) - set(do_ways))
if config.cleanup and do_ways:
except Exception as e:
framework_fail(name, 'runTest', 'Unhandled exception during cleanup: ' + str(e))
package_conf_cache_file_end_timestamp = get_package_cache_timestamp();
......@@ -1910,8 +1913,8 @@ if config.msys:
import time
def cleanup():
testdir = getTestOpts().testdir
max_attemps = 5
retries = max_attemps
max_attempts = 5
retries = max_attempts
def on_error(function, path, excinfo):
# At least one test (T11489) removes the write bit from a file it
# produces. Windows refuses to delete read-only files with a
......@@ -1935,13 +1938,18 @@ if config.msys:
# with an even more cryptic error.
# See Trac #13162
exception = None
while retries > 0 and os.path.exists(testdir):
shutil.rmtree(testdir, onerror=on_error, ignore_errors=False)
shutil.rmtree(testdir, onerror=on_error, ignore_errors=False)
except Exception as e:
exception = e
retries -= 1
if retries == 0 and os.path.exists(testdir):
raise Exception("Unable to remove folder '" + testdir + "'. Unable to start current test.")
raise Exception("Unable to remove folder '%s': %s\nUnable to start current test."
% (testdir, exception))
def cleanup():
testdir = getTestOpts().testdir
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment