Changeset 90796 in webkit
- Timestamp:
- Jul 11, 2011 5:10:19 PM (13 years ago)
- Location:
- trunk/Tools
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r90793 r90796 1 2011-07-08 Dirk Pranke <dpranke@chromium.org> 2 3 nrwt: linting fixes 4 https://bugs.webkit.org/show_bug.cgi?id=64225 5 6 Reviewed by Eric Siedel. 7 8 Miscellaneous linting fixes. The most notable change is that 9 we add public attributes for user, executive, filesystem, and 10 options on the Port object, so we don't have to refer to the 11 "protected" versions all over the place". 12 13 * Scripts/webkitpy/layout_tests/controllers/manager.py: 14 * Scripts/webkitpy/layout_tests/controllers/manager_worker_broker.py: 15 * Scripts/webkitpy/layout_tests/controllers/message_broker.py: 16 * Scripts/webkitpy/layout_tests/controllers/message_broker_unittest.py: 17 * Scripts/webkitpy/layout_tests/controllers/worker.py: 18 * Scripts/webkitpy/layout_tests/port/base.py: 19 * Scripts/webkitpy/layout_tests/run_webkit_tests.py: 20 1 21 2011-07-11 Ryosuke Niwa <rniwa@webkit.org> 2 22 -
trunk/Tools/Scripts/webkitpy/layout_tests/controllers/manager.py
r90679 r90796 38 38 from __future__ import with_statement 39 39 40 import copy41 40 import errno 42 41 import logging … … 54 53 from webkitpy.layout_tests.layout_package import json_layout_results_generator 55 54 from webkitpy.layout_tests.layout_package import json_results_generator 56 from webkitpy.layout_tests.layout_package import test_results_uploader57 55 from webkitpy.layout_tests.models import test_expectations 58 56 from webkitpy.layout_tests.models import test_failures … … 62 60 from webkitpy.layout_tests.views import printing 63 61 64 from webkitpy.thirdparty import simplejson65 62 from webkitpy.tool import grammar 66 63 … … 224 221 """Raised when a test run should be stopped immediately.""" 225 222 def __init__(self, reason): 223 Exception.__init__(self) 226 224 self.reason = reason 227 225 self.msg = reason … … 270 268 """ 271 269 self._port = port 272 self._fs = port. _filesystem270 self._fs = port.filesystem 273 271 self._options = options 274 272 self._printer = printer 275 273 self._message_broker = None 274 self._expectations = None 276 275 277 276 self.HTTP_SUBDIR = port.TEST_PATH_SEPARATOR + 'http' + port.TEST_PATH_SEPARATOR … … 323 322 return path[len(self.LAYOUT_TESTS_DIRECTORY + self._port.TEST_PATH_SEPARATOR):] 324 323 if path.startswith(self.LAYOUT_TESTS_DIRECTORY + self._fs.sep): 325 return path[len(self.LAYOUT_TEST _DIRECTORY + self._fs.sep):]324 return path[len(self.LAYOUT_TESTS_DIRECTORY + self._fs.sep):] 326 325 return path 327 326 … … 409 408 test_size = int(chunk_len) 410 409 assert(test_size > 0) 411 except :410 except AssertionError: 412 411 _log.critical("invalid chunk '%s'" % chunk_value) 413 412 return None … … 755 754 # reading messsages after receiving a stop, we can be sure each 756 755 # worker will get a stop message and hence they will all shut down. 757 for iin xrange(num_workers):756 for _ in xrange(num_workers): 758 757 manager_connection.post_message('stop') 759 758 … … 761 760 while not self.is_done(): 762 761 # Temporarily disabled to see how this code effect performance on the buildbots. 763 # if self._port.executive ().running_pids(self._port.is_crash_reporter):762 # if self._port.executive.running_pids(self._port.is_crash_reporter): 764 763 # self._printer.print_update("Waiting for crash reporter ...") 765 # self._port.executive ().wait_newest(self._port.is_crash_reporter)764 # self._port.executive.wait_newest(self._port.is_crash_reporter) 766 765 manager_connection.run_message_loop(delay_secs=1.0) 767 766 … … 1092 1091 generator.upload_json_files(json_files) 1093 1092 1094 def _print_config(self):1093 def print_config(self): 1095 1094 """Prints the configuration for the test run.""" 1096 1095 p = self._printer … … 1292 1291 mean = sum(timings) / num_tests 1293 1292 1294 for tim ein timings:1295 sum_of_deviations = math.pow(tim e- mean, 2)1293 for timing in timings: 1294 sum_of_deviations = math.pow(timing - mean, 2) 1296 1295 1297 1296 std_deviation = math.sqrt(sum_of_deviations / num_tests) … … 1438 1437 1439 1438 def _log_worker_stack(self, stack): 1440 webkitpydir = self._port.path_from_webkit_base('Tools', 'Scripts', 'webkitpy') + self._port. _filesystem.sep1439 webkitpydir = self._port.path_from_webkit_base('Tools', 'Scripts', 'webkitpy') + self._port.filesystem.sep 1441 1440 for filename, line_number, function_name, text in stack: 1442 1441 if filename.startswith(webkitpydir): … … 1446 1445 1447 1446 1448 def read_test_files(fs, file s, test_path_separator):1447 def read_test_files(fs, filenames, test_path_separator): 1449 1448 tests = [] 1450 for file in files:1449 for filename in filenames: 1451 1450 try: 1452 1451 if test_path_separator != fs.sep: 1453 file = file.replace(test_path_separator, fs.sep)1454 file_contents = fs.read_text_file(file ).split('\n')1452 filename = filename.replace(test_path_separator, fs.sep) 1453 file_contents = fs.read_text_file(filename).split('\n') 1455 1454 for line in file_contents: 1456 1455 line = test_expectations.strip_comments(line) … … 1489 1488 try: 1490 1489 return int(val) 1491 except :1490 except ValueError: 1492 1491 return val 1493 1492 -
trunk/Tools/Scripts/webkitpy/layout_tests/controllers/manager_worker_broker.py
r90679 r90796 46 46 import Queue 47 47 import sys 48 import thread49 import threading50 import time51 48 52 49 # Handle Python < 2.6 where multiprocessing isn't available. … … 56 53 multiprocessing = None 57 54 58 from webkitpy.common.system import stack_utils 59 from webkitpy.layout_tests import port 55 from webkitpy import layout_tests 60 56 from webkitpy.layout_tests.controllers import message_broker 61 57 from webkitpy.layout_tests.views import printing … … 112 108 113 109 class AbstractWorker(message_broker.BrokerClient): 114 def __init__(self, broker_connection, worker_number, options):110 def __init__(self, worker_connection, worker_number, options): 115 111 """The constructor should be used to do any simple initialization 116 112 necessary, but should not do anything that creates data structures … … 120 116 121 117 Args: 122 broker_connection - handle to the BrokerConnection object creating118 worker_connection - handle to the BrokerConnection object creating 123 119 the worker and that can be used for messaging. 124 120 worker_number - identifier for this particular worker 125 121 options - command-line argument object from optparse""" 126 127 raise NotImplementedError 122 message_broker.BrokerClient.__init__(self) 123 self._worker_connection = worker_connection 124 self._options = options 125 self._worker_number = worker_number 126 self._name = 'worker/%d' % worker_number 128 127 129 128 def run(self, port): … … 214 213 class _InlineWorkerConnection(_WorkerConnection): 215 214 def __init__(self, broker, port, manager_client, worker_class, worker_number): 216 _WorkerConnection.__init__(self, broker, worker_class, worker_number, port. _options)215 _WorkerConnection.__init__(self, broker, worker_class, worker_number, port.options) 217 216 self._alive = False 218 217 self._port = port … … 255 254 def run(self): 256 255 options = self._options 257 port_obj = port.get(self._platform_name, options)256 port_obj = layout_tests.port.get(self._platform_name, options) 258 257 259 258 # The unix multiprocessing implementation clones the -
trunk/Tools/Scripts/webkitpy/layout_tests/controllers/message_broker.py
r90679 r90796 58 58 BrokerConnection). 59 59 """ 60 import sys 61 import traceback 60 62 61 63 import cPickle 62 64 import logging 63 65 import Queue 64 import sys65 import time66 import traceback67 66 68 67 from webkitpy.common.system import stack_utils … … 81 80 src indicates the name of the sender. If the message contains values in 82 81 the message body, those will be provided as optparams.""" 83 84 def __init__(self, *optargs, **kwargs):85 raise NotImplementedError86 82 87 83 def is_done(self): … … 157 153 class _Message(object): 158 154 @staticmethod 159 def loads(str ):160 obj = cPickle.loads(str )155 def loads(string_value): 156 obj = cPickle.loads(string_value) 161 157 assert(isinstance(obj, _Message)) 162 158 return obj -
trunk/Tools/Scripts/webkitpy/layout_tests/controllers/message_broker_unittest.py
r90523 r90796 66 66 67 67 def test_brokerclient_is_abstract(self): 68 # Test that we can't create an instance directly.69 self.assertRaises(NotImplementedError, message_broker.BrokerClient)70 71 class TestClient(message_broker.BrokerClient):72 def __init__(self):73 pass74 75 68 # Test that all the base class methods are abstract and have the 76 69 # signature we expect. 77 obj = TestClient()70 obj = message_broker.BrokerClient() 78 71 self.assertRaises(NotImplementedError, obj.is_done) 79 72 self.assertRaises(NotImplementedError, obj.name) -
trunk/Tools/Scripts/webkitpy/layout_tests/controllers/worker.py
r90679 r90796 45 45 class Worker(manager_worker_broker.AbstractWorker): 46 46 def __init__(self, worker_connection, worker_number, options): 47 self._worker_connection = worker_connection 48 self._worker_number = worker_number 49 self._options = options 50 self._name = 'worker/%d' % worker_number 47 manager_worker_broker.AbstractWorker.__init__(self, worker_connection, worker_number, options) 51 48 self._done = False 52 49 self._canceled = False 53 50 self._port = None 51 self._batch_size = 0 52 self._batch_count = 0 53 self._filesystem = None 54 self._driver = None 55 self._tests_run_file = None 56 self._tests_run_filename = None 54 57 55 58 def __del__(self): … … 63 66 across into a child process.""" 64 67 self._port = port 65 self._filesystem = port. _filesystem68 self._filesystem = port.filesystem 66 69 self._batch_count = 0 67 70 self._batch_size = self._options.batch_size 68 self._driver = None69 71 tests_run_filename = self._filesystem.join(port.results_directory(), 70 72 "tests_run%d.txt" % self._worker_number) … … 125 127 # 126 128 # Temporarily disabled to see how this code effect performance on the buildbots. 127 # self._port.executive ().wait_newest(self._port.is_crash_reporter)129 # self._port.executive.wait_newest(self._port.is_crash_reporter) 128 130 129 131 test_timeout_sec = self.timeout(test_input) … … 169 171 if self._options.run_singly: 170 172 return self._run_test_in_another_thread(test_input, timeout) 171 else: 172 return self._run_test_in_this_thread(test_input) 173 return result 173 return self._run_test_in_this_thread(test_input) 174 174 175 175 def clean_up_after_test(self, test_input, result): … … 214 214 worker = self 215 215 216 driver = worker._port.create_driver(worker._worker_number)216 driver = self._port.create_driver(self._worker_number) 217 217 driver.start() 218 218 219 219 class SingleTestThread(threading.Thread): 220 def __init__(self): 221 threading.Thread.__init__(self) 222 self.result = None 223 220 224 def run(self): 221 self.result = worker. _run_single_test(driver, test_input)225 self.result = worker.run_single_test(driver, test_input) 222 226 223 227 thread = SingleTestThread() 224 228 thread.start() 225 229 thread.join(thread_timeout_sec) 226 result = getattr(thread, 'result', None)230 result = thread.result 227 231 if thread.isAlive(): 228 232 # If join() returned with the thread still running, the … … 253 257 self._driver = self._port.create_driver(self._worker_number) 254 258 self._driver.start() 255 return self. _run_single_test(self._driver, test_input)256 257 def _run_single_test(self, driver, test_input):259 return self.run_single_test(self._driver, test_input) 260 261 def run_single_test(self, driver, test_input): 258 262 return single_test_runner.run_single_test(self._port, self._options, 259 263 test_input, driver, self._name) -
trunk/Tools/Scripts/webkitpy/layout_tests/port/base.py
r90607 r90796 37 37 import errno 38 38 import os 39 import sys40 import time41 39 42 40 from webkitpy.common.net.testoutputset import AggregateTestOutputSet … … 49 47 50 48 from webkitpy.common import system 51 from webkitpy.common.system import filesystem52 49 from webkitpy.common.system import logutils 53 50 from webkitpy.common.system import path … … 64 61 _log = logutils.get_logger(__file__) 65 62 66 67 63 class DummyOptions(object): 68 64 """Fake implementation of optparse.Values. Cloned from webkitpy.tool.mocktool.MockOptions.""" … … 104 100 # well-formed options object that had all of the necessary 105 101 # options defined on it. 106 self._options = options or DummyOptions() 107 108 self._executive = executive or Executive() 109 self._user = user or User() 110 self._filesystem = filesystem or system.filesystem.FileSystem() 111 self._config = config or port_config.Config(self._executive, self._filesystem) 102 self.options = options or DummyOptions() 103 104 self.executive = executive or Executive() 105 self.user = user or User() 106 self.filesystem = filesystem or system.filesystem.FileSystem() 107 self.config = config or port_config.Config(self.executive, self.filesystem) 108 109 # FIXME: Remove all of the old "protected" versions when we can. 110 self._options = self.options 111 self._executive = self.executive 112 self._filesystem = self.filesystem 113 self._user = self.user 114 self._config = self.config 112 115 113 116 self._helper = None … … 140 143 self._results_directory = None 141 144 142 def executive(self):143 return self._executive144 145 145 def wdiff_available(self): 146 146 if self._wdiff_available is None: … … 194 194 """Checks whether we can use the PrettyPatch ruby script.""" 195 195 try: 196 result= self._executive.run_command(['ruby', '--version'])196 _ = self._executive.run_command(['ruby', '--version']) 197 197 except OSError, e: 198 198 if e.errno in [errno.ENOENT, errno.EACCES, errno.ECHILD]: … … 216 216 217 217 try: 218 result= self._executive.run_command([self._path_to_wdiff(), '--help'])218 _ = self._executive.run_command([self._path_to_wdiff(), '--help']) 219 219 except OSError: 220 220 if logging: … … 226 226 def check_httpd(self): 227 227 if self._uses_apache(): 228 path = self._path_to_apache()228 httpd_path = self._path_to_apache() 229 229 else: 230 path = self._path_to_lighttpd()230 httpd_path = self._path_to_lighttpd() 231 231 232 232 try: 233 233 env = self.setup_environ_for_server() 234 return self._executive.run_command([ path, "-v"], env=env, return_exit_code=True) == 0235 except OSError , e:234 return self._executive.run_command([httpd_path, "-v"], env=env, return_exit_code=True) == 0 235 except OSError: 236 236 _log.error("No httpd found. Cannot run http tests.") 237 237 return False … … 270 270 # raw bytes and not unicode, so that they don't trigger join() 271 271 # trying to decode the input. 272 def to_raw_bytes(str ):273 if isinstance(str , unicode):274 return str .encode('utf-8')275 return str 272 def to_raw_bytes(string_value): 273 if isinstance(string_value, unicode): 274 return string_value.encode('utf-8') 275 return string_value 276 276 expected_filename = to_raw_bytes(expected_filename) 277 277 actual_filename = to_raw_bytes(actual_filename) … … 378 378 def expected_image(self, test_name): 379 379 """Returns the image we expect the test to produce.""" 380 path = self.expected_filename(test_name, '.png')381 if not self._filesystem.exists( path):380 baseline_path = self.expected_filename(test_name, '.png') 381 if not self._filesystem.exists(baseline_path): 382 382 return None 383 return self._filesystem.read_binary_file( path)383 return self._filesystem.read_binary_file(baseline_path) 384 384 385 385 def expected_audio(self, test_name): 386 path = self.expected_filename(test_name, '.wav')387 if not self._filesystem.exists( path):386 baseline_path = self.expected_filename(test_name, '.wav') 387 if not self._filesystem.exists(baseline_path): 388 388 return None 389 return self._filesystem.read_binary_file( path)389 return self._filesystem.read_binary_file(baseline_path) 390 390 391 391 def expected_text(self, test_name): … … 396 396 # output from DRT (instead treating it as a binary string), we read the 397 397 # baselines as a binary string, too. 398 path = self.expected_filename(test_name, '.txt')399 if not self._filesystem.exists( path):400 path = self.expected_filename(test_name, '.webarchive')401 if not self._filesystem.exists( path):398 baseline_path = self.expected_filename(test_name, '.txt') 399 if not self._filesystem.exists(baseline_path): 400 baseline_path = self.expected_filename(test_name, '.webarchive') 401 if not self._filesystem.exists(baseline_path): 402 402 return None 403 text = self._filesystem.read_binary_file( path)403 text = self._filesystem.read_binary_file(baseline_path) 404 404 return text.replace("\r\n", "\n") 405 405 … … 418 418 419 419 port = None 420 use_ssl = False421 420 422 421 relative_path = test_name … … 454 453 """Return True if the test name refers to a directory of tests.""" 455 454 # Used by test_expectations.py to apply rules to whole directories. 456 path = self.abspath_for_test(test_name)457 return self._filesystem.isdir( path)455 test_path = self.abspath_for_test(test_name) 456 return self._filesystem.isdir(test_path) 458 457 459 458 def test_exists(self, test_name): … … 461 460 # Used by test_expectations.py to determine if an entry refers to a 462 461 # valid test and by printing.py to determine if baselines exist. 463 path = self.abspath_for_test(test_name)464 return self._filesystem.exists( path)462 test_path = self.abspath_for_test(test_name) 463 return self._filesystem.exists(test_path) 465 464 466 465 def split_test(self, test_name): … … 482 481 return driver.cmd_line() 483 482 484 def update_baseline(self, path, data):483 def update_baseline(self, baseline_path, data): 485 484 """Updates the baseline for a test. 486 485 487 486 Args: 488 path: the actual path to use for baseline, not the path to487 baseline_path: the actual path to use for baseline, not the path to 489 488 the test. This function is used to update either generic or 490 489 platform-specific baselines, but we can't infer which here. 491 490 data: contents of the baseline. 492 491 """ 493 self._filesystem.write_binary_file( path, data)492 self._filesystem.write_binary_file(baseline_path, data) 494 493 495 494 def uri_to_test_name(self, uri): … … 522 521 """Return the absolute path to the top of the LayoutTests directory.""" 523 522 return self.path_from_webkit_base('LayoutTests') 523 524 def skipped_layout_tests(self): 525 return [] 524 526 525 527 def skips_layout_test(self, test_name): … … 537 539 return False 538 540 539 def maybe_make_directory(self, * path):541 def maybe_make_directory(self, *comps): 540 542 """Creates the specified directory if it doesn't already exist.""" 541 self._filesystem.maybe_make_directory(* path)543 self._filesystem.maybe_make_directory(*comps) 542 544 543 545 def name(self): … … 922 924 self.version = version or port.version() 923 925 self.architecture = architecture or port.architecture() 924 self.build_type = build_type or port. _options.configuration.lower()926 self.build_type = build_type or port.options.configuration.lower() 925 927 self.graphics_type = graphics_type or port.graphics_type() 926 928 … … 947 949 # every configuration on every system. 948 950 test_configurations = [] 949 for systemin self.all_systems():951 for version, architecture in self.all_systems(): 950 952 for build_type in self.all_build_types(): 951 953 for graphics_type in self.all_graphics_types(): 952 954 test_configurations.append(TestConfiguration( 953 version= system[0],954 architecture= system[1],955 version=version, 956 architecture=architecture, 955 957 build_type=build_type, 956 958 graphics_type=graphics_type)) -
trunk/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests.py
r90546 r90796 39 39 import sys 40 40 41 from webkitpy .common.net import resultsjsonparser42 from webkitpy.layout_tests import layout_package 41 from webkitpy import layout_tests 42 43 43 from webkitpy.layout_tests.controllers.manager import Manager, WorkerException 44 from webkitpy.layout_tests.layout_package import json_results_generator45 44 from webkitpy.layout_tests.views import printing 46 45 47 from webkitpy.common.system import user48 from webkitpy.thirdparty import simplejson49 50 import port51 46 52 47 _log = logging.getLogger(__name__) … … 87 82 try: 88 83 manager = Manager(port, options, printer) 89 manager. _print_config()84 manager.print_config() 90 85 91 86 printer.print_update("Collecting tests ...") … … 120 115 121 116 122 def _set_up_derived_options(port _obj, options):117 def _set_up_derived_options(port, options): 123 118 """Sets the options values that depend on other options values.""" 124 119 # We return a list of warnings to print after the printer is initialized. … … 126 121 127 122 if options.worker_model is None: 128 options.worker_model = port _obj.default_worker_model()123 options.worker_model = port.default_worker_model() 129 124 130 125 if options.worker_model == 'inline': … … 134 129 if not options.child_processes: 135 130 options.child_processes = os.environ.get("WEBKIT_TEST_CHILD_PROCESSES", 136 str(port _obj.default_child_processes()))131 str(port.default_child_processes())) 137 132 138 133 if not options.configuration: 139 options.configuration = port _obj.default_configuration()134 options.configuration = port.default_configuration() 140 135 141 136 if options.pixel_tests is None: … … 153 148 normalized_platform_directories = [] 154 149 for path in options.additional_platform_directory: 155 if not port _obj._filesystem.isabs(path):150 if not port.filesystem.isabs(path): 156 151 warnings.append("--additional-platform-directory=%s is ignored since it is not absolute" % path) 157 152 continue 158 normalized_platform_directories.append(port _obj._filesystem.normpath(path))153 normalized_platform_directories.append(port.filesystem.normpath(path)) 159 154 options.additional_platform_directory = normalized_platform_directories 160 155 … … 430 425 def main(): 431 426 options, args = parse_args() 432 port _obj =port.get(options.platform, options)433 return run(port _obj, options, args)427 port = layout_tests.port.get(options.platform, options) 428 return run(port, options, args) 434 429 435 430 … … 441 436 INTERRUPTED_EXIT_STATUS = signal.SIGINT + 128 442 437 sys.exit(INTERRUPTED_EXIT_STATUS) 443 except WorkerException , e:438 except WorkerException: 444 439 # This is a randomly chosen exit code that can be tested against to 445 440 # indicate that an unexpected exception occurred.
Note: See TracChangeset
for help on using the changeset viewer.