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 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 Args: | 353 Args: |
354 test_info: Object containing the test filename, uri and timeout | 354 test_info: Object containing the test filename, uri and timeout |
355 | 355 |
356 Return: | 356 Return: |
357 A list of TestFailure objects describing the error. | 357 A list of TestFailure objects describing the error. |
358 """ | 358 """ |
359 self._EnsureTestShellIsRunning() | 359 self._EnsureTestShellIsRunning() |
360 # Args to test_shell is a space-separated list of "uri timeout pixel_hash" | 360 # Args to test_shell is a space-separated list of "uri timeout pixel_hash" |
361 # The timeout and pixel_hash are optional. The timeout is used if this | 361 # The timeout and pixel_hash are optional. The timeout is used if this |
362 # test has a custom timeout. The pixel_hash is used to avoid doing an image | 362 # test has a custom timeout. The pixel_hash is used to avoid doing an image |
363 # dump if the checksums match. | 363 # dump if the checksums match, so it should be set to a bogus value if we |
| 364 # are generating a new baseline. (Otherwise, an image from a previous run |
| 365 # will be copied into the baseline.) |
| 366 image_hash = test_info.image_hash |
| 367 if image_hash and self._test_args.new_baseline: |
| 368 image_hash = "" |
364 self._test_shell_proc.stdin.write(("%s %s %s\n" % | 369 self._test_shell_proc.stdin.write(("%s %s %s\n" % |
365 (test_info.uri, test_info.timeout, test_info.image_hash))) | 370 (test_info.uri, test_info.timeout, image_hash))) |
366 | 371 |
367 # If the test shell is dead, the above may cause an IOError as we | 372 # If the test shell is dead, the above may cause an IOError as we |
368 # try to write onto the broken pipe. If this is the first test for | 373 # try to write onto the broken pipe. If this is the first test for |
369 # this test shell process, than the test shell did not | 374 # this test shell process, than the test shell did not |
370 # successfully start. If this is not the first test, then the | 375 # successfully start. If this is not the first test, then the |
371 # previous tests have caused some kind of delayed crash. We don't | 376 # previous tests have caused some kind of delayed crash. We don't |
372 # try to recover here. | 377 # try to recover here. |
373 self._test_shell_proc.stdin.flush() | 378 self._test_shell_proc.stdin.flush() |
374 | 379 |
375 stats = ProcessOutput(self._test_shell_proc, test_info, self._test_types, | 380 stats = ProcessOutput(self._test_shell_proc, test_info, self._test_types, |
(...skipping 17 matching lines...) Expand all Loading... |
393 """Kill the test shell process if it's running.""" | 398 """Kill the test shell process if it's running.""" |
394 if self._test_shell_proc: | 399 if self._test_shell_proc: |
395 self._test_shell_proc.stdin.close() | 400 self._test_shell_proc.stdin.close() |
396 self._test_shell_proc.stdout.close() | 401 self._test_shell_proc.stdout.close() |
397 if self._test_shell_proc.stderr: | 402 if self._test_shell_proc.stderr: |
398 self._test_shell_proc.stderr.close() | 403 self._test_shell_proc.stderr.close() |
399 if sys.platform not in ('win32', 'cygwin'): | 404 if sys.platform not in ('win32', 'cygwin'): |
400 # Closing stdin/stdout/stderr hangs sometimes on OS X. | 405 # Closing stdin/stdout/stderr hangs sometimes on OS X. |
401 subprocess.Popen(["kill", "-9", str(self._test_shell_proc.pid)]) | 406 subprocess.Popen(["kill", "-9", str(self._test_shell_proc.pid)]) |
402 self._test_shell_proc = None | 407 self._test_shell_proc = None |
OLD | NEW |