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'), 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 pylib_test_env = dict(input_api.environ) 83 pylib_test_env.update({ 84 'PYTHONPATH': build_android_dir, 85 'PYTHONDONTWRITEBYTECODE': '1', 86 }) 87 tests.extend( 88 input_api.canned_checks.GetUnitTests( 89 input_api, 90 output_api, 91 unit_tests=[ 92 J('.', 'fast_local_dev_server_test.py'), 93 J('.', 'list_class_verification_failures_test.py'), 94 J('.', 'convert_dex_profile_tests.py'), 95 J('gyp', 'compile_java_tests.py'), 96 J('gyp', 'create_unwind_table_tests.py'), 97 J('gyp', 'dex_test.py'), 98 J('gyp', 'extract_unwind_tables_tests.py'), 99 J('gyp', 'gcc_preprocess_tests.py'), 100 J('gyp', 'java_cpp_enum_tests.py'), 101 J('gyp', 'java_cpp_features_tests.py'), 102 J('gyp', 'java_cpp_strings_tests.py'), 103 J('gyp', 'java_google_api_keys_tests.py'), 104 J('gyp', 'util', 'build_utils_test.py'), 105 J('gyp', 'util', 'manifest_utils_test.py'), 106 J('gyp', 'util', 'md5_check_test.py'), 107 J('gyp', 'util', 'resource_utils_test.py'), 108 J('pylib', 'base', 'output_manager_test_case.py'), 109 J('pylib', 'constants', 'host_paths_unittest.py'), 110 J('pylib', 'gtest', 'gtest_test_instance_test.py'), 111 J('pylib', 'instrumentation', 'instrumentation_parser_test.py'), 112 J('pylib', 'instrumentation', 113 'instrumentation_test_instance_test.py'), 114 J('pylib', 'local', 'device', 'local_device_gtest_run_test.py'), 115 J('pylib', 'local', 'device', 116 'local_device_instrumentation_test_run_test.py'), 117 J('pylib', 'local', 'device', 'local_device_test_run_test.py'), 118 J('pylib', 'local', 'emulator', 'ini_test.py'), 119 J('pylib', 'local', 'machine', 120 'local_machine_junit_test_run_test.py'), 121 J('pylib', 'output', 'local_output_manager_test.py'), 122 J('pylib', 'output', 'noop_output_manager_test.py'), 123 J('pylib', 'output', 'remote_output_manager_test.py'), 124 J('pylib', 'results', 'flakiness_dashboard', 125 'json_results_generator_unittest.py'), 126 J('pylib', 'results', 'json_results_test.py'), 127 J('pylib', 'utils', 'chrome_proxy_utils_test.py'), 128 J('pylib', 'utils', 'code_coverage_utils_test.py'), 129 J('pylib', 'utils', 'decorators_test.py'), 130 J('pylib', 'utils', 'device_dependencies_test.py'), 131 J('pylib', 'utils', 'dexdump_test.py'), 132 J('pylib', 'utils', 'gold_utils_test.py'), 133 J('pylib', 'utils', 'test_filter_test.py'), 134 ], 135 env=pylib_test_env)) 136 137 return input_api.RunTests(tests) 138 139 140def CheckChangeOnUpload(input_api, output_api): 141 return CommonChecks(input_api, output_api) 142 143 144def CheckChangeOnCommit(input_api, output_api): 145 return CommonChecks(input_api, output_api) 146