Don't nuke our multiprocessing efforts objc!

This commit is contained in:
Pedro Algarvio 2019-11-12 17:25:30 +00:00
parent 3fc9d13046
commit 635e7f2b33
No known key found for this signature in database
GPG key ID: BB36BF6584A298FF

View file

@ -350,19 +350,23 @@ def _run_with_coverage(session, *test_cmd):
python_path_entries.remove(SITECUSTOMIZE_DIR)
python_path_entries.insert(0, SITECUSTOMIZE_DIR)
python_path_env_var = os.pathsep.join(python_path_entries)
env = {
# The updated python path so that sitecustomize is importable
'PYTHONPATH': python_path_env_var,
# The full path to the .coverage data file. Makes sure we always write
# them to the same directory
'COVERAGE_FILE': os.path.abspath(os.path.join(REPO_ROOT, '.coverage')),
# Instruct sub processes to also run under coverage
'COVERAGE_PROCESS_START': os.path.join(REPO_ROOT, '.coveragerc')
}
if IS_DARWIN:
# Don't nuke our multiprocessing efforts objc!
# https://stackoverflow.com/questions/50168647/multiprocessing-causes-python-to-crash-and-gives-an-error-may-have-been-in-progr
env['OBJC_DISABLE_INITIALIZE_FORK_SAFETY'] = 'YES'
try:
session.run(
*test_cmd,
env={
# The updated python path so that sitecustomize is importable
'PYTHONPATH': python_path_env_var,
# The full path to the .coverage data file. Makes sure we always write
# them to the same directory
'COVERAGE_FILE': os.path.abspath(os.path.join(REPO_ROOT, '.coverage')),
# Instruct sub processes to also run under coverage
'COVERAGE_PROCESS_START': os.path.join(REPO_ROOT, '.coveragerc')
}
)
session.run(*test_cmd, env=env)
finally:
# Always combine and generate the XML coverage report
try:
@ -394,7 +398,13 @@ def _runtests(session, coverage, cmd_args):
if coverage is True:
_run_with_coverage(session, 'coverage', 'run', os.path.join('tests', 'runtests.py'), *cmd_args)
else:
session.run('python', os.path.join('tests', 'runtests.py'), *cmd_args)
cmd_args = ['python', os.path.join('tests', 'runtests.py')] + list(cmd_args)
env = None
if IS_DARWIN:
# Don't nuke our multiprocessing efforts objc!
# https://stackoverflow.com/questions/50168647/multiprocessing-causes-python-to-crash-and-gives-an-error-may-have-been-in-progr
env = {'OBJC_DISABLE_INITIALIZE_FORK_SAFETY': 'YES'}
session.run(*cmd_args, env=env)
except CommandFailed:
# Disabling re-running failed tests for the time being
raise
@ -845,11 +855,17 @@ def _pytest(session, coverage, cmd_args):
# Create required artifacts directories
_create_ci_directories()
env = None
if IS_DARWIN:
# Don't nuke our multiprocessing efforts objc!
# https://stackoverflow.com/questions/50168647/multiprocessing-causes-python-to-crash-and-gives-an-error-may-have-been-in-progr
env = {'OBJC_DISABLE_INITIALIZE_FORK_SAFETY': 'YES'}
try:
if coverage is True:
_run_with_coverage(session, 'coverage', 'run', '-m', 'py.test', *cmd_args)
else:
session.run('py.test', *cmd_args)
session.run('py.test', *cmd_args, env=env)
except CommandFailed:
# Re-run failed tests
session.log('Re-running failed tests')
@ -857,7 +873,7 @@ def _pytest(session, coverage, cmd_args):
if coverage is True:
_run_with_coverage(session, 'coverage', 'run', '-m', 'py.test', *cmd_args)
else:
session.run('py.test', *cmd_args)
session.run('py.test', *cmd_args, env=env)
def _lint(session, rcfile, flags, paths):