| 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 (line != '' and | |
| 90 # not line.endswith('alias ISO-8859-8-I maps to ISO-8859-8-I already, ' | |
| 91 # 'but someone is trying to make it map to ' | |
| 92 # 'ISO-8859-8')): | |
| 93 # outlines.append(line) | |
| 94 # line = proc.stderr.readline() | |
| 95 | |
| 96 # Check the output and save the results. | 81 # Check the output and save the results. |
| 97 for test_type in test_types: | 82 for test_type in test_types: |
| 98 new_failures = test_type.CompareOutput(filename, proc, | 83 new_failures = test_type.CompareOutput(filename, proc, |
| 99 ''.join(outlines), | 84 ''.join(outlines), |
| 100 local_test_args) | 85 local_test_args) |
| 101 # Don't add any more failures if we already have a crash or timeout, so | 86 # Don't add any more failures if we already have a crash or timeout, so |
| 102 # we don't double-report those tests. | 87 # we don't double-report those tests. |
| 103 if not crash_or_timeout: | 88 if not crash_or_timeout: |
| 104 failures.extend(new_failures) | 89 failures.extend(new_failures) |
| 105 | 90 |
| 106 return failures | 91 return failures |
| 107 | 92 |
| 108 | 93 |
| 109 def StartTestShell(binary, args): | 94 def StartTestShell(binary, args): |
| 110 """Returns the process for a new test_shell started in layout-tests mode.""" | 95 """Returns the process for a new test_shell started in layout-tests mode.""" |
| 111 cmd = [binary, '--layout-tests'] + args | 96 cmd = [binary, '--layout-tests'] + args |
| 112 # We'd really like to combine stderr into stdout here by setting stderr to | |
| 113 # subprocess.STDOUT, but on Windows that's just dropping stderr output on | |
| 114 # the floor, at least in Python 2.4.1. | |
| 115 return subprocess.Popen(cmd, | 97 return subprocess.Popen(cmd, |
| 116 stdin=subprocess.PIPE, | 98 stdin=subprocess.PIPE, |
| 117 stdout=subprocess.PIPE, | 99 stdout=subprocess.PIPE, |
| 118 stderr=subprocess.PIPE) | 100 stderr=subprocess.STDOUT) |
| 119 | 101 |
| 120 | 102 |
| 121 class SingleTestThread(threading.Thread): | 103 class SingleTestThread(threading.Thread): |
| 122 """Thread wrapper for running a single test file.""" | 104 """Thread wrapper for running a single test file.""" |
| 123 def __init__(self, test_shell_binary, shell_args, test_uri, filename, | 105 def __init__(self, test_shell_binary, shell_args, test_uri, filename, |
| 124 test_types, test_args): | 106 test_types, test_args): |
| 125 """ | 107 """ |
| 126 Args: | 108 Args: |
| 127 test_uri: full file:// or http:// URI of the test file to be run | 109 test_uri: full file:// or http:// URI of the test file to be run |
| 128 filename: absolute local path to the test file | 110 filename: absolute local path to the test file |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 | 269 |
| 288 def _KillTestShell(self): | 270 def _KillTestShell(self): |
| 289 """Kill the test shell process if it's running.""" | 271 """Kill the test shell process if it's running.""" |
| 290 if self._test_shell_proc: | 272 if self._test_shell_proc: |
| 291 self._test_shell_proc.stdin.close() | 273 self._test_shell_proc.stdin.close() |
| 292 self._test_shell_proc.stdout.close() | 274 self._test_shell_proc.stdout.close() |
| 293 if self._test_shell_proc.stderr: | 275 if self._test_shell_proc.stderr: |
| 294 self._test_shell_proc.stderr.close() | 276 self._test_shell_proc.stderr.close() |
| 295 self._test_shell_proc = None | 277 self._test_shell_proc = None |
| 296 | 278 |
| OLD | NEW |