def make_driver(self, worker_number=0, xorg_running=False, executive=None): port = Port(MockSystemHost(log_executive=True, executive=executive), 'waylanddrivertestport', options=MockOptions(configuration='Release')) port._config.build_directory = lambda configuration: '/mock-build' port._server_process_constructor = MockServerProcess driver = WaylandDriver(port, worker_number=worker_number, pixel_tests=True) driver._startup_delay_secs = 0 driver._environment = port.setup_environ_for_server(port.driver_name()) return driver
def make_driver(self, filesystem=None): port = Port(MockSystemHost(log_executive=True, filesystem=filesystem), 'westondrivertestport', options=MockOptions(configuration='Release')) port._config.build_directory = lambda configuration: "/mock_build" port._server_process_constructor = MockServerProcess driver = WestonDriver(port, worker_number=0, pixel_tests=True) driver._startup_delay_secs = 0 return driver
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 make_driver(self, filesystem=None): port = Port(MockSystemHost(log_executive=True, filesystem=filesystem), 'westondrivertestport', options=MockOptions(configuration='Release')) port._config.build_directory = lambda configuration: "/mock_build" port._server_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
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 driver._xvfb_screen_depth = lambda: '24' return driver
def __init__(self, host, port_name=None, **kwargs): Port.__init__(self, host, port_name or TestPort.default_port_name, **kwargs) self._tests = unit_test_list() self._flakes = set() self._expectations_path = LAYOUT_TEST_DIR + '/platform/test/TestExpectations' self._results_directory = None self._operating_system = self._name.split('-')[1] if self._operating_system == 'linux': self._os_version = None else: self._os_version = VersionNameMap.map(self.host.platform).from_name(self._name.split('-')[2])[1]
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
def test_is_reference_html_file(self): filesystem = MockFileSystem() self.assertTrue(Port.is_reference_html_file(filesystem, '', 'foo-expected.html')) self.assertTrue(Port.is_reference_html_file(filesystem, '', 'foo-expected-mismatch.xml')) self.assertTrue(Port.is_reference_html_file(filesystem, '', 'foo-ref.xhtml')) self.assertTrue(Port.is_reference_html_file(filesystem, '', 'foo-notref.svg')) self.assertFalse(Port.is_reference_html_file(filesystem, '', 'foo.html')) self.assertFalse(Port.is_reference_html_file(filesystem, '', 'foo-expected.txt')) self.assertFalse(Port.is_reference_html_file(filesystem, '', 'foo-expected.shtml')) self.assertFalse(Port.is_reference_html_file(filesystem, '', 'foo-expected.php')) self.assertFalse(Port.is_reference_html_file(filesystem, '', 'foo-expected.mht'))
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 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._environment = port.setup_environ_for_server(port.driver_name()) return driver
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
def test_parse_reftest_list(self): port = self.make_port(with_tests=True) port.host.filesystem.files["bar/reftest.list"] = "\n".join( [ "== test.html test-ref.html", "", "# some comment", "!= test-2.html test-notref.html # more comments", "== test-3.html test-ref.html", "== test-3.html test-ref2.html", "!= test-3.html test-notref.html", ] ) reftest_list = Port._parse_reftest_list(port.host.filesystem, "bar") self.assertEqual( reftest_list, { "bar/test.html": [("==", "bar/test-ref.html")], "bar/test-2.html": [("!=", "bar/test-notref.html")], "bar/test-3.html": [ ("==", "bar/test-ref.html"), ("==", "bar/test-ref2.html"), ("!=", "bar/test-notref.html"), ], }, )
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)
def test_previously_spawned_instance(self): host = MockHost() port = Port(host, "test") server = WebPlatformTestServer(port, "wpttest", "/mock/output_dir", "/mock/output_dir/pid.txt") server._check_that_all_ports_are_available = lambda: True server._is_server_running_on_all_ports = lambda: True host.filesystem.write_text_file("/mock_output_dir/pid.txt", "0") server.start() server.stop()
def __init__(self, host, port_name=None, **kwargs): Port.__init__(self, host, port_name or TestPort.default_port_name, **kwargs) self._tests = unit_test_list() self._flakes = set() self._expectations_path = LAYOUT_TEST_DIR + "/platform/test/TestExpectations" self._results_directory = None self._operating_system = "mac" if self._name.startswith("test-win"): self._operating_system = "win" elif self._name.startswith("test-linux"): self._operating_system = "linux" version_map = { "test-win-xp": "xp", "test-win-win7": "win7", "test-win-vista": "vista", "test-mac-leopard": "leopard", "test-mac-snowleopard": "snowleopard", "test-linux-x86_64": "lucid", } self._version = version_map[self._name]
def __init__(self, host, port_name=None, **kwargs): Port.__init__(self, host, port_name or TestPort.default_port_name, **kwargs) self._tests = unit_test_list() self._flakes = set() self._expectations_path = LAYOUT_TEST_DIR + '/platform/test/TestExpectations' self._results_directory = None self._operating_system = 'mac' if self._name.startswith('test-win'): self._operating_system = 'win' elif self._name.startswith('test-linux'): self._operating_system = 'linux' version_map = { 'test-win-xp': 'xp', 'test-win-win7': 'win7', 'test-win-vista': 'vista', 'test-mac-leopard': 'leopard', 'test-mac-snowleopard': 'snowleopard', 'test-linux-x86_64': 'lucid', } self._version = version_map[self._name]
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)
def test_parse_reftest_list(self): port = self.make_port(with_tests=True) port.host.filesystem.files['bar/reftest.list'] = "\n".join(["== test.html test-ref.html", "", "# some comment", "!= test-2.html test-notref.html # more comments", "== test-3.html test-ref.html", "== test-3.html test-ref2.html", "!= test-3.html test-notref.html"]) reftest_list = Port._parse_reftest_list(port.host.filesystem, 'bar') self.assertEqual(reftest_list, {'bar/test.html': [('==', 'bar/test-ref.html')], 'bar/test-2.html': [('!=', 'bar/test-notref.html')], 'bar/test-3.html': [('==', 'bar/test-ref.html'), ('==', 'bar/test-ref2.html'), ('!=', 'bar/test-notref.html')]})
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)
def test_stop(self): filesystem = MockFileSystem(files={'/tmp/.X42-lock': '1234\n'}) port = Port(MockSystemHost(log_executive=True, filesystem=filesystem), '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() driver._lock_file = '/tmp/.X42-lock' expected_logs = "MOCK kill_process pid: 1234\n" OutputCapture().assert_outputs(self, driver.stop, [], expected_logs=expected_logs) self.assertIsNone(driver._xvfb_process) self.assertFalse(port._filesystem.exists(driver._lock_file))
def test_previously_spawned_instance(self): host = MockHost() options = optparse.Values() options.ensure_value("results_directory", "/mock/output_dir") port = Port(host, "test", options) server = WebPlatformTestServer(port, "wpttest", "/mock/output_dir/pid.txt") server._check_that_all_ports_are_available = lambda: True server._is_server_running_on_all_ports = lambda: True host.filesystem.write_text_file( "/mock-checkout/LayoutTests/resources/testharness.js", "0") host.filesystem.write_text_file( "/mock-checkout/LayoutTests/imported/w3c/web-platform-tests/resources/testharness.js", "0") host.filesystem.write_text_file("/mock_output_dir/pid.txt", "0") server.start() server.stop()
def test_corrupted_subserver_files(self): host = MockHost() options = optparse.Values() options.ensure_value("results_directory", "/mock/output_dir") port = Port(host, "test", options) server = WebPlatformTestServer(port, "wpttest", "/mock/output_dir/pid.txt") server._check_that_all_ports_are_available = lambda: True server._is_server_running_on_all_ports = lambda: True host.filesystem.write_text_file( "/mock-checkout/LayoutTests/resources/testharness.js", "0") host.filesystem.write_text_file( "/mock-checkout/LayoutTests/imported/w3c/web-platform-tests/resources/testharness.js", "0") host.filesystem.write_text_file( "/mock_output_dir/wpttest_servers.json", "0") server.stop() self.assertFalse( host.filesystem.exists("/mock/output_dir/wpttest_servers.json")) host.filesystem.write_text_file( "/mock_output_dir/wpttest_servers.json", "[0,") server.start() self.assertFalse( host.filesystem.exists("/mock/output_dir/wpttest_servers.json")) server.stop() host.filesystem.write_text_file( "/mock_output_dir/wpttest_servers.json", "[{'protocol': 'http', 'port': 80 }]") server.start() self.assertFalse( host.filesystem.exists("/mock/output_dir/wpttest_servers.json")) server.stop() host.filesystem.write_text_file( "/mock_output_dir/wpttest_servers.json", "[{'protocol': 'http', 'port': 80, 'pid': {} }]") server.start() self.assertFalse( host.filesystem.exists("/mock/output_dir/wpttest_servers.json")) server.stop()
def test_server_fails_to_start_throws_exception(self): host = MockHost() options = optparse.Values() options.ensure_value("results_directory", "/mock/output_dir") port = Port(host, "test", options) server = WebPlatformTestServer(port, "wpttest", "/mock/output_dir/pid.txt") server._check_that_all_ports_are_available = lambda: True server._is_server_running_on_all_ports = lambda: True host.filesystem.write_text_file( "/mock-checkout/LayoutTests/resources/testharness.js", "0") host.filesystem.write_text_file( "/mock-checkout/LayoutTests/imported/w3c/web-platform-tests/resources/testharness.js", "0") server.start() server.stop() server._process.poll = lambda: 1 self.assertRaises(ServerError, server.start)
def test_corrupted_subserver_files(self): host = MockHost() port = Port(host, "test") server = WebPlatformTestServer(port, "wpttest", "/mock/output_dir", "/mock/output_dir/pid.txt") server._check_that_all_ports_are_available = lambda: True server._is_server_running_on_all_ports = lambda: True host.filesystem.write_text_file( "/mock_output_dir/wpttest_servers.json", "0") server.stop() self.assertFalse( host.filesystem.exists("/mock/output_dir/wpttest_servers.json")) host.filesystem.write_text_file( "/mock_output_dir/wpttest_servers.json", "[0,") server.start() self.assertFalse( host.filesystem.exists("/mock/output_dir/wpttest_servers.json")) server.stop() host.filesystem.write_text_file( "/mock_output_dir/wpttest_servers.json", "[{'protocol': 'http', 'port': 80 }]") server.start() self.assertFalse( host.filesystem.exists("/mock/output_dir/wpttest_servers.json")) server.stop() host.filesystem.write_text_file( "/mock_output_dir/wpttest_servers.json", "[{'protocol': 'http', 'port': 80, 'pid': {} }]") server.start() self.assertFalse( host.filesystem.exists("/mock/output_dir/wpttest_servers.json")) server.stop()
def test_is_test_file(self): filesystem = MockFileSystem() self.assertTrue(Port._is_test_file(filesystem, "", "foo.html")) self.assertTrue(Port._is_test_file(filesystem, "", "foo.shtml")) self.assertTrue(Port._is_test_file(filesystem, "", "foo.svg")) self.assertTrue(Port._is_test_file(filesystem, "", "test-ref-test.html")) self.assertFalse(Port._is_test_file(filesystem, "", "foo.png")) self.assertFalse(Port._is_test_file(filesystem, "", "foo-expected.html")) self.assertFalse(Port._is_test_file(filesystem, "", "foo-expected.svg")) self.assertFalse(Port._is_test_file(filesystem, "", "foo-expected.xht")) self.assertFalse(Port._is_test_file(filesystem, "", "foo-expected-mismatch.html")) self.assertFalse(Port._is_test_file(filesystem, "", "foo-expected-mismatch.svg")) self.assertFalse(Port._is_test_file(filesystem, "", "foo-expected-mismatch.xhtml")) self.assertFalse(Port._is_test_file(filesystem, "", "foo-ref.html")) self.assertFalse(Port._is_test_file(filesystem, "", "foo-notref.html")) self.assertFalse(Port._is_test_file(filesystem, "", "foo-notref.xht")) self.assertFalse(Port._is_test_file(filesystem, "", "foo-ref.xhtml")) self.assertFalse(Port._is_test_file(filesystem, "", "ref-foo.html")) self.assertFalse(Port._is_test_file(filesystem, "", "notref-foo.xhr"))
def make_port(self): port = Port(MockSystemHost(), 'test', MockOptions(configuration='Release')) port._config.build_directory = lambda configuration: '/mock-build' return port
def make_port(self, host=None, options=None): port = Port(host or MockSystemHost(), 'test', options or MockOptions(configuration='Release')) port._config.build_directory = lambda configuration: '/mock-build' return port
def test_is_test_file(self): filesystem = MockFileSystem() self.assertTrue(Port._is_test_file(filesystem, '', 'foo.html')) self.assertTrue(Port._is_test_file(filesystem, '', 'foo.shtml')) self.assertTrue(Port._is_test_file(filesystem, '', 'foo.svg')) self.assertTrue(Port._is_test_file(filesystem, '', 'test-ref-test.html')) self.assertFalse(Port._is_test_file(filesystem, '', 'foo.png')) self.assertFalse(Port._is_test_file(filesystem, '', 'foo-expected.html')) self.assertFalse(Port._is_test_file(filesystem, '', 'foo-expected.svg')) self.assertFalse(Port._is_test_file(filesystem, '', 'foo-expected.xht')) self.assertFalse(Port._is_test_file(filesystem, '', 'foo-expected-mismatch.html')) self.assertFalse(Port._is_test_file(filesystem, '', 'foo-expected-mismatch.svg')) self.assertFalse(Port._is_test_file(filesystem, '', 'foo-expected-mismatch.xhtml')) self.assertFalse(Port._is_test_file(filesystem, '', 'foo-ref.html')) self.assertFalse(Port._is_test_file(filesystem, '', 'foo-notref.html')) self.assertFalse(Port._is_test_file(filesystem, '', 'foo-notref.xht')) self.assertFalse(Port._is_test_file(filesystem, '', 'foo-ref.xhtml')) self.assertFalse(Port._is_test_file(filesystem, '', 'ref-foo.html')) self.assertFalse(Port._is_test_file(filesystem, '', 'notref-foo.xhr'))