1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
# Copyright (c) 2013 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""LayoutTests/ presubmit script for Blink.
See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
for more details about the presubmit API built into gcl.
"""
import filecmp
def _CheckTestharnessResults(input_api, output_api):
expected_files = [f.AbsoluteLocalPath() for f in input_api.AffectedFiles() if f.LocalPath().endswith('-expected.txt') and f.Action() != 'D']
if len(expected_files) == 0:
return []
checker_path = input_api.os_path.join(input_api.PresubmitLocalPath(),
'..', 'Tools', 'Scripts', 'check-testharness-expected-pass')
args = [input_api.python_executable, checker_path]
args.extend(expected_files)
_, errs = input_api.subprocess.Popen(args,
stdout=input_api.subprocess.PIPE,
stderr=input_api.subprocess.PIPE).communicate()
if errs:
return [output_api.PresubmitError(errs)]
return []
def _CheckIdenticalFiles(input_api, output_api):
"""Verifies that certain files are identical in various locations.
These files should always be updated together."""
dirty_files = set(input_api.LocalPaths())
groups = [[
'resources/testharness.js',
'http/tests/resources/testharness.js',
'http/tests/w3c/resources/testharness.js',
], [
'resources/testharnessreport.js',
'http/tests/resources/testharnessreport.js',
'http/tests/w3c/resources/testharnessreport.js',
], [
'resources/idlharness.js',
'http/tests/w3c/resources/idlharness.js',
], [
'resources/WebIDLParser.js',
'http/tests/w3c/resources/WebIDLParser.js',
], [
'resources/testharness-helpers.js',
'http/tests/resources/testharness-helpers.js',
]]
def _absolute_path(s):
return input_api.os_path.join(input_api.PresubmitLocalPath(), *s.split('/'))
def _local_path(s):
return input_api.os_path.join('third_party', 'WebKit', 'LayoutTests', *s.split('/'))
errors = []
for group in groups:
if any(_local_path(p) in dirty_files for p in group):
a = group[0]
for b in group[1:]:
if not filecmp.cmp(_absolute_path(a), _absolute_path(b), shallow=False):
errors.append(output_api.PresubmitError(
'Files that should match differ: (see https://crbug.com/362788)\n' +
' %s <=> %s' % (_local_path(a), _local_path(b))))
return errors
def CheckChangeOnUpload(input_api, output_api):
results = []
results.extend(_CheckTestharnessResults(input_api, output_api))
results.extend(_CheckIdenticalFiles(input_api, output_api))
return results
def CheckChangeOnCommit(input_api, output_api):
results = []
results.extend(_CheckTestharnessResults(input_api, output_api))
results.extend(_CheckIdenticalFiles(input_api, output_api))
return results
|