tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

PRESUBMIT.py (5546B)


      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 
      7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts for
      8 details on the presubmit API built into depot_tools.
      9 """
     10 
     11 
     12 
     13 def CommonChecks(input_api, output_api, *, is_upload):
     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 
     88  pytests = [
     89      J('.', 'list_class_verification_failures_test.py'),
     90      J('.', 'convert_dex_profile_tests.py'),
     91      J('gyp', 'compile_java_tests.py'),
     92      J('gyp', 'create_unwind_table_tests.py'),
     93      J('gyp', 'dex_test.py'),
     94      J('gyp', 'extract_unwind_tables_tests.py'),
     95      J('gyp', 'gcc_preprocess_tests.py'),
     96      J('gyp', 'java_cpp_enum_tests.py'),
     97      J('gyp', 'java_cpp_features_tests.py'),
     98      J('gyp', 'java_cpp_strings_tests.py'),
     99      J('gyp', 'java_google_api_keys_tests.py'),
    100      J('gyp', 'util', 'build_utils_test.py'),
    101      J('gyp', 'util', 'manifest_utils_test.py'),
    102      J('gyp', 'util', 'md5_check_test.py'),
    103      J('gyp', 'util', 'resource_utils_test.py'),
    104      J('pylib', 'base', 'output_manager_test_case.py'),
    105      J('pylib', 'constants', 'host_paths_unittest.py'),
    106      J('pylib', 'gtest', 'gtest_test_instance_test.py'),
    107      J('pylib', 'instrumentation', 'instrumentation_parser_test.py'),
    108      J('pylib', 'instrumentation', 'instrumentation_test_instance_test.py'),
    109      J('pylib', 'local', 'device', 'local_device_gtest_run_test.py'),
    110      J('pylib', 'local', 'device',
    111        'local_device_instrumentation_test_run_test.py'),
    112      J('pylib', 'local', 'device', 'local_device_test_run_test.py'),
    113      J('pylib', 'local', 'emulator', 'ini_test.py'),
    114      J('pylib', 'local', 'machine', 'local_machine_junit_test_run_test.py'),
    115      J('pylib', 'output', 'local_output_manager_test.py'),
    116      J('pylib', 'output', 'noop_output_manager_test.py'),
    117      J('pylib', 'output', 'remote_output_manager_test.py'),
    118      J('pylib', 'results', 'flakiness_dashboard',
    119        'json_results_generator_unittest.py'),
    120      J('pylib', 'results', 'json_results_test.py'),
    121      J('pylib', 'utils', 'chrome_proxy_utils_test.py'),
    122      J('pylib', 'utils', 'code_coverage_utils_test.py'),
    123      J('pylib', 'utils', 'decorators_test.py'),
    124      J('pylib', 'utils', 'device_dependencies_test.py'),
    125      J('pylib', 'utils', 'dexdump_test.py'),
    126      J('pylib', 'utils', 'gold_utils_test.py'),
    127      J('pylib', 'utils', 'test_filter_test.py'),
    128  ]
    129  if is_upload:
    130    pytests += [J('.', 'fast_local_dev_server_test.py')]
    131 
    132  # Build server tests are flaky on bots.
    133  # E.g.: https://ci.chromium.org/ui/p/chromium/builders/try/chromium_presubmit/3085167/overview
    134  tests.extend(
    135      input_api.canned_checks.GetUnitTests(input_api,
    136                                           output_api,
    137                                           unit_tests=pytests,
    138                                           env=pylib_test_env))
    139 
    140  return input_api.RunTests(tests)
    141 
    142 
    143 def CheckChangeOnUpload(input_api, output_api):
    144  return CommonChecks(input_api, output_api, is_upload=True)
    145 
    146 
    147 def CheckChangeOnCommit(input_api, output_api):
    148  return CommonChecks(input_api, output_api, is_upload=False)