Пример #1
0
 def _assert_skipped_path(self, search_paths, os_name, use_webkit2=False, qt_version='4.8'):
     host = MockSystemHost(os_name=os_name)
     host.executive = MockExecutive2(self._qt_version(qt_version))
     port_name = 'qt-' + os_name
     port = self.make_port(host=host, qt_version=qt_version, port_name=port_name,
                           options=MockOptions(webkit_test_runner=use_webkit2, platform='qt'))
     self.assertEquals(port._skipped_file_search_paths(), search_paths)
Пример #2
0
    def test_format_docstrings(self):
        host = MockSystemHost()
        host.stdin = StringIO.StringIO(
            '''
def f():
    """
    triple-quoted docstring
    with multiple lines

    """
    x = """
    this is a regular multi-line string, not a docstring
    """
    return x
'''
        )
        main(host, ["-"])
        self.assertMultiLineEqual(
            host.stdout.getvalue(),
            '''
def f():
    """triple-quoted docstring
    with multiple lines
    """
    x = """
    this is a regular multi-line string, not a docstring
    """
    return x
''',
        )
Пример #3
0
 def make_port(self, executive=None, with_tests=False, **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, **kwargs)
Пример #4
0
 def _assert_search_path(self, search_paths, sys_platform, use_webkit2=False, qt_version='4.8'):
     # FIXME: Port constructors should not "parse" the port name, but
     # rather be passed components (directly or via setters).  Once
     # we fix that, this method will need a re-write.
     host = MockSystemHost()
     host.executive = MockExecutive2(self._qt_version(qt_version))
     port = QtPort(host, sys_platform=sys_platform, options=MockOptions(webkit_test_runner=use_webkit2, platform='qt'))
     absolute_search_paths = map(port._webkit_baseline_path, search_paths)
     self.assertEquals(port.baseline_search_path(), absolute_search_paths)
 def assert_version_properties(self, port_name, os_version, expected_name,
                               expected_version,
                               driver_file_output=None):
     host = MockSystemHost(os_name=self.os_name, os_version=(os_version or self.os_version))
     host.filesystem.isfile = lambda x: 'content_shell' in x
     if driver_file_output:
         host.executive = executive_mock.MockExecutive2(driver_file_output)
     port = self.make_port(host=host, port_name=port_name, os_version=os_version)
     self.assertEqual(port.name(), expected_name)
     self.assertEqual(port.version(), expected_version)
Пример #6
0
 def _assert_expectations_files(self, search_paths, os_name, use_webkit2=False, qt_version='4.8'):
     # FIXME: Port constructors should not "parse" the port name, but
     # rather be passed components (directly or via setters).  Once
     # we fix that, this method will need a re-write.
     host = MockSystemHost(os_name=os_name)
     host.executive = MockExecutive2(self._qt_version(qt_version))
     port_name = 'qt-' + os_name
     port = self.make_port(host=host, qt_version=qt_version, port_name=port_name,
                           options=MockOptions(webkit_test_runner=use_webkit2, platform='qt'))
     self.assertEquals(port.expectations_files(), search_paths)
Пример #7
0
    def test_wdiff_text_fails(self):
        host = MockSystemHost(os_name=self.os_name, os_version=self.os_version)
        host.executive = MockExecutive(should_throw=True)
        port = self.make_port(host=host)
        port._executive = host.executive  # AndroidPortTest.make_port sets its own executive, so reset that as well.

        # This should raise a ScriptError that gets caught and turned into the
        # error text, and also mark wdiff as not available.
        self.make_wdiff_available(port)
        self.assertTrue(port.wdiff_available())
        diff_txt = port.wdiff_text("/tmp/foo.html", "/tmp/bar.html")
        self.assertEqual(diff_txt, port._wdiff_error_html)
        self.assertFalse(port.wdiff_available())
Пример #8
0
    def test_test_files(self):
        host = MockSystemHost()
        files = {
            "/mock-checkout/LayoutTests/canvas/philip/test.html": "",
            "/mock-checkout/LayoutTests/fast/canvas/test.html": "",
            "/mock-checkout/LayoutTests/fast/html/test.html": "",
            "/mock-checkout/LayoutTests/foo/bar.html": "",
        }
        host.filesystem = MockFileSystem(files)

        def test_paths(port_name):
            return PortFactory(host).get(port_name).tests([])

        self.assertEqual(test_paths("chromium-gpu-linux"), set(["canvas/philip/test.html", "fast/canvas/test.html"]))
