Add a make server target, fix paths to scripts.

This commit is contained in:
Rob Sayre 2011-07-05 13:51:02 -07:00
parent 54bfa1d7e9
commit 4530384769
5 changed files with 33 additions and 23 deletions

View File

@ -15,6 +15,13 @@ PDF_JS_FILES = \
# not sure what to do for all yet # not sure what to do for all yet
all: help all: help
# make server
#
# This target starts a local web server at localhost:8888. This can be
# used for testing all browsers.
server:
@cd test; python test.py --port=8888;
test: shell-test browser-test test: shell-test browser-test
# make browser-test # make browser-test
@ -150,4 +157,4 @@ help:
@echo "Read the comments in the Makefile for guidance."; @echo "Read the comments in the Makefile for guidance.";
.PHONY: all test browser-test font-test shell-test \ .PHONY: all test browser-test font-test shell-test \
shell-msg lint clean web compiler help shell-msg lint clean web compiler help server

View File

@ -17,7 +17,6 @@ TMPDIR = 'tmp'
VERBOSE = False VERBOSE = False
SERVER_HOST = "localhost" SERVER_HOST = "localhost"
SERVER_PORT = 8080
class TestOptions(OptionParser): class TestOptions(OptionParser):
def __init__(self, **kwargs): def __init__(self, **kwargs):
@ -34,6 +33,8 @@ class TestOptions(OptionParser):
self.add_option("--reftest", action="store_true", dest="reftest", self.add_option("--reftest", action="store_true", dest="reftest",
help="Automatically start reftest showing comparison test failures, if there are any.", help="Automatically start reftest showing comparison test failures, if there are any.",
default=False) default=False)
self.add_option("--port", action="store", dest="port", type="int",
help="The port the HTTP server should listen on.", default=8080)
self.set_usage(USAGE_EXAMPLE) self.set_usage(USAGE_EXAMPLE)
def verifyOptions(self, options): def verifyOptions(self, options):
@ -44,7 +45,7 @@ class TestOptions(OptionParser):
if options.browser and options.browserManifestFile: if options.browser and options.browserManifestFile:
print "Warning: ignoring browser argument since manifest file was also supplied" print "Warning: ignoring browser argument since manifest file was also supplied"
if not options.browser and not options.browserManifestFile: if not options.browser and not options.browserManifestFile:
print "No browser arguments supplied, so just starting server on port %s." % SERVER_PORT print "Starting server on port %s." % options.port
return options return options
def prompt(question): def prompt(question):
@ -325,7 +326,7 @@ def startBrowsers(browsers, options):
for b in browsers: for b in browsers:
b.setup() b.setup()
print 'Launching', b.name print 'Launching', b.name
host = 'http://%s:%s' % (SERVER_HOST, SERVER_PORT) host = 'http://%s:%s' % (SERVER_HOST, options.port)
path = '/test/test_slave.html?' path = '/test/test_slave.html?'
qs = 'browser='+ urllib.quote(b.name) +'&manifestFile='+ urllib.quote(options.manifestFile) qs = 'browser='+ urllib.quote(b.name) +'&manifestFile='+ urllib.quote(options.manifestFile)
qs += '&path=' + b.path qs += '&path=' + b.path
@ -482,8 +483,8 @@ def maybeUpdateRefImages(options, browser):
print 'done' print 'done'
def startReftest(browser): def startReftest(browser, options):
url = "http://%s:%s" % (SERVER_HOST, SERVER_PORT) url = "http://%s:%s" % (SERVER_HOST, options.port)
url += "/test/resources/reftest-analyzer.xhtml" url += "/test/resources/reftest-analyzer.xhtml"
url += "#web=/test/eq.log" url += "#web=/test/eq.log"
try: try:
@ -511,7 +512,7 @@ def runTests(options, browsers):
maybeUpdateRefImages(options, browsers[0]) maybeUpdateRefImages(options, browsers[0])
elif options.reftest and State.numEqFailures > 0: elif options.reftest and State.numEqFailures > 0:
print "\nStarting reftest harness to examine %d eq test failures." % State.numEqFailures print "\nStarting reftest harness to examine %d eq test failures." % State.numEqFailures
startReftest(browsers[0]) startReftest(browsers[0], options)
def main(): def main():
optionParser = TestOptions() optionParser = TestOptions()
@ -520,7 +521,7 @@ def main():
if options == None: if options == None:
sys.exit(1) sys.exit(1)
httpd = TestServer((SERVER_HOST, SERVER_PORT), PDFTestHandler) httpd = TestServer((SERVER_HOST, options.port), PDFTestHandler)
httpd_thread = threading.Thread(target=httpd.serve_forever) httpd_thread = threading.Thread(target=httpd.serve_forever)
httpd_thread.setDaemon(True) httpd_thread.setDaemon(True)
httpd_thread.start() httpd_thread.start()
@ -531,8 +532,11 @@ def main():
else: else:
# just run the server # just run the server
print "Running HTTP server. Press Ctrl-C to quit." print "Running HTTP server. Press Ctrl-C to quit."
while True: try:
time.sleep(1) while True:
time.sleep(1)
except (KeyboardInterrupt):
print "\nExiting."
if __name__ == '__main__': if __name__ == '__main__':
main() main()

