def _run_with_coverage(session, *test_cmd, env=None):
    if (SKIP_REQUIREMENTS_INSTALL is False):
        session.install('--progress-bar=off', 'coverage==5.2', silent=PIP_INSTALL_SILENT)
    session.run('coverage', 'erase')
    python_path_env_var = (os.environ.get('PYTHONPATH') or None)
    if (python_path_env_var is None):
        python_path_env_var = SITECUSTOMIZE_DIR
    else:
        python_path_entries = python_path_env_var.split(os.pathsep)
        if (SITECUSTOMIZE_DIR in python_path_entries):
            python_path_entries.remove(SITECUSTOMIZE_DIR)
        python_path_entries.insert(0, SITECUSTOMIZE_DIR)
        python_path_env_var = os.pathsep.join(python_path_entries)
    if (env is None):
        env = {}
    env.update({'PYTHONPATH': python_path_env_var, 'COVERAGE_FILE': os.path.abspath(os.path.join(REPO_ROOT, '.coverage')), 'COVERAGE_PROCESS_START': os.path.join(REPO_ROOT, '.coveragerc')})
    try:
        session.run(*test_cmd, env=env)
    finally:
        try:
            session.run('coverage', 'combine')
        except CommandFailed:
            pass
        session.run('coverage', 'xml', '-o', os.path.join('artifacts', 'coverage', 'salt.xml'), '--omit=tests/*', '--include=salt/*')
        session.run('coverage', 'xml', '-o', os.path.join('artifacts', 'coverage', 'tests.xml'), '--omit=salt/*', '--include=tests/*')
        shutil.move('.coverage', os.path.join('artifacts', 'coverage', '.coverage'))
def _run_with_coverage(session, *test_cmd, env=None):
    if (SKIP_REQUIREMENTS_INSTALL is False):
        session.install('--progress-bar=off', 'coverage==5.2', silent=PIP_INSTALL_SILENT)
    session.run('coverage', 'erase')
    python_path_env_var = (os.environ.get('PYTHONPATH') or None)
    if (python_path_env_var is None):
        python_path_env_var = SITECUSTOMIZE_DIR
    else:
        python_path_entries = python_path_env_var.split(os.pathsep)
        if (SITECUSTOMIZE_DIR in python_path_entries):
            python_path_entries.remove(SITECUSTOMIZE_DIR)
        python_path_entries.insert(0, SITECUSTOMIZE_DIR)
        python_path_env_var = os.pathsep.join(python_path_entries)
    if (env is None):
        env = {}
    env.update({'PYTHONPATH': python_path_env_var, 'COVERAGE_FILE': os.path.abspath(os.path.join(REPO_ROOT, '.coverage')), 'COVERAGE_PROCESS_START': os.path.join(REPO_ROOT, '.coveragerc')})
    try:
        session.run(*test_cmd, env=env)
    finally:
        try:
            session.run('coverage', 'combine')
        except CommandFailed:
            pass
        session.run('coverage', 'xml', '-o', os.path.join('artifacts', 'coverage', 'salt.xml'), '--omit=tests/*', '--include=salt/*')
        session.run('coverage', 'xml', '-o', os.path.join('artifacts', 'coverage', 'tests.xml'), '--omit=salt/*', '--include=tests/*')
        shutil.move('.coverage', os.path.join('artifacts', 'coverage', '.coverage'))