Пример #9
0
 def _assert_search_path(self, search_paths, os_name, use_webkit2=False, qt_version="4.8"):
     # FIXME: Port constructors should not "parse" the port name, but
     # rather be passed components (directly or via setters).  Once
     # we fix that, this method will need a re-write.
     host = MockSystemHost(os_name=os_name)
     host.executive = MockExecutive2(self._qt_version(qt_version))
     port_name = "qt-" + os_name
     port = self.make_port(
         host=host,
         qt_version=qt_version,
         port_name=port_name,
         options=MockOptions(webkit_test_runner=use_webkit2, platform="qt"),
     )
     absolute_search_paths = map(port._webkit_baseline_path, search_paths)
     self.assertEqual(port.baseline_search_path(), absolute_search_paths)
    def __init__(self, log_executive=False, executive_throws_when_run=None, initialize_scm_by_default=True, web=None, scm=None):
        MockSystemHost.__init__(self, log_executive, executive_throws_when_run)
        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)
Пример #11
0
    def assert_architecture(self, port_name=None, file_output=None, expected_architecture=None):
        host = MockSystemHost()
        host.filesystem.exists = lambda x: 'content_shell' in x
        if file_output:
            host.executive = executive_mock.MockExecutive2(file_output)

        port = self.make_port(host, port_name=port_name)
        self.assertEqual(port.architecture(), expected_architecture)
        if expected_architecture == 'x86':
            self.assertTrue(port.baseline_path().endswith('chromium-linux-x86'))
            self.assertTrue(port.baseline_search_path()[0].endswith('chromium-linux-x86'))
            self.assertTrue(port.baseline_search_path()[1].endswith('chromium-linux'))
        else:
            self.assertTrue(port.baseline_path().endswith('chromium-linux'))
            self.assertTrue(port.baseline_search_path()[0].endswith('chromium-linux'))
Пример #12
0
    def test_determine_architecture_fails(self):
        # Test that we default to 'x86' if the driver doesn't exist.
        port = self.make_port()
        self.assertEqual(port.architecture(), 'x86_64')

        # Test that we default to 'x86' on an unknown architecture.
        host = MockSystemHost()
        host.filesystem.exists = lambda x: True
        host.executive = executive_mock.MockExecutive2('win32')
        port = self.make_port(host=host)
        self.assertEqual(port.architecture(), 'x86_64')

        # Test that we raise errors if something weird happens.
        host.executive = executive_mock.MockExecutive2(exception=AssertionError)
        self.assertRaises(AssertionError, chromium_linux.ChromiumLinuxPort, host, self.port_name)
Пример #13
0
    def test_test_files(self):
        host = MockSystemHost()
        files = {
            '/mock-checkout/LayoutTests/canvas/philip/test.html': '',
            '/mock-checkout/LayoutTests/fast/canvas/test.html': '',
            '/mock-checkout/LayoutTests/fast/html/test.html': '',
            '/mock-checkout/LayoutTests/media/test.html': '',
            '/mock-checkout/LayoutTests/foo/bar.html': '',
        }
        host.filesystem = MockFileSystem(files)

        def test_paths(port_name):
            return PortFactory(host).get(port_name).tests([])

        self.assertEqual(test_paths('chromium-gpu-linux'), set(['canvas/philip/test.html', 'fast/canvas/test.html', 'media/test.html']))
        self.assertEqual(test_paths('chromium-gpu-mac-leopard'), set(['canvas/philip/test.html', 'fast/canvas/test.html']))
Пример #14
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()
Пример #15
0
    def test_helper_fails_to_stop(self):
        host = MockSystemHost(MockExecutive())
        host.executive._proc = MockProcess()

        def bad_waiter():
            raise IOError('failed to wait')
        host.executive._proc.wait = bad_waiter

        port = self.make_port(host)
        with OutputCapture():
            port.start_helper()
            port.stop_helper()
Пример #16
0
    def test_format_docstrings_indentation(self):
        host = MockSystemHost()
        host.stdin = StringIO.StringIO(
            '''
def f():
    """This is a docstring
       With extra indentation on this line.

     """
'''
        )
        main(host, ["-"])
        self.assertMultiLineEqual(
            host.stdout.getvalue(),
            '''
def f():
    """This is a docstring
       With extra indentation on this line.
    """
''',
        )
