| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 """Utility module for testharness.""" | 5 """Utility module for testharness.""" |
| 6 | 6 |
| 7 | 7 |
| 8 # const definitions | 8 # const definitions |
| 9 TESTHARNESSREPORT_HEADER = 'This is a testharness.js-based test.' | 9 TESTHARNESSREPORT_HEADER = 'This is a testharness.js-based test.' |
| 10 TESTHARNESSREPORT_FOOTER = 'Harness: the test ran to completion.' | 10 TESTHARNESSREPORT_FOOTER = 'Harness: the test ran to completion.' |
| 11 | 11 |
| 12 | 12 |
| 13 def is_all_pass_testharness_result(content_text): |
| 14 """Returns whether |content_text| is a testharness result that only contains
PASS lines.""" |
| 15 return (is_testharness_output(content_text) and |
| 16 is_testharness_output_passing(content_text) and |
| 17 not is_testharness_output_with_console_errors_or_warnings(content_te
xt)) |
| 18 |
| 19 |
| 13 def is_testharness_output(content_text): | 20 def is_testharness_output(content_text): |
| 14 """Returns whether the content_text in parameter is a testharness output.""" | 21 """Returns whether the content_text in parameter is a testharness output.""" |
| 15 | 22 |
| 16 # Leading and trailing white spaces are accepted. | 23 # Leading and trailing white spaces are accepted. |
| 17 lines = content_text.strip().splitlines() | 24 lines = content_text.strip().splitlines() |
| 18 lines = [line.strip() for line in lines] | 25 lines = [line.strip() for line in lines] |
| 19 | 26 |
| 20 # A testharness output is defined as containing the header and the footer. | 27 # A testharness output is defined as containing the header and the footer. |
| 21 found_header = False | 28 found_header = False |
| 22 found_footer = False | 29 found_footer = False |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 Note: | 92 Note: |
| 86 It is expected that the |content_text| is a testharness output. | 93 It is expected that the |content_text| is a testharness output. |
| 87 """ | 94 """ |
| 88 | 95 |
| 89 lines = content_text.strip().splitlines() | 96 lines = content_text.strip().splitlines() |
| 90 for line in lines: | 97 for line in lines: |
| 91 if line.startswith('CONSOLE ERROR:') or line.startswith('CONSOLE WARNING
:'): | 98 if line.startswith('CONSOLE ERROR:') or line.startswith('CONSOLE WARNING
:'): |
| 92 return True | 99 return True |
| 93 | 100 |
| 94 return False | 101 return False |
| OLD | NEW |