def main() -> None: parser = argparse.ArgumentParser() 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") args = T.cast('ArgumentType', parser.parse_args()) 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, False, True) for t in tests ] failed = False for test, result in zip(tests, results): if result is None: msg = mlog.yellow('SKIP:') elif result.msg: msg = mlog.red('FAIL:') failed = True else: msg = mlog.green('PASS:'******'reason:', result.msg) if result.step is BuildStep.configure: # For configure failures, instead of printing stdout, # print the meson log if available since it's a superset # of stdout and often has very useful information. mlog.log(result.mlog) else: mlog.log(result.stdo) for cmd_res in result.cicmds: mlog.log(cmd_res) mlog.log(result.stde) exit(1 if failed else 0)
def main() -> None: parser = argparse.ArgumentParser() 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] 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()))): msg = mlog.yellow('SKIP:') elif result.msg: msg = mlog.red('FAIL:') failed = True
def main() -> None: parser = argparse.ArgumentParser() 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] 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): msg = mlog.yellow('SKIP:') elif result.msg: msg = mlog.red('FAIL:') failed = True else: msg = mlog.green('PASS:'******'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, # print the meson log if available since it's a superset # of stdout and often has very useful information. mlog.log(result.mlog) else: mlog.log(result.stdo) for cmd_res in result.cicmds: mlog.log(cmd_res) mlog.log(result.stde) exit(1 if failed else 0)
def main() -> None: parser = argparse.ArgumentParser() 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") args = T.cast('ArgumentType', parser.parse_args()) 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, False, 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()))): msg = mlog.yellow('SKIP:') elif result.msg: msg = mlog.red('FAIL:') failed = True
def _generate_object(self, obj: Object) -> None: tags = [] tags += [{ ObjectType.ELEMENTARY: mlog.yellow('[elementary]'), ObjectType.BUILTIN: mlog.green('[builtin]'), ObjectType.MODULE: mlog.blue('[module]'), ObjectType.RETURNED: mlog.cyan('[returned]'), }[obj.obj_type]] if obj.is_container: tags += [mlog.red('[container]')] mlog.log() mlog.log('Object', mlog.bold(obj.name), *tags) with my_nested(): desc = obj.description if '\n' in desc: desc = desc[:desc.index('\n')] mlog.log('Description:', mlog.bold(desc)) mlog.log('Returned by:', mlog.bold(str([x.name for x in obj.returned_by]))) mlog.log('Methods:') with my_nested(): for m in obj.methods: self._generate_function(m)
def yellow(text): return mlog.yellow(text).get_text(mlog.colorize_console)
def main() -> None: parser = argparse.ArgumentParser() 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] def should_fail(path: pathlib.Path) -> str: dir_ = path.parent.stem # FIXME: warning tets might not be handled correctly still… if dir_.startswith(('failing', 'warning')): if ' ' in dir_: return dir_.split(' ')[1] return 'meson' return '' results = [ run_test(t, t.args, should_fail(t.path), args.use_tmpdir) for t in tests ] failed = False for test, result in zip(tests, results): if result is None: is_skipped = True skip_reason = 'not run because preconditions were not met' else: for l in result.stdo.splitlines(): if test_emits_skip_msg(l): is_skipped = True offset = l.index('MESON_SKIP_TEST') + 16 skip_reason = l[offset:].strip() break else: is_skipped = False skip_reason = '' if is_skipped: msg = mlog.yellow('SKIP:') elif result.msg: msg = mlog.red('FAIL:') failed = True else: msg = mlog.green('PASS:'******'Reason:'), skip_reason) 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, # print the meson log if available since it's a superset # of stdout and often has very useful information. mlog.log(result.mlog) else: mlog.log(result.stdo) for cmd_res in result.cicmds: mlog.log(cmd_res) mlog.log(result.stde) exit(1 if failed else 0)