Merge pull request #122 from sayrer/master

Fix up -b / --browser option
This commit is contained in:
Andreas Gal 2011-06-29 11:17:41 -07:00
commit 68aa1f9bbb

View File

@ -237,14 +237,23 @@ class ChromeBrowserCommand(BaseBrowserCommand):
def makeBrowserCommand(browser): def makeBrowserCommand(browser):
path = browser["path"].lower() path = browser["path"].lower()
name = browser["name"].lower() name = browser["name"]
if name.find("firefox") > -1 or path.find("firefox") > -1: if name is not None:
return FirefoxBrowserCommand(browser) name = name.lower()
elif name.find("chrom") > -1 or path.find("chrom") > -1:
return ChromeBrowserCommand(browser) types = {"firefox": FirefoxBrowserCommand,
else: "chrome": ChromeBrowserCommand }
command = None
for key in types.keys():
if (name and name.find(key) > -1) or path.find(key) > -1:
command = types[key](browser)
command.name = command.name or key
if command is None:
raise Exception("Unrecognized browser: %s" % browser) raise Exception("Unrecognized browser: %s" % browser)
return command
def makeBrowserCommands(browserManifestFile): def makeBrowserCommands(browserManifestFile):
with open(browserManifestFile) as bmf: with open(browserManifestFile) as bmf:
browsers = [makeBrowserCommand(browser) for browser in json.load(bmf)] browsers = [makeBrowserCommand(browser) for browser in json.load(bmf)]
@ -284,7 +293,7 @@ def setUp(options):
if options.browserManifestFile: if options.browserManifestFile:
testBrowsers = makeBrowserCommands(options.browserManifestFile) testBrowsers = makeBrowserCommands(options.browserManifestFile)
elif options.browser: elif options.browser:
testBrowsers = [BrowserCommand({"path":options.browser, "name":"firefox"})] testBrowsers = [makeBrowserCommand({"path":options.browser, "name":None})]
assert len(testBrowsers) > 0 assert len(testBrowsers) > 0
with open(options.manifestFile) as mf: with open(options.manifestFile) as mf: