예제 #1
0
    def _verify_expectations_overrides(self, port_name):
        host = MockSystemHost()
        chromium_port = PortFactory(host).get("chromium-mac-leopard")
        chromium_base = chromium_port.path_from_chromium_base()
        port = PortFactory(host).get(port_name=port_name, options=None)

        expected_chromium_overrides = '// chromium overrides\n'
        expected_chrome_overrides = '// chrome overrides\n'
        chromium_path = host.filesystem.join(chromium_base, 'webkit', 'tools',
                                             'layout_tests',
                                             'test_expectations.txt')
        chrome_path = host.filesystem.join(chromium_base, 'webkit', 'tools',
                                           'layout_tests',
                                           'test_expectations_chrome.txt')

        host.filesystem.files[chromium_path] = expected_chromium_overrides
        host.filesystem.files[chrome_path] = None
        actual_chrome_overrides = port.test_expectations_overrides()
        self.assertEqual(expected_chromium_overrides, actual_chrome_overrides)

        host.filesystem.files[chrome_path] = expected_chrome_overrides
        actual_chrome_overrides = port.test_expectations_overrides()
        self.assertEqual(
            actual_chrome_overrides,
            expected_chromium_overrides + expected_chrome_overrides)
예제 #2
0
    def assert_port_works(self, port_name, input_name=None, platform=None):
        host = MockSystemHost()
        host.filesystem = FileSystem(
        )  # FIXME: This test should not use a real filesystem!

        # test that we got the right port
        mock_options = MockOptions(accelerated_2d_canvas=None,
                                   accelerated_video=None,
                                   builder_name='foo',
                                   child_processes=None)
        if input_name and platform:
            port = PortFactory(host).get(host,
                                         platform=platform,
                                         port_name=input_name,
                                         options=mock_options)
        else:
            port = PortFactory(host).get(host,
                                         port_name=port_name,
                                         options=mock_options)
        self.assertTrue(port._options.accelerated_2d_canvas)
        self.assertTrue(port._options.accelerated_video)
        self.assertTrue(port._options.experimental_fully_parallel)
        self.assertEqual(port._options.builder_name, 'foo - GPU')

        self.assertTrue(port.name().startswith(port_name))

        # test that it has the right directories in front of the search path.
        paths = port.baseline_search_path()
        self.assertEqual(port._webkit_baseline_path(port_name), paths[0])
        if port_name == 'chromium-gpu-linux':
            self.assertEqual(port._webkit_baseline_path('chromium-gpu-win'),
                             paths[1])
            self.assertEqual(port._webkit_baseline_path('chromium-gpu'),
                             paths[2])
        else:
            self.assertEqual(port._webkit_baseline_path('chromium-gpu'),
                             paths[1])

        # Test that we're limiting to the correct directories.
        # These two tests are picked mostly at random, but we make sure they
        # exist separately from being filtered out by the port.

        # Note that this is using a real filesystem.
        files = port.tests(None)

        path = 'fast/html/keygen.html'
        self.assertTrue(port._filesystem.exists(port.abspath_for_test(path)))
        self.assertFalse(path in files)
예제 #3
0
 def __init__(self, host, **kwargs):
     prefix = 'mock-'
     if 'port_name' in kwargs:
         kwargs['port_name'] = kwargs['port_name'][len(prefix):]
     self._host = host
     self.__delegate = PortFactory(host).get(**kwargs)
     self.__real_name = prefix + self.__delegate.name()
    def test_basic(self):
        cmd = [
            sys.executable, '-c',
            'import sys; import time; time.sleep(0.02); print "stdout"; sys.stdout.flush(); print >>sys.stderr, "stderr"'
        ]
        host = SystemHost()
        factory = PortFactory(host)
        port = factory.get()
        now = time.time()
        proc = server_process.ServerProcess(port, 'python', cmd)
        proc.write('')

        self.assertEquals(proc.poll(), None)
        self.assertFalse(proc.has_crashed())

        # check that doing a read after an expired deadline returns
        # nothing immediately.
        line = proc.read_stdout_line(now - 1)
        self.assertEquals(line, None)

        # FIXME: This part appears to be flaky. line should always be non-None.
        # FIXME: https://bugs.webkit.org/show_bug.cgi?id=88280
        line = proc.read_stdout_line(now + 1.0)
        if line:
            self.assertEquals(line.strip(), "stdout")

        line = proc.read_stderr_line(now + 1.0)
        if line:
            self.assertEquals(line.strip(), "stderr")

        proc.stop(0)
