def print_system_info(): print(mlog.bold('System information.').get_text(mlog.colorize_console())) print('Architecture:', platform.architecture()) print('Machine:', platform.machine()) print('Platform:', platform.system()) print('Processor:', platform.processor()) print('System:', platform.system()) print('') print(flush=True)
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') 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 cross = options.cross backend, _ = guess_backend(options.backend, shutil.which('msbuild')) no_unittests = options.no_unittests # Running on a developer machine? Be nice! if not mesonlib.is_windows() and not mesonlib.is_haiku() and 'CI' not in os.environ: os.nice(20) # Appveyor sets the `platform` environment variable which completely messes # up building with the vs2010 and vs2015 backends. # # Specifically, MSBuild reads the `platform` environment variable to set # the configured value for the platform (Win32/x64/arm), which breaks x86 # builds. # # Appveyor setting this also breaks our 'native build arch' detection for # Windows in environment.py:detect_windows_arch() by overwriting the value # of `platform` set by vcvarsall.bat. # # While building for x86, `platform` should be unset. if 'APPVEYOR' in os.environ and os.environ['arch'] == 'x86': os.environ.pop('platform') # Run tests # Can't pass arguments to unit tests, so set the backend to use in the environment env = os.environ.copy() env['MESON_UNIT_TEST_BACKEND'] = backend.name 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 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.').get_text(mlog.colorize_console())) print(flush=True) cmd = mesonlib.python_command + ['run_unittests.py', '-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:] 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('Running {} cross tests.'.format(cf)).get_text(mlog.colorize_console())) print(flush=True) cmd = cross_test_args + ['cross/' + cf] if options.failfast: cmd += ['--failfast'] returncode += subprocess.call(cmd, env=env) if options.failfast and returncode != 0: return returncode return returncode