Skip to content

Commit

Permalink
Make firstPage work in test_manifest.json + rename pageLimit -> lastPage
Browse files Browse the repository at this point in the history
  • Loading branch information
mduan committed Jan 30, 2013
1 parent f18655f commit 48c15b7
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 51 deletions.
17 changes: 11 additions & 6 deletions test/driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,16 @@ function nextTask() {
});
}

function isLastPage(task) {
var limit = task.pageLimit || 0;
if (!limit || limit > task.pdfDoc.numPages)
limit = task.pdfDoc.numPages;
function getLastPageNum(task) {
var lastPageNum = task.lastPage || 0;
if (!lastPageNum || lastPageNum > task.pdfDoc.numPages) {
lastPageNum = task.pdfDoc.numPages;
}
return lastPageNum;
}

return task.pageNum > limit;
function isLastPage(task) {
return task.pageNum > getLastPageNum(task);
}

function canvasToDataURL() {
Expand Down Expand Up @@ -347,7 +351,8 @@ function sendTaskResult(snapshot, task, failure, result) {
browser: browser,
id: task.id,
numPages: task.pdfDoc ?
(task.pageLimit || task.pdfDoc.numPages) : 0,
(task.lastPage || task.pdfDoc.numPages) : 0,
lastPageNum: getLastPageNum(task),
failure: failure,
file: task.file,
round: task.round,
Expand Down
31 changes: 20 additions & 11 deletions test/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,12 @@ def do_POST(self):
print result['message']
return

id, failure, round, page, snapshot = result['id'], result['failure'], result['round'], result['page'], result['snapshot']
id = result['id']
failure = result['failure']
round = result['round']
page = result['page']
snapshot = result['snapshot']

taskResults = State.taskResults[browser][id]
taskResults[round].append(Result(snapshot, failure, page))
if State.saveStats:
Expand All @@ -347,10 +352,13 @@ def do_POST(self):
State.stats.append(stat)

def isTaskDone():
numPages = result["numPages"]
rounds = State.manifest[id]["rounds"]
last_page_num = result['lastPageNum']
rounds = State.manifest[id]['rounds']
for round in range(0,rounds):
if len(taskResults[round]) < numPages:
if not taskResults[round]:
return False
latest_page = taskResults[round][-1]
if not latest_page.page == last_page_num:
return False
return True

Expand Down Expand Up @@ -643,12 +651,13 @@ def checkEq(task, results, browser, masterMode):
taskType = task['type']

passed = True
for page in xrange(len(results)):
snapshot = results[page].snapshot
for result in results:
page = result.page
snapshot = result.snapshot
ref = None
eq = True

path = os.path.join(pfx, str(page + 1))
path = os.path.join(pfx, str(page))
if not os.access(path, os.R_OK):
State.numEqNoSnapshot += 1
if not masterMode:
Expand All @@ -660,7 +669,7 @@ def checkEq(task, results, browser, masterMode):

eq = (ref == snapshot)
if not eq:
print 'TEST-UNEXPECTED-FAIL |', taskType, taskId, '| in', browser, '| rendering of page', page + 1, '!= reference rendering'
print 'TEST-UNEXPECTED-FAIL |', taskType, taskId, '| in', browser, '| rendering of page', page, '!= reference rendering'

if not State.eqLog:
State.eqLog = open(EQLOG_FILE, 'w')
Expand All @@ -669,7 +678,7 @@ def checkEq(task, results, browser, masterMode):
# NB: this follows the format of Mozilla reftest
# output so that we can reuse its reftest-analyzer
# script
eqLog.write('REFTEST TEST-UNEXPECTED-FAIL | ' + browser +'-'+ taskId +'-page'+ str(page + 1) + ' | image comparison (==)\n')
eqLog.write('REFTEST TEST-UNEXPECTED-FAIL | ' + browser +'-'+ taskId +'-page'+ str(page) + ' | image comparison (==)\n')
eqLog.write('REFTEST IMAGE 1 (TEST): ' + snapshot + '\n')
eqLog.write('REFTEST IMAGE 2 (REFERENCE): ' + ref + '\n')

Expand All @@ -683,8 +692,8 @@ def checkEq(task, results, browser, masterMode):
except OSError, e:
if e.errno != 17: # file exists
print >>sys.stderr, 'Creating', tmpTaskDir, 'failed!'
of = open(os.path.join(tmpTaskDir, str(page + 1)), 'w')

of = open(os.path.join(tmpTaskDir, str(page)), 'w')
of.write(snapshot)
of.close()

Expand Down
Loading

0 comments on commit 48c15b7

Please sign in to comment.