Пример #17
0
 def test_test_expectations(self):
     # Check that we read the expectations file
     host = MockSystemHost()
     host.filesystem.write_text_file(
         '/mock-checkout/LayoutTests/platform/testwebkitport/TestExpectations',
         'BUG_TESTEXPECTATIONS SKIP : fast/html/article-element.html = FAIL\n'
     )
     port = TestWebKitPort(host=host)
     self.assertEqual(
         ''.join(port.expectations_dict().values()),
         'BUG_TESTEXPECTATIONS SKIP : fast/html/article-element.html = FAIL\n'
     )
Пример #18
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, {})
Пример #19
0
    def test_get_timestamp_from_logs_darwin(self):
        if not SystemHost().platform.is_mac():
            return

        crash_report = make_mock_crash_report_darwin('DumpRenderTree', 28528)
        crash_logs = CrashLogs(MockSystemHost(), CrashLogsTest.DARWIN_MOCK_CRASH_DIRECTORY)
        crash_timestamp = crash_logs.get_timestamp_from_log(crash_report)
        self.assertIn('2011-12-07 13:27:34.816', str(crash_timestamp))

        crash_report = crash_report.replace("Date/Time", "")
        crash_timestamp = crash_logs.get_timestamp_from_log(crash_report)
        self.assertIsNone(crash_timestamp)
Пример #20
0
 def test_main(self):
     host = MockSystemHost()
     test.add_unit_tests_to_mock_filesystem(host.filesystem)
     stdin = io.BytesIO()
     stdout = io.BytesIO()
     stderr = io.BytesIO()
     res = mock_drt.main(['--run-layout-test', '--platform', 'test', '-'],
                         host, stdin, stdout, stderr)
     self.assertEqual(res, 0)
     self.assertEqual(stdout.getvalue(), '#READY\n')
     self.assertEqual(stderr.getvalue(), '')
     self.assertEqual(host.filesystem.written_files, {})
Пример #21
0
    def test_helper_starts(self):
        host = MockSystemHost(MockExecutive())
        port = self.make_port(host)
        oc = OutputCapture()
        oc.capture_output()
        host.executive._proc = MockProcess('ready\n')
        port.start_helper()
        port.stop_helper()
        oc.restore_output()

        # make sure trying to stop the helper twice is safe.
        port.stop_helper()
Пример #22
0
 def get_shards(self,
                num_workers,
                fully_parallel,
                run_singly,
                test_list=None,
                max_locked_shards=1):
     port = TestPort(MockSystemHost())
     self.sharder = Sharder(port.split_test, max_locked_shards)
     test_list = test_list or self.test_list
     return self.sharder.shard_tests(
         [self.get_test_input(test) for test in test_list], num_workers,
         fully_parallel, run_singly)
Пример #23
0
    def test_two_drivers(self):
        mock_adb = MockAndroidDebugBridge(2)
        mock_executive = MockExecutive2(run_command_fn=mock_adb.run_command)

        port = android.AndroidPort(MockSystemHost(executive=mock_executive), 'android')
        driver0 = android.ChromiumAndroidDriver(port, worker_number=0, pixel_tests=True,
            driver_details=android.ContentShellDriverDetails(), android_devices=port._devices)
        driver1 = android.ChromiumAndroidDriver(port, worker_number=1, pixel_tests=True,
            driver_details=android.ContentShellDriverDetails(), android_devices=port._devices)

        self.assertEqual(['adb', '-s', '123456789ABCDEF0', 'shell'], driver0.cmd_line(True, []))
        self.assertEqual(['adb', '-s', '123456789ABCDEF1', 'shell'], driver1.cmd_line(True, ['anything']))
Пример #24
0
 def __init__(self,
              port_name=None,
              expectations_file=None,
              skips_file=None,
              host=None,
              config=None,
              **kwargs):
     port_name = port_name or TestWebKitPort.port_name
     host = host or MockSystemHost()
     super(TestWebKitPort, self).__init__(host,
                                          port_name=port_name,
                                          **kwargs)
