aboutsummaryrefslogtreecommitdiff
path: root/run_single_test.py
diff options
context:
space:
mode:
authorDaniel Mensinger <daniel@mensinger-ka.de>2021-06-08 14:42:40 +0200
committerDaniel Mensinger <daniel@mensinger-ka.de>2021-06-09 13:25:36 +0200
commite1708d3de9192ebd85923d1ef99a0212101244a6 (patch)
treebc5db1e24367130817eacdbd6ff4e7fecf273a4b /run_single_test.py
parent99d3897caf111a9e14b203408708ab67925b863c (diff)
downloadmeson-e1708d3de9192ebd85923d1ef99a0212101244a6.zip
meson-e1708d3de9192ebd85923d1ef99a0212101244a6.tar.gz
meson-e1708d3de9192ebd85923d1ef99a0212101244a6.tar.bz2
tests: Reduce complexity of the run_tests signature
Diffstat (limited to 'run_single_test.py')
-rwxr-xr-xrun_single_test.py36
1 files changed, 12 insertions, 24 deletions
diff --git a/run_single_test.py b/run_single_test.py
index b491c38..703f0a6 100755
--- a/run_single_test.py
+++ b/run_single_test.py
@@ -10,23 +10,16 @@ test, with all of the rules from the test.json file loaded.
import argparse
import pathlib
-import shutil
import typing as T
-from mesonbuild import environment
from mesonbuild import mlog
-from mesonbuild import mesonlib
from run_project_tests import TestDef, load_test_json, run_test, BuildStep, skippable
-from run_tests import get_backend_commands, guess_backend, get_fake_options
+from run_project_tests import setup_commands, detect_system_compiler, print_tool_versions
if T.TYPE_CHECKING:
- try:
- from typing import Protocol
- except ImportError:
- # Mypy gets grump about this even though it's fine
- from typing_extensions import Protocol # type: ignore
+ from run_project_tests import CompilerArgumentType
- class ArgumentType(Protocol):
+ class ArgumentType(CompilerArgumentType):
"""Typing information for command line arguments."""
@@ -40,26 +33,21 @@ def main() -> None:
parser.add_argument('case', type=pathlib.Path, help='The test case to run')
parser.add_argument('--subtest', type=int, action='append', dest='subtests', help='which subtests to run')
parser.add_argument('--backend', action='store', help="Which backend to use")
+ parser.add_argument('--cross-file', action='store', help='File describing cross compilation environment.')
+ parser.add_argument('--native-file', action='store', help='File describing native compilation environment.')
+ parser.add_argument('--use-tmpdir', action='store_true', help='Use tmp directory for temporary files.')
args = T.cast('ArgumentType', parser.parse_args())
+ setup_commands(args.backend)
+ detect_system_compiler(args)
+ print_tool_versions()
+
test = TestDef(args.case, args.case.stem, [])
tests = load_test_json(test, False)
if args.subtests:
tests = [t for i, t in enumerate(tests) if i in args.subtests]
- with mesonlib.TemporaryDirectoryWinProof() as build_dir:
- fake_opts = get_fake_options('/')
- env = environment.Environment(None, build_dir, fake_opts)
- try:
- comp = env.compiler_from_language('c', mesonlib.MachineChoice.HOST).get_id()
- except mesonlib.MesonException:
- raise RuntimeError('Could not detect C compiler')
-
- backend, backend_args = guess_backend(args.backend, shutil.which('msbuild'))
- _cmds = get_backend_commands(backend, False)
- commands = (_cmds[0], _cmds[1], _cmds[3], _cmds[4])
-
- results = [run_test(t, t.args, comp, backend, backend_args, commands, '', True) for t in tests]
+ results = [run_test(t, t.args, '', True) for t in tests]
failed = False
for test, result in zip(tests, results):
if (result is None) or (('MESON_SKIP_TEST' in result.stdo) and (skippable(str(args.case.parent), test.path.as_posix()))):
@@ -70,7 +58,7 @@ def main() -> None:
else:
msg = mlog.green('PASS:')
mlog.log(msg, test.display_name())
- if result.msg and 'MESON_SKIP_TEST' not in result.stdo:
+ if result is not None and result.msg and 'MESON_SKIP_TEST' not in result.stdo:
mlog.log('reason:', result.msg)
if result.step is BuildStep.configure:
# For configure failures, instead of printing stdout,