本文整理汇总了Python中mozbuild.base.MachCommandConditions类的典型用法代码示例。如果您正苦于以下问题:Python MachCommandConditions类的具体用法?Python MachCommandConditions怎么用?Python MachCommandConditions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MachCommandConditions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, environment):
if not MachCommandConditions.is_android(environment):
raise Exception(
'The Android Eclipse backend is not available with this '
'configuration.')
super(AndroidEclipseBackend, self).__init__(environment)
示例2: config_status
#.........这里部分代码省略.........
if 'CONFIG_FILES' in os.environ:
raise Exception('Using the CONFIG_FILES environment variable is not '
'supported.')
if 'CONFIG_HEADERS' in os.environ:
raise Exception('Using the CONFIG_HEADERS environment variable is not '
'supported.')
if not os.path.isabs(topsrcdir):
raise Exception('topsrcdir must be defined as an absolute directory: '
'%s' % topsrcdir)
default_backends = ['RecursiveMake']
default_backends = (substs or {}).get('BUILD_BACKENDS', ['RecursiveMake'])
parser = ArgumentParser()
parser.add_argument('-v', '--verbose', dest='verbose', action='store_true',
help='display verbose output')
parser.add_argument('-n', dest='not_topobjdir', action='store_true',
help='do not consider current directory as top object directory')
parser.add_argument('-d', '--diff', action='store_true',
help='print diffs of changed files.')
parser.add_argument('-b', '--backend', nargs='+', choices=sorted(backends),
default=default_backends,
help='what backend to build (default: %s).' %
' '.join(default_backends))
parser.add_argument('--dry-run', action='store_true',
help='do everything except writing files out.')
options = parser.parse_args()
# Without -n, the current directory is meant to be the top object directory
if not options.not_topobjdir:
topobjdir = os.path.abspath('.')
env = ConfigEnvironment(topsrcdir, topobjdir, defines=defines,
non_global_defines=non_global_defines, substs=substs,
source=source, mozconfig=mozconfig)
# mozinfo.json only needs written if configure changes and configure always
# passes this environment variable.
if 'WRITE_MOZINFO' in os.environ:
write_mozinfo(os.path.join(topobjdir, 'mozinfo.json'), env, os.environ)
cpu_start = time.clock()
time_start = time.time()
# Make appropriate backend instances, defaulting to RecursiveMakeBackend,
# or what is in BUILD_BACKENDS.
selected_backends = [get_backend_class(b)(env) for b in options.backend]
if options.dry_run:
for b in selected_backends:
b.dry_run = True
reader = BuildReader(env)
emitter = TreeMetadataEmitter(env)
# This won't actually do anything because of the magic of generators.
definitions = emitter.emit(reader.read_topsrcdir())
log_level = logging.DEBUG if options.verbose else logging.INFO
log_manager.add_terminal_logging(level=log_level)
log_manager.enable_unstructured()
print('Reticulating splines...', file=sys.stderr)
if len(selected_backends) > 1:
definitions = list(definitions)
for the_backend in selected_backends:
the_backend.consume(definitions)
execution_time = 0.0
for obj in chain((reader, emitter), selected_backends):
summary = obj.summary()
print(summary, file=sys.stderr)
execution_time += summary.execution_time
cpu_time = time.clock() - cpu_start
wall_time = time.time() - time_start
efficiency = cpu_time / wall_time if wall_time else 100
untracked = wall_time - execution_time
print(
'Total wall time: {:.2f}s; CPU time: {:.2f}s; Efficiency: '
'{:.0%}; Untracked: {:.2f}s'.format(
wall_time, cpu_time, efficiency, untracked),
file=sys.stderr
)
if options.diff:
for the_backend in selected_backends:
for path, diff in sorted(the_backend.file_diffs.items()):
print('\n'.join(diff))
# Advertise Visual Studio if appropriate.
if os.name == 'nt' and 'VisualStudio' not in options.backend:
print(VISUAL_STUDIO_ADVERTISEMENT)
# Advertise Eclipse if it is appropriate.
if MachCommandConditions.is_android(env):
if 'AndroidEclipse' not in options.backend:
print(ANDROID_IDE_ADVERTISEMENT)
示例3: run_mochitest_chrome
def run_mochitest_chrome(self, test_paths, **kwargs):
if conditions.is_firefox(self):
return self.run_mochitest(test_paths, 'chrome', **kwargs)
elif conditions.is_b2g(self) and conditions.is_emulator(self):
return self.run_mochitest_remote(test_paths, chrome=True, **kwargs)
elif conditions.is_android(self):
return self.run_mochitest_android(test_paths, chrome=True, **kwargs)
示例4: run_xpcshell_test
def run_xpcshell_test(self, **params):
from mozbuild.controller.building import BuildDriver
# We should probably have a utility function to ensure the tree is
# ready to run tests. Until then, we just create the state dir (in
# case the tree wasn't built with mach).
self._ensure_state_subdir_exists('.')
driver = self._spawn(BuildDriver)
driver.install_tests(remove=False)
structured.commandline.formatter_option_defaults['verbose'] = True
params['log'] = structured.commandline.setup_logging("XPCShellTests",
params,
{"mach": sys.stdout})
if conditions.is_android(self):
xpcshell = self._spawn(AndroidXPCShellRunner)
elif conditions.is_b2g(self):
xpcshell = self._spawn(B2GXPCShellRunner)
params['b2g_home'] = self.b2g_home
params['device_name'] = self.device_name
else:
xpcshell = self._spawn(XPCShellRunner)
xpcshell.cwd = self._mach_context.cwd
try:
return xpcshell.run_test(**params)
except InvalidTestPathError as e:
print(e.message)
return 1
示例5: run_xpcshell_test
def run_xpcshell_test(self, **params):
from mozbuild.controller.building import BuildDriver
# We should probably have a utility function to ensure the tree is
# ready to run tests. Until then, we just create the state dir (in
# case the tree wasn't built with mach).
self._ensure_state_subdir_exists('.')
driver = self._spawn(BuildDriver)
driver.install_tests(remove=False)
if conditions.is_android(self):
xpcshell = self._spawn(AndroidXPCShellRunner)
elif conditions.is_b2g(self):
xpcshell = self._spawn(B2GXPCShellRunner)
params['b2g_home'] = self.b2g_home
else:
xpcshell = self._spawn(XPCShellRunner)
xpcshell.cwd = self._mach_context.cwd
try:
return xpcshell.run_test(**params)
except InvalidTestPathError as e:
print(e.message)
return 1
示例6: get_parser
def get_parser():
build_obj = MozbuildObject.from_environment(cwd=here)
if conditions.is_android(build_obj):
return parser_remote()
elif conditions.is_b2g(build_obj):
return parser_b2g()
else:
return parser_desktop()
示例7: get_parser
def get_parser():
here = os.path.abspath(os.path.dirname(__file__))
build_obj = MozbuildObject.from_environment(cwd=here)
if conditions.is_android(build_obj):
return reftestcommandline.RemoteArgumentsParser()
elif conditions.is_mulet(build_obj):
return reftestcommandline.B2GArgumentParser()
else:
return reftestcommandline.DesktopArgumentsParser()
示例8: run_mochitest_plain
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)
示例9: _run_reftest
def _run_reftest(self, **kwargs):
process_test_objects(kwargs)
reftest = self._spawn(ReftestRunner)
if conditions.is_android(self):
from mozrunner.devices.android_device import verify_android_device
verify_android_device(self, install=True, xre=True)
return reftest.run_android_test(**kwargs)
elif conditions.is_mulet(self):
return reftest.run_mulet_test(**kwargs)
return reftest.run_desktop_test(**kwargs)
示例10: test_info
def test_info(self, **params):
import which
from mozbuild.base import MozbuildObject
self.branches = params['branches']
self.start = params['start']
self.end = params['end']
self.show_info = params['show_info']
self.show_results = params['show_results']
self.show_durations = params['show_durations']
self.show_bugs = params['show_bugs']
self.verbose = params['verbose']
if (not self.show_info and
not self.show_results and
not self.show_durations and
not self.show_bugs):
# by default, show everything
self.show_info = True
self.show_results = True
self.show_durations = True
self.show_bugs = True
here = os.path.abspath(os.path.dirname(__file__))
build_obj = MozbuildObject.from_environment(cwd=here)
self._hg = None
if conditions.is_hg(build_obj):
if self._is_windows():
self._hg = which.which('hg.exe')
else:
self._hg = which.which('hg')
self._git = None
if conditions.is_git(build_obj):
if self._is_windows():
self._git = which.which('git.exe')
else:
self._git = which.which('git')
for test_name in params['test_names']:
print("===== %s =====" % test_name)
self.test_name = test_name
if len(self.test_name) < 6:
print("'%s' is too short for a test name!" % self.test_name)
continue
if self.show_info:
self.set_test_name()
if self.show_results:
self.report_test_results()
if self.show_durations:
self.report_test_durations()
if self.show_bugs:
self.report_bugs()
示例11: run_xpcshell_test
def run_xpcshell_test(self, test_objects=None, **params):
from mozbuild.controller.building import BuildDriver
if test_objects is not None:
from manifestparser import TestManifest
m = TestManifest()
m.tests.extend(test_objects)
params['manifest'] = m
driver = self._spawn(BuildDriver)
driver.install_tests(test_objects)
# We should probably have a utility function to ensure the tree is
# ready to run tests. Until then, we just create the state dir (in
# case the tree wasn't built with mach).
self._ensure_state_subdir_exists('.')
params['log'] = structured.commandline.setup_logging("XPCShellTests",
params,
{"mach": sys.stdout},
{"verbose": True})
if conditions.is_android(self):
from mozrunner.devices.android_device import verify_android_device
verify_android_device(self)
xpcshell = self._spawn(AndroidXPCShellRunner)
else:
xpcshell = self._spawn(XPCShellRunner)
xpcshell.cwd = self._mach_context.cwd
try:
return xpcshell.run_test(**params)
except InvalidTestPathError as e:
print(e.message)
return 1
示例12: emulator
def emulator(self, version, wait=False, force_update=False, verbose=False):
from mozrunner.devices.android_device import AndroidEmulator
emulator = AndroidEmulator(version, verbose, substs=self.substs, device_serial='emulator-5554')
if emulator.is_running():
# It is possible to run multiple emulators simultaneously, but:
# - if more than one emulator is using the same avd, errors may
# occur due to locked resources;
# - additional parameters must be specified when running tests,
# to select a specific device.
# To avoid these complications, allow just one emulator at a time.
self.log(logging.ERROR, "emulator", {},
"An Android emulator is already running.\n"
"Close the existing emulator and re-run this command.")
return 1
if not emulator.is_available():
self.log(logging.WARN, "emulator", {},
"Emulator binary not found.\n"
"Install the Android SDK and make sure 'emulator' is in your PATH.")
return 2
if not emulator.check_avd(force_update):
self.log(logging.INFO, "emulator", {},
"Fetching and installing AVD. This may take a few minutes...")
emulator.update_avd(force_update)
self.log(logging.INFO, "emulator", {},
"Starting Android emulator running %s..." %
emulator.get_avd_description())
emulator.start()
if emulator.wait_for_start():
self.log(logging.INFO, "emulator", {},
"Android emulator is running.")
else:
# This is unusual but the emulator may still function.
self.log(logging.WARN, "emulator", {},
"Unable to verify that emulator is running.")
if conditions.is_android(self):
self.log(logging.INFO, "emulator", {},
"Use 'mach install' to install or update Firefox on your emulator.")
else:
self.log(logging.WARN, "emulator", {},
"No Firefox for Android build detected.\n"
"Switch to a Firefox for Android build context or use 'mach bootstrap'\n"
"to setup an Android build environment.")
if wait:
self.log(logging.INFO, "emulator", {},
"Waiting for Android emulator to close...")
rc = emulator.wait()
if rc is not None:
self.log(logging.INFO, "emulator", {},
"Android emulator completed with return code %d." % rc)
else:
self.log(logging.WARN, "emulator", {},
"Unable to retrieve Android emulator return code.")
return 0
示例13: run_marionette_test
def run_marionette_test(self, tests, **kwargs):
if 'test_objects' in kwargs:
tests = []
for obj in kwargs['test_objects']:
tests.append(obj['file_relpath'])
del kwargs['test_objects']
if not kwargs.get('binary') and conditions.is_firefox(self):
kwargs['binary'] = self.get_binary_path('app')
return run_marionette(tests, topsrcdir=self.topsrcdir, **kwargs)
示例14: run_luciddream_test
def run_luciddream_test(self, browser_path, b2g_desktop_path, test_paths, consoles, **params):
# import luciddream lazily as its marionette dependency make ./mach clobber fails
# early on TBPL
import luciddream.runluciddream
# get_binary_path is going to throw if we haven't built any product
# but luciddream can still be run if we provide both binaries...
binary_path = False
try:
binary_path = self.get_binary_path()
except Exception:
pass
# otherwise, if we have a build, automatically fetch the binary
if conditions.is_b2g(self):
if not b2g_desktop_path and binary_path:
b2g_desktop_path = binary_path
else:
if not browser_path and binary_path:
browser_path = binary_path
if not browser_path:
print "Need firefox binary path via --browser_path argument"
return 1
elif not os.path.exists(browser_path):
print "Firefox binary doesn't exists: " + browser_path
return 1
if not b2g_desktop_path:
print "Need b2g desktop binary path via --b2g-desktop argument"
return 1
elif not os.path.exists(b2g_desktop_path):
print "B2G desktop binary doesn't exists: " + b2g_desktop_path
return 1
if not test_paths or len(test_paths) == 0:
print "Please specify a test manifest to run"
return 1
browser_args = None
if consoles:
browser_args = ["-jsconsole"]
if "app_args" in params and isinstance(params["app_args"], list):
params["app_args"].append("-jsconsole")
else:
params["app_args"] = ["-jsconsole"]
for test in test_paths:
luciddream.runluciddream.run(
browser_path=browser_path,
b2g_desktop_path=b2g_desktop_path,
manifest=test,
browser_args=browser_args,
**params
)
示例15: run_marionette_test
def run_marionette_test(self, tests, **kwargs):
if 'test_objects' in kwargs:
tests = []
for obj in kwargs['test_objects']:
tests.append(obj['file_relpath'])
del kwargs['test_objects']
if conditions.is_firefox(self):
bin_path = self.get_binary_path('app')
if kwargs.get('binary') is not None:
print "Warning: ignoring '--binary' option, using binary at " + bin_path
kwargs['binary'] = bin_path
return run_marionette(tests, topsrcdir=self.topsrcdir, **kwargs)