Browse Source

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>
v1.8.0-commit
Bert Belder 10 years ago
parent
commit
b57e9a9973
  1. 18
      tools/test.py

18
tools/test.py

@ -41,6 +41,7 @@ import time
import threading import threading
import utils import utils
import multiprocessing import multiprocessing
import errno
from os.path import join, dirname, abspath, basename, isdir, exists from os.path import join, dirname, abspath, basename, isdir, exists
from datetime import datetime from datetime import datetime
@ -570,11 +571,18 @@ def PrintError(str):
def CheckedUnlink(name): def CheckedUnlink(name):
try: while True:
os.unlink(name) try:
except OSError, e: os.unlink(name)
PrintError("os.unlink() " + str(e)) 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={}): def Execute(args, context, timeout=None, env={}):
(fd_out, outname) = tempfile.mkstemp() (fd_out, outname) = tempfile.mkstemp()

Loading…
Cancel
Save