| OLD | NEW |
| 1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2013 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 """LayoutTests/ presubmit script for Blink. | 5 """LayoutTests/ presubmit script for Blink. |
| 6 | 6 |
| 7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts | 7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts |
| 8 for more details about the presubmit API built into gcl. | 8 for more details about the presubmit API built into gcl. |
| 9 """ | 9 """ |
| 10 | 10 |
| 11 import filecmp | 11 import filecmp |
| 12 | 12 |
| 13 | 13 |
| 14 def _CheckTestharnessResults(input_api, output_api): | 14 def _CheckTestharnessResults(input_api, output_api): |
| 15 """Checks for testharness.js test baseline files that contain only PASS line
s. | 15 expected_files = [f.AbsoluteLocalPath() for f in input_api.AffectedFiles() i
f f.LocalPath().endswith('-expected.txt') and f.Action() != 'D'] |
| 16 | 16 if len(expected_files) == 0: |
| 17 In general these files are unnecessary because for testharness.js tests, if
there is | |
| 18 no baseline file then the test is considered to pass when the output is all
PASS. | |
| 19 """ | |
| 20 baseline_files = _TestharnessBaselineFilesToCheck(input_api) | |
| 21 if not baseline_files: | |
| 22 return [] | 17 return [] |
| 23 | 18 |
| 24 checker_path = input_api.os_path.join(input_api.PresubmitLocalPath(), | 19 checker_path = input_api.os_path.join(input_api.PresubmitLocalPath(), |
| 25 '..', 'Tools', 'Scripts', 'check-testharness-expected-pass') | 20 '..', 'Tools', 'Scripts', 'check-testharness-expected-pass') |
| 26 | 21 |
| 27 args = [input_api.python_executable, checker_path] | 22 args = [input_api.python_executable, checker_path] |
| 28 args.extend(expected_files) | 23 args.extend(expected_files) |
| 29 _, errs = input_api.subprocess.Popen(args, | 24 _, errs = input_api.subprocess.Popen(args, |
| 30 stdout=input_api.subprocess.PIPE, | 25 stdout=input_api.subprocess.PIPE, |
| 31 stderr=input_api.subprocess.PIPE).communicate() | 26 stderr=input_api.subprocess.PIPE).communicate() |
| 32 if errs: | 27 if errs: |
| 33 return [output_api.PresubmitError(errs)] | 28 return [output_api.PresubmitError(errs)] |
| 34 return [] | 29 return [] |
| 35 | 30 |
| 36 | 31 |
| 37 def _TestharnessBaselineFilesToCheck(input_api): | |
| 38 """Returns a list of paths of -expected.txt files for testharness.js tests."
"" | |
| 39 baseline_files = [] | |
| 40 for f in input_api.AffectedFiles(): | |
| 41 if f.Action() == 'D': | |
| 42 continue | |
| 43 path = f.AbsoluteLocalPath() | |
| 44 if not path.endswith('-expected.txt'): | |
| 45 continue | |
| 46 if (input_api.os_path.join('LayoutTests', 'platform') in path or | |
| 47 input_api.os_path.join('LayoutTests', 'virtual') in path): | |
| 48 # We want to ignore files in LayoutTests/platform, because some all-
PASS | |
| 49 # platform specific baselines may be necessary to prevent fallback t
o a | |
| 50 # more general baseline; we also ignore files in LayoutTests/virtual | |
| 51 # for a similar reason; some all-pass baselines are necessary to | |
| 52 # prevent fallback to the corresponding non-virtual test baseline. | |
| 53 continue | |
| 54 baseline_files.append(path) | |
| 55 return baseline_files | |
| 56 | |
| 57 | |
| 58 def _CheckIdenticalFiles(input_api, output_api): | 32 def _CheckIdenticalFiles(input_api, output_api): |
| 59 """Verifies that certain files are identical in various locations. | 33 """Verifies that certain files are identical in various locations. |
| 60 These files should always be updated together.""" | 34 These files should always be updated together.""" |
| 61 | 35 |
| 62 dirty_files = set(input_api.LocalPaths()) | 36 dirty_files = set(input_api.LocalPaths()) |
| 63 | 37 |
| 64 groups = [[ | 38 groups = [[ |
| 65 'imported/wpt/resources/testharness.js', | 39 'imported/wpt/resources/testharness.js', |
| 66 'resources/testharness.js', | 40 'resources/testharness.js', |
| 67 ], [ | 41 ], [ |
| (...skipping 27 matching lines...) Expand all Loading... |
| 95 results.extend(_CheckTestharnessResults(input_api, output_api)) | 69 results.extend(_CheckTestharnessResults(input_api, output_api)) |
| 96 results.extend(_CheckIdenticalFiles(input_api, output_api)) | 70 results.extend(_CheckIdenticalFiles(input_api, output_api)) |
| 97 return results | 71 return results |
| 98 | 72 |
| 99 | 73 |
| 100 def CheckChangeOnCommit(input_api, output_api): | 74 def CheckChangeOnCommit(input_api, output_api): |
| 101 results = [] | 75 results = [] |
| 102 results.extend(_CheckTestharnessResults(input_api, output_api)) | 76 results.extend(_CheckTestharnessResults(input_api, output_api)) |
| 103 results.extend(_CheckIdenticalFiles(input_api, output_api)) | 77 results.extend(_CheckIdenticalFiles(input_api, output_api)) |
| 104 return results | 78 return results |
| OLD | NEW |