Exemplo n.º 1
0
 def wrapped(*args, **kwargs):
     try:
         compiler_from_language(get_fake_env(), lang,
                                MachineChoice.HOST)
     except EnvironmentException:
         raise unittest.SkipTest(f'No {lang} compiler found.')
     return func(*args, **kwargs)
Exemplo n.º 2
0
 def helper_for_compiler(self, lang, cb, for_machine=MachineChoice.HOST):
     """Helper for generating tests for overriding compilers for langaugages
     with more than one implementation, such as C, C++, ObjC, ObjC++, and D.
     """
     env = get_fake_env()
     getter = lambda: compiler_from_language(env, lang, for_machine)
     cc = getter()
     binary, newid = cb(cc)
     env.binaries[for_machine].binaries[lang] = binary
     compiler = getter()
     self.assertEqual(compiler.id, newid)
Exemplo n.º 3
0
    def _single_implementation_compiler(self, lang: str, binary: str,
                                        version_str: str,
                                        version: str) -> None:
        """Helper for languages with a single (supported) implementation.

        Builds a wrapper around the compiler to override the version.
        """
        wrapper = self.helper_create_binary_wrapper(binary,
                                                    version=version_str)
        env = get_fake_env()
        env.binaries.host.binaries[lang] = [wrapper]
        compiler = compiler_from_language(env, lang, MachineChoice.HOST)
        self.assertEqual(compiler.version, version)
Exemplo n.º 4
0
    def _check_ld(self, name: str, lang: str, expected: str) -> None:
        if not shutil.which(name):
            raise SkipTest(f'Could not find {name}.')
        envvars = [mesonbuild.envconfig.ENV_VAR_PROG_MAP[f'{lang}_ld']]

        # Also test a deprecated variable if there is one.
        if f'{lang}_ld' in mesonbuild.envconfig.DEPRECATED_ENV_PROG_MAP:
            envvars.append(
                mesonbuild.envconfig.DEPRECATED_ENV_PROG_MAP[f'{lang}_ld'])

        for envvar in envvars:
            with mock.patch.dict(os.environ, {envvar: name}):
                env = get_fake_env()
                try:
                    comp = compiler_from_language(env, lang, MachineChoice.HOST)
                except EnvironmentException:
                    raise SkipTest(f'Could not find a compiler for {lang}')
                self.assertEqual(comp.linker.id, expected)