Ejemplo n.º 1
0
    def get_result(self, command='', args=[], environ={},
                   prog='/bin/configure', extra_paths=None,
                   includes=('util.configure', 'checks.configure')):
        config = {}
        out = StringIO()
        paths = {
            self.KNOWN_A: None,
            self.KNOWN_B: None,
            self.KNOWN_C: None,
        }
        if extra_paths:
            paths.update(extra_paths)
        environ = dict(environ)
        if 'PATH' not in environ:
            environ['PATH'] = os.pathsep.join(os.path.dirname(p) for p in paths)
        paths[self.OTHER_A] = None
        sandbox = ConfigureTestSandbox(paths, config, environ, [prog] + args,
                                       out, out)
        base_dir = os.path.join(topsrcdir, 'build', 'moz.configure')
        for f in includes:
            sandbox.include_file(os.path.join(base_dir, f))

        status = 0
        try:
            exec_(command, sandbox)
            sandbox.run()
        except SystemExit as e:
            status = e.code

        return config, out.getvalue(), status
Ejemplo n.º 2
0
    def do_compile_test(self, command, expected_test_content=None,
                        expected_flags=None):

        paths = {
            os.path.abspath('/usr/bin/mockcc'): self.get_mock_compiler(
                expected_test_content=expected_test_content,
                expected_flags=expected_flags),
        }

        base_dir = os.path.join(topsrcdir, 'build', 'moz.configure')

        mock_compiler_defs = textwrap.dedent('''\
            @depends('--help')
            def extra_toolchain_flags(_):
                return []

            include('%s/compilers-util.configure')

            @compiler_class
            @depends('--help')
            def c_compiler(_):
                return namespace(
                    flags=[],
                    type='gcc',
                    compiler=os.path.abspath('/usr/bin/mockcc'),
                    wrapper=[],
                    language='C',
                )

            @compiler_class
            @depends('--help')
            def cxx_compiler(_):
                return namespace(
                    flags=[],
                    type='gcc',
                    compiler=os.path.abspath('/usr/bin/mockcc'),
                    wrapper=[],
                    language='C++',
                )
        ''' % mozpath.normsep(base_dir))

        config = {}
        out = StringIO()
        sandbox = ConfigureTestSandbox(paths, config, {}, ['/bin/configure'],
                                       out, out)
        sandbox.include_file(os.path.join(base_dir, 'util.configure'))
        sandbox.include_file(os.path.join(base_dir, 'checks.configure'))
        exec_(mock_compiler_defs, sandbox)
        sandbox.include_file(os.path.join(base_dir, 'compile-checks.configure'))

        status = 0
        try:
            exec_(command, sandbox)
            sandbox.run()
        except SystemExit as e:
            status = e.code

        return config, out.getvalue(), status
Ejemplo n.º 3
0
    def get_result(self,
                   command='',
                   args=[],
                   environ={},
                   prog='/bin/configure'):
        config = {}
        out = StringIO()
        paths = {
            self.KNOWN_A: None,
            self.KNOWN_B: None,
            self.KNOWN_C: None,
        }
        environ = dict(environ)
        environ['PATH'] = os.pathsep.join(os.path.dirname(p) for p in paths)
        sandbox = ConfigureTestSandbox(paths, config, environ, [prog] + args,
                                       out, out)
        base_dir = os.path.join(topsrcdir, 'build', 'moz.configure')
        sandbox.include_file(os.path.join(base_dir, 'util.configure'))
        sandbox.include_file(os.path.join(base_dir, 'checks.configure'))

        status = 0
        try:
            exec_(command, sandbox)
            sandbox.run()
        except SystemExit as e:
            status = e.code

        return config, out.getvalue(), status
Ejemplo n.º 4
0
 def get_result(self, command='', paths=None):
     paths = paths or {}
     config = {}
     out = StringIO()
     sandbox = ConfigureTestSandbox(paths, config, {}, ['/bin/configure'],
                                    out, out)
     sandbox.include_file(mozpath.join(topsrcdir, 'build',
                          'moz.configure', 'util.configure'))
     status = 0
     try:
         exec_(command, sandbox)
         sandbox.run()
     except SystemExit as e:
         status = e.code
     return config, out.getvalue(), status
