def preprocess_args(self, environ={}, compiler_name=None,
                        source='a.c', output=None, cpp_options=[]):
        """Returns a list of arguments that would be passed to the preprocessor executing given preprocessing step."""

        try:
            from unittest.mock import patch
        except ImportError as e:
            raise unittest.SkipTest(e)

        with patch.object(distutils.ccompiler.CCompiler, 'spawn') as spawn:
            with Environ(environ):
                cc = CCompiler(compiler_name=compiler_name)
                # Avoid check if target is newer from source.
                cc.compiler.force = True
                # Don't actually do anything.
                cc.compiler.dry_run = True
                cc.preprocess(source, output, cpp_options)
        self.assertEqual(1, spawn.call_count)
        args, kwargs = spawn.call_args
        return args[0]
    def compile_args(self, environ={}, compiler_name='unix',
                     pkg_config_cflags=[], cpp_includes=[],
                     source='a.c', init_sections=[]):
        """Returns a list of arguments that would be passed to the compiler executing given compilation step."""

        try:
            from unittest.mock import patch
        except ImportError as e:
            raise unittest.SkipTest(e)

        with patch.object(distutils.ccompiler.CCompiler, 'spawn') as spawn:
            with Environ(environ):
                cc = CCompiler(compiler_name=compiler_name)
                # Avoid check if target is newer from source.
                cc.compiler.force = True
                # Don't actually do anything.
                cc.compiler.dry_run = True
                cc.compile(pkg_config_cflags, cpp_includes, [source], init_sections)
        self.assertEqual(1, spawn.call_count)
        args, kwargs = spawn.call_args
        return args[0]
 def test_link_args_override(self):
     with Environ(dict(CC="foobar")):
         compiler = CCompiler()
         self.assertEqual(compiler.compiler.linker_so[0], "foobar")
Esempio n. 4
0
 def test_link_cmd(self):
     with Environ(dict(CC="foobar")):
         compiler = CCompiler()
         self.assertEqual(compiler.linker_cmd[0], "foobar")