diff options
author | Ben Gamari <bgamari.foss@gmail.com> | 2017-04-24 09:41:56 -0400 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2017-04-24 12:53:43 -0400 |
commit | 6f9f5ff16599814d8b10869be6dd424a5f7645d8 (patch) | |
tree | e66717da2dd149a9a0f360825948f2fded4f50fb | |
parent | b68697e579d38ca29c2b84377dc2affa04659a28 (diff) | |
download | haskell-6f9f5ff16599814d8b10869be6dd424a5f7645d8.tar.gz |
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: https://phabricator.haskell.org/D3492
-rw-r--r-- | testsuite/driver/testlib.py | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/testsuite/driver/testlib.py b/testsuite/driver/testlib.py index 457e3800d7..1f08f5b38a 100644 --- a/testsuite/driver/testlib.py +++ b/testsuite/driver/testlib.py @@ -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: - cleanup() + try: + cleanup() + 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): - time.sleep((max_attemps-retries)*6) - shutil.rmtree(testdir, onerror=on_error, ignore_errors=False) - retries=-1 + time.sleep((max_attempts-retries)*6) + try: + 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)) else: def cleanup(): testdir = getTestOpts().testdir |