예제 #1
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:
            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)
예제 #2
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):
            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)
예제 #3
0
    def declaration(self, state, args, kwargs):
        if len(args) != 2:
            raise InterpreterException('declaration takes exactly two arguments.')
        check_stringlist(args)

        disabled, required, _ = extract_required_kwarg(kwargs, state.subproject)
        if disabled:
            return ModuleReturnValue(False, [False])

        lang, compiler = self._compiler(state)
        parser = declaration_parsers.get(lang)
        if not parser:
            raise InterpreterException('no declaration parser for language %s' % lang)

        compiler_args = self._compile_args(compiler, state, kwargs)
        compiler_args += compiler.get_werror_args()

        pkg = args[0]
        decl = args[1]

        tree = parser.parse(decl)
        name = extract_declaration_name(tree)
        proto = rewrite_declaration(tree, name)

        check_prototype = not is_lone_identifier(tree)

        if check_prototype:
            checker = prototype_checkers.get(lang)
            if not checker:
                raise InterpreterException('no checker program for language %s' % lang)

            prog = checker(tree, pkg, name)
            ok = compiler.compiles(prog, state.environment, compiler_args, None)
            status = mlog.green('YES') if ok else mlog.red('NO')
            mlog.log('Checking that', mlog.bold(name, True), 'has prototype', mlog.bold(proto, True), ':', status)
        else:
            ok = compiler.has_header_symbol(pkg, name, '', state.environment, compiler_args, None)
            self._checklog('declaration for', name, ok)

        self._set_config_var(state, ok, name, kwargs)
        if not ok and required:
            raise InterpreterException('{} declaration {} required but not found.'.format(lang, name))
        return ModuleReturnValue(ok, [ok])
예제 #4
0
 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)
예제 #5
0
def green(text):
    return mlog.green(text).get_text(mlog.colorize_console)
예제 #6
0
    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
        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)
예제 #7
0
 def _checklog(self, which, what, ok):
     status = mlog.green('YES') if ok else mlog.red('NO')
     mlog.log('Checking that', which, mlog.bold(what, True), 'exists:', status)
예제 #8
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]

    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)