Changeset 104340 in webkit
- Timestamp:
- Jan 6, 2012 2:27:18 PM (12 years ago)
- Location:
- trunk/Tools
- Files:
-
- 1 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r104331 r104340 1 2012-01-05 Dirk Pranke <dpranke@chromium.org> 2 3 webkitpy: clean up test/uri conversion routines 4 https://bugs.webkit.org/show_bug.cgi?id=75648 5 6 Reviewed by Eric Seidel. 7 8 This change moves test_to_uri and uri_to_test from the Port 9 class to the Driver class (the routines were only being 10 called by the drivers), and removes a bunch of stale and/or 11 busted logic. 12 13 * Scripts/webkitpy/layout_tests/port/base.py: 14 * Scripts/webkitpy/layout_tests/port/base_unittest.py: 15 * Scripts/webkitpy/layout_tests/port/chromium.py: 16 * Scripts/webkitpy/layout_tests/port/chromium_unittest.py: 17 * Scripts/webkitpy/layout_tests/port/driver.py: 18 (is_http_test): 19 (test_to_uri): 20 (uri_to_test): 21 * Scripts/webkitpy/layout_tests/port/mock_drt.py: 22 (run_one_test): 23 * Scripts/webkitpy/layout_tests/port/mock_drt_unittest.py: 24 (MockDRTTest.input_line): 25 (input_line): 26 (expected_output): 27 * Scripts/webkitpy/layout_tests/port/test.py: 28 * Scripts/webkitpy/layout_tests/port/webkit.py: 29 (_command_from_driver_input): 30 1 31 2012-01-06 Simon Fraser <simon.fraser@apple.com> 2 32 -
trunk/Tools/Scripts/webkitpy/layout_tests/port/base.py
r104206 r104340 40 40 41 41 from webkitpy.common.memoized import memoized 42 from webkitpy.common.system import path 42 43 43 44 … … 50 51 from webkitpy.common import find_files 51 52 from webkitpy.common.system import logutils 52 from webkitpy.common.system import path53 53 from webkitpy.common.system.executive import ScriptError 54 54 from webkitpy.common.system.systemhost import SystemHost … … 462 462 return filename in reftest_list 463 463 464 def test_to_uri(self, test_name):465 """Convert a test name to a URI."""466 LAYOUTTEST_HTTP_DIR = "http/tests/"467 LAYOUTTEST_WEBSOCKET_DIR = "http/tests/websocket/tests/"468 469 port = None470 471 relative_path = test_name472 if (relative_path.startswith(LAYOUTTEST_WEBSOCKET_DIR)473 or relative_path.startswith(LAYOUTTEST_HTTP_DIR)):474 relative_path = relative_path[len(LAYOUTTEST_HTTP_DIR):]475 port = 8000476 477 # Make http/tests/local run as local files. This is to mimic the478 # logic in run-webkit-tests.479 #480 # TODO(dpranke): remove the SSL reference?481 if (port and not relative_path.startswith("local/")):482 if relative_path.startswith("ssl/"):483 port += 443484 protocol = "https"485 else:486 protocol = "http"487 return "%s://127.0.0.1:%u/%s" % (protocol, port, relative_path)488 489 return path.abspath_to_uri(self.abspath_for_test(test_name))490 491 464 def tests(self, paths): 492 465 """Return the list of tests found.""" … … 567 540 """ 568 541 self._filesystem.write_binary_file(baseline_path, data) 569 570 def uri_to_test_name(self, uri):571 """Return the base layout test name for a given URI.572 573 This returns the test name for a given URI, e.g., if you passed in574 "file:///src/LayoutTests/fast/html/keygen.html" it would return575 "fast/html/keygen.html".576 577 """578 test = uri579 if uri.startswith("file:///"):580 prefix = path.abspath_to_uri(self.layout_tests_dir()) + "/"581 return test[len(prefix):]582 583 if uri.startswith("http://127.0.0.1:8880/"):584 # websocket tests585 return test.replace('http://127.0.0.1:8880/', '')586 587 if uri.startswith("http://"):588 # regular HTTP test589 return test.replace('http://127.0.0.1:8000/', 'http/tests/')590 591 if uri.startswith("https://"):592 return test.replace('https://127.0.0.1:8443/', 'http/tests/')593 594 raise NotImplementedError('unknown url type: %s' % uri)595 542 596 543 def layout_tests_dir(self): -
trunk/Tools/Scripts/webkitpy/layout_tests/port/base_unittest.py
r103952 r104340 227 227 self.assertTrue('css2.1' in dirs) 228 228 229 def test_test_to_uri(self):230 port = self.make_port()231 layout_test_dir = port.layout_tests_dir()232 test = 'foo/bar.html'233 path = port._filesystem.join(layout_test_dir, test)234 if sys.platform == 'win32':235 path = path.replace("\\", "/")236 237 self.assertEqual(port.test_to_uri(test), abspath_to_uri(path))238 239 229 def test_get_option__set(self): 240 230 options, args = optparse.OptionParser().parse_args([]) -
trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium.py
r102400 r104340 525 525 has_base64 = False 526 526 527 uri = self. _port.test_to_uri(driver_input.test_name)527 uri = self.test_to_uri(driver_input.test_name) 528 528 cmd = self._test_shell_command(uri, driver_input.timeout, driver_input.image_hash) 529 529 line, crash = self._write_command_and_read_line(input=cmd) -
trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_unittest.py
r100674 r104340 99 99 self.driver._proc.stdout.readline = mock_readline 100 100 101 self.driver. _port.test_to_uri = lambda test: 'mocktesturi'101 self.driver.test_to_uri = lambda test: 'mocktesturi' 102 102 driver_output = self.driver.run_test(DriverInput(test_name='some/test.html', timeout=1, image_hash=None, is_reftest=False)) 103 103 self.assertEqual(self.driver._port.driver_name(), driver_output.crashed_process_name) -
trunk/Tools/Scripts/webkitpy/layout_tests/port/driver.py
r100326 r104340 28 28 29 29 import shlex 30 31 from webkitpy.common.system import path 30 32 31 33 … … 92 94 return shlex.split(wrapper_option) if wrapper_option else [] 93 95 96 HTTP_DIR = "http/tests/" 97 HTTP_LOCAL_DIR = "http/tests/local/" 98 99 def is_http_test(self, test_name): 100 return test_name.startswith(self.HTTP_DIR) and not test_name.startswith(self.HTTP_LOCAL_DIR) 101 102 def test_to_uri(self, test_name): 103 """Convert a test name to a URI.""" 104 if not self.is_http_test(test_name): 105 return path.abspath_to_uri(self._port.abspath_for_test(test_name)) 106 107 relative_path = test_name[len(self.HTTP_DIR):] 108 109 # TODO(dpranke): remove the SSL reference? 110 if relative_path.startswith("ssl/"): 111 return "https://127.0.0.1:8443/" + relative_path 112 return "http://127.0.0.1:8000/" + relative_path 113 114 def uri_to_test(self, uri): 115 """Return the base layout test name for a given URI. 116 117 This returns the test name for a given URI, e.g., if you passed in 118 "file:///src/LayoutTests/fast/html/keygen.html" it would return 119 "fast/html/keygen.html". 120 121 """ 122 if uri.startswith("file:///"): 123 return uri[len(path.abspath_to_uri(self._port.layout_tests_dir()) + "/"):] 124 if uri.startswith("http://"): 125 return uri.replace('http://127.0.0.1:8000/', self.HTTP_DIR) 126 if uri.startswith("https://"): 127 return uri.replace('https://127.0.0.1:8443/', self.HTTP_DIR) 128 raise NotImplementedError('unknown url type: %s' % uri) 129 94 130 def has_crashed(self): 95 131 return False … … 114 150 self._reftest_driver = driver_instance_constructor(port, worker_number, pixel_tests=True) 115 151 152 def is_http_test(self, test_name): 153 return self._driver.is_http_test(test_name) 154 155 def test_to_uri(self, test_name): 156 return self._driver.test_to_uri(test_name) 157 158 def uri_to_test(self, uri): 159 return self._driver.uri_to_test(uri) 160 116 161 def run_test(self, driver_input): 117 162 if driver_input.is_reftest: -
trunk/Tools/Scripts/webkitpy/layout_tests/port/mock_drt.py
r103012 r104340 187 187 port_name = options.platform 188 188 self._port = PortFactory(host).get(port_name=port_name, options=options) 189 self._driver = self._port.create_driver(0) 189 190 190 191 def run(self): … … 201 202 def run_one_test(self, test_input): 202 203 port = self._port 203 if test_input.uri.startswith('http '):204 test_name = port.uri_to_test_name(test_input.uri)204 if test_input.uri.startswith('http://') or test_input.uri.startswith('https://'): 205 test_name = self._driver.uri_to_test(test_input.uri) 205 206 else: 206 207 test_name = port.relative_test_filename(test_input.uri) … … 257 258 def run_one_test(self, test_input): 258 259 port = self._port 259 test_name = self._ port.uri_to_test_name(test_input.uri)260 test_name = self._driver.uri_to_test(test_input.uri) 260 261 261 262 actual_text = port.expected_text(test_name) -
trunk/Tools/Scripts/webkitpy/layout_tests/port/mock_drt_unittest.py
r103253 r104340 90 90 class MockDRTTest(unittest.TestCase): 91 91 def input_line(self, port, test_name, checksum=None): 92 url = port. test_to_uri(test_name)92 url = port.create_driver(0).test_to_uri(test_name) 93 93 # FIXME: we shouldn't have to work around platform-specific issues 94 94 # here. … … 216 216 217 217 def input_line(self, port, test_name, checksum=None): 218 url = port. test_to_uri(test_name)218 url = port.create_driver(0).test_to_uri(test_name) 219 219 if checksum: 220 220 return url + ' 6000 ' + checksum + '\n' … … 222 222 223 223 def expected_output(self, port, test_name, pixel_tests, text_output, expected_checksum): 224 url = port. test_to_uri(test_name)224 url = port.create_driver(0).test_to_uri(test_name) 225 225 if pixel_tests and expected_checksum: 226 226 return ['#URL:%s\n' % url, -
trunk/Tools/Scripts/webkitpy/layout_tests/port/test.py
r103952 r104340 451 451 return self.ALL_BASELINE_VARIANTS 452 452 453 # FIXME: These next two routines are copied from base.py with454 # the calls to path.abspath_to_uri() removed. We shouldn't have455 # to do this.456 def test_to_uri(self, test_name):457 """Convert a test file (which is an absolute path) to a URI."""458 LAYOUTTEST_HTTP_DIR = "http/tests/"459 LAYOUTTEST_WEBSOCKET_DIR = "http/tests/websocket/tests/"460 461 port = None462 use_ssl = False463 464 relative_path = test_name465 if (relative_path.startswith(LAYOUTTEST_WEBSOCKET_DIR)466 or relative_path.startswith(LAYOUTTEST_HTTP_DIR)):467 relative_path = relative_path[len(LAYOUTTEST_HTTP_DIR):]468 port = 8000469 470 # Make http/tests/local run as local files. This is to mimic the471 # logic in run-webkit-tests.472 #473 # TODO(dpranke): remove the media reference and the SSL reference?474 if (port and not relative_path.startswith("local/") and475 not relative_path.startswith("media/")):476 if relative_path.startswith("ssl/"):477 port += 443478 protocol = "https"479 else:480 protocol = "http"481 return "%s://127.0.0.1:%u/%s" % (protocol, port, relative_path)482 483 return "file://" + self.abspath_for_test(test_name)484 485 def abspath_for_test(self, test_name):486 return self.layout_tests_dir() + self.TEST_PATH_SEPARATOR + test_name487 488 def uri_to_test_name(self, uri):489 """Return the base layout test name for a given URI.490 491 This returns the test name for a given URI, e.g., if you passed in492 "file:///src/LayoutTests/fast/html/keygen.html" it would return493 "fast/html/keygen.html".494 495 """496 test = uri497 if uri.startswith("file:///"):498 prefix = "file://" + self.layout_tests_dir() + "/"499 return test[len(prefix):]500 501 if uri.startswith("http://127.0.0.1:8880/"):502 # websocket tests503 return test.replace('http://127.0.0.1:8880/', '')504 505 if uri.startswith("http://"):506 # regular HTTP test507 return test.replace('http://127.0.0.1:8000/', 'http/tests/')508 509 if uri.startswith("https://"):510 return test.replace('https://127.0.0.1:8443/', 'http/tests/')511 512 raise NotImplementedError('unknown url type: %s' % uri)513 514 453 515 454 class TestDriver(Driver): -
trunk/Tools/Scripts/webkitpy/layout_tests/port/webkit.py
r104273 r104340 522 522 523 523 def _command_from_driver_input(self, driver_input): 524 uri = self._port.test_to_uri(driver_input.test_name) 525 command = uri[7:] if uri.startswith("file:///") else uri 524 if self.is_http_test(driver_input.test_name): 525 command = self.test_to_uri(driver_input.test_name) 526 else: 527 command = self._port.abspath_for_test(driver_input.test_name) 526 528 527 529 if driver_input.image_hash:
Note: See TracChangeset
for help on using the changeset viewer.