| 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 expected_files = [f.AbsoluteLocalPath() for f in input_api.AffectedFiles() i
f f.LocalPath().endswith('-expected.txt') and f.Action() != 'D'] | 15 """Checks for testharness.js test baseline files that contain only PASS line
s. |
| 16 if len(expected_files) == 0: | 16 |
| 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: |
| 17 return [] | 22 return [] |
| 18 | 23 |
| 19 checker_path = input_api.os_path.join(input_api.PresubmitLocalPath(), | 24 checker_path = input_api.os_path.join(input_api.PresubmitLocalPath(), |
| 20 '..', 'Tools', 'Scripts', 'check-testharness-expected-pass') | 25 '..', 'Tools', 'Scripts', 'check-testharness-expected-pass') |
| 21 | 26 |
| 22 args = [input_api.python_executable, checker_path] | 27 args = [input_api.python_executable, checker_path] |
| 23 args.extend(expected_files) | 28 args.extend(baseline_files) |
| 24 _, errs = input_api.subprocess.Popen(args, | 29 _, errs = input_api.subprocess.Popen(args, |
| 25 stdout=input_api.subprocess.PIPE, | 30 stdout=input_api.subprocess.PIPE, |
| 26 stderr=input_api.subprocess.PIPE).communicate() | 31 stderr=input_api.subprocess.PIPE).communicate() |
| 27 if errs: | 32 if errs: |
| 28 return [output_api.PresubmitError(errs)] | 33 return [output_api.PresubmitError(errs)] |
| 29 return [] | 34 return [] |
| 30 | 35 |
| 31 | 36 |
| 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 |
| 32 def _CheckIdenticalFiles(input_api, output_api): | 58 def _CheckIdenticalFiles(input_api, output_api): |
| 33 """Verifies that certain files are identical in various locations. | 59 """Verifies that certain files are identical in various locations. |
| 34 These files should always be updated together.""" | 60 These files should always be updated together.""" |
| 35 | 61 |
| 36 dirty_files = set(input_api.LocalPaths()) | 62 dirty_files = set(input_api.LocalPaths()) |
| 37 | 63 |
| 38 groups = [[ | 64 groups = [[ |
| 39 'imported/wpt/resources/testharness.js', | 65 'imported/wpt/resources/testharness.js', |
| 40 'resources/testharness.js', | 66 'resources/testharness.js', |
| 41 ], [ | 67 ], [ |
| (...skipping 27 matching lines...) Expand all Loading... |
| 69 results.extend(_CheckTestharnessResults(input_api, output_api)) | 95 results.extend(_CheckTestharnessResults(input_api, output_api)) |
| 70 results.extend(_CheckIdenticalFiles(input_api, output_api)) | 96 results.extend(_CheckIdenticalFiles(input_api, output_api)) |
| 71 return results | 97 return results |
| 72 | 98 |
| 73 | 99 |
| 74 def CheckChangeOnCommit(input_api, output_api): | 100 def CheckChangeOnCommit(input_api, output_api): |
| 75 results = [] | 101 results = [] |
| 76 results.extend(_CheckTestharnessResults(input_api, output_api)) | 102 results.extend(_CheckTestharnessResults(input_api, output_api)) |
| 77 results.extend(_CheckIdenticalFiles(input_api, output_api)) | 103 results.extend(_CheckIdenticalFiles(input_api, output_api)) |
| 78 return results | 104 return results |
| OLD | NEW |