Include COVERAGE_FILE as an env variable.

This will tell coverage where to save all coverage files.
This commit is contained in:
Pedro Algarvio 2019-04-20 18:07:47 +01:00
parent 0af561ef24
commit 8948b690b1
No known key found for this signature in database
GPG key ID: BB36BF6584A298FF
2 changed files with 7 additions and 0 deletions

View file

@ -253,7 +253,12 @@ def _run_with_coverage(session, *test_cmd):
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')
}
)

View file

@ -103,6 +103,7 @@ SCRIPT_TEMPLATES = {
'coverage': textwrap.dedent(
'''
SITECUSTOMIZE_DIR = os.path.join(CODE_DIR, 'tests', 'support', 'coverage')
COVERAGE_FILE = os.path.join(CODE_DIR, '.coverage')
COVERAGE_PROCESS_START = os.path.join(CODE_DIR, '.coveragerc')
PYTHONPATH = os.environ.get('PYTHONPATH') or None
if PYTHONPATH is None:
@ -114,6 +115,7 @@ SCRIPT_TEMPLATES = {
PYTHON_PATH_ENTRIES.insert(0, SITECUSTOMIZE_DIR)
PYTHONPATH_ENV_VAR = os.pathsep.join(PYTHON_PATH_ENTRIES)
os.environ['PYTHONPATH'] = PYTHONPATH_ENV_VAR
os.environ['COVERAGE_FILE'] = COVERAGE_FILE
os.environ['COVERAGE_PROCESS_START'] = COVERAGE_PROCESS_START
'''
)