Пример #25
0
    def mock_host_for_simctl():
        simctl_json = json.loads(
            simctl_json_output
        )  # Construct enough of a filesystem for all our simctl code to work.
        filesystem_map = {}
        runtime_name_to_id = {}

        # Runtime mapping
        for runtime_group in simctl_json['runtimes']:
            runtime_name_to_id[
                runtime_group['name']] = runtime_group['identifier']

        # Device type mapping
        device_type_name_to_id = {}
        for device_type in simctl_json['devicetypes']:
            device_type_name_to_id[
                device_type['name']] = device_type['identifier']

        for runtime, device_groups in simctl_json['devices'].iteritems():
            for device in device_groups:
                file_path = '/Users/mock' + SimulatedDeviceManager.simulator_device_path[
                    1:] + '/' + device['udid'] + '/device.plist'
                # We're taking advantage the fact that the names of the devices match the names of their runtimes in the
                # provided JSON ouput. This is not generally true, which is why we're only using this fact to build up
                # a mock filesystem that is used by the actual simctl parsing code.
                filesystem_map[
                    file_path] = """<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist SYSTEM "{}">
<plist version="1.0">
<dict>
    <key>UDID</key>
    <string>{}</string>
    <key>deviceType</key>
    <string>{}</string>
    <key>name</key>
    <string>{}</string>
    <key>runtime</key>
    <string>{}</string>
    <key>state</key>
    <integer>{}</integer>
</dict>
</plist>""".format(
                        file_path, device['udid'],
                        device_type_name_to_id[device['name']], device['name'],
                        runtime_name_to_id[runtime],
                        SimulatedDevice.NAME_FOR_STATE.index(
                            device['state'].upper()))

        return MockSystemHost(
            executive=MockExecutive2(output=simctl_json_output),
            filesystem=MockFileSystem(files=filesystem_map),
        )
Пример #26
0
 def setUp(self):
     host = MockSystemHost()
     options = MockOptions(configuration='Release',
                           additional_drt_flag=['--test-shell'])
     config = MockConfig(filesystem=host.filesystem,
                         default_configuration='Release')
     self.port = chromium_mac.ChromiumMacPort(host,
                                              'chromium-mac-snowleopard',
                                              options=options,
                                              config=config)
     self.driver = chromium.ChromiumDriver(self.port,
                                           worker_number=0,
                                           pixel_tests=True)
Пример #27
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)
Пример #28
0
 def make_port(self, options=mock_options):
     host = MockSystemHost()
     test.add_unit_tests_to_mock_filesystem(host.filesystem)
     if sys.platform == 'win32':
         # We use this because the 'win' port doesn't work yet.
         host.platform.os_name = 'win'
         host.platform.os_version = 'xp'
         return mock_drt.MockDRTPort(host,
                                     port_name='mock-chromium-win',
                                     options=options)
     return mock_drt.MockDRTPort(host,
                                 port_name='mock-mac',
                                 options=options)
Пример #29
0
    def setUp(self):
        self._mock_adb = MockAndroidDebugBridge(1)
        self._mock_executive = MockExecutive2(run_command_fn=self._mock_adb.run_command)

        self._port = android.AndroidPort(MockSystemHost(executive=self._mock_executive), 'android')
        self._driver = android.ChromiumAndroidDriver(self._port, worker_number=0,
            pixel_tests=True, driver_details=android.ContentShellDriverDetails(), android_devices=self._port._devices)

        self._errors = []
        self._driver._log_error = lambda msg: self._errors.append(msg)

        self._warnings = []
        self._driver._log_warning = lambda msg: self._warnings.append(msg)
Пример #30
0
    def make_driver(self, worker_number=0, xorg_running=False, executive=None):
        port = Port(host=MockSystemHost(log_executive=True,
                                        executive=executive),
                    config=MockConfig())
        port._server_process_constructor = MockServerProcess
        if xorg_running:
            port._executive._running_pids['Xorg'] = 108

        driver = XvfbDriver(port,
                            worker_number=worker_number,
                            pixel_tests=True)
        driver._startup_delay_secs = 0
        return driver
    def assert_architecture(self,
                            port_name=None,
                            file_output=None,
                            expected_architecture=None):
        host = MockSystemHost()
        host.filesystem.exists = lambda x: 'DumpRenderTree' in x
        if file_output:
            host.executive = executive_mock.MockExecutive2(file_output)

        port = self.make_port(host, port_name=port_name)
        self.assertEqual(port.architecture(), expected_architecture)
        if expected_architecture == 'x86':
            self.assertTrue(
                port.baseline_path().endswith('chromium-linux-x86'))
            self.assertTrue(
                port.baseline_search_path()[0].endswith('chromium-linux-x86'))
            self.assertTrue(
                port.baseline_search_path()[1].endswith('chromium-linux'))
        else:
            self.assertTrue(port.baseline_path().endswith('chromium-linux'))
            self.assertTrue(
                port.baseline_search_path()[0].endswith('chromium-linux'))