예제 #5
0
    def __init__(self,
                 log_executive=False,
                 initialize_scm_by_default=True,
                 web=None,
                 scm=None,
                 os_name=None,
                 os_version=None,
                 time_return_val=123):
        super(MockHost, self).__init__(log_executive=log_executive,
                                       os_name=os_name,
                                       os_version=os_version,
                                       time_return_val=time_return_val)

        add_unit_tests_to_mock_filesystem(self.filesystem)
        self.web = web or MockWeb()

        self._scm = scm
        # TODO(qyearsley): 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.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.builders = BuilderList(BUILDERS)
    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 = ['--run-layout-test', '--platform', port_name, '-']
        stdin = io.BytesIO(drt_input)
        stdout = io.BytesIO()
        stderr = io.BytesIO()
        options, args = mock_drt.parse_options(args)

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

        self.assertEqual(res, 0)

        self.assertEqual(stdout.getvalue(), ''.join(drt_output))
        self.assertEqual(stderr.getvalue(), '#EOF\n')
예제 #7
0
    def __init__(self,
                 log_executive=False,
                 executive_throws_when_run=None,
                 initialize_scm_by_default=True,
                 web=None,
                 scm=None,
                 os_name=None,
                 os_version=None):
        MockSystemHost.__init__(self,
                                log_executive,
                                executive_throws_when_run,
                                os_name=os_name,
                                os_version=os_version)
        add_unit_tests_to_mock_filesystem(self.filesystem)
        self.web = web or MockWeb()

        self._scm = scm
        # 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.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.builders = Builders()
    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 = ['--dump-render-tree', '--platform', port_name, '-']
        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')
예제 #9
0
    def test_basic(self):
        cmd = [
            sys.executable, '-c',
            'import sys; import time; time.sleep(0.02); print "stdout"; sys.stdout.flush(); print >>sys.stderr, "stderr"'
        ]
        host = SystemHost()
        factory = PortFactory(host)
        port = factory.get()
        now = time.time()
        proc = server_process.ServerProcess(port, 'python', cmd)
        proc.write('')

        self.assertEquals(proc.poll(), None)
        self.assertFalse(proc.has_crashed())

        # check that doing a read after an expired deadline returns
        # nothing immediately.
        line = proc.read_stdout_line(now - 1)
        self.assertEquals(line, None)

        line = proc.read_stdout_line(now + 1.0)
        self.assertEquals(line.strip(), "stdout")

        line = proc.read_stderr_line(now + 1.0)
        self.assertEquals(line.strip(), "stderr")

        proc.stop()
예제 #10
0
 def _verify_baseline_search_path_startswith(self, port_name,
                                             expected_platform_dirs):
     port = PortFactory(MockSystemHost()).get(port_name=port_name)
     actual_platform_dirs = [
         port._filesystem.basename(path)
         for path in port.baseline_search_path()
     ]
     self.assertEqual(expected_platform_dirs,
                      actual_platform_dirs[0:len(expected_platform_dirs)])
