mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-23 17:24:48 +00:00
lit/TestRunner.py: [Win32] Rework WinWaitReleased().
We can simply confirm the handle released to open it with EXCLUSIVE. Attempting renaming was bad. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152915 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -29,12 +29,20 @@ def RemoveForce(f):
|
|||||||
except OSError:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def WinRename(f_o, f_n):
|
def WinWaitReleased(f):
|
||||||
import time
|
import time, win32file
|
||||||
retry_cnt = 256
|
retry_cnt = 256
|
||||||
while (True):
|
while True:
|
||||||
try:
|
try:
|
||||||
os.rename(f_o, f_n)
|
h = win32file.CreateFile(
|
||||||
|
f,
|
||||||
|
0, # Querying, neither GENERIC_READ nor GENERIC_WRITE
|
||||||
|
0, # Exclusive
|
||||||
|
None,
|
||||||
|
win32file.OPEN_EXISTING,
|
||||||
|
win32file.FILE_ATTRIBUTE_NORMAL,
|
||||||
|
None)
|
||||||
|
h.close()
|
||||||
break
|
break
|
||||||
except WindowsError, (winerror, strerror):
|
except WindowsError, (winerror, strerror):
|
||||||
retry_cnt = retry_cnt - 1
|
retry_cnt = retry_cnt - 1
|
||||||
@ -45,21 +53,6 @@ def WinRename(f_o, f_n):
|
|||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
def WinWaitReleased(f):
|
|
||||||
import random
|
|
||||||
t = "%s%06d" % (f, random.randint(0, 999999))
|
|
||||||
RemoveForce(t)
|
|
||||||
try:
|
|
||||||
WinRename(f, t) # rename
|
|
||||||
WinRename(t, f) # restore
|
|
||||||
except WindowsError, (winerror, strerror):
|
|
||||||
if winerror in (2, 3):
|
|
||||||
# 2: ERROR_FILE_NOT_FOUND
|
|
||||||
# 3: ERROR_PATH_NOT_FOUND
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
raise
|
|
||||||
|
|
||||||
def executeCommand(command, cwd=None, env=None):
|
def executeCommand(command, cwd=None, env=None):
|
||||||
p = subprocess.Popen(command, cwd=cwd,
|
p = subprocess.Popen(command, cwd=cwd,
|
||||||
stdin=subprocess.PIPE,
|
stdin=subprocess.PIPE,
|
||||||
|
Reference in New Issue
Block a user