[commit: ghc] ghc-8.2: testsuite/driver: Fix deletion retry logic on Windows (5b0058e)

git at git.haskell.org git at git.haskell.org
Thu Apr 27 20:10:27 UTC 2017


Repository : ssh://git@git.haskell.org/ghc

On branch  : ghc-8.2
Link       : http://ghc.haskell.org/trac/ghc/changeset/5b0058e13910d74983375898036eec2201c32aba/ghc

>---------------------------------------------------------------

commit 5b0058e13910d74983375898036eec2201c32aba
Author: Ben Gamari <bgamari.foss at gmail.com>
Date:   Mon Apr 24 09:41:56 2017 -0400

    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
    
    (cherry picked from commit 6f9f5ff16599814d8b10869be6dd424a5f7645d8)


>---------------------------------------------------------------

5b0058e13910d74983375898036eec2201c32aba
 testsuite/driver/testlib.py | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/testsuite/driver/testlib.py b/testsuite/driver/testlib.py
index 457e380..1f08f5b 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



More information about the ghc-commits mailing list