예제 #11
0
    def __init__(self, options, args, host, stdin, stdout, stderr):
        self._options = options
        self._args = args
        self._host = host
        self._stdout = stdout
        self._stdin = stdin
        self._stderr = stderr

        port_name = None
        if options.platform:
            port_name = options.platform
        self._port = PortFactory(host).get(port_name=port_name, options=options)
        self._driver = self._port.create_driver(0)
 def test_pixeltest__fails(self):
     host = MockSystemHost()
     url = '#URL:file://'
     url = url + '%s/failures/expected/image_checksum.html' % PortFactory(host).get('test').layout_tests_dir()
     self.assertTest('failures/expected/image_checksum.html', pixel_tests=True,
         expected_checksum='image_checksum',
         drt_output=[url + '\n',
                     '#MD5:image_checksum-checksum\n',
                     'image_checksum-txt',
                     '\n',
                     '#EOF\n'],
         host=host)
     self.assertEqual(host.filesystem.written_files,
         {'/tmp/png_result0.png': 'image_checksum\x8a-pngtEXtchecksum\x00image_checksum-checksum'})
예제 #13
0
    def __init__(self):
        SystemHost.__init__(self)
        self.web = web.Web()

        self._git = None

        # Everything below this line is WebKit-specific and belongs on a higher-level object.
        self.buildbot = BuildBot()

        # FIXME: Unfortunately Port objects are currently the central-dispatch objects of the NRWT world.
        # In order to instantiate a port correctly, we have to pass it at least an executive, user, git, and filesystem
        # so for now we just pass along the whole Host object.
        # FIXME: PortFactory doesn't belong on this Host object if Port is going to have a Host (circular dependency).
        self.port_factory = PortFactory(self)

        self.builders = BuilderList.load_default_builder_list(self.filesystem)
예제 #14
0
    def __init__(self,
                 log_executive=False,
                 web=None,
                 git=None,
                 os_name=None,
                 os_version=None,
                 time_return_val=123):
        super(MockHost, self).__init__(log_executive=log_executive,
                                       os_name=os_name,
                                       os_version=os_version,
                                       time_return_val=time_return_val)

        add_unit_tests_to_mock_filesystem(self.filesystem)
        self._add_base_manifest_to_mock_filesystem(self.filesystem)
        self.web = web or MockWeb()
        self._git = git

        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.builders = BuilderList({
            'Fake Test Win10': {
                'port_name': 'win-win10',
                'specifiers': ['Win10', 'Release']
            },
            'Fake Test Linux': {
                'port_name': 'linux-trusty',
                'specifiers': ['Trusty', 'Release']
            },
            'Fake Test Linux (dbg)': {
                'port_name': 'linux-trusty',
                'specifiers': ['Trusty', 'Debug']
            },
            'Fake Test Mac10.12': {
                'port_name': 'mac-mac10.12',
                'specifiers': ['Mac10.12', 'Release']
            },
            'Fake Test Linux Try Bot': {
                'port_name': 'linux-trusty',
                'specifiers': ['Trusty', 'Release'],
                'is_try_builder': True,
            },
        })
예제 #15
0
 def __init__(self):
     self.bugs = bugzilla.Bugzilla()
     self.buildbot = buildbot.BuildBot()
     self.executive = executive.Executive()
     self.web = web.Web()
     self._irc = None
     self.filesystem = filesystem.FileSystem()
     self.workspace = workspace.Workspace(self.filesystem, self.executive)
     self._port = None
     self.user = user.User()
     self._scm = None
     self._checkout = None
     self.status_server = statusserver.StatusServer()
     # FIXME: Unfortunately Port objects are currently the central-dispatch objects of the NRWT world.
     # In order to instantiate a port correctly, we have to pass it at least an executive, user, scm, and filesystem
     # so for now we just pass along the whole Host object.
     self.port_factory = PortFactory(self)
     self.platform = platforminfo.PlatformInfo()
예제 #16
0
    def __init__(self, log_executive=False, executive_throws_when_run=None, initialize_scm_by_default=True):
        MockSystemHost.__init__(self, log_executive, executive_throws_when_run)
        add_unit_tests_to_mock_filesystem(self.filesystem)
        self.web = 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()
        self._chromium_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()