Ejemplo n.º 5
0
    def do_compile_test(self, command, expected_test_content=None,
                        expected_flags=None):

        paths = {
            os.path.abspath('/usr/bin/mockcc'): self.get_mock_compiler(
                expected_test_content=expected_test_content,
                expected_flags=expected_flags),
        }

        mock_compiler_defs = textwrap.dedent('''\
            @depends('--help')
            def c_compiler(_):
                return namespace(
                    flags=[],
                    compiler=os.path.abspath('/usr/bin/mockcc'),
                    wrapper=[],
                )

            @depends('--help')
            def cxx_compiler(_):
                return namespace(
                    flags=[],
                    compiler=os.path.abspath('/usr/bin/mockcc'),
                    wrapper=[],
                )
            @depends('--help')
            def extra_toolchain_flags(_):
                return []
        ''')

        config = {}
        out = StringIO()
        sandbox = ConfigureTestSandbox(paths, config, {}, ['/bin/configure'],
                                       out, out)
        base_dir = os.path.join(topsrcdir, 'build', 'moz.configure')
        sandbox.include_file(os.path.join(base_dir, 'util.configure'))
        sandbox.include_file(os.path.join(base_dir, 'checks.configure'))
        exec_(mock_compiler_defs, sandbox)
        sandbox.include_file(os.path.join(base_dir, 'compilechecks.configure'))

        status = 0
        try:
            exec_(command, sandbox)
            sandbox.run()
        except SystemExit as e:
            status = e.code

        return config, out.getvalue(), status
Ejemplo n.º 6
0
    def get_result(
            self,
            command="",
            args=[],
            environ={},
            prog="/bin/configure",
            extra_paths=None,
            includes=("util.configure", "checks.configure"),
    ):
        config = {}
        out = StringIO()
        paths = {self.KNOWN_A: None, self.KNOWN_B: None, self.KNOWN_C: None}
        if extra_paths:
            paths.update(extra_paths)
        environ = dict(environ)
        if "PATH" not in environ:
            environ["PATH"] = os.pathsep.join(
                os.path.dirname(p) for p in paths)
        paths[self.OTHER_A] = None
        sandbox = ConfigureTestSandbox(paths, config, environ, [prog] + args,
                                       out, out)
        base_dir = os.path.join(topsrcdir, "build", "moz.configure")
        for f in includes:
            sandbox.include_file(os.path.join(base_dir, f))

        status = 0
        try:
            exec_(command, sandbox)
            sandbox.run()
        except SystemExit as e:
            status = e.code

        return config, out.getvalue(), status
Ejemplo n.º 7
0
 def get_result(self, command='', paths=None):
     paths = paths or {}
     config = {}
     out = StringIO()
     sandbox = ConfigureTestSandbox(paths, config, {}, ['/bin/configure'],
                                    out, out)
     sandbox.include_file(mozpath.join(topsrcdir, 'build',
                                       'moz.configure', 'util.configure'))
     status = 0
     try:
         exec_(command, sandbox)
         sandbox.run()
     except SystemExit as e:
         status = e.code
     return config, out.getvalue(), status
Ejemplo n.º 8
0
    def do_compile_test(self,
                        command,
                        expected_test_content=None,
                        expected_flags=None):

        paths = {
            os.path.abspath('/usr/bin/mockcc'):
            self.get_mock_compiler(expected_test_content=expected_test_content,
                                   expected_flags=expected_flags),
        }

        base_dir = os.path.join(topsrcdir, 'build', 'moz.configure')

        mock_compiler_defs = textwrap.dedent('''\
            @depends(when=True)
            def extra_toolchain_flags():
                return []

            target = depends(when=True)(lambda: True)

            include('%s/compilers-util.configure')

            @template
            def wrap_compiler(compiler):
                return compiler_class(compiler, False)

            @wrap_compiler
            @depends(when=True)
            def c_compiler():
                return namespace(
                    flags=[],
                    type='gcc',
                    compiler=os.path.abspath('/usr/bin/mockcc'),
                    wrapper=[],
                    language='C',
                )

            @wrap_compiler
            @depends(when=True)
            def cxx_compiler():
                return namespace(
                    flags=[],
                    type='gcc',
                    compiler=os.path.abspath('/usr/bin/mockcc'),
                    wrapper=[],
                    language='C++',
                )
        ''' % mozpath.normsep(base_dir))

        config = {}
        out = StringIO()
        sandbox = ConfigureTestSandbox(paths, config, {}, ['/bin/configure'],
                                       out, out)
        sandbox.include_file(os.path.join(base_dir, 'util.configure'))
        sandbox.include_file(os.path.join(base_dir, 'checks.configure'))
        exec_(mock_compiler_defs, sandbox)
        sandbox.include_file(os.path.join(base_dir,
                                          'compile-checks.configure'))

        status = 0
        try:
            exec_(command, sandbox)
            sandbox.run()
        except SystemExit as e:
            status = e.code

        return config, out.getvalue(), status