16
16
TMPDIR = 'tmp'
17
17
VERBOSE = False
18
18
19
+ SERVER_HOST = "localhost"
20
+ SERVER_PORT = 8080
21
+
19
22
class TestOptions (OptionParser ):
20
23
def __init__ (self , ** kwargs ):
21
24
OptionParser .__init__ (self , ** kwargs )
@@ -41,7 +44,7 @@ def verifyOptions(self, options):
41
44
if options .browser and options .browserManifestFile :
42
45
print "Warning: ignoring browser argument since manifest file was also supplied"
43
46
if not options .browser and not options .browserManifestFile :
44
- self . error ( "No test browsers found. Use --browserManifest or --browser args." )
47
+ print "No browser arguments supplied, so just starting server on port %s." % SERVER_PORT
45
48
return options
46
49
47
50
def prompt (question ):
@@ -295,7 +298,9 @@ def setUp(options):
295
298
testBrowsers = makeBrowserCommands (options .browserManifestFile )
296
299
elif options .browser :
297
300
testBrowsers = [makeBrowserCommand ({"path" :options .browser , "name" :None })]
298
- assert len (testBrowsers ) > 0
301
+
302
+ if options .browserManifestFile or options .browser :
303
+ assert len (testBrowsers ) > 0
299
304
300
305
with open (options .manifestFile ) as mf :
301
306
manifestList = json .load (mf )
@@ -320,9 +325,11 @@ def startBrowsers(browsers, options):
320
325
for b in browsers :
321
326
b .setup ()
322
327
print 'Launching' , b .name
328
+ host = 'http://%s:%s' % (SERVER_HOST , SERVER_PORT )
329
+ path = '/test/test_slave.html?'
323
330
qs = 'browser=' + urllib .quote (b .name ) + '&manifestFile=' + urllib .quote (options .manifestFile )
324
331
qs += '&path=' + b .path
325
- b .start ('http://localhost:8080/test/test_slave.html?' + qs )
332
+ b .start (host + path + qs )
326
333
327
334
def teardownBrowsers (browsers ):
328
335
for b in browsers :
@@ -476,7 +483,8 @@ def maybeUpdateRefImages(options, browser):
476
483
print 'done'
477
484
478
485
def startReftest (browser ):
479
- url = "http://127.0.0.1:8080/test/resources/reftest-analyzer.xhtml"
486
+ url = "http://%s:%s" % (SERVER_HOST , SERVER_PORT )
487
+ url += "/test/resources/reftest-analyzer.xhtml"
480
488
url += "#web=/test/eq.log"
481
489
try :
482
490
browser .setup ()
@@ -487,20 +495,8 @@ def startReftest(browser):
487
495
teardownBrowsers ([browser ])
488
496
print "Completed reftest usage."
489
497
490
- def main ( ):
498
+ def runTests ( options , browsers ):
491
499
t1 = time .time ()
492
- optionParser = TestOptions ()
493
- options , args = optionParser .parse_args ()
494
- options = optionParser .verifyOptions (options )
495
- if options == None :
496
- sys .exit (1 )
497
-
498
- httpd = TestServer (('127.0.0.1' , 8080 ), PDFTestHandler )
499
- httpd_thread = threading .Thread (target = httpd .serve_forever )
500
- httpd_thread .setDaemon (True )
501
- httpd_thread .start ()
502
-
503
- browsers = setUp (options )
504
500
try :
505
501
startBrowsers (browsers , options )
506
502
while not State .done :
@@ -517,5 +513,26 @@ def main():
517
513
print "\n Starting reftest harness to examine %d eq test failures." % State .numEqFailures
518
514
startReftest (browsers [0 ])
519
515
516
+ def main ():
517
+ optionParser = TestOptions ()
518
+ options , args = optionParser .parse_args ()
519
+ options = optionParser .verifyOptions (options )
520
+ if options == None :
521
+ sys .exit (1 )
522
+
523
+ httpd = TestServer ((SERVER_HOST , SERVER_PORT ), PDFTestHandler )
524
+ httpd_thread = threading .Thread (target = httpd .serve_forever )
525
+ httpd_thread .setDaemon (True )
526
+ httpd_thread .start ()
527
+
528
+ browsers = setUp (options )
529
+ if len (browsers ) > 0 :
530
+ runTests (options , browsers )
531
+ else :
532
+ # just run the server
533
+ print "Running HTTP server. Press Ctrl-C to quit."
534
+ while True :
535
+ time .sleep (1 )
536
+
520
537
if __name__ == '__main__' :
521
538
main ()
0 commit comments