Files
palemoon27/python/mach_commands.py
T
roytam1 538b35a4ee import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1147951, part 2 - Remove unused JAVASCRIPT definition from nsJSEnvironment.cpp. r=baku (607909217)
- Bug 1147951, part 1 - Remove uses of JAVASCRIPT2 from Console.cpp. r=baku (46cde7cfa)
- pointer style (5504c22d4)
- Bug 1165384 - Add a typedef for the statistics phase table; r=sfink (484a24237)
- Bug 1165385 - Remove the rarely used !fullFormat mode of MOZ_GCTIMER; r=sfink (ab8b17eb1)
- Bug 1165390 - Make the detailed statistics formatting methods have consistent names; r=sfink (55c5db543)
- Bug 1165410 - Reimplement GC statistics JSON output formatter; r=sfink (04c13c874)
- Bug 1166789 - Cleanup javascript.options.mem.log formatting; r=sfink, r=mccr8 (f23b455b4)
- Bug 1171451 - Use the correct type for the argv argument to NS_CreateJSArgv and the nsJSArgArray constructor; r=jst (edfa21a59)
- Bug 886459, part 1 - Remove unused includes of nsIJSRuntimeService.h. r=bholley (bbc277ac1)
- Bug 886459, part 2 - Remove context callbacks from XPCJSRuntime. r=bholley (2c3c8515a)
- Bug 886459, part 3 - Remove simple uses of nsIJSRuntimeService to get the JSRuntime. r=bholley (ff5bfe304)
- pointer style (2ea264afd)
- Bug 1169457 - Add null check in OnWrapperDestroy. r=jimm (741739513)
-  Bug 886459, part 4 - Remove nsIJSRuntimeService. r=bholley,aklotz (61563f53b)
- Bug 1176642 - Use absolute_import in mach_commands.py files; r=glandium (a9fcb3b3f)
- Bug 1176642 - Defer import of autotry and pprint; r=chmanchester (de40855cb)
- Bug 1178772 - Add check_macroassembler_style.py: Verify that each MacroAssembler declaration maps to all its definitions. r=h4writer (fd406593a)
- Bug 1152556 - Add moz.build bugzilla metadata in dom/media. r=kinetik (fa2ffa121)
- Bug 1152556 - Add moz.build bugzilla metadata in dom/media webrtc. r=abr (d208b839a)
- re-enable peerconnection (42e8c412b)
- Bug 1152538 - Enable WebRTC identity, r=jesup (13a47adcb)
- Bug 1231123 - Simplify LaunchApp on BSDs by dropping fork/exec version. r=jld (c35e6e36f)
- bug 1171120 - Fix mtransport+signalling to build on iOS. r=ekr (7034b20ab)
- Bug 1150609 Patch 1 WebRTC SDP - add tmmbr to offer. r=jesup (52ca72d09)
- Bug 1150609 Patch 2 - WebRTC enable tmmbr r=jesup (d59c6adb9)
- Bug 1150609 Patch 3 - WebRTC enable tmmbr unittest changes. r=jesup (eeffed826)
- Bug 1087161 - Upgrading B2G toolchain to gcc-4.9 (851194ca0)
2020-12-01 21:03:44 +08:00

121 lines
4.8 KiB
Python

# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import absolute_import, print_function, unicode_literals
import argparse
import glob
import logging
import mozpack.path as mozpath
import os
from mozbuild.base import (
MachCommandBase,
)
from mach.decorators import (
CommandArgument,
CommandProvider,
Command,
)
@CommandProvider
class MachCommands(MachCommandBase):
@Command('python', category='devenv',
description='Run Python.')
@CommandArgument('args', nargs=argparse.REMAINDER)
def python(self, args):
# Avoid logging the command
self.log_manager.terminal_handler.setLevel(logging.CRITICAL)
self._activate_virtualenv()
return self.run_process([self.virtualenv_manager.python_path] + args,
pass_thru=True, # Allow user to run Python interactively.
ensure_exit_code=False, # Don't throw on non-zero exit code.
# Note: subprocess requires native strings in os.environ on Windows
append_env={b'PYTHONDONTWRITEBYTECODE': str('1')})
@Command('python-test', category='testing',
description='Run Python unit tests.')
@CommandArgument('--verbose',
default=False,
action='store_true',
help='Verbose output.')
@CommandArgument('--stop',
default=False,
action='store_true',
help='Stop running tests after the first error or failure.')
@CommandArgument('tests', nargs='+',
metavar='TEST',
help='Tests to run. Each test can be a single file or a directory.')
def python_test(self, tests, verbose=False, stop=False):
self._activate_virtualenv()
# Python's unittest, and in particular discover, has problems with
# clashing namespaces when importing multiple test modules. What follows
# is a simple way to keep environments separate, at the price of
# launching Python multiple times. This also runs tests via mozunit,
# which produces output in the format Mozilla infrastructure expects.
return_code = 0
files = []
# We search for files in both the current directory (for people running
# from topsrcdir or cd'd into their test directory) and topsrcdir (to
# support people running mach from the objdir). The |break|s in the
# loop below ensure that we don't run tests twice if we're running mach
# from topsrcdir
search_dirs = ['.', self.topsrcdir]
last_search_dir = search_dirs[-1]
for t in tests:
for d in search_dirs:
test = mozpath.join(d, t)
if test.endswith('.py') and os.path.isfile(test):
files.append(test)
break
elif os.path.isfile(test + '.py'):
files.append(test + '.py')
break
elif os.path.isdir(test):
files += glob.glob(mozpath.join(test, 'test*.py'))
files += glob.glob(mozpath.join(test, 'unit*.py'))
break
elif d == last_search_dir:
self.log(logging.WARN, 'python-test',
{'test': t},
'TEST-UNEXPECTED-FAIL | Invalid test: {test}')
if stop:
return 1
for f in files:
file_displayed_test = [] # Used as a boolean.
def _line_handler(line):
if not file_displayed_test and line.startswith('TEST-'):
file_displayed_test.append(True)
inner_return_code = self.run_process(
[self.virtualenv_manager.python_path, f],
ensure_exit_code=False, # Don't throw on non-zero exit code.
log_name='python-test',
# subprocess requires native strings in os.environ on Windows
append_env={b'PYTHONDONTWRITEBYTECODE': str('1')},
line_handler=_line_handler)
return_code += inner_return_code
if not file_displayed_test:
self.log(logging.WARN, 'python-test', {'file': f},
'TEST-UNEXPECTED-FAIL | No test output (missing mozunit.main() call?): {file}')
if verbose:
if inner_return_code != 0:
self.log(logging.INFO, 'python-test', {'file': f},
'Test failed: {file}')
else:
self.log(logging.INFO, 'python-test', {'file': f},
'Test passed: {file}')
if stop and return_code > 0:
return 1
return 0 if return_code == 0 else 1