Changeset 252443 in webkit
- Timestamp:
- Nov 13, 2019, 6:08:56 PM (7 years ago)
- Location:
- trunk/Tools
- Files:
-
- 11 edited
-
ChangeLog (modified) (1 diff)
-
Scripts/test-webkitpy-python3 (modified) (1 diff)
-
Scripts/webkitpy/common/message_pool.py (modified) (7 diffs)
-
Scripts/webkitpy/common/read_checksum_from_png.py (modified) (2 diffs)
-
Scripts/webkitpy/common/system/filesystem.py (modified) (2 diffs)
-
Scripts/webkitpy/common/system/filesystem_mock.py (modified) (1 diff)
-
Scripts/webkitpy/layout_tests/controllers/layout_test_finder_unittest.py (modified) (5 diffs)
-
Scripts/webkitpy/layout_tests/controllers/layout_test_runner.py (modified) (3 diffs)
-
Scripts/webkitpy/layout_tests/controllers/manager.py (modified) (7 diffs)
-
Scripts/webkitpy/port/base.py (modified) (1 diff)
-
Scripts/webkitpy/port/mock_drt.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r252442 r252443 1 2019-11-13 Jonathan Bedard <jbedard@apple.com> 2 3 Python 3: Add support in webkitpy.layout_tests.controllers 4 https://bugs.webkit.org/show_bug.cgi?id=204180 5 6 Reviewed by Stephanie Lewis. 7 8 * Scripts/test-webkitpy-python3: Add webkitpy.layout_tests.controllers. 9 * Scripts/webkitpy/common/message_pool.py: 10 (_MessagePool.__init__): Use Python 3 queue syntax. 11 (_MessagePool._can_pickle): Use Python 3 pickle syntax. 12 (_MessagePool._loop): Use Python 3 queue syntax. 13 (_Worker.run): Use Python 3 queue syntax. 14 (_Worker._raise): Python 2 and Python 3 have different semantics for raising an exception 15 With a stack trace. However, 'raise' will raise the exception we are in the process of capturing, 16 Which is exactly what we want in this case. 17 * Scripts/webkitpy/common/read_checksum_from_png.py: 18 (read_checksum): Standardize checksum as a string. 19 * Scripts/webkitpy/common/system/filesystem.py: 20 (FileSystem.write_binary_file): Binary files should be written with bytes, not strings. 21 * Scripts/webkitpy/common/system/filesystem_mock.py: 22 (MockFileSystem.write_binary_file): Binary files should be written with bytes, not strings. 23 * Scripts/webkitpy/layout_tests/controllers/layout_test_finder_unittest.py: assertItemsEqual is not 24 Defined in Python 3. 25 * Scripts/webkitpy/layout_tests/controllers/layout_test_runner.py: 26 (Worker._do_post_tests_work): Use compatible iteritems. 27 (Sharder._shard_by_directory): Ditto. 28 * Scripts/webkitpy/layout_tests/controllers/manager.py: 29 (Manager.run): Use compatible itervalues. 30 (Manager._look_for_new_crash_logs): Use Python 3 item iteration. 31 (Manager._results_to_upload_json_trie): Use compatible itervalues. 32 (Manager._stats_trie): Use compatible iteritems. 33 * Scripts/webkitpy/port/base.py: 34 (Port.expected_text): Be explicit about decoding text expectations. 35 * Scripts/webkitpy/port/mock_drt.py: 36 (MockDRT.write_test_output): 37 1 38 2019-11-13 Per Arne Vollan <pvollan@apple.com> 2 39 -
trunk/Tools/Scripts/test-webkitpy-python3
r252440 r252443 36 36 PYTHON3_COMPATIBLE_DIRECTORIES = [ 37 37 'webkitpy.common', 38 'webkitpy.layout_tests.controllers', 38 39 'webkitpy.layout_tests.models', 39 40 'webkitpy.port', -
trunk/Tools/Scripts/webkitpy/common/message_pool.py
r244571 r252443 41 41 """ 42 42 43 import cPickle44 43 import logging 45 44 import multiprocessing 46 45 import os 47 import Queue48 46 import signal 49 47 import sys … … 51 49 import traceback 52 50 51 if sys.version_info > (3, 0): 52 import pickle 53 import queue 54 else: 55 import cPickle as pickle 56 import Queue as queue 53 57 54 58 from webkitpy.common.host import Host … … 77 81 self._timeout = timeout 78 82 if self._running_inline: 79 self._messages_to_worker = Queue.Queue()80 self._messages_to_manager = Queue.Queue()83 self._messages_to_worker = queue.Queue() 84 self._messages_to_manager = queue.Queue() 81 85 else: 82 86 self._messages_to_worker = multiprocessing.Queue() … … 176 180 def _can_pickle(self, host): 177 181 try: 178 cPickle.dumps(host)182 pickle.dumps(host) 179 183 return True 180 184 except TypeError: … … 194 198 assert method, 'bad message %s' % repr(message) 195 199 method(message.src, *message.args) 196 except Queue.Empty:200 except queue.Empty: 197 201 pass 198 202 … … 273 277 274 278 _log.debug("%s exiting" % self.name) 275 except Queue.Empty:279 except queue.Empty: 276 280 assert False, '%s: ran out of messages in worker queue.' % self.name 277 281 except KeyboardInterrupt as e: … … 303 307 exception_type, exception_value, exception_traceback = exc_info 304 308 if self._running_inline: 305 raise exception_type, exception_value, exception_traceback309 raise 306 310 307 311 if exception_type == KeyboardInterrupt: -
trunk/Tools/Scripts/webkitpy/common/read_checksum_from_png.py
r136545 r252443 28 28 29 29 30 from webkitpy.common.unicode_compatibility import encode_if_necessary, decode_for 31 30 32 def read_checksum(filehandle): 31 33 # We expect the comment to be at the beginning of the file. 32 data = filehandle.read(2048)33 comment_key = 'tEXtchecksum\x00'34 data = encode_if_necessary(filehandle.read(2048)) 35 comment_key = b'tEXtchecksum\x00' 34 36 comment_pos = data.find(comment_key) 35 37 if comment_pos == -1: … … 37 39 38 40 checksum_pos = comment_pos + len(comment_key) 39 return d ata[checksum_pos:checksum_pos + 32]41 return decode_for(data[checksum_pos:checksum_pos + 32], str) -
trunk/Tools/Scripts/webkitpy/common/system/filesystem.py
r250375 r252443 40 40 import time 41 41 42 from webkitpy.common.unicode_compatibility import decode_if_necessary 42 from webkitpy.common.unicode_compatibility import decode_if_necessary, encode_for 43 43 44 44 … … 228 228 def write_binary_file(self, path, contents): 229 229 with open(path, 'wb') as f: 230 f.write( contents)230 f.write(encode_for(contents, bytes)) 231 231 232 232 def open_text_file_for_reading(self, path, errors='strict'): -
trunk/Tools/Scripts/webkitpy/common/system/filesystem_mock.py
r251608 r252443 330 330 # FIXME: should this assert if dirname(path) doesn't exist? 331 331 self.maybe_make_directory(self.dirname(path)) 332 self.files[path] = contents333 self.written_files[path] = contents332 self.files[path] = unicode_compatibility.encode_for(contents, bytes) 333 self.written_files[path] = unicode_compatibility.encode_for(contents, bytes) 334 334 335 335 def open_text_file_for_reading(self, path, errors='strict'): -
trunk/Tools/Scripts/webkitpy/layout_tests/controllers/layout_test_finder_unittest.py
r240150 r252443 56 56 paths = ['LayoutTests/test.html', 'LayoutTests/test', 'test2.html', 'Source/test1.html'] 57 57 fs, touched_tests = self.touched_files(paths) 58 self.assert ItemsEqual(touched_tests, ['test.html'])58 self.assertEqual(touched_tests, ['test.html']) 59 59 60 60 def test_expected_touched_test(self): … … 63 63 fs.write_text_file('/test.checkout/LayoutTests/test.html', 'This is a test') 64 64 fs, touched_tests = self.touched_files(paths, fs) 65 self.assert ItemsEqual(touched_tests, ['test.html'])65 self.assertEqual(touched_tests, ['test.html']) 66 66 67 67 def test_platform_expected_touched_test(self): … … 70 70 fs.write_text_file('/test.checkout/LayoutTests/test.html', 'This is a test') 71 71 fs, touched_tests = self.touched_files(paths, fs) 72 self.assert ItemsEqual(touched_tests, ['test.html'])72 self.assertEqual(touched_tests, ['test.html']) 73 73 74 74 def test_platform_duplicate_touched_test(self): … … 77 77 fs.write_text_file('/test.checkout/LayoutTests/test2.html', 'This is a test') 78 78 fs, touched_tests = self.touched_files(paths, fs) 79 self.assert ItemsEqual(touched_tests, ['test1.html', 'test2.html'])79 self.assertEqual(sorted(touched_tests), sorted(['test1.html', 'test2.html'])) 80 80 81 81 def test_touched_but_skipped_test(self): … … 93 93 94 94 touched_tests = LayoutTestFinder(port, optparse.Values({'skipped': 'always', 'skip_failing_tests': False, 'http': True})).find_touched_tests(paths) 95 self.assert ItemsEqual(touched_tests, ['test0.html', 'test2.html'])95 self.assertEqual(sorted(touched_tests), sorted(['test0.html', 'test2.html'])) -
trunk/Tools/Scripts/webkitpy/layout_tests/controllers/layout_test_runner.py
r239989 r252443 34 34 35 35 from webkitpy.common import message_pool 36 from webkitpy.common.iteration_compatibility import iteritems 36 37 from webkitpy.layout_tests.controllers import single_test_runner 37 38 from webkitpy.layout_tests.models.test_run_results import TestRunResults … … 332 333 post_test_output = driver.do_post_tests_work() 333 334 if post_test_output: 334 for test_name, doc_list in post_test_output.world_leaks_dict.iteritems():335 for test_name, doc_list in iteritems(post_test_output.world_leaks_dict): 335 336 additional_results.append(test_results.TestResult(test_name, [test_failures.FailureDocumentLeak(doc_list)])) 336 337 return additional_results … … 537 538 tests_by_dir[directory].append(test_input) 538 539 539 for directory, test_inputs in tests_by_dir.iteritems():540 for directory, test_inputs in iteritems(tests_by_dir): 540 541 shard = TestShard(directory, test_inputs) 541 542 shards.append(shard) -
trunk/Tools/Scripts/webkitpy/layout_tests/controllers/manager.py
r249652 r252443 45 45 from webkitpy.common.checkout.scm.detection import SCMDetector 46 46 from webkitpy.common.net.file_uploader import FileUploader 47 from webkitpy.common.iteration_compatibility import iteritems, itervalues 47 48 from webkitpy.layout_tests.controllers.layout_test_finder import LayoutTestFinder 48 49 from webkitpy.layout_tests.controllers.layout_test_runner import LayoutTestRunner … … 219 220 220 221 # Check to make sure we're not skipping every test. 221 if not sum([len(tests) for tests in tests_to_run_by_device.itervalues()]):222 if not sum([len(tests) for tests in itervalues(tests_to_run_by_device)]): 222 223 _log.critical('No tests to run.') 223 224 return test_run_results.RunDetails(exit_code=-1) 224 225 225 needs_http = any((self._is_http_test(test) and not self._needs_web_platform_test(test)) for tests in tests_to_run_by_device.itervalues() for test in tests)226 needs_web_platform_test_server = any(self._needs_web_platform_test(test) for tests in tests_to_run_by_device.itervalues() for test in tests)227 needs_websockets = any(self._is_websocket_test(test) for tests in tests_to_run_by_device.itervalues() for test in tests)226 needs_http = any((self._is_http_test(test) and not self._needs_web_platform_test(test)) for tests in itervalues(tests_to_run_by_device) for test in tests) 227 needs_web_platform_test_server = any(self._needs_web_platform_test(test) for tests in itervalues(tests_to_run_by_device) for test in tests) 228 needs_websockets = any(self._is_websocket_test(test) for tests in itervalues(tests_to_run_by_device) for test in tests) 228 229 self._runner = LayoutTestRunner(self._options, self._port, self._printer, self._results_directory, self._test_is_slow, 229 230 needs_http=needs_http, needs_web_platform_test_server=needs_web_platform_test_server, needs_websockets=needs_websockets) … … 428 429 """ 429 430 crashed_processes = [] 430 for test, result in run_results.unexpected_results_by_name.ite ritems():431 for test, result in run_results.unexpected_results_by_name.items(): 431 432 if (result.type != test_expectations.CRASH): 432 433 continue … … 438 439 sample_files = self._port.look_for_new_samples(crashed_processes, start_time) 439 440 if sample_files: 440 for test, sample_file in sample_files.ite ritems():441 for test, sample_file in sample_files.items(): 441 442 writer = TestResultWriter(self._port._filesystem, self._port, self._port.results_directory(), test) 442 443 writer.copy_sample_file(sample_file) … … 444 445 crash_logs = self._port.look_for_new_crash_logs(crashed_processes, start_time) 445 446 if crash_logs: 446 for test, crash_log in crash_logs.ite ritems():447 for test, crash_log in crash_logs.items(): 447 448 writer = TestResultWriter(self._port._filesystem, self._port, self._port.results_directory(), test) 448 449 writer.write_crash_log(crash_log) … … 492 493 493 494 results_trie = {} 494 for result in results.results_by_name.itervalues():495 for result in itervalues(results.results_by_name): 495 496 if result.type == test_expectations.SKIP: 496 497 continue … … 646 647 stats[result.test_name] = {'results': (_worker_number(result.worker_name), result.test_number, result.pid, int(result.test_run_time * 1000), int(result.total_run_time * 1000))} 647 648 stats_trie = {} 648 for name, value in stats.iteritems():649 for name, value in iteritems(stats): 649 650 json_results_generator.add_path_to_trie(name, value, stats_trie) 650 651 return stats_trie -
trunk/Tools/Scripts/webkitpy/port/base.py
r252058 r252443 501 501 if not self._filesystem.exists(baseline_path): 502 502 return None 503 text = self._filesystem.read_binary_file(baseline_path)503 text = decode_for(self._filesystem.read_binary_file(baseline_path), str) 504 504 return text.replace("\r\n", "\n") 505 505 -
trunk/Tools/Scripts/webkitpy/port/mock_drt.py
r233651 r252443 49 49 sys.path.append(script_dir) 50 50 51 from webkitpy.common.unicode_compatibility import decode_for 51 52 from webkitpy.common.system.systemhost import SystemHost 52 53 from webkitpy.port.driver import DriverInput, DriverOutput, DriverProxy … … 231 232 self._stdout.write('Content-Type: image/png\n') 232 233 self._stdout.write('Content-Length: %s\n' % len(output.image)) 233 self._stdout.write( output.image)234 self._stdout.write(decode_for(output.image, str)) 234 235 self._stdout.write('#EOF\n') 235 236 self._stdout.flush()
Note:
See TracChangeset
for help on using the changeset viewer.