Пример #32
0
    def test_default_profiler_output(self):
        host = MockSystemHost()
        self.assertFalse(host.filesystem.exists("/tmp/output"))

        # Default mocks are Mac, so iprofile should be default.
        profiler = ProfilerFactory.create_profiler(host, '/bin/executable', '/tmp/output')
        self.assertTrue(host.filesystem.exists("/tmp/output"))
        self.assertEqual(profiler._output_path, "/tmp/output/test.dtps")

        # Linux defaults to perf.
        host.platform.os_name = 'linux'
        profiler = ProfilerFactory.create_profiler(host, '/bin/executable', '/tmp/output')
        self.assertEqual(profiler._output_path, "/tmp/output/test.data")
Пример #33
0
 def __init__(self,
              port_name=None,
              symbols_string=None,
              expectations_file=None,
              skips_file=None,
              host=None,
              config=None,
              **kwargs):
     port_name = port_name or TestWebKitPort.port_name
     self.symbols_string = symbols_string  # Passing "" disables all staticly-detectable features.
     host = host or MockSystemHost()
     super(TestWebKitPort, self).__init__(host,
                                          port_name=port_name,
                                          **kwargs)
Пример #34
0
    def test_stop(self):
        port = Port(MockSystemHost(log_executive=True), 'xvfbdrivertestport', options=MockOptions(configuration='Release'))
        port._executive.kill_process = lambda x: _log.info("MOCK kill_process pid: " + str(x))
        driver = XvfbDriver(port, worker_number=0, pixel_tests=True)

        class FakeXvfbProcess(object):
            pid = 1234

        driver._xvfb_process = FakeXvfbProcess()

        expected_logs = "MOCK kill_process pid: 1234\n"
        OutputCapture().assert_outputs(self, driver.stop, [], expected_logs=expected_logs)

        self.assertIsNone(driver._xvfb_process)
Пример #35
0
    def make_driver(self, worker_number=0, xorg_running=False, executive=None):
        port = Port(MockSystemHost(log_executive=True, executive=executive),
                    'xvfbdrivertestport',
                    options=MockOptions(configuration='Release'))
        port._config.build_directory = lambda configuration: "/mock-build"
        port._server_process_constructor = MockServerProcess
        if xorg_running:
            port._executive._running_pids['Xorg'] = 108

        driver = XvfbDriver(port,
                            worker_number=worker_number,
                            pixel_tests=True)
        driver._startup_delay_secs = 0
        return driver
 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'})
    def test_two_drivers(self):
        mock_run_command = MockRunCommand()
        mock_run_command.mock_two_devices()
        port = chromium_android.ChromiumAndroidPort(
                MockSystemHost(executive=MockExecutive2(run_command_fn=mock_run_command.mock_run_command_fn)),
                'chromium-android')
        driver0 = chromium_android.ChromiumAndroidDriver(port, worker_number=0, pixel_tests=True)
        driver1 = chromium_android.ChromiumAndroidDriver(port, worker_number=1, pixel_tests=True)

        cmd_line0 = driver0.cmd_line(True, ['anything'])
        self.assertEquals(['adb', '-s', mock_run_command._mock_devices[0], 'shell'], cmd_line0)

        cmd_line1 = driver1.cmd_line(True, ['anything'])
        self.assertEquals(['adb', '-s', mock_run_command._mock_devices[1], 'shell'], cmd_line1)
Пример #38
0
    def make_driver(self):
        port = Port(MockSystemHost(log_executive=True),
                    'westondrivertestport',
                    options=MockOptions(configuration='Release'))
        port._config.build_directory = lambda configuration: "/mock_build"
        port._test_runner_process_constructor = MockServerProcess

        driver = WestonDriver(port, worker_number=0, pixel_tests=True)
        driver._startup_delay_secs = 0
        driver._expected_xvfbdisplay = 23
        driver._xvfbdriver = WestonXvfbDriverDisplayTest(
            driver._expected_xvfbdisplay)
        driver._environment = port.setup_environ_for_server(port.driver_name())
        return driver
