| OLD | NEW |
| 1 # Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2006-2008 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 elif line.startswith("#MD5:"): | 71 elif line.startswith("#MD5:"): |
| 72 local_test_args.hash = line.rstrip()[5:] | 72 local_test_args.hash = line.rstrip()[5:] |
| 73 elif line.startswith("#TEST_TIMED_OUT"): | 73 elif line.startswith("#TEST_TIMED_OUT"): |
| 74 # Test timed out, but we still need to read until #EOF. | 74 # Test timed out, but we still need to read until #EOF. |
| 75 crash_or_timeout = True | 75 crash_or_timeout = True |
| 76 failures.append(test_failures.FailureTimeout()) | 76 failures.append(test_failures.FailureTimeout()) |
| 77 else: | 77 else: |
| 78 outlines.append(line) | 78 outlines.append(line) |
| 79 line = proc.stdout.readline() | 79 line = proc.stdout.readline() |
| 80 | 80 |
| 81 # If we had any stderr output, append that. This is not ideal, but at least |
| 82 # it'll catch errors. |
| 83 line = proc.stderr.readline() |
| 84 while line.rstrip() != "#EOF": |
| 85 # TODO(pamg): We suppress this stderr message temporarily so we can run |
| 86 # the tests deterministically until someone has a chance to fix the |
| 87 # underlying problem. |
| 88 # See http://code.google.com/p/chromium/issues/detail?id=4285 |
| 89 if not line.endswith('alias ISO-8859-8-I maps to ISO-8859-8-I already, but' |
| 90 ' someone is trying to make it map to ISO-8859-8'): |
| 91 outlines.append(line) |
| 92 line = proc.stderr.readline() |
| 93 |
| 81 # Check the output and save the results. | 94 # Check the output and save the results. |
| 82 for test_type in test_types: | 95 for test_type in test_types: |
| 83 new_failures = test_type.CompareOutput(filename, proc, | 96 new_failures = test_type.CompareOutput(filename, proc, |
| 84 ''.join(outlines), | 97 ''.join(outlines), |
| 85 local_test_args) | 98 local_test_args) |
| 86 # Don't add any more failures if we already have a crash or timeout, so | 99 # Don't add any more failures if we already have a crash or timeout, so |
| 87 # we don't double-report those tests. | 100 # we don't double-report those tests. |
| 88 if not crash_or_timeout: | 101 if not crash_or_timeout: |
| 89 failures.extend(new_failures) | 102 failures.extend(new_failures) |
| 90 | 103 |
| 91 return failures | 104 return failures |
| 92 | 105 |
| 93 | 106 |
| 94 def StartTestShell(binary, args): | 107 def StartTestShell(binary, args): |
| 95 """Returns the process for a new test_shell started in layout-tests mode.""" | 108 """Returns the process for a new test_shell started in layout-tests mode.""" |
| 96 cmd = [binary, '--layout-tests'] + args | 109 cmd = [binary, '--layout-tests'] + args |
| 110 # We'd really like to combine stderr into stdout here by setting stderr to |
| 111 # subprocess.STDOUT, but on Windows that's just dropping stderr output on |
| 112 # the floor, at least in Python 2.4.1. |
| 97 return subprocess.Popen(cmd, | 113 return subprocess.Popen(cmd, |
| 98 stdin=subprocess.PIPE, | 114 stdin=subprocess.PIPE, |
| 99 stdout=subprocess.PIPE, | 115 stdout=subprocess.PIPE, |
| 100 stderr=subprocess.STDOUT) | 116 stderr=subprocess.PIPE) |
| 101 | 117 |
| 102 | 118 |
| 103 class SingleTestThread(threading.Thread): | 119 class SingleTestThread(threading.Thread): |
| 104 """Thread wrapper for running a single test file.""" | 120 """Thread wrapper for running a single test file.""" |
| 105 def __init__(self, test_shell_binary, shell_args, test_uri, filename, | 121 def __init__(self, test_shell_binary, shell_args, test_uri, filename, |
| 106 test_types, test_args): | 122 test_types, test_args): |
| 107 """ | 123 """ |
| 108 Args: | 124 Args: |
| 109 test_uri: full file:// or http:// URI of the test file to be run | 125 test_uri: full file:// or http:// URI of the test file to be run |
| 110 filename: absolute local path to the test file | 126 filename: absolute local path to the test file |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 | 285 |
| 270 def _KillTestShell(self): | 286 def _KillTestShell(self): |
| 271 """Kill the test shell process if it's running.""" | 287 """Kill the test shell process if it's running.""" |
| 272 if self._test_shell_proc: | 288 if self._test_shell_proc: |
| 273 self._test_shell_proc.stdin.close() | 289 self._test_shell_proc.stdin.close() |
| 274 self._test_shell_proc.stdout.close() | 290 self._test_shell_proc.stdout.close() |
| 275 if self._test_shell_proc.stderr: | 291 if self._test_shell_proc.stderr: |
| 276 self._test_shell_proc.stderr.close() | 292 self._test_shell_proc.stderr.close() |
| 277 self._test_shell_proc = None | 293 self._test_shell_proc = None |
| 278 | 294 |
| OLD | NEW |