本文整理汇总了Python中mozbuild.base.MachCommandConditions.is_b2g_desktop方法的典型用法代码示例。如果您正苦于以下问题:Python MachCommandConditions.is_b2g_desktop方法的具体用法?Python MachCommandConditions.is_b2g_desktop怎么用?Python MachCommandConditions.is_b2g_desktop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mozbuild.base.MachCommandConditions
的用法示例。
在下文中一共展示了MachCommandConditions.is_b2g_desktop方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run_mochitest_plain
# 需要导入模块: from mozbuild.base import MachCommandConditions [as 别名]
# 或者: from mozbuild.base.MachCommandConditions import is_b2g_desktop [as 别名]
def run_mochitest_plain(self, test_paths, **kwargs):
if is_platform_in('firefox', 'mulet')(self):
return self.run_mochitest(test_paths, 'plain', **kwargs)
elif conditions.is_emulator(self):
return self.run_mochitest_remote(test_paths, **kwargs)
elif conditions.is_b2g_desktop(self):
return self.run_mochitest_b2g_desktop(test_paths, **kwargs)
elif conditions.is_android(self):
return self.run_mochitest_android(test_paths, **kwargs)
示例2: run_b2g_test
# 需要导入模块: from mozbuild.base import MachCommandConditions [as 别名]
# 或者: from mozbuild.base.MachCommandConditions import is_b2g_desktop [as 别名]
def run_b2g_test(self, b2g_home=None, xre_path=None, **kwargs):
"""Runs a b2g reftest.
filter is a regular expression (in JS syntax, as could be passed to the
RegExp constructor) to select which reftests to run from the manifest.
test_file is a path to a test file. It can be a relative path from the
top source directory, an absolute filename, or a directory containing
test files.
suite is the type of reftest to run. It can be one of ('reftest',
'crashtest').
"""
if kwargs["suite"] not in ('reftest', 'crashtest'):
raise Exception('None or unrecognized reftest suite type.')
sys.path.insert(0, self.reftest_dir)
test_subdir = {"reftest": os.path.join('layout', 'reftests'),
"crashtest": os.path.join('layout', 'crashtest')}[kwargs["suite"]]
# Find the manifest file
if not kwargs["tests"]:
if not os.path.exists(os.path.join(self.topsrcdir, test_subdir)):
test_file = mozpath.relpath(os.path.abspath(test_subdir),
self.topsrcdir)
kwargs["tests"] = [test_subdir]
tests = os.path.join(self.reftest_dir, 'tests')
if not os.path.isdir(tests):
os.symlink(self.topsrcdir, tests)
for i, path in enumerate(kwargs["tests"]):
# Non-absolute paths are relative to the packaged directory, which
# has an extra tests/ at the start
if os.path.exists(os.path.abspath(path)):
path = os.path.relpath(path, os.path.join(self.topsrcdir))
kwargs["tests"][i] = os.path.join('tests', path)
if conditions.is_b2g_desktop(self):
return self.run_b2g_desktop(**kwargs)
return self.run_b2g_remote(b2g_home, xre_path, **kwargs)
示例3: __init__
# 需要导入模块: from mozbuild.base import MachCommandConditions [as 别名]
# 或者: from mozbuild.base.MachCommandConditions import is_b2g_desktop [as 别名]
def __init__(self, app=None, **kwargs):
ArgumentParser.__init__(self, usage=self.__doc__, conflict_handler='resolve', **kwargs)
self.oldcwd = os.getcwd()
self.app = app
if not self.app and build_obj:
if conditions.is_android(build_obj):
self.app = 'android'
elif conditions.is_b2g(build_obj) or conditions.is_b2g_desktop(build_obj):
self.app = 'b2g'
if not self.app:
# platform can't be determined and app wasn't specified explicitly,
# so just use generic arguments and hope for the best
self.app = 'generic'
if self.app not in container_map:
self.error("Unrecognized app '{}'! Must be one of: {}".format(
self.app, ', '.join(container_map.keys())))
defaults = {}
for container in self.containers:
defaults.update(container.defaults)
group = self.add_argument_group(container.__class__.__name__, container.__doc__)
for cli, kwargs in container.args:
# Allocate new lists so references to original don't get mutated.
# allowing multiple uses within a single process.
if "default" in kwargs and isinstance(kwargs['default'], list):
kwargs["default"] = []
if 'suppress' in kwargs:
if kwargs['suppress']:
kwargs['help'] = SUPPRESS
del kwargs['suppress']
group.add_argument(*cli, **kwargs)
self.set_defaults(**defaults)
structured.commandline.add_logging_group(self)
示例4: run_b2g_test
# 需要导入模块: from mozbuild.base import MachCommandConditions [as 别名]
# 或者: from mozbuild.base.MachCommandConditions import is_b2g_desktop [as 别名]
def run_b2g_test(self, b2g_home=None, xre_path=None, test_file=None,
suite=None, **kwargs):
"""Runs a b2g reftest.
test_file is a path to a test file. It can be a relative path from the
top source directory, an absolute filename, or a directory containing
test files.
suite is the type of reftest to run. It can be one of ('reftest',
'crashtest').
"""
if suite not in ('reftest', 'crashtest'):
raise Exception('None or unrecognized reftest suite type.')
# Find the manifest file
if not test_file:
if suite == 'reftest':
test_file = mozpack.path.join('layout', 'reftests')
elif suite == 'crashtest':
test_file = mozpack.path.join('testing', 'crashtest')
if not os.path.exists(os.path.join(self.topsrcdir, test_file)):
test_file = mozpack.path.relpath(os.path.abspath(test_file),
self.topsrcdir)
manifest = self._find_manifest(suite, test_file)
if not os.path.exists(mozpack.path.join(self.topsrcdir, manifest)):
raise Exception('No manifest file was found at %s.' % manifest)
# Need to chdir to reftest_dir otherwise imports fail below.
os.chdir(self.reftest_dir)
# The imp module can spew warnings if the modules below have
# already been imported, ignore them.
with warnings.catch_warnings():
warnings.simplefilter('ignore')
import imp
path = os.path.join(self.reftest_dir, 'runreftestb2g.py')
with open(path, 'r') as fh:
imp.load_module('reftest', fh, path, ('.py', 'r', imp.PY_SOURCE))
import reftest
# Set up the reftest options.
parser = reftest.B2GOptions()
options, args = parser.parse_args([])
# Tests need to be served from a subdirectory of the server. Symlink
# topsrcdir here to get around this.
tests = os.path.join(self.reftest_dir, 'tests')
if not os.path.isdir(tests):
os.symlink(self.topsrcdir, tests)
args.insert(0, os.path.join('tests', manifest))
for k, v in kwargs.iteritems():
setattr(options, k, v)
if conditions.is_b2g_desktop(self):
if self.substs.get('ENABLE_MARIONETTE') != '1':
print(MARIONETTE_DISABLED % ('mochitest-b2g-desktop',
self.mozconfig['path']))
return 1
options.profile = options.profile or os.environ.get('GAIA_PROFILE')
if not options.profile:
print(GAIA_PROFILE_NOT_FOUND % 'reftest-b2g-desktop')
return 1
if os.path.isfile(os.path.join(options.profile, 'extensions', \
'[email protected]')):
print(GAIA_PROFILE_IS_DEBUG % ('mochitest-b2g-desktop',
options.profile))
return 1
options.desktop = True
options.app = self.get_binary_path()
if options.oop:
options.browser_arg = '-oop'
if not options.app.endswith('-bin'):
options.app = '%s-bin' % options.app
if not os.path.isfile(options.app):
options.app = options.app[:-len('-bin')]
return reftest.run_desktop_reftests(parser, options, args)
try:
which.which('adb')
except which.WhichError:
# TODO Find adb automatically if it isn't on the path
raise Exception(ADB_NOT_FOUND % ('%s-remote' % suite, b2g_home))
options.b2gPath = b2g_home
options.logcat_dir = self.reftest_dir
options.httpdPath = os.path.join(self.topsrcdir, 'netwerk', 'test', 'httpserver')
options.xrePath = xre_path
options.ignoreWindowSize = True
# Don't enable oop for crashtest until they run oop in automation
if suite == 'reftest':
#.........这里部分代码省略.........
示例5: validate
# 需要导入模块: from mozbuild.base import MachCommandConditions [as 别名]
# 或者: from mozbuild.base.MachCommandConditions import is_b2g_desktop [as 别名]
def validate(self, parser, options, context):
"""Validate b2g options."""
if options.desktop and not options.app:
if not (build_obj and conditions.is_b2g_desktop(build_obj)):
parser.error(
"--desktop specified, but no b2g desktop build detected! Either "
"build for b2g desktop, or point --appname to a b2g desktop binary.")
elif build_obj and conditions.is_b2g_desktop(build_obj):
options.desktop = True
if not options.app:
options.app = build_obj.get_binary_path()
if not options.app.endswith('-bin'):
options.app = '%s-bin' % options.app
if not os.path.isfile(options.app):
options.app = options.app[:-len('-bin')]
if options.remoteWebServer is None:
if os.name != "nt":
options.remoteWebServer = moznetwork.get_ip()
else:
parser.error(
"You must specify a --remote-webserver=<ip address>")
options.webServer = options.remoteWebServer
if not options.b2gPath and hasattr(context, 'b2g_home'):
options.b2gPath = context.b2g_home
if hasattr(context, 'device_name') and not options.emulator:
if context.device_name.startswith('emulator'):
options.emulator = 'x86' if 'x86' in context.device_name else 'arm'
if options.geckoPath and not options.emulator:
parser.error(
"You must specify --emulator if you specify --gecko-path")
if options.logdir and not options.emulator:
parser.error("You must specify --emulator if you specify --logdir")
elif not options.logdir and options.emulator and build_obj:
options.logdir = os.path.join(
build_obj.topobjdir, '_tests', 'testing', 'mochitest')
if hasattr(context, 'xre_path'):
options.xrePath = context.xre_path
if not os.path.isdir(options.xrePath):
parser.error("--xre-path '%s' is not a directory" % options.xrePath)
xpcshell = os.path.join(options.xrePath, 'xpcshell')
if not os.access(xpcshell, os.F_OK):
parser.error('xpcshell not found at %s' % xpcshell)
if self.elf_arm(xpcshell):
parser.error('--xre-path points to an ARM version of xpcshell; it '
'should instead point to a version that can run on '
'your desktop')
if not options.httpdPath and build_obj:
options.httpdPath = os.path.join(
build_obj.topobjdir, '_tests', 'testing', 'mochitest')
# Bug 1071866 - B2G Mochitests do not always produce a leak log.
options.ignoreMissingLeaks.append("default")
# Bug 1070068 - Leak logging does not work for tab processes on B2G.
options.ignoreMissingLeaks.append("tab")
if options.pidFile != "":
f = open(options.pidFile, 'w')
f.write("%s" % os.getpid())
f.close()
return options
示例6: run_b2g_test
# 需要导入模块: from mozbuild.base import MachCommandConditions [as 别名]
# 或者: from mozbuild.base.MachCommandConditions import is_b2g_desktop [as 别名]
def run_b2g_test(self, test_file=None, b2g_home=None, xre_path=None, **kwargs):
"""Runs a b2g mochitest.
test_file is a path to a test file. It can be a relative path from the
top source directory, an absolute filename, or a directory containing
test files.
"""
# Need to call relpath before os.chdir() below.
test_path = ''
if test_file:
test_path = self._wrap_path_argument(test_file).relpath()
# TODO without os.chdir, chained imports fail below
os.chdir(self.mochitest_dir)
# The imp module can spew warnings if the modules below have
# already been imported, ignore them.
with warnings.catch_warnings():
warnings.simplefilter('ignore')
import imp
path = os.path.join(self.mochitest_dir, 'runtestsb2g.py')
with open(path, 'r') as fh:
imp.load_module('mochitest', fh, path,
('.py', 'r', imp.PY_SOURCE))
import mochitest
from mochitest_options import B2GOptions
parser = B2GOptions()
options = parser.parse_args([])[0]
if test_path:
test_root_file = mozpack.path.join(self.mochitest_dir, 'tests', test_path)
if not os.path.exists(test_root_file):
print('Specified test path does not exist: %s' % test_root_file)
return 1
options.testPath = test_path
else:
options.testManifest = 'b2g.json'
for k, v in kwargs.iteritems():
setattr(options, k, v)
options.consoleLevel = 'INFO'
if conditions.is_b2g_desktop(self):
if self.substs.get('ENABLE_MARIONETTE') != '1':
print(MARIONETTE_DISABLED % ('mochitest-b2g-desktop',
self.mozconfig['path']))
return 1
options.profile = options.profile or os.environ.get('GAIA_PROFILE')
if not options.profile:
print(GAIA_PROFILE_NOT_FOUND % 'mochitest-b2g-desktop')
return 1
if os.path.isfile(os.path.join(options.profile, 'extensions', \
'[email protected]')):
print(GAIA_PROFILE_IS_DEBUG % ('mochitest-b2g-desktop',
options.profile))
return 1
options.desktop = True
options.app = self.get_binary_path()
if not options.app.endswith('-bin'):
options.app = '%s-bin' % options.app
if not os.path.isfile(options.app):
options.app = options.app[:-len('-bin')]
return mochitest.run_desktop_mochitests(parser, options)
try:
which.which('adb')
except which.WhichError:
# TODO Find adb automatically if it isn't on the path
print(ADB_NOT_FOUND % ('mochitest-remote', b2g_home))
return 1
options.b2gPath = b2g_home
options.logcat_dir = self.mochitest_dir
options.httpdPath = self.mochitest_dir
options.xrePath = xre_path
return mochitest.run_remote_mochitests(parser, options)
示例7: run_b2g_test
# 需要导入模块: from mozbuild.base import MachCommandConditions [as 别名]
# 或者: from mozbuild.base.MachCommandConditions import is_b2g_desktop [as 别名]
def run_b2g_test(
self, test_file=None, b2g_home=None, xre_path=None, total_chunks=None, this_chunk=None, no_window=None, **kwargs
):
"""Runs a b2g mochitest.
test_file is a path to a test file. It can be a relative path from the
top source directory, an absolute filename, or a directory containing
test files.
"""
# Need to call relpath before os.chdir() below.
test_path = ""
if test_file:
test_path = self._wrap_path_argument(test_file).relpath()
# TODO without os.chdir, chained imports fail below
os.chdir(self.mochitest_dir)
# The imp module can spew warnings if the modules below have
# already been imported, ignore them.
with warnings.catch_warnings():
warnings.simplefilter("ignore")
import imp
path = os.path.join(self.mochitest_dir, "runtestsb2g.py")
with open(path, "r") as fh:
imp.load_module("mochitest", fh, path, (".py", "r", imp.PY_SOURCE))
import mochitest
from mochitest_options import B2GOptions
parser = B2GOptions()
options = parser.parse_args([])[0]
if test_path:
test_root_file = mozpack.path.join(self.mochitest_dir, "tests", test_path)
if not os.path.exists(test_root_file):
print("Specified test path does not exist: %s" % test_root_file)
return 1
options.testPath = test_path
elif conditions.is_b2g_desktop(self):
options.testManifest = "b2g-desktop.json"
else:
options.testManifest = "b2g.json"
for k, v in kwargs.iteritems():
setattr(options, k, v)
options.noWindow = no_window
options.totalChunks = total_chunks
options.thisChunk = this_chunk
options.symbolsPath = os.path.join(self.distdir, "crashreporter-symbols")
options.consoleLevel = "INFO"
if conditions.is_b2g_desktop(self):
if self.substs.get("ENABLE_MARIONETTE") != "1":
print(MARIONETTE_DISABLED % ("mochitest-b2g-desktop", self.mozconfig["path"]))
return 1
options.profile = options.profile or os.environ.get("GAIA_PROFILE")
if not options.profile:
print(GAIA_PROFILE_NOT_FOUND % "mochitest-b2g-desktop")
return 1
if os.path.isfile(os.path.join(options.profile, "extensions", "[email protected]")):
print(GAIA_PROFILE_IS_DEBUG % ("mochitest-b2g-desktop", options.profile))
return 1
options.desktop = True
options.app = self.get_binary_path()
if not options.app.endswith("-bin"):
options.app = "%s-bin" % options.app
if not os.path.isfile(options.app):
options.app = options.app[: -len("-bin")]
return mochitest.run_desktop_mochitests(parser, options)
try:
which.which("adb")
except which.WhichError:
# TODO Find adb automatically if it isn't on the path
print(ADB_NOT_FOUND % ("mochitest-remote", b2g_home))
return 1
options.b2gPath = b2g_home
options.logcat_dir = self.mochitest_dir
options.httpdPath = self.mochitest_dir
options.xrePath = xre_path
return mochitest.run_remote_mochitests(parser, options)