Пример #39
0
    def test_test_files(self):
        host = MockSystemHost()
        files = {
            '/mock-checkout/LayoutTests/canvas/philip/test.html': '',
            '/mock-checkout/LayoutTests/fast/canvas/test.html': '',
            '/mock-checkout/LayoutTests/fast/html/test.html': '',
            '/mock-checkout/LayoutTests/media/test.html': '',
            '/mock-checkout/LayoutTests/foo/bar.html': '',
        }
        host.filesystem = MockFileSystem(files)

        def test_paths(port_name):
            return PortFactory(host).get(port_name).tests([])

        self.assertEqual(
            test_paths('chromium-gpu-linux'),
            set([
                'canvas/philip/test.html', 'fast/canvas/test.html',
                'media/test.html'
            ]))
        self.assertEqual(
            test_paths('chromium-gpu-mac-leopard'),
            set(['canvas/philip/test.html', 'fast/canvas/test.html']))
Пример #40
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()
Пример #41
0
    def test_check(self):
        errors = []

        def mock_handle_style_error(line_number, category, confidence, message):
            error = (line_number, category, confidence, message)
            errors.append(error)

        file_path = ''

        fs = MockFileSystem()

        scm = MockSCMDetector('svn')
        checker = PNGChecker(file_path, mock_handle_style_error, scm, MockSystemHost(filesystem=fs))
        checker.check()
        self.assertEquals(len(errors), 1)
        self.assertEquals(errors[0],
                          (0, 'image/png', 5, 'Set the svn:mime-type property (svn propset svn:mime-type image/png ).'))

        files = {'/Users/mock/.subversion/config': 'enable-auto-props = yes\n*.png = svn:mime-type=image/png'}
        fs = MockFileSystem(files)
        scm = MockSCMDetector('git')
        errors = []
        checker = PNGChecker("config", mock_handle_style_error, scm, MockSystemHost(os_name='linux', filesystem=fs))
        checker.check()
        self.assertEquals(len(errors), 0)

        files = {'/Users/mock/.subversion/config': '#enable-auto-props = yes'}
        fs = MockFileSystem(files)
        scm = MockSCMDetector('git')
        errors = []
        checker = PNGChecker("config", mock_handle_style_error, scm, MockSystemHost(os_name='linux', filesystem=fs))
        checker.check()
        self.assertEquals(len(errors), 1)

        files = {'/Users/mock/.subversion/config': 'enable-auto-props = yes\n#enable-auto-props = yes\n*.png = svn:mime-type=image/png'}
        fs = MockFileSystem(files)
        scm = MockSCMDetector('git')
        errors = []
        checker = PNGChecker("config", mock_handle_style_error, scm, MockSystemHost(os_name='linux', filesystem=fs))
        checker.check()
        self.assertEquals(len(errors), 0)

        files = {'/Users/mock/.subversion/config': '#enable-auto-props = yes\nenable-auto-props = yes\n*.png = svn:mime-type=image/png'}
        fs = MockFileSystem(files)
        scm = MockSCMDetector('git')
        errors = []
        checker = PNGChecker("config", mock_handle_style_error, scm, MockSystemHost(os_name='linux', filesystem=fs))
        checker.check()
        self.assertEquals(len(errors), 0)

        files = {'/Users/mock/.subversion/config': 'enable-auto-props = no'}
        fs = MockFileSystem(files)
        scm = MockSCMDetector('git')
        errors = []
        checker = PNGChecker("config", mock_handle_style_error, scm, MockSystemHost(os_name='linux', filesystem=fs))
        checker.check()
        self.assertEquals(len(errors), 1)
