| 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 """Top-level presubmit script for Blink. | 5 """Top-level 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 os |
| 11 import re | 12 import re |
| 12 import sys | 13 import sys |
| 13 | 14 |
| 14 | 15 |
| 15 _EXCLUDED_PATHS = () | 16 _EXCLUDED_PATHS = () |
| 16 | 17 |
| 17 | 18 |
| 18 def _CheckForNonBlinkVariantMojomIncludes(input_api, output_api): | 19 def _CheckForNonBlinkVariantMojomIncludes(input_api, output_api): |
| 19 pattern = input_api.re.compile(r'#include\s+.+\.mojom(.*)\.h[>"]') | 20 pattern = input_api.re.compile(r'#include\s+.+\.mojom(.*)\.h[>"]') |
| 20 errors = [] | 21 errors = [] |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 | 314 |
| 314 def CheckChangeOnCommit(input_api, output_api): | 315 def CheckChangeOnCommit(input_api, output_api): |
| 315 results = [] | 316 results = [] |
| 316 results.extend(_CommonChecks(input_api, output_api)) | 317 results.extend(_CommonChecks(input_api, output_api)) |
| 317 results.extend(input_api.canned_checks.CheckTreeIsOpen( | 318 results.extend(input_api.canned_checks.CheckTreeIsOpen( |
| 318 input_api, output_api, | 319 input_api, output_api, |
| 319 json_url='http://chromium-status.appspot.com/current?format=json')) | 320 json_url='http://chromium-status.appspot.com/current?format=json')) |
| 320 results.extend(input_api.canned_checks.CheckChangeHasDescription( | 321 results.extend(input_api.canned_checks.CheckChangeHasDescription( |
| 321 input_api, output_api)) | 322 input_api, output_api)) |
| 322 return results | 323 return results |
| 324 |
| 325 |
| 326 def _ArePaintOrCompositingDirectoriesModified(change): # pylint: disable=C0103 |
| 327 """Checks whether CL has changes to paint or compositing directories.""" |
| 328 paint_or_compositing_paths = [ |
| 329 os.path.join('third_party', 'WebKit', 'Source', 'platform', 'graphics', |
| 330 'compositing'), |
| 331 os.path.join('third_party', 'WebKit', 'Source', 'platform', 'graphics', |
| 332 'paint'), |
| 333 os.path.join('third_party', 'WebKit', 'Source', 'core', 'layout', |
| 334 'compositing'), |
| 335 os.path.join('third_party', 'WebKit', 'Source', 'core', 'paint'), |
| 336 ] |
| 337 for affected_file in change.AffectedFiles(): |
| 338 file_path = affected_file.LocalPath() |
| 339 if any(x in file_path for x in paint_or_compositing_paths): |
| 340 return True |
| 341 return False |
| 342 |
| 343 |
| 344 def PostUploadHook(cl, change, output_api): # pylint: disable=C0103 |
| 345 """git cl upload will call this hook after the issue is created/modified. |
| 346 |
| 347 This hook adds extra try bots to the CL description in order to run slimming |
| 348 paint v2 tests in addition to the CQ try bots if the change contains paint |
| 349 or compositing changes (see: _ArePaintOrCompositingDirectoriesModified). For |
| 350 more information about slimming-paint-v2 tests see https://crbug.com/601275. |
| 351 """ |
| 352 if not _ArePaintOrCompositingDirectoriesModified(change): |
| 353 return [] |
| 354 |
| 355 rietveld_obj = cl.RpcServer() |
| 356 issue = cl.issue |
| 357 description = rietveld_obj.get_description(issue) |
| 358 if re.search(r'^CQ_INCLUDE_TRYBOTS=.*', description, re.M | re.I): |
| 359 return [] |
| 360 |
| 361 bots = [ |
| 362 'master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2', |
| 363 ] |
| 364 |
| 365 results = [] |
| 366 new_description = description |
| 367 new_description += '\nCQ_INCLUDE_TRYBOTS=%s' % ';'.join(bots) |
| 368 results.append(output_api.PresubmitNotifyResult( |
| 369 'Automatically added slimming-paint-v2 tests to run on CQ due to ' |
| 370 'changes in paint or compositing directories.')) |
| 371 |
| 372 if new_description != description: |
| 373 rietveld_obj.update_description(issue, new_description) |
| 374 |
| 375 return results |
| OLD | NEW |