run_*_tests: Add some type annotations

pull/8389/head
Dylan Baker 4 years ago
parent 8a12115741
commit 3e11da6db5
  1. 11
      run_project_tests.py
  2. 31
      run_tests.py

@ -476,7 +476,7 @@ def format_parameter_file(file_basename: str, test: TestDef, test_build_dir: str
return destination return destination
def detect_parameter_files(test: TestDef, test_build_dir: str) -> (Path, Path): def detect_parameter_files(test: TestDef, test_build_dir: str) -> T.Tuple[Path, Path]:
nativefile = test.path / 'nativefile.ini' nativefile = test.path / 'nativefile.ini'
crossfile = test.path / 'crossfile.ini' crossfile = test.path / 'crossfile.ini'
@ -488,7 +488,9 @@ def detect_parameter_files(test: TestDef, test_build_dir: str) -> (Path, Path):
return nativefile, crossfile return nativefile, crossfile
def run_test(test: TestDef, extra_args, compiler, backend, flags, commands, should_fail, use_tmp: bool): def run_test(test: TestDef, extra_args: T.List[str], compiler: str, backend: Backend,
flags: T.List[str], commands: T.Tuple[T.List[str], T.List[str], T.List[str], T.List[str]],
should_fail: bool, use_tmp: bool) -> T.Optional[TestResult]:
if test.skip: if test.skip:
return None return None
build_dir = create_deterministic_builddir(test, use_tmp) build_dir = create_deterministic_builddir(test, use_tmp)
@ -503,7 +505,10 @@ def run_test(test: TestDef, extra_args, compiler, backend, flags, commands, shou
finally: finally:
mesonlib.windows_proof_rmtree(build_dir) mesonlib.windows_proof_rmtree(build_dir)
def _run_test(test: TestDef, test_build_dir: str, install_dir: str, extra_args, compiler, backend, flags, commands, should_fail): def _run_test(test: TestDef, test_build_dir: str, install_dir: str,
extra_args: T.List[str], compiler: str, backend: Backend,
flags: T.List[str], commands: T.Tuple[T.List[str], T.List[str], T.List[str], T.List[str]],
should_fail: bool) -> TestResult:
compile_commands, clean_commands, install_commands, uninstall_commands = commands compile_commands, clean_commands, install_commands, uninstall_commands = commands
gen_start = time.time() gen_start = time.time()
# Configure in-process # Configure in-process

@ -27,6 +27,8 @@ from enum import Enum
from glob import glob from glob import glob
from pathlib import Path from pathlib import Path
from unittest import mock from unittest import mock
import typing as T
from mesonbuild import compilers from mesonbuild import compilers
from mesonbuild import dependencies from mesonbuild import dependencies
from mesonbuild import mesonlib from mesonbuild import mesonlib
@ -57,26 +59,27 @@ else:
if NINJA_CMD is None: if NINJA_CMD is None:
raise RuntimeError('Could not find Ninja v1.7 or newer') raise RuntimeError('Could not find Ninja v1.7 or newer')
def guess_backend(backend, msbuild_exe: str): def guess_backend(backend_str: str, msbuild_exe: str) -> T.Tuple['Backend', T.List[str]]:
# Auto-detect backend if unspecified # Auto-detect backend if unspecified
backend_flags = [] backend_flags = []
if backend is None: if backend_str is None:
if msbuild_exe is not None and (mesonlib.is_windows() and not _using_intelcl()): if msbuild_exe is not None and (mesonlib.is_windows() and not _using_intelcl()):
backend = 'vs' # Meson will auto-detect VS version to use backend_str = 'vs' # Meson will auto-detect VS version to use
else: else:
backend = 'ninja' backend_str = 'ninja'
# Set backend arguments for Meson # Set backend arguments for Meson
if backend.startswith('vs'): if backend_str.startswith('vs'):
backend_flags = ['--backend=' + backend] backend_flags = ['--backend=' + backend_str]
backend = Backend.vs backend = Backend.vs
elif backend == 'xcode': elif backend_str == 'xcode':
backend_flags = ['--backend=xcode'] backend_flags = ['--backend=xcode']
backend = Backend.xcode backend = Backend.xcode
elif backend == 'ninja': elif backend_str == 'ninja':
backend_flags = ['--backend=ninja'] backend_flags = ['--backend=ninja']
backend = Backend.ninja backend = Backend.ninja
else: else:
raise RuntimeError('Unknown backend: {!r}'.format(backend)) raise RuntimeError('Unknown backend: {!r}'.format(backend_str))
return (backend, backend_flags) return (backend, backend_flags)
@ -208,9 +211,13 @@ def get_builddir_target_args(backend, builddir, target):
raise AssertionError('Unknown backend: {!r}'.format(backend)) raise AssertionError('Unknown backend: {!r}'.format(backend))
return target_args + dir_args return target_args + dir_args
def get_backend_commands(backend, debug=False): def get_backend_commands(backend: Backend, debug: bool = False) -> \
install_cmd = [] T.Tuple[T.List[str], T.List[str], T.List[str], T.List[str], T.List[str]]:
uninstall_cmd = [] install_cmd: T.List[str] = []
uninstall_cmd: T.List[str] = []
clean_cmd: T.List[str]
cmd: T.List[str]
test_cmd: T.List[str]
if backend is Backend.vs: if backend is Backend.vs:
cmd = ['msbuild'] cmd = ['msbuild']
clean_cmd = cmd + ['/target:Clean'] clean_cmd = cmd + ['/target:Clean']

Loading…
Cancel
Save