Пример #42
0
    def create_crash_logs_darwin(self):
        if not SystemHost().platform.is_mac():
            return

        self.older_mock_crash_report = make_mock_crash_report_darwin(
            'DumpRenderTree', 28528)
        self.sandbox_crash_report = make_mock_sandbox_report_darwin(
            'DumpRenderTree', 28530)
        self.mock_crash_report = make_mock_crash_report_darwin(
            'DumpRenderTree', 28530)
        self.newer_mock_crash_report = make_mock_crash_report_darwin(
            'DumpRenderTree', 28529)
        self.other_process_mock_crash_report = make_mock_crash_report_darwin(
            'FooProcess', 28527)
        self.misformatted_mock_crash_report = 'Junk that should not appear in a crash report' + make_mock_crash_report_darwin(
            'DumpRenderTree', 28526)[200:]
        self.files = {}
        self.files[
            '/Users/mock/Library/Logs/DiagnosticReports/DumpRenderTree_2011-06-13-150715_quadzen.crash'] = self.older_mock_crash_report
        self.files[
            '/Users/mock/Library/Logs/DiagnosticReports/DumpRenderTree_2011-06-13-150716_quadzen_1.crash'] = self.older_mock_crash_report
        self.files[
            '/Users/mock/Library/Logs/DiagnosticReports/DumpRenderTree_2011-06-13-150717_quadzen_2.crash'] = self.older_mock_crash_report
        self.files[
            '/Users/mock/Library/Logs/DiagnosticReports/DumpRenderTree_2011-06-13-150718_quadzen.crash'] = self.sandbox_crash_report
        self.files[
            '/Users/mock/Library/Logs/DiagnosticReports/DumpRenderTree_2011-06-13-150719_quadzen.crash'] = self.mock_crash_report
        self.files[
            '/Users/mock/Library/Logs/DiagnosticReports/DumpRenderTree_2011-06-13-150720_quadzen.crash'] = self.newer_mock_crash_report
        self.files[
            '/Users/mock/Library/Logs/DiagnosticReports/DumpRenderTree_2011-06-13-150721_quadzen.crash'] = None
        self.files[
            '/Users/mock/Library/Logs/DiagnosticReports/DumpRenderTree_2011-06-13-150722_quadzen.crash'] = self.other_process_mock_crash_report
        self.files[
            '/Users/mock/Library/Logs/DiagnosticReports/DumpRenderTree_2011-06-13-150723_quadzen.crash'] = self.misformatted_mock_crash_report

        self.files = {
            key: string_utils.encode(value)
            for key, value in self.files.items()
        }

        self.filesystem = MockFileSystem(self.files)
        crash_logs = CrashLogs(MockSystemHost(filesystem=self.filesystem),
                               CrashLogsTest.DARWIN_MOCK_CRASH_DIRECTORY)
        logs = self.filesystem.files_under(
            '/Users/mock/Library/Logs/DiagnosticReports/')
        for path in reversed(sorted(logs)):
            self.assertTrue(path in self.files.keys())
        return crash_logs
Пример #43
0
    def make_driver(self, worker_number=0, xorg_running=False, executive=None):
        port = Port(MockSystemHost(log_executive=True, executive=executive), 'xvfbdrivertestport', options=MockOptions(configuration='Release'))
        port._config.build_directory = lambda configuration: "/mock-build"
        port._test_runner_process_constructor = MockServerProcess
        if xorg_running:
            port._executive._running_pids['Xorg'] = 108

        driver = XvfbDriver(port, worker_number=worker_number, pixel_tests=True)
        driver._startup_delay_secs = 0
        driver._xvfb_screen_depth = lambda: '24'
        driver._xvfb_pipe = lambda: (3, 4)
        driver._xvfb_read_display_id = lambda x: 1
        driver._xvfb_close_pipe = lambda p: None
        driver._port_server_environment = port.setup_environ_for_server(port.driver_name())
        return driver
Пример #44
0
 def make_port(self,
               host=None,
               port_name=None,
               options=None,
               os_name=None,
               os_version=None,
               **kwargs):
     host = host or MockSystemHost(os_name=(os_name or self.os_name),
                                   os_version=(os_version
                                               or self.os_version))
     options = options or optparse.Values({'configuration': 'Release'})
     port_name = port_name or self.port_name
     port_name = self.port_maker.determine_full_port_name(
         host, options, port_name)
     return self.port_maker(host, port_name, options=options, **kwargs)
Пример #45
0
    def test_stop(self):
        port = Port(MockSystemHost(log_executive=True), 'xvfbdrivertestport', options=MockOptions(configuration='Release'))
        port._executive.kill_process = lambda x: _log.info("MOCK kill_process pid: " + str(x))
        driver = XvfbDriver(port, worker_number=0, pixel_tests=True)

        class FakeXvfbProcess(object):
            pid = 1234

        driver._xvfb_process = FakeXvfbProcess()

        with OutputCapture(level=logging.INFO) as captured:
            driver.stop()
        self.assertEqual(captured.root.log.getvalue(), "MOCK kill_process pid: 1234\n")

        self.assertIsNone(driver._xvfb_process)