예제 #17
0
    def __init__(self, log_executive=False, executive_throws_when_run=None):
        MockSystemHost.__init__(self, log_executive, executive_throws_when_run)
        add_unit_tests_to_mock_filesystem(self.filesystem)
        self.web = MockWeb()

        self._checkout = MockCheckout()
        self._scm = MockSCM(filesystem=self.filesystem,
                            executive=self.executive)
        # Various pieces of code (wrongly) call filesystem.chdir(checkout_root).
        # Making the checkout_root exist in the mock filesystem makes that chdir not raise.
        self.filesystem.maybe_make_directory(self._scm.checkout_root)

        self.bugs = MockBugzilla()
        self.buildbot = MockBuildBot()
        self._chromium_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()
예제 #18
0
 def test_pixeltest__fails(self):
     host = MockSystemHost()
     url = '#URL:file://'
     if sys.platform == 'win32':
         host = MockSystemHost(os_name='win', os_version='xp')
         url = '#URL:file:///'
     url = url + '%s/failures/expected/checksum.html' % PortFactory(
         host).get('test').layout_tests_dir()
     self.assertTest('failures/expected/checksum.html',
                     pixel_tests=True,
                     expected_checksum='wrong-checksum',
                     drt_output=[
                         url + '\n', '#MD5:checksum-checksum\n',
                         'checksum-txt', '\n', '#EOF\n'
                     ],
                     host=host)
     self.assertEquals(
         host.filesystem.written_files, {
             '/tmp/png_result0.png':
             'checksum\x8a-pngtEXtchecksum\x00checksum-checksum'
         })
예제 #19
0
파일: host_mock.py 프로젝트: IncoCura/qt5
    def __init__(self,
                 log_executive=False,
                 web=None,
                 git=None,
                 os_name=None,
                 os_version=None,
                 time_return_val=123):
        super(MockHost, self).__init__(log_executive=log_executive,
                                       os_name=os_name,
                                       os_version=os_version,
                                       time_return_val=time_return_val)

        add_unit_tests_to_mock_filesystem(self.filesystem)
        self._add_base_manifest_to_mock_filesystem(self.filesystem)
        self.web = web or MockWeb()
        self._git = git

        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.builders = BuilderList(BUILDERS)
예제 #20
0
 def __init__(self, host, port_name, **kwargs):
     self.__delegate = PortFactory(host).get(port_name.replace('mock-', ''), **kwargs)
예제 #21
0
 def _assert_baseline_path(self, port_name, baseline_path):
     port = PortFactory(MockSystemHost()).get(port_name)
     self.assertEquals(port.name(), port_name)
     self.assertEquals(port.baseline_path(),
                       port._webkit_baseline_path(baseline_path))
예제 #22
0
 def test_paths(port_name):
     return chromium_gpu._default_tests_paths(
         PortFactory(MockSystemHost()).get(port_name))
예제 #23
0
 def test_paths(port_name):
     return PortFactory(host).get(port_name).tests([])
예제 #24
0
 def _verify_baseline_path(self, expected_path, port_name):
     port = PortFactory(MockSystemHost()).get(port_name=port_name)
     path = port.baseline_search_path()[0]
     self.assertEqual(expected_path, port._filesystem.basename(path))
예제 #25
0
 def __init__(self, host, port_name, **kwargs):
     self.__delegate = PortFactory(host).get(port_name.replace('mock-', ''),
                                             **kwargs)
     self.__delegate_driver_class = self.__delegate._driver_class
     self.__delegate._driver_class = types.MethodType(
         self._driver_class, self.__delegate)
예제 #26
0
 def test_graphics_type(self):
     port = PortFactory(MockSystemHost()).get('chromium-gpu-mac')
     self.assertEquals('gpu', port.graphics_type())