diff options
author | Daniel Mensinger <daniel@mensinger-ka.de> | 2021-06-07 13:00:59 +0200 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2021-06-22 21:05:11 +0300 |
commit | 765aff5a42d9b7568bbd89f711d52c2da346e91c (patch) | |
tree | 11e3b60053d4f5061f3b970dccc4a9b91e313770 /run_tests.py | |
parent | edfe24178d86450a8184bd139e03c5cdcad91100 (diff) | |
download | meson-765aff5a42d9b7568bbd89f711d52c2da346e91c.zip meson-765aff5a42d9b7568bbd89f711d52c2da346e91c.tar.gz meson-765aff5a42d9b7568bbd89f711d52c2da346e91c.tar.bz2 |
coverage: Enable coverage reports
Diffstat (limited to 'run_tests.py')
-rwxr-xr-x | run_tests.py | 78 |
1 files changed, 29 insertions, 49 deletions
diff --git a/run_tests.py b/run_tests.py index 10d63df..ae96bfa 100755 --- a/run_tests.py +++ b/run_tests.py @@ -20,7 +20,6 @@ import sys import time import shutil import subprocess -import tempfile import platform import argparse import traceback @@ -311,7 +310,6 @@ def print_system_info(): def main(): print_system_info() parser = argparse.ArgumentParser() - parser.add_argument('--cov', action='store_true') parser.add_argument('--backend', default=None, dest='backend', choices=backendlist) parser.add_argument('--cross', default=[], dest='cross', action='append') @@ -319,13 +317,6 @@ def main(): parser.add_argument('--failfast', action='store_true') parser.add_argument('--no-unittests', action='store_true', default=False) (options, _) = parser.parse_known_args() - # Enable coverage early... - enable_coverage = options.cov - if enable_coverage: - os.makedirs('.coverage', exist_ok=True) - sys.argv.remove('--cov') - import coverage - coverage.process_startup() returncode = 0 backend, _ = guess_backend(options.backend, shutil.which('msbuild')) no_unittests = options.no_unittests @@ -349,52 +340,41 @@ def main(): # Run tests # Can't pass arguments to unit tests, so set the backend to use in the environment env = os.environ.copy() - with tempfile.TemporaryDirectory() as temp_dir: - # Enable coverage on all subsequent processes. - if enable_coverage: - Path(temp_dir, 'usercustomize.py').open('w').write( - 'import coverage\n' - 'coverage.process_startup()\n') - env['COVERAGE_PROCESS_START'] = '.coveragerc' - if 'PYTHONPATH' in env: - env['PYTHONPATH'] = os.pathsep.join([temp_dir, env.get('PYTHONPATH')]) - else: - env['PYTHONPATH'] = temp_dir - if not options.cross: - cmd = mesonlib.python_command + ['run_meson_command_tests.py', '-v'] + if not options.cross: + cmd = mesonlib.python_command + ['run_meson_command_tests.py', '-v'] + if options.failfast: + cmd += ['--failfast'] + returncode += subprocess.call(cmd, env=env) + if options.failfast and returncode != 0: + return returncode + if no_unittests: + print('Skipping all unit tests.') + print(flush=True) + returncode = 0 + else: + print(mlog.bold('Running unittests.')) + print(flush=True) + cmd = mesonlib.python_command + ['run_unittests.py', '--backend=' + backend.name, '-v'] if options.failfast: cmd += ['--failfast'] returncode += subprocess.call(cmd, env=env) if options.failfast and returncode != 0: return returncode - if no_unittests: - print('Skipping all unit tests.') - print(flush=True) - returncode = 0 - else: - print(mlog.bold('Running unittests.')) - print(flush=True) - cmd = mesonlib.python_command + ['run_unittests.py', '--backend=' + backend.name, '-v'] - if options.failfast: - cmd += ['--failfast'] - returncode += subprocess.call(cmd, env=env) - if options.failfast and returncode != 0: - return returncode - cmd = mesonlib.python_command + ['run_project_tests.py'] + sys.argv[1:] + cmd = mesonlib.python_command + ['run_project_tests.py'] + sys.argv[1:] + returncode += subprocess.call(cmd, env=env) + else: + cross_test_args = mesonlib.python_command + ['run_cross_test.py'] + for cf in options.cross: + print(mlog.bold(f'Running {cf} cross tests.')) + print(flush=True) + cmd = cross_test_args + ['cross/' + cf] + if options.failfast: + cmd += ['--failfast'] + if options.cross_only: + cmd += ['--cross-only'] returncode += subprocess.call(cmd, env=env) - else: - cross_test_args = mesonlib.python_command + ['run_cross_test.py'] - for cf in options.cross: - print(mlog.bold(f'Running {cf} cross tests.')) - print(flush=True) - cmd = cross_test_args + ['cross/' + cf] - if options.failfast: - cmd += ['--failfast'] - if options.cross_only: - cmd += ['--cross-only'] - returncode += subprocess.call(cmd, env=env) - if options.failfast and returncode != 0: - return returncode + if options.failfast and returncode != 0: + return returncode return returncode if __name__ == '__main__': |