Chromium Code Reviews| 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(expected_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('Layout', 'virtual') in path): | |
|
tkent
2016/05/22 23:30:38
Layout -> LayoutTests
qyearsley
2016/05/23 17:31:36
Fixed
| |
| 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. | |
| 51 continue | |
| 52 baseline_files.append(path) | |
| 53 return baseline_files | |
| 54 | |
| 55 | |
| 32 def _CheckIdenticalFiles(input_api, output_api): | 56 def _CheckIdenticalFiles(input_api, output_api): |
| 33 """Verifies that certain files are identical in various locations. | 57 """Verifies that certain files are identical in various locations. |
| 34 These files should always be updated together.""" | 58 These files should always be updated together.""" |
| 35 | 59 |
| 36 dirty_files = set(input_api.LocalPaths()) | 60 dirty_files = set(input_api.LocalPaths()) |
| 37 | 61 |
| 38 groups = [[ | 62 groups = [[ |
| 39 'imported/web-platform-tests/resources/testharness.js', | 63 'imported/web-platform-tests/resources/testharness.js', |
| 40 'resources/testharness.js', | 64 'resources/testharness.js', |
| 41 ], [ | 65 ], [ |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 69 results.extend(_CheckTestharnessResults(input_api, output_api)) | 93 results.extend(_CheckTestharnessResults(input_api, output_api)) |
| 70 results.extend(_CheckIdenticalFiles(input_api, output_api)) | 94 results.extend(_CheckIdenticalFiles(input_api, output_api)) |
| 71 return results | 95 return results |
| 72 | 96 |
| 73 | 97 |
| 74 def CheckChangeOnCommit(input_api, output_api): | 98 def CheckChangeOnCommit(input_api, output_api): |
| 75 results = [] | 99 results = [] |
| 76 results.extend(_CheckTestharnessResults(input_api, output_api)) | 100 results.extend(_CheckTestharnessResults(input_api, output_api)) |
| 77 results.extend(_CheckIdenticalFiles(input_api, output_api)) | 101 results.extend(_CheckIdenticalFiles(input_api, output_api)) |
| 78 return results | 102 return results |
| OLD | NEW |