Add browser test timeout.
This commit is contained in:
parent
9b0224b5cf
commit
9ffc49e512
26
test/test.py
26
test/test.py
@ -16,6 +16,7 @@ BROWSERLOG_FILE = 'browser.log'
|
|||||||
REFDIR = 'ref'
|
REFDIR = 'ref'
|
||||||
TMPDIR = 'tmp'
|
TMPDIR = 'tmp'
|
||||||
VERBOSE = False
|
VERBOSE = False
|
||||||
|
BROWSER_TIMEOUT = 60
|
||||||
|
|
||||||
SERVER_HOST = "localhost"
|
SERVER_HOST = "localhost"
|
||||||
|
|
||||||
@ -74,7 +75,7 @@ class State:
|
|||||||
browsers = [ ]
|
browsers = [ ]
|
||||||
manifest = { }
|
manifest = { }
|
||||||
taskResults = { }
|
taskResults = { }
|
||||||
remaining = 0
|
remaining = { }
|
||||||
results = { }
|
results = { }
|
||||||
done = False
|
done = False
|
||||||
numErrors = 0
|
numErrors = 0
|
||||||
@ -83,6 +84,7 @@ class State:
|
|||||||
numFBFFailures = 0
|
numFBFFailures = 0
|
||||||
numLoadFailures = 0
|
numLoadFailures = 0
|
||||||
eqLog = None
|
eqLog = None
|
||||||
|
lastPost = { }
|
||||||
|
|
||||||
class Result:
|
class Result:
|
||||||
def __init__(self, snapshot, failure, page):
|
def __init__(self, snapshot, failure, page):
|
||||||
@ -180,6 +182,7 @@ class PDFTestHandler(BaseHTTPRequestHandler):
|
|||||||
|
|
||||||
result = json.loads(self.rfile.read(numBytes))
|
result = json.loads(self.rfile.read(numBytes))
|
||||||
browser, id, failure, round, page, snapshot = result['browser'], result['id'], result['failure'], result['round'], result['page'], result['snapshot']
|
browser, id, failure, round, page, snapshot = result['browser'], result['id'], result['failure'], result['round'], result['page'], result['snapshot']
|
||||||
|
State.lastPost[browser] = int(time.time())
|
||||||
taskResults = State.taskResults[browser][id]
|
taskResults = State.taskResults[browser][id]
|
||||||
taskResults[round].append(Result(snapshot, failure, page))
|
taskResults[round].append(Result(snapshot, failure, page))
|
||||||
|
|
||||||
@ -199,9 +202,16 @@ class PDFTestHandler(BaseHTTPRequestHandler):
|
|||||||
self.server.masterMode)
|
self.server.masterMode)
|
||||||
# Please oh please GC this ...
|
# Please oh please GC this ...
|
||||||
del State.taskResults[browser][id]
|
del State.taskResults[browser][id]
|
||||||
State.remaining -= 1
|
State.remaining[browser] -= 1
|
||||||
|
|
||||||
State.done = (0 == State.remaining)
|
checkIfDone()
|
||||||
|
|
||||||
|
def checkIfDone():
|
||||||
|
State.done = True
|
||||||
|
for key in State.remaining:
|
||||||
|
if State.remaining[key] != 0:
|
||||||
|
State.done = False
|
||||||
|
return
|
||||||
|
|
||||||
# Applescript hack to quit Chrome on Mac
|
# Applescript hack to quit Chrome on Mac
|
||||||
def tellAppToQuit(path, query):
|
def tellAppToQuit(path, query):
|
||||||
@ -376,6 +386,8 @@ def setUp(options):
|
|||||||
|
|
||||||
for b in testBrowsers:
|
for b in testBrowsers:
|
||||||
State.taskResults[b.name] = { }
|
State.taskResults[b.name] = { }
|
||||||
|
State.remaining[b.name] = len(manifestList)
|
||||||
|
State.lastPost[b.name] = int(time.time())
|
||||||
for item in manifestList:
|
for item in manifestList:
|
||||||
id, rounds = item['id'], int(item['rounds'])
|
id, rounds = item['id'], int(item['rounds'])
|
||||||
State.manifest[id] = item
|
State.manifest[id] = item
|
||||||
@ -384,8 +396,6 @@ def setUp(options):
|
|||||||
taskResults.append([ ])
|
taskResults.append([ ])
|
||||||
State.taskResults[b.name][id] = taskResults
|
State.taskResults[b.name][id] = taskResults
|
||||||
|
|
||||||
State.remaining = len(testBrowsers) * len(manifestList)
|
|
||||||
|
|
||||||
return testBrowsers
|
return testBrowsers
|
||||||
|
|
||||||
def startBrowsers(browsers, options):
|
def startBrowsers(browsers, options):
|
||||||
@ -568,6 +578,12 @@ def runTests(options, browsers):
|
|||||||
try:
|
try:
|
||||||
startBrowsers(browsers, options)
|
startBrowsers(browsers, options)
|
||||||
while not State.done:
|
while not State.done:
|
||||||
|
for b in State.lastPost:
|
||||||
|
if State.remaining[b] > 0 and int(time.time()) - State.lastPost[b] > BROWSER_TIMEOUT:
|
||||||
|
print 'TEST-UNEXPECTED-FAIL | test failed', b, "has not responded in", BROWSER_TIMEOUT, "s"
|
||||||
|
State.numErrors += State.remaining[b]
|
||||||
|
State.remaining[b] = 0
|
||||||
|
checkIfDone()
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
processResults()
|
processResults()
|
||||||
finally:
|
finally:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user