From 99f419fa6b4f2f2661968497fec9f1f3ce479233 Mon Sep 17 00:00:00 2001 From: Artur Adib Date: Mon, 3 Oct 2011 14:53:45 -0400 Subject: [PATCH 1/4] New test/ features, useful for bot test.py: added option --noPrompts removed unnecessary warnings (masterMode) removed unnecessary "Creating tmp failed" message when error is simply b/c it already exists driver.js: added per PDF manifest option "pageLimit", e.g. "pageLimit":100 --- test/driver.js | 4 ++-- test/test.py | 16 ++++++++++------ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/test/driver.js b/test/driver.js index 7162af6f3..65dd3fa27 100644 --- a/test/driver.js +++ b/test/driver.js @@ -86,7 +86,7 @@ function nextTask() { } function isLastPage(task) { - return (task.pageNum > task.pdfDoc.numPages); + return task.pageNum > task.pdfDoc.numPages || task.pageNum > task.pageLimit; } function canvasToDataURL() { @@ -205,7 +205,7 @@ function done() { function sendTaskResult(snapshot, task, failure) { var result = { browser: browser, id: task.id, - numPages: task.pdfDoc ? task.pdfDoc.numPages : 0, + numPages: task.pdfDoc ? (task.pageLimit || task.pdfDoc.numPages) : 0, failure: failure, file: task.file, round: task.round, diff --git a/test/test.py b/test/test.py index 0d40efbc8..313a5e03a 100644 --- a/test/test.py +++ b/test/test.py @@ -23,6 +23,8 @@ class TestOptions(OptionParser): OptionParser.__init__(self, **kwargs) self.add_option("-m", "--masterMode", action="store_true", dest="masterMode", help="Run the script in master mode.", default=False) + self.add_option("--noPrompts", action="store_true", dest="noPrompts", + help="Uses default answers (intended for CLOUD TESTS only!).", default=False) self.add_option("--manifestFile", action="store", type="string", dest="manifestFile", help="A JSON file in the form of test_manifest.json (the default).") self.add_option("-b", "--browser", action="store", type="string", dest="browser", @@ -321,7 +323,7 @@ def setUp(options): if options.masterMode and os.path.isdir(TMPDIR): print 'Temporary snapshot dir tmp/ is still around.' print 'tmp/ can be removed if it has nothing you need.' - if prompt('SHOULD THIS SCRIPT REMOVE tmp/? THINK CAREFULLY'): + if options.noPrompts or prompt('SHOULD THIS SCRIPT REMOVE tmp/? THINK CAREFULLY'): subprocess.call(( 'rm', '-rf', 'tmp' )) assert not os.path.isdir(TMPDIR) @@ -414,8 +416,9 @@ def checkEq(task, results, browser, masterMode): path = os.path.join(pfx, str(page + 1)) if not os.access(path, os.R_OK): - print 'WARNING: no reference snapshot', path State.numEqNoSnapshot += 1 + if not masterMode: + print 'WARNING: no reference snapshot', path else: f = open(path) ref = f.read() @@ -444,8 +447,9 @@ def checkEq(task, results, browser, masterMode): try: os.makedirs(tmpTaskDir) except OSError, e: - print >>sys.stderr, 'Creating', tmpTaskDir, 'failed!' - + if e.errno != 17: # file exists + print >>sys.stderr, 'Creating', tmpTaskDir, 'failed!' + of = open(os.path.join(tmpTaskDir, str(page + 1)), 'w') of.write(snapshot) of.close() @@ -503,10 +507,10 @@ def maybeUpdateRefImages(options, browser): print ' Yes! The references in tmp/ can be synced with ref/.' if options.reftest: startReftest(browser, options) - if not prompt('Would you like to update the master copy in ref/?'): + if options.noPrompts or not prompt('Would you like to update the master copy in ref/?'): print ' OK, not updating.' else: - sys.stdout.write(' Updating ... ') + sys.stdout.write(' Updating ref/ ... ') # XXX unclear what to do on errors here ... # NB: do *NOT* pass --delete to rsync. That breaks this From 2f209a8e855cbff4e29580d2de039b9500375046 Mon Sep 17 00:00:00 2001 From: Artur Adib Date: Mon, 3 Oct 2011 15:21:26 -0400 Subject: [PATCH 2/4] Oh, 80-char limit... super modern --- test/driver.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/driver.js b/test/driver.js index 65dd3fa27..fe02a997d 100644 --- a/test/driver.js +++ b/test/driver.js @@ -205,7 +205,8 @@ function done() { function sendTaskResult(snapshot, task, failure) { var result = { browser: browser, id: task.id, - numPages: task.pdfDoc ? (task.pageLimit || task.pdfDoc.numPages) : 0, + numPages: task.pdfDoc ? + (task.pageLimit || task.pdfDoc.numPages) : 0, failure: failure, file: task.file, round: task.round, From 07b52bf1c6ff735ab2dc5f2dbc736dc3d993bb17 Mon Sep 17 00:00:00 2001 From: Artur Adib Date: Mon, 3 Oct 2011 15:25:02 -0400 Subject: [PATCH 3/4] Lint, extra space eol --- test/driver.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/driver.js b/test/driver.js index fe02a997d..4bc14bf15 100644 --- a/test/driver.js +++ b/test/driver.js @@ -205,7 +205,7 @@ function done() { function sendTaskResult(snapshot, task, failure) { var result = { browser: browser, id: task.id, - numPages: task.pdfDoc ? + numPages: task.pdfDoc ? (task.pageLimit || task.pdfDoc.numPages) : 0, failure: failure, file: task.file, From 25448945a4827f1e4efc2167c2cf01e0520dee9d Mon Sep 17 00:00:00 2001 From: Artur Adib Date: Mon, 3 Oct 2011 15:57:04 -0400 Subject: [PATCH 4/4] Lint - fixing double quotes --- pdf.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pdf.js b/pdf.js index 2eba4e652..8d877cf84 100644 --- a/pdf.js +++ b/pdf.js @@ -4888,8 +4888,8 @@ var CanvasExtraState = (function canvasExtraState() { this.fillColorObj = null; this.strokeColorObj = null; // Default fore and background colors - this.fillColor = "#000000"; - this.strokeColor = "#000000"; + this.fillColor = '#000000'; + this.strokeColor = '#000000'; this.old = old; }