OLD | NEW |
---|---|
1 # Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 1 # Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
2 # | 2 # |
3 # Use of this source code is governed by a BSD-style license | 3 # Use of this source code is governed by a BSD-style license |
4 # that can be found in the LICENSE file in the root of the source | 4 # that can be found in the LICENSE file in the root of the source |
5 # tree. An additional intellectual property rights grant can be found | 5 # tree. An additional intellectual property rights grant can be found |
6 # in the file PATENTS. All contributing project authors may | 6 # in the file PATENTS. All contributing project authors may |
7 # be found in the AUTHORS file in the root of the source tree. | 7 # be found in the AUTHORS file in the root of the source tree. |
8 | 8 |
9 import json | 9 import json |
10 import os | 10 import os |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
332 error_descriptions)) | 332 error_descriptions)) |
333 if warning_descriptions: | 333 if warning_descriptions: |
334 results.append(output_api.PresubmitPromptOrNotify( | 334 results.append(output_api.PresubmitPromptOrNotify( |
335 'You added one or more #includes of files that are temporarily\n' | 335 'You added one or more #includes of files that are temporarily\n' |
336 'allowed but being removed. Can you avoid introducing the\n' | 336 'allowed but being removed. Can you avoid introducing the\n' |
337 '#include? See relevant DEPS file(s) for details and contacts.', | 337 '#include? See relevant DEPS file(s) for details and contacts.', |
338 warning_descriptions)) | 338 warning_descriptions)) |
339 return results | 339 return results |
340 | 340 |
341 | 341 |
342 def _GetJSONParseError(input_api, filename): | |
343 try: | |
344 contents = input_api.ReadFile(filename) | |
345 input_api.json.loads(contents) | |
346 except ValueError as e: | |
347 return e | |
348 return None | |
349 | |
350 | |
351 def _CheckJSONParseErrors(input_api, output_api): | |
352 """Check that JSON files do not contain syntax errors.""" | |
353 actions = { | |
phoglund
2016/02/11 08:38:56
Is this a pattern generally followed by all presub
kjellander_webrtc
2016/02/11 09:24:15
Chromium has IDL files as well (https://code.googl
| |
354 '.json': _GetJSONParseError, | |
355 } | |
356 | |
357 def get_action(affected_file): | |
358 filename = affected_file.LocalPath() | |
359 return actions.get(input_api.os_path.splitext(filename)[1]) | |
360 | |
361 def FilterFile(affected_file): | |
362 action = get_action(affected_file) | |
363 if not action: | |
364 return False | |
365 return True | |
366 | |
367 results = [] | |
368 for affected_file in input_api.AffectedFiles( | |
369 file_filter=FilterFile, include_deletes=False): | |
370 action = get_action(affected_file) | |
371 parse_error = action(input_api, affected_file.AbsoluteLocalPath()) | |
372 if parse_error: | |
373 results.append(output_api.PresubmitError('%s could not be parsed: %s' % | |
374 (affected_file.LocalPath(), parse_error))) | |
375 return results | |
376 | |
377 | |
342 def _RunPythonTests(input_api, output_api): | 378 def _RunPythonTests(input_api, output_api): |
343 def join(*args): | 379 def join(*args): |
344 return input_api.os_path.join(input_api.PresubmitLocalPath(), *args) | 380 return input_api.os_path.join(input_api.PresubmitLocalPath(), *args) |
345 | 381 |
346 test_directories = [ | 382 test_directories = [ |
347 join('tools', 'autoroller', 'unittests'), | 383 join('tools', 'autoroller', 'unittests'), |
348 ] | 384 ] |
349 | 385 |
350 tests = [] | 386 tests = [] |
351 for directory in test_directories: | 387 for directory in test_directories: |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
416 input_api, output_api)) | 452 input_api, output_api)) |
417 results.extend(input_api.canned_checks.CheckChangeHasNoStrayWhitespace( | 453 results.extend(input_api.canned_checks.CheckChangeHasNoStrayWhitespace( |
418 input_api, output_api)) | 454 input_api, output_api)) |
419 results.extend(input_api.canned_checks.CheckChangeTodoHasOwner( | 455 results.extend(input_api.canned_checks.CheckChangeTodoHasOwner( |
420 input_api, output_api)) | 456 input_api, output_api)) |
421 results.extend(_CheckNativeApiHeaderChanges(input_api, output_api)) | 457 results.extend(_CheckNativeApiHeaderChanges(input_api, output_api)) |
422 results.extend(_CheckNoIOStreamInHeaders(input_api, output_api)) | 458 results.extend(_CheckNoIOStreamInHeaders(input_api, output_api)) |
423 results.extend(_CheckNoFRIEND_TEST(input_api, output_api)) | 459 results.extend(_CheckNoFRIEND_TEST(input_api, output_api)) |
424 results.extend(_CheckGypChanges(input_api, output_api)) | 460 results.extend(_CheckGypChanges(input_api, output_api)) |
425 results.extend(_CheckUnwantedDependencies(input_api, output_api)) | 461 results.extend(_CheckUnwantedDependencies(input_api, output_api)) |
462 results.extend(_CheckJSONParseErrors(input_api, output_api)) | |
426 results.extend(_RunPythonTests(input_api, output_api)) | 463 results.extend(_RunPythonTests(input_api, output_api)) |
427 return results | 464 return results |
428 | 465 |
429 | 466 |
430 def CheckChangeOnUpload(input_api, output_api): | 467 def CheckChangeOnUpload(input_api, output_api): |
431 results = [] | 468 results = [] |
432 results.extend(_CommonChecks(input_api, output_api)) | 469 results.extend(_CommonChecks(input_api, output_api)) |
433 results.extend( | 470 results.extend( |
434 input_api.canned_checks.CheckGNFormatted(input_api, output_api)) | 471 input_api.canned_checks.CheckGNFormatted(input_api, output_api)) |
435 return results | 472 return results |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
470 for builder in masters[master]: | 507 for builder in masters[master]: |
471 if 'presubmit' in builder: | 508 if 'presubmit' in builder: |
472 # Do not trigger presubmit builders, since they're likely to fail | 509 # Do not trigger presubmit builders, since they're likely to fail |
473 # (e.g. OWNERS checks before finished code review), and we're running | 510 # (e.g. OWNERS checks before finished code review), and we're running |
474 # local presubmit anyway. | 511 # local presubmit anyway. |
475 pass | 512 pass |
476 else: | 513 else: |
477 try_config[master][builder] = ['defaulttests'] | 514 try_config[master][builder] = ['defaulttests'] |
478 | 515 |
479 return try_config | 516 return try_config |
OLD | NEW |