View File

@ -4,10 +4,10 @@
<title>pdf.js Multi-Page Viewer</title> <title>pdf.js Multi-Page Viewer</title>
<meta http-equiv="Content-type" content="text/html;charset=UTF-8"/> <meta http-equiv="Content-type" content="text/html;charset=UTF-8"/>
<link rel="stylesheet" href="multi_page_viewer.css" type="text/css" media="screen"/> <link rel="stylesheet" href="multi_page_viewer.css" type="text/css" media="screen"/>
<script type="text/javascript" src="pdf.js"></script> <script type="text/javascript" src="../pdf.js"></script>
<script type="text/javascript" src="fonts.js"></script> <script type="text/javascript" src="../fonts.js"></script>
<script type="text/javascript" src="crypto.js"></script> <script type="text/javascript" src="../crypto.js"></script>
<script type="text/javascript" src="glyphlist.js"></script> <script type="text/javascript" src="../glyphlist.js"></script>
<script type="text/javascript" src="multi_page_viewer.js"></script> <script type="text/javascript" src="multi_page_viewer.js"></script>
</head> </head>
<body> <body>

View File

@ -4,11 +4,10 @@
<link rel="stylesheet" href="viewer.css"></link> <link rel="stylesheet" href="viewer.css"></link>
<script type="text/javascript" src="viewer.js"></script> <script type="text/javascript" src="viewer.js"></script>
<script type="text/javascript" src="pdf.js"></script> <script type="text/javascript" src="../pdf.js"></script>
<script type="text/javascript" src="utils/fonts_utils.js"></script> <script type="text/javascript" src="../fonts.js"></script>
<script type="text/javascript" src="fonts.js"></script> <script type="text/javascript" src="../crypto.js"></script>
<script type="text/javascript" src="crypto.js"></script> <script type="text/javascript" src="../glyphlist.js"></script>
<script type="text/javascript" src="glyphlist.js"></script>
</head> </head>
<body onload="load();"> <body onload="load();">

View File

@ -1,10 +1,10 @@
<html> <html>
<head> <head>
<title>Simple pdf.js page worker viewer</title> <title>Simple pdf.js page worker viewer</title>
<script type="text/javascript" src="fonts.js"></script> <script type="text/javascript" src="../fonts.js"></script>
<script type="text/javascript" src="glyphlist.js"></script> <script type="text/javascript" src="../glyphlist.js"></script>
<script type="text/javascript" src="pdf.js"></script> <script type="text/javascript" src="../pdf.js"></script>
<script type="text/javascript" src="worker/client.js"></script> <script type="text/javascript" src="../worker/client.js"></script>
<script> <script>