Пример #1
0
    def assertTest(
        self, test_name, pixel_tests, expected_checksum=None, drt_output=None, host=None, expected_text=None
    ):
        port_name = "test"
        host = host or MockSystemHost()
        test.add_unit_tests_to_mock_filesystem(host.filesystem)
        port = PortFactory(host).get(port_name)
        drt_input, drt_output = self.make_input_output(
            port, test_name, pixel_tests, expected_checksum, drt_output, drt_input=None, expected_text=expected_text
        )

        args = ["--platform", port_name] + self.extra_args(pixel_tests)
        stdin = newstringio.StringIO(drt_input)
        stdout = newstringio.StringIO()
        stderr = newstringio.StringIO()
        options, args = mock_drt.parse_options(args)

        drt = self.make_drt(options, args, host, stdin, stdout, stderr)
        res = drt.run()

        self.assertEqual(res, 0)

        # We use the StringIO.buflist here instead of getvalue() because
        # the StringIO might be a mix of unicode/ascii and 8-bit strings.
        self.assertEqual(stdout.buflist, drt_output)
        self.assertEqual(stderr.getvalue(), "#EOF\n")
Пример #2
0
    def assertTest(self,
                   test_name,
                   pixel_tests,
                   expected_checksum=None,
                   drt_output=None,
                   host=None,
                   expected_text=None):
        port_name = 'test'
        host = host or MockSystemHost()
        test.add_unit_tests_to_mock_filesystem(host.filesystem)
        port = PortFactory(host).get(port_name)
        drt_input, drt_output = self.make_input_output(
            port,
            test_name,
            pixel_tests,
            expected_checksum,
            drt_output,
            drt_input=None,
            expected_text=expected_text)

        args = ['--platform', port_name] + self.extra_args(pixel_tests)
        stdin = newstringio.StringIO(drt_input)
        stdout = newstringio.StringIO()
        stderr = newstringio.StringIO()
        options, args = mock_drt.parse_options(args)

        drt = self.make_drt(options, args, host, stdin, stdout, stderr)
        res = drt.run()

        self.assertEqual(res, 0)

        # We use the StringIO.buflist here instead of getvalue() because
        # the StringIO might be a mix of unicode/ascii and 8-bit strings.
        self.assertEqual(stdout.buflist, drt_output)
        self.assertEqual(stderr.getvalue(), '#EOF\n')
Пример #3
0
 def make_port(self, executive=None, with_tests=False, port_name=None, **kwargs):
     host = MockSystemHost()
     if executive:
         host.executive = executive
     if with_tests:
         add_unit_tests_to_mock_filesystem(host.filesystem)
         return TestPort(host, **kwargs)
     return Port(host, port_name or 'baseport', **kwargs)
Пример #4
0
 def test_main(self):
     host = MockSystemHost()
     test.add_unit_tests_to_mock_filesystem(host.filesystem)
     stdin = newstringio.StringIO()
     stdout = newstringio.StringIO()
     stderr = newstringio.StringIO()
     res = mock_drt.main(["--platform", "test"] + self.extra_args(False), host, stdin, stdout, stderr)
     self.assertEqual(res, 0)
     self.assertEqual(stdout.getvalue(), "")
     self.assertEqual(stderr.getvalue(), "")
     self.assertEqual(host.filesystem.written_files, {})
Пример #5
0
 def test_main(self):
     host = MockSystemHost()
     test.add_unit_tests_to_mock_filesystem(host.filesystem)
     stdin = newstringio.StringIO()
     stdout = newstringio.StringIO()
     stderr = newstringio.StringIO()
     res = mock_drt.main(['--platform', 'test'] + self.extra_args(False),
                         host, stdin, stdout, stderr)
     self.assertEqual(res, 0)
     self.assertEqual(stdout.getvalue(), '')
     self.assertEqual(stderr.getvalue(), '')
     self.assertEqual(host.filesystem.written_files, {})
Пример #6
0
    def __init__(self, log_executive=False, executive_throws_when_run=None, initialize_scm_by_default=True, web=None):
        MockSystemHost.__init__(self, log_executive, executive_throws_when_run)
        add_unit_tests_to_mock_filesystem(self.filesystem)
        self.web = web or MockWeb()

        self._checkout = MockCheckout()
        self._scm = None
        # FIXME: we should never initialize the SCM by default, since the real
        # object doesn't either. This has caused at least one bug (see bug 89498).
        if initialize_scm_by_default:
            self.initialize_scm()
        self.bugs = MockBugzilla()
        self.buildbot = MockBuildBot()

        # Note: We're using a real PortFactory here.  Tests which don't wish to depend
        # on the list of known ports should override this with a MockPortFactory.
        self.port_factory = PortFactory(self)

        self._watch_list = MockWatchList()
Пример #7
0
 def make_port(self, options=mock_options):
     host = MockSystemHost()
     test.add_unit_tests_to_mock_filesystem(host.filesystem)
     return mock_drt.MockDRTPort(host, port_name='mock-mac-lion', options=options)
Пример #8
0
 def make_port(self, options=mock_options):
     host = MockSystemHost()
     test.add_unit_tests_to_mock_filesystem(host.filesystem)
     return mock_drt.MockDRTPort(host,
                                 port_name='mock-mac-lion',
                                 options=options)
 def make_finder(self):
     host = MockHost(create_stub_repository_files=True)
     add_unit_tests_to_mock_filesystem(host.filesystem)
     port = TestPort(host)
     return LayoutTestFinder(port, None)