diff --git a/test/test.py b/test/test.py index bc30d5f8a..a89aa0a7b 100644 --- a/test/test.py +++ b/test/test.py @@ -69,9 +69,10 @@ class State: eqLog = None class Result: - def __init__(self, snapshot, failure): + def __init__(self, snapshot, failure, page): self.snapshot = snapshot self.failure = failure + self.page = page class TestServer(SocketServer.TCPServer): allow_reuse_address = True @@ -122,10 +123,20 @@ class PDFTestHandler(BaseHTTPRequestHandler): 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'] taskResults = State.taskResults[browser][id] - taskResults[round].append(Result(snapshot, failure)) - assert len(taskResults[round]) == page + taskResults[round].append(Result(snapshot, failure, page)) - if result['taskDone']: + def isTaskDone(): + numPages = result["numPages"] + rounds = State.manifest[id]["rounds"] + for round in range(0,rounds): + if len(taskResults[round]) < numPages: + return False + return True + + if isTaskDone(): + # sort the results since they sometimes come in out of order + for results in taskResults: + results.sort(key=lambda result: result.page) check(State.manifest[id], taskResults, browser) # Please oh please GC this ... del State.taskResults[browser][id] diff --git a/test/test_slave.html b/test/test_slave.html index 1053025e1..03982bbb5 100644 --- a/test/test_slave.html +++ b/test/test_slave.html @@ -139,31 +139,41 @@ function snapshotCurrentPage(gfx) { } } - currentTask.taskDone = (currentTask.pageNum == pdfDoc.numPages - && (1 + currentTask.round) == currentTask.rounds); sendTaskResult(canvas.toDataURL("image/png")); log("done"+ (failure ? " (failed!)" : "") +"\n"); - ++currentTask.pageNum, nextPage(); -} - -function done() { - log("Done!\n"); + // Set up the next request + backoff = (inFlightRequests > 0) ? inFlightRequests * 10 : 0; setTimeout(function() { - document.body.innerHTML = "Tests are finished.

CLOSE ME!

"; - if (window.SpecialPowers) - SpecialPowers.quitApplication(); - else - window.close(); + ++currentTask.pageNum, nextPage(); }, - 100 + backoff ); } +function quitApp() { + log("Done!"); + document.body.innerHTML = "Tests are finished.

CLOSE ME!

"; + if (window.SpecialPowers) + SpecialPowers.quitApplication(); + else + window.close(); +} + +function done() { + if (inFlightRequests > 0) { + document.getElementById("inFlightCount").innerHTML = inFlightRequests; + setTimeout(done, 100); + } else { + setTimeout(quitApp, 100); + } +} + +var inFlightRequests = 0; function sendTaskResult(snapshot) { var result = { browser: browser, id: currentTask.id, - taskDone: currentTask.taskDone, + numPages: pdfDoc.numPages, failure: failure, file: currentTask.file, round: currentTask.round, @@ -172,9 +182,14 @@ function sendTaskResult(snapshot) { var r = new XMLHttpRequest(); // (The POST URI is ignored atm.) - r.open("POST", "/submit_task_results", false); + r.open("POST", "/submit_task_results", true); r.setRequestHeader("Content-Type", "application/json"); - // XXX async + r.onreadystatechange = function(e) { + if (r.readyState == 4) { + inFlightRequests--; + } + } + document.getElementById("inFlightCount").innerHTML = inFlightRequests++; r.send(JSON.stringify(result)); } @@ -194,7 +209,8 @@ function log(str) { -

+  

+  

Inflight requests: