| OLD | NEW |
| 1 # Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 """A Thread object for running the test shell and processing URLs from a | 5 """A Thread object for running the test shell and processing URLs from a |
| 6 shared queue. | 6 shared queue. |
| 7 | 7 |
| 8 Each thread runs a separate instance of the test_shell binary and validates | 8 Each thread runs a separate instance of the test_shell binary and validates |
| 9 the output. When there are no more URLs to process in the shared queue, the | 9 the output. When there are no more URLs to process in the shared queue, the |
| 10 thread exits. | 10 thread exits. |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 """Main work entry point of the thread. Basically we pull urls from the | 238 """Main work entry point of the thread. Basically we pull urls from the |
| 239 filename queue and run the tests until we run out of urls.""" | 239 filename queue and run the tests until we run out of urls.""" |
| 240 batch_size = 0 | 240 batch_size = 0 |
| 241 batch_count = 0 | 241 batch_count = 0 |
| 242 if self._options.batch_size: | 242 if self._options.batch_size: |
| 243 try: | 243 try: |
| 244 batch_size = int(self._options.batch_size) | 244 batch_size = int(self._options.batch_size) |
| 245 except: | 245 except: |
| 246 logging.info("Ignoring invalid batch size '%s'" % | 246 logging.info("Ignoring invalid batch size '%s'" % |
| 247 self._options.batch_size) | 247 self._options.batch_size) |
| 248 |
| 249 # Append tests we're running to the existing tests_run.txt file. |
| 250 # This is created in run_webkit_tests.py:_PrepareListsAndPrintOutput. |
| 251 tests_run_filename = os.path.join(self._options.results_directory, |
| 252 "tests_run.txt") |
| 253 tests_run_file = open(tests_run_filename, "a") |
| 254 |
| 248 while True: | 255 while True: |
| 249 if self._canceled: | 256 if self._canceled: |
| 250 logging.info('Testing canceled') | 257 logging.info('Testing canceled') |
| 258 tests_run_file.close() |
| 251 return | 259 return |
| 252 | 260 |
| 253 if len(self._filename_list) is 0: | 261 if len(self._filename_list) is 0: |
| 254 if self._current_dir is not None: | 262 if self._current_dir is not None: |
| 255 self._directory_timing_stats[self._current_dir] = \ | 263 self._directory_timing_stats[self._current_dir] = \ |
| 256 (self._num_tests_in_current_dir, | 264 (self._num_tests_in_current_dir, |
| 257 time.time() - self._current_dir_start_time) | 265 time.time() - self._current_dir_start_time) |
| 258 | 266 |
| 259 try: | 267 try: |
| 260 self._current_dir, self._filename_list = \ | 268 self._current_dir, self._filename_list = \ |
| 261 self._filename_list_queue.get_nowait() | 269 self._filename_list_queue.get_nowait() |
| 262 except Queue.Empty: | 270 except Queue.Empty: |
| 263 self._KillTestShell() | 271 self._KillTestShell() |
| 264 logging.debug("queue empty, quitting test shell thread") | 272 logging.debug("queue empty, quitting test shell thread") |
| 273 tests_run_file.close() |
| 265 return | 274 return |
| 266 | 275 |
| 267 self._num_tests_in_current_dir = len(self._filename_list) | 276 self._num_tests_in_current_dir = len(self._filename_list) |
| 268 self._current_dir_start_time = time.time() | 277 self._current_dir_start_time = time.time() |
| 269 | 278 |
| 270 test_info = self._filename_list.pop() | 279 test_info = self._filename_list.pop() |
| 271 | 280 |
| 272 # We have a url, run tests. | 281 # We have a url, run tests. |
| 273 batch_count += 1 | 282 batch_count += 1 |
| 274 if self._options.run_singly: | 283 if self._options.run_singly: |
| 275 failures = self._RunTestSingly(test_info) | 284 failures = self._RunTestSingly(test_info) |
| 276 else: | 285 else: |
| 277 failures = self._RunTest(test_info) | 286 failures = self._RunTest(test_info) |
| 278 | 287 |
| 279 filename = test_info.filename | 288 filename = test_info.filename |
| 289 tests_run_file.write(filename + "\n") |
| 280 if failures: | 290 if failures: |
| 281 # Check and kill test shell if we need too. | 291 # Check and kill test shell if we need too. |
| 282 if len([1 for f in failures if f.ShouldKillTestShell()]): | 292 if len([1 for f in failures if f.ShouldKillTestShell()]): |
| 283 self._KillTestShell() | 293 self._KillTestShell() |
| 284 # Reset the batch count since the shell just bounced. | 294 # Reset the batch count since the shell just bounced. |
| 285 batch_count = 0 | 295 batch_count = 0 |
| 286 # Print the error message(s). | 296 # Print the error message(s). |
| 287 error_str = '\n'.join([' ' + f.Message() for f in failures]) | 297 error_str = '\n'.join([' ' + f.Message() for f in failures]) |
| 288 logging.error("%s failed:\n%s" % | 298 logging.error("%s failed:\n%s" % |
| 289 (path_utils.RelativeTestFilename(filename), error_str)) | 299 (path_utils.RelativeTestFilename(filename), error_str)) |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 """Kill the test shell process if it's running.""" | 405 """Kill the test shell process if it's running.""" |
| 396 if self._test_shell_proc: | 406 if self._test_shell_proc: |
| 397 self._test_shell_proc.stdin.close() | 407 self._test_shell_proc.stdin.close() |
| 398 self._test_shell_proc.stdout.close() | 408 self._test_shell_proc.stdout.close() |
| 399 if self._test_shell_proc.stderr: | 409 if self._test_shell_proc.stderr: |
| 400 self._test_shell_proc.stderr.close() | 410 self._test_shell_proc.stderr.close() |
| 401 if sys.platform not in ('win32', 'cygwin'): | 411 if sys.platform not in ('win32', 'cygwin'): |
| 402 # Closing stdin/stdout/stderr hangs sometimes on OS X. | 412 # Closing stdin/stdout/stderr hangs sometimes on OS X. |
| 403 subprocess.Popen(["kill", "-9", str(self._test_shell_proc.pid)]) | 413 subprocess.Popen(["kill", "-9", str(self._test_shell_proc.pid)]) |
| 404 self._test_shell_proc = None | 414 self._test_shell_proc = None |
| OLD | NEW |