From 375c4bf529b4cc5a7769f3f39672bd07478c6ed7 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Tue, 21 Jun 2011 15:14:42 -0700 Subject: [PATCH] add support for linking pdfs we can't/won't distribute --- test.py | 23 ++++++++++++++++++++--- test_manifest.json | 6 ++++++ tests/pdf.pdf.link | 1 + 3 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 tests/pdf.pdf.link diff --git a/test.py b/test.py index 7c3c4048a..dae723b8a 100644 --- a/test.py +++ b/test.py @@ -1,4 +1,4 @@ -import json, os, sys, subprocess +import json, os, sys, subprocess, urllib2 from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer from urlparse import urlparse @@ -82,6 +82,8 @@ class PDFTestHandler(BaseHTTPRequestHandler): if result['taskDone']: check(State.manifest[id], taskResults, browser) + # Please oh please GC this ... + del State.taskResults[browser][id] State.remaining -= 1 State.done = (0 == State.remaining) @@ -100,6 +102,23 @@ def set_up(manifestFile): manifestList = json.load(mf) mf.close() + for item in manifestList: + f, isLink = item['file'], item.get('link', False) + if isLink and not os.access(f, os.R_OK): + linkFile = open(f +'.link') + link = linkFile.read() + linkFile.close() + + sys.stdout.write('Downloading '+ link +' to '+ f +' ...') + sys.stdout.flush() + response = urllib2.urlopen(link) + + out = open(f, 'w') + out.write(response.read()) + out.close() + + print 'done' + for b in testBrowsers: State.taskResults[b] = { } for item in manifestList: @@ -169,8 +188,6 @@ def checkEq(task, results, browser): print 'TEST-PASS | eq test', task['id'], '| in', browser -printed = [False] - def checkFBF(task, results, browser): round0, round1 = results[0], results[1] assert len(round0) == len(round1) diff --git a/test_manifest.json b/test_manifest.json index e31b8b2b4..036b7aafc 100644 --- a/test_manifest.json +++ b/test_manifest.json @@ -13,5 +13,11 @@ "file": "tests/canvas.pdf", "rounds": 1, "type": "load" + }, + { "id": "pdfspec-load", + "file": "tests/pdf.pdf", + "link": true, + "rounds": 1, + "type": "load" } ] diff --git a/tests/pdf.pdf.link b/tests/pdf.pdf.link new file mode 100644 index 000000000..bbc2b3a11 --- /dev/null +++ b/tests/pdf.pdf.link @@ -0,0 +1 @@ +http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/en/devnet/pdf/pdfs/pdf_reference_1-7.pdf \ No newline at end of file