1# Copyright 2013 The Chromium Authors 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4 5"""Presubmit script for android buildbot. 6 7See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts for 8details on the presubmit API built into depot_tools. 9""" 10 11 12 13def CommonChecks(input_api, output_api): 14 # These tools don't run on Windows so these tests don't work and give many 15 # verbose and cryptic failure messages. Linting the code is also skipped on 16 # Windows because it will fail due to os differences. 17 if input_api.sys.platform == 'win32': 18 return [] 19 20 build_android_dir = input_api.PresubmitLocalPath() 21 22 def J(*dirs): 23 """Returns a path relative to presubmit directory.""" 24 return input_api.os_path.join(build_android_dir, *dirs) 25 26 build_pys = [ 27 r'gn/.*\.py$', 28 r'gyp/.*\.py$', 29 ] 30 tests = [] 31 # yapf likes formatting the extra_paths_list to be less readable. 32 # yapf: disable 33 tests.extend( 34 input_api.canned_checks.GetPylint( 35 input_api, 36 output_api, 37 pylintrc='pylintrc', 38 files_to_skip=[ 39 r'.*_pb2\.py' 40 ] + build_pys, 41 extra_paths_list=[ 42 J(), 43 J('gyp'), 44 J('buildbot'), 45 J('..', 'util', 'lib', 'common'), 46 J('..', '..', 'third_party', 'catapult', 'common', 47 'py_trace_event'), 48 J('..', '..', 'third_party', 'catapult', 'common', 'py_utils'), 49 J('..', '..', 'third_party', 'catapult', 'devil'), 50 J('..', '..', 'third_party', 'catapult', 'tracing'), 51 J('..', '..', 'third_party', 'depot_tools'), 52 J('..', '..', 'third_party', 'colorama', 'src'), 53 J('..', '..', 'build'), 54 ], 55 version='2.7')) 56 tests.extend( 57 input_api.canned_checks.GetPylint( 58 input_api, 59 output_api, 60 files_to_check=build_pys, 61 files_to_skip=[ 62 r'.*_pb2\.py', 63 r'.*_pb2\.py', 64 r'.*create_unwind_table\.py', 65 r'.*create_unwind_table_tests\.py', 66 ], 67 extra_paths_list=[J('gyp'), J('gn')], 68 version='2.7')) 69 70 tests.extend( 71 input_api.canned_checks.GetPylint( 72 input_api, 73 output_api, 74 files_to_check=[ 75 r'.*create_unwind_table\.py', 76 r'.*create_unwind_table_tests\.py', 77 ], 78 extra_paths_list=[J('gyp'), J('gn')], 79 version='2.7')) 80 # yapf: enable 81 82 # Disabled due to http://crbug.com/410936 83 #output.extend(input_api.canned_checks.RunUnitTestsInDirectory( 84 #input_api, output_api, J('buildbot', 'tests'))) 85 86 pylib_test_env = dict(input_api.environ) 87 pylib_test_env.update({ 88 'PYTHONPATH': build_android_dir, 89 'PYTHONDONTWRITEBYTECODE': '1', 90 }) 91 tests.extend( 92 input_api.canned_checks.GetUnitTests( 93 input_api, 94 output_api, 95 unit_tests=[ 96 J('.', 'list_class_verification_failures_test.py'), 97 J('pylib', 'constants', 'host_paths_unittest.py'), 98 J('pylib', 'gtest', 'gtest_test_instance_test.py'), 99 J('pylib', 'instrumentation', 100 'instrumentation_test_instance_test.py'), 101 J('pylib', 'local', 'device', 'local_device_gtest_run_test.py'), 102 J('pylib', 'local', 'device', 103 'local_device_instrumentation_test_run_test.py'), 104 J('pylib', 'local', 'device', 'local_device_test_run_test.py'), 105 J('pylib', 'local', 'machine', 106 'local_machine_junit_test_run_test.py'), 107 J('pylib', 'output', 'local_output_manager_test.py'), 108 J('pylib', 'output', 'noop_output_manager_test.py'), 109 J('pylib', 'output', 'remote_output_manager_test.py'), 110 J('pylib', 'results', 'json_results_test.py'), 111 J('pylib', 'utils', 'chrome_proxy_utils_test.py'), 112 J('pylib', 'utils', 'code_coverage_utils_test.py'), 113 J('pylib', 'utils', 'decorators_test.py'), 114 J('pylib', 'utils', 'device_dependencies_test.py'), 115 J('pylib', 'utils', 'dexdump_test.py'), 116 J('pylib', 'utils', 'gold_utils_test.py'), 117 J('pylib', 'utils', 'test_filter_test.py'), 118 J('gyp', 'dex_test.py'), 119 J('gyp', 'util', 'build_utils_test.py'), 120 J('gyp', 'util', 'manifest_utils_test.py'), 121 J('gyp', 'util', 'md5_check_test.py'), 122 J('gyp', 'util', 'resource_utils_test.py'), 123 ], 124 env=pylib_test_env)) 125 126 return input_api.RunTests(tests) 127 128 129def CheckChangeOnUpload(input_api, output_api): 130 return CommonChecks(input_api, output_api) 131 132 133def CheckChangeOnCommit(input_api, output_api): 134 return CommonChecks(input_api, output_api) 135