Merge pull request #3310 from yurydelendik/ignore-bad-downloads
Skips failed-to-download tests
This commit is contained in:
commit
3b86ebeacb
@ -161,12 +161,20 @@ var WorkerMessageHandler = {
|
|||||||
var source = data.source;
|
var source = data.source;
|
||||||
var disableRange = data.disableRange;
|
var disableRange = data.disableRange;
|
||||||
if (source.data) {
|
if (source.data) {
|
||||||
pdfManager = new LocalPdfManager(source.data, source.password);
|
try {
|
||||||
pdfManagerPromise.resolve();
|
pdfManager = new LocalPdfManager(source.data, source.password);
|
||||||
|
pdfManagerPromise.resolve();
|
||||||
|
} catch (ex) {
|
||||||
|
pdfManagerPromise.reject(ex);
|
||||||
|
}
|
||||||
return pdfManagerPromise;
|
return pdfManagerPromise;
|
||||||
} else if (source.chunkedViewerLoading) {
|
} else if (source.chunkedViewerLoading) {
|
||||||
pdfManager = new NetworkPdfManager(source, handler);
|
try {
|
||||||
pdfManagerPromise.resolve();
|
pdfManager = new NetworkPdfManager(source, handler);
|
||||||
|
pdfManagerPromise.resolve();
|
||||||
|
} catch (ex) {
|
||||||
|
pdfManagerPromise.reject(ex);
|
||||||
|
}
|
||||||
return pdfManagerPromise;
|
return pdfManagerPromise;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -203,14 +211,22 @@ var WorkerMessageHandler = {
|
|||||||
networkManager.abortRequest(fullRequestXhrId);
|
networkManager.abortRequest(fullRequestXhrId);
|
||||||
|
|
||||||
source.length = length;
|
source.length = length;
|
||||||
pdfManager = new NetworkPdfManager(source, handler);
|
try {
|
||||||
pdfManagerPromise.resolve(pdfManager);
|
pdfManager = new NetworkPdfManager(source, handler);
|
||||||
|
pdfManagerPromise.resolve(pdfManager);
|
||||||
|
} catch (ex) {
|
||||||
|
pdfManagerPromise.reject(ex);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onDone: function onDone(args) {
|
onDone: function onDone(args) {
|
||||||
// the data is array, instantiating directly from it
|
// the data is array, instantiating directly from it
|
||||||
pdfManager = new LocalPdfManager(args.chunk, source.password);
|
try {
|
||||||
pdfManagerPromise.resolve();
|
pdfManager = new LocalPdfManager(args.chunk, source.password);
|
||||||
|
pdfManagerPromise.resolve();
|
||||||
|
} catch (ex) {
|
||||||
|
pdfManagerPromise.reject(ex);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onError: function onError(status) {
|
onError: function onError(status) {
|
||||||
@ -310,8 +326,8 @@ var WorkerMessageHandler = {
|
|||||||
pdfManager.onLoadedStream().then(function() {
|
pdfManager.onLoadedStream().then(function() {
|
||||||
loadDocument(true).then(onSuccess, onFailure);
|
loadDocument(true).then(onSuccess, onFailure);
|
||||||
});
|
});
|
||||||
});
|
}, onFailure);
|
||||||
});
|
}, onFailure);
|
||||||
});
|
});
|
||||||
|
|
||||||
handler.on('GetPageRequest', function wphSetupGetPage(data) {
|
handler.on('GetPageRequest', function wphSetupGetPage(data) {
|
||||||
|
@ -153,6 +153,9 @@ function nextTask() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getLastPageNum(task) {
|
function getLastPageNum(task) {
|
||||||
|
if (!task.pdfDoc) {
|
||||||
|
return task.firstPage || 1;
|
||||||
|
}
|
||||||
var lastPageNum = task.lastPage || 0;
|
var lastPageNum = task.lastPage || 0;
|
||||||
if (!lastPageNum || lastPageNum > task.pdfDoc.numPages) {
|
if (!lastPageNum || lastPageNum > task.pdfDoc.numPages) {
|
||||||
lastPageNum = task.pdfDoc.numPages;
|
lastPageNum = task.pdfDoc.numPages;
|
||||||
|
1
test/pdfs/.gitignore
vendored
1
test/pdfs/.gitignore
vendored
@ -1,4 +1,5 @@
|
|||||||
*.pdf
|
*.pdf
|
||||||
|
*.error
|
||||||
|
|
||||||
!tracemonkey.pdf
|
!tracemonkey.pdf
|
||||||
!issue2391-1.pdf
|
!issue2391-1.pdf
|
||||||
|
29
test/test.py
29
test/test.py
@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
import json, platform, os, shutil, sys, subprocess, tempfile, threading
|
import json, platform, os, shutil, sys, subprocess, tempfile, threading
|
||||||
import time, urllib, urllib2, hashlib, re, base64, uuid, socket, errno
|
import time, urllib, urllib2, hashlib, re, base64, uuid, socket, errno
|
||||||
|
import traceback
|
||||||
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
|
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
|
||||||
from SocketServer import ThreadingMixIn
|
from SocketServer import ThreadingMixIn
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
@ -64,8 +65,6 @@ class TestOptions(OptionParser):
|
|||||||
help="Run the font tests.", default=False)
|
help="Run the font tests.", default=False)
|
||||||
self.add_option("--noDownload", action="store_true", dest="noDownload",
|
self.add_option("--noDownload", action="store_true", dest="noDownload",
|
||||||
help="Skips test PDFs downloading.", default=False)
|
help="Skips test PDFs downloading.", default=False)
|
||||||
self.add_option("--ignoreDownloadErrors", action="store_true", dest="ignoreDownloadErrors",
|
|
||||||
help="Ignores errors during test PDFs downloading.", default=False)
|
|
||||||
self.add_option("--statsFile", action="store", dest="statsFile", type="string",
|
self.add_option("--statsFile", action="store", dest="statsFile", type="string",
|
||||||
help="The file where to store stats.", default=None)
|
help="The file where to store stats.", default=None)
|
||||||
self.add_option("--statsDelay", action="store", dest="statsDelay", type="int",
|
self.add_option("--statsDelay", action="store", dest="statsDelay", type="int",
|
||||||
@ -554,24 +553,29 @@ def downloadLinkedPDF(f):
|
|||||||
|
|
||||||
print 'done'
|
print 'done'
|
||||||
|
|
||||||
def downloadLinkedPDFs(manifestList, ignoreDownloadErrors):
|
def downloadLinkedPDFs(manifestList):
|
||||||
for item in manifestList:
|
for item in manifestList:
|
||||||
f, isLink = item['file'], item.get('link', False)
|
f, isLink = item['file'], item.get('link', False)
|
||||||
if isLink and not os.access(f, os.R_OK):
|
if isLink and not os.access(f, os.R_OK):
|
||||||
try:
|
try:
|
||||||
downloadLinkedPDF(f)
|
downloadLinkedPDF(f)
|
||||||
except:
|
except:
|
||||||
|
exc_type, exc_value, exc_traceback = sys.exc_info()
|
||||||
print 'ERROR: Unable to download file "' + f + '".'
|
print 'ERROR: Unable to download file "' + f + '".'
|
||||||
if ignoreDownloadErrors:
|
open(f, 'wb').close()
|
||||||
open(f, 'wb').close()
|
with open(f + '.error', 'w') as out:
|
||||||
else:
|
out.write('\n'.join(traceback.format_exception(exc_type,
|
||||||
raise
|
exc_value,
|
||||||
|
exc_traceback)))
|
||||||
|
|
||||||
def verifyPDFs(manifestList):
|
def verifyPDFs(manifestList):
|
||||||
error = False
|
error = False
|
||||||
for item in manifestList:
|
for item in manifestList:
|
||||||
f = item['file']
|
f = item['file']
|
||||||
if os.access(f, os.R_OK):
|
if os.path.isfile(f + '.error'):
|
||||||
|
print 'WARNING: File was not downloaded. See "' + f + '.error" file.'
|
||||||
|
error = True
|
||||||
|
elif os.access(f, os.R_OK):
|
||||||
fileMd5 = hashlib.md5(open(f, 'rb').read()).hexdigest()
|
fileMd5 = hashlib.md5(open(f, 'rb').read()).hexdigest()
|
||||||
if 'md5' not in item:
|
if 'md5' not in item:
|
||||||
print 'WARNING: Missing md5 for file "' + f + '".',
|
print 'WARNING: Missing md5 for file "' + f + '".',
|
||||||
@ -618,7 +622,7 @@ def setUp(options):
|
|||||||
manifestList = json.load(mf)
|
manifestList = json.load(mf)
|
||||||
|
|
||||||
if not options.noDownload:
|
if not options.noDownload:
|
||||||
downloadLinkedPDFs(manifestList, options.ignoreDownloadErrors)
|
downloadLinkedPDFs(manifestList)
|
||||||
|
|
||||||
if not verifyPDFs(manifestList):
|
if not verifyPDFs(manifestList):
|
||||||
print 'Unable to verify the checksum for the files that are used for testing.'
|
print 'Unable to verify the checksum for the files that are used for testing.'
|
||||||
@ -682,8 +686,11 @@ def check(task, results, browser, masterMode):
|
|||||||
failure = pageResult.failure
|
failure = pageResult.failure
|
||||||
if failure:
|
if failure:
|
||||||
failed = True
|
failed = True
|
||||||
State.numErrors += 1
|
if os.path.isfile(task['file'] + '.error'):
|
||||||
print 'TEST-UNEXPECTED-FAIL | test failed', task['id'], '| in', browser, '| page', p + 1, 'round', r, '|', failure
|
print 'TEST-SKIPPED | PDF was not downloaded', task['id'], '| in', browser, '| page', p + 1, 'round', r, '|', failure
|
||||||
|
else:
|
||||||
|
State.numErrors += 1
|
||||||
|
print 'TEST-UNEXPECTED-FAIL | test failed', task['id'], '| in', browser, '| page', p + 1, 'round', r, '|', failure
|
||||||
|
|
||||||
if failed:
|
if failed:
|
||||||
return
|
return
|
||||||
|
Loading…
x
Reference in New Issue
Block a user