Пример #46
0
    def test_find_log_darwin(self):
        if not SystemHost().platform.is_mac():
            return

        older_mock_crash_report = make_mock_crash_report_darwin(
            'DumpRenderTree', 28528)
        mock_crash_report = make_mock_crash_report_darwin(
            'DumpRenderTree', 28530)
        newer_mock_crash_report = make_mock_crash_report_darwin(
            'DumpRenderTree', 28529)
        other_process_mock_crash_report = make_mock_crash_report_darwin(
            'FooProcess', 28527)
        misformatted_mock_crash_report = 'Junk that should not appear in a crash report' + make_mock_crash_report_darwin(
            'DumpRenderTree', 28526)[200:]
        files = {}
        files[
            '/Users/mock/Library/Logs/DiagnosticReports/DumpRenderTree_2011-06-13-150718_quadzen.crash'] = older_mock_crash_report
        files[
            '/Users/mock/Library/Logs/DiagnosticReports/DumpRenderTree_2011-06-13-150719_quadzen.crash'] = mock_crash_report
        files[
            '/Users/mock/Library/Logs/DiagnosticReports/DumpRenderTree_2011-06-13-150720_quadzen.crash'] = newer_mock_crash_report
        files[
            '/Users/mock/Library/Logs/DiagnosticReports/DumpRenderTree_2011-06-13-150721_quadzen.crash'] = None
        files[
            '/Users/mock/Library/Logs/DiagnosticReports/DumpRenderTree_2011-06-13-150722_quadzen.crash'] = other_process_mock_crash_report
        files[
            '/Users/mock/Library/Logs/DiagnosticReports/DumpRenderTree_2011-06-13-150723_quadzen.crash'] = misformatted_mock_crash_report
        filesystem = MockFileSystem(files)
        crash_logs = CrashLogs(MockSystemHost(filesystem=filesystem))
        log = crash_logs.find_newest_log("DumpRenderTree")
        self.assertLinesEqual(log, newer_mock_crash_report)
        log = crash_logs.find_newest_log("DumpRenderTree", 28529)
        self.assertLinesEqual(log, newer_mock_crash_report)
        log = crash_logs.find_newest_log("DumpRenderTree", 28530)
        self.assertLinesEqual(log, mock_crash_report)
        log = crash_logs.find_newest_log("DumpRenderTree", 28531)
        self.assertEqual(log, None)
        log = crash_logs.find_newest_log("DumpRenderTree", newer_than=1.0)
        self.assertEqual(log, None)

        def bad_read(path):
            raise IOError('No such file or directory')

        filesystem.read_text_file = bad_read
        log = crash_logs.find_newest_log("DumpRenderTree",
                                         28531,
                                         include_errors=True)
        self.assertTrue('No such file or directory' in log)
Пример #47
0
 def test_stdin_chromium(self):
     host = MockSystemHost()
     host.stdin = StringIO.StringIO(ACTUAL_INPUT)
     main(host, ["--chromium", "-"])
     self.assertMultiLineEqual(host.stdout.getvalue(), EXPECTED_CHROMIUM_OUTPUT)
Пример #48
0
 def test_stdin_blink(self):
     host = MockSystemHost()
     host.stdin = StringIO.StringIO(ACTUAL_INPUT)
     main(host, ["-"])
     self.assertMultiLineEqual(host.stdout.getvalue(), EXPECTED_BLINK_OUTPUT)
Пример #49
0
 def test_stdin_no_changes(self):
     host = MockSystemHost()
     host.stdin = StringIO.StringIO(ACTUAL_INPUT)
     main(host, ["--no-autopep8", "--leave-strings-alone", "-"])
     self.assertMultiLineEqual(host.stdout.getvalue(), ACTUAL_INPUT)
Пример #50
0
 def test_stdin_only_double_quoting(self):
     host = MockSystemHost()
     host.stdin = StringIO.StringIO(ACTUAL_INPUT)
     main(host, ["--no-autopep8", "--double-quote-strings", "-"])
     self.assertMultiLineEqual(host.stdout.getvalue(), EXPECTED_ONLY_DOUBLE_QUOTED_OUTPUT)