|
|
@ -1,4 +1,4 @@ |
|
|
|
import json, platform, os, shutil, sys, subprocess, tempfile, threading, urllib, urllib2 |
|
|
|
import json, platform, os, shutil, sys, subprocess, tempfile, threading, time, urllib, urllib2 |
|
|
|
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer |
|
|
|
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer |
|
|
|
import SocketServer |
|
|
|
import SocketServer |
|
|
|
from optparse import OptionParser |
|
|
|
from optparse import OptionParser |
|
|
@ -138,6 +138,7 @@ class BrowserCommand(): |
|
|
|
def __init__(self, browserRecord): |
|
|
|
def __init__(self, browserRecord): |
|
|
|
self.name = browserRecord["name"] |
|
|
|
self.name = browserRecord["name"] |
|
|
|
self.path = browserRecord["path"] |
|
|
|
self.path = browserRecord["path"] |
|
|
|
|
|
|
|
self.tempDir = None |
|
|
|
|
|
|
|
|
|
|
|
if platform.system() == "Darwin" and (self.path.endswith(".app") or self.path.endswith(".app/")): |
|
|
|
if platform.system() == "Darwin" and (self.path.endswith(".app") or self.path.endswith(".app/")): |
|
|
|
self._fixupMacPath() |
|
|
|
self._fixupMacPath() |
|
|
@ -151,19 +152,19 @@ class BrowserCommand(): |
|
|
|
def setup(self): |
|
|
|
def setup(self): |
|
|
|
self.tempDir = tempfile.mkdtemp() |
|
|
|
self.tempDir = tempfile.mkdtemp() |
|
|
|
self.profileDir = os.path.join(self.tempDir, "profile") |
|
|
|
self.profileDir = os.path.join(self.tempDir, "profile") |
|
|
|
print self.profileDir |
|
|
|
|
|
|
|
shutil.copytree(os.path.join(DOC_ROOT, "test", "resources", "firefox"), |
|
|
|
shutil.copytree(os.path.join(DOC_ROOT, "test", "resources", "firefox"), |
|
|
|
self.profileDir) |
|
|
|
self.profileDir) |
|
|
|
|
|
|
|
|
|
|
|
def teardown(self): |
|
|
|
def teardown(self): |
|
|
|
shutil.rmtree(self.tempDir) |
|
|
|
if self.tempDir is not None and os.path.exists(self.tempDir): |
|
|
|
|
|
|
|
shutil.rmtree(self.tempDir) |
|
|
|
|
|
|
|
|
|
|
|
def start(self, url): |
|
|
|
def start(self, url): |
|
|
|
cmds = [self.path] |
|
|
|
cmds = [self.path] |
|
|
|
if platform.system() == "Darwin": |
|
|
|
if platform.system() == "Darwin": |
|
|
|
cmds.append("-foreground") |
|
|
|
cmds.append("-foreground") |
|
|
|
cmds.extend(["-no-remote", "-profile", self.profileDir, url]) |
|
|
|
cmds.extend(["-no-remote", "-profile", self.profileDir, url]) |
|
|
|
subprocess.call(cmds) |
|
|
|
subprocess.Popen(cmds) |
|
|
|
|
|
|
|
|
|
|
|
def makeBrowserCommands(browserManifestFile): |
|
|
|
def makeBrowserCommands(browserManifestFile): |
|
|
|
with open(browserManifestFile) as bmf: |
|
|
|
with open(browserManifestFile) as bmf: |
|
|
@ -223,15 +224,22 @@ def setUp(options): |
|
|
|
|
|
|
|
|
|
|
|
State.remaining = len(testBrowsers) * len(manifestList) |
|
|
|
State.remaining = len(testBrowsers) * len(manifestList) |
|
|
|
|
|
|
|
|
|
|
|
for b in testBrowsers: |
|
|
|
return testBrowsers |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def startBrowsers(browsers, options): |
|
|
|
|
|
|
|
for b in browsers: |
|
|
|
|
|
|
|
b.setup() |
|
|
|
|
|
|
|
print 'Launching', b.name |
|
|
|
|
|
|
|
qs = 'browser='+ urllib.quote(b.name) +'&manifestFile='+ urllib.quote(options.manifestFile) |
|
|
|
|
|
|
|
b.start('http://localhost:8080/test/test_slave.html?'+ qs) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def teardownBrowsers(browsers): |
|
|
|
|
|
|
|
for b in browsers: |
|
|
|
try: |
|
|
|
try: |
|
|
|
b.setup() |
|
|
|
|
|
|
|
print 'Launching', b.name |
|
|
|
|
|
|
|
qs = 'browser='+ urllib.quote(b.name) +'&manifestFile='+ urllib.quote(options.manifestFile) |
|
|
|
|
|
|
|
b.start('http://localhost:8080/test/test_slave.html?'+ qs) |
|
|
|
|
|
|
|
finally: |
|
|
|
|
|
|
|
b.teardown() |
|
|
|
b.teardown() |
|
|
|
|
|
|
|
except: |
|
|
|
|
|
|
|
print "Error cleaning up after browser at ", b.path |
|
|
|
|
|
|
|
|
|
|
|
def check(task, results, browser): |
|
|
|
def check(task, results, browser): |
|
|
|
failed = False |
|
|
|
failed = False |
|
|
|
for r in xrange(len(results)): |
|
|
|
for r in xrange(len(results)): |
|
|
@ -385,8 +393,14 @@ def main(): |
|
|
|
httpd_thread.setDaemon(True) |
|
|
|
httpd_thread.setDaemon(True) |
|
|
|
httpd_thread.start() |
|
|
|
httpd_thread.start() |
|
|
|
|
|
|
|
|
|
|
|
setUp(options) |
|
|
|
browsers = setUp(options) |
|
|
|
processResults() |
|
|
|
try: |
|
|
|
|
|
|
|
startBrowsers(browsers, options) |
|
|
|
|
|
|
|
while not State.done: |
|
|
|
|
|
|
|
time.sleep(1) |
|
|
|
|
|
|
|
processResults() |
|
|
|
|
|
|
|
finally: |
|
|
|
|
|
|
|
teardownBrowsers(browsers) |
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__': |
|
|
|
if __name__ == '__main__': |
|
|
|
main() |
|
|
|
main() |
|
|
|