diff options
author | Bert Belder <bertbelder@gmail.com> | 2015-01-11 01:49:33 +0100 |
---|---|---|
committer | Bert Belder <bertbelder@gmail.com> | 2015-01-11 01:54:35 +0100 |
commit | b57e9a99739c634053daa04667674090c07e1938 (patch) | |
tree | c29e4788037bc48a376e837510ee91273a4dc1cc /tools | |
parent | 7f9a6c6213763fbc072e4052e7ce13c6c00648e4 (diff) | |
download | node-new-b57e9a99739c634053daa04667674090c07e1938.tar.gz |
win,test: try again if file unlink fails
Now that parallel tests are enabled, the test runner spits out a ton of
'access denied' errors while running the tests. These happen because a
virus scanner or the indexing service temporarily open the file after it
has been updated, and the test runner tries to unlink() them at the same
time.
This patch resolves this issue by attempting to unlink the file until it
succeeds.
PR-URL: https://github.com/iojs/io.js/pull/284
Reviewed-by: Ben Noordhuis <info@bnoordhuis.nl>
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/test.py | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/tools/test.py b/tools/test.py index 3414425a10..c78599bf06 100755 --- a/tools/test.py +++ b/tools/test.py @@ -41,6 +41,7 @@ import time import threading import utils import multiprocessing +import errno from os.path import join, dirname, abspath, basename, isdir, exists from datetime import datetime @@ -570,11 +571,18 @@ def PrintError(str): def CheckedUnlink(name): - try: - os.unlink(name) - except OSError, e: - PrintError("os.unlink() " + str(e)) - + while True: + try: + os.unlink(name) + except OSError, e: + # On Windows unlink() fails if another process (typically a virus scanner + # or the indexing service) has the file open. Those processes keep a + # file open for a short time only, so yield and try again; it'll succeed. + if sys.platform == 'win32' and e.errno == errno.EACCES: + time.sleep(0) + continue + PrintError("os.unlink() " + str(e)) + break def Execute(args, context, timeout=None, env={}): (fd_out, outname) = tempfile.mkstemp() |