You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
depot_tools/tests
Bruce Dawson 10a8286824 Don't halt presubmits on exceptions
Some presubmit failures result in uncaught exceptions which historically
have halted presubmit runs. This behavior makes it more difficult to
find all failures, measure presubmit times, or detect other behavior
over time. This is particularly problematic when running "git cl
presubmit --all".

As an example, presubmit --all was broken and would not complete from
when crrev.com/3642633 landed until crrev.com/c/3657600. The minimal
repro was this presubmit command:

    git cl presubmit --files ui\accessibility\ax_mode.h

This command, or presubmit --all, triggered this error, which halts the
presubmits:

Evaluation of CheckChangeOnCommit failed: [Errno 2] No such file or directory: 'chrome/browser/resources/accessibility/accessibility.js'
Traceback (most recent call last):
  File "presubmit_support.py", line 2038, in <module>
    sys.exit(main())
  File "presubmit_support.py", line 2015, in main
    return DoPresubmitChecks(
  File "presubmit_support.py", line 1738, in DoPresubmitChecks
    results += executer.ExecPresubmitScript(presubmit_script, filename)
  File "presubmit_support.py", line 1602, in ExecPresubmitScript
    self._run_check_function(function_name, context, sink,
  File "presubmit_support.py", line 1640, in _run_check_function
    six.reraise(e_type, e_value, e_tb)
  File "C:\Users\brucedawson\.vpython-root\e726d2\lib\site-packages\six.py", line 686, in reraise
    raise value
  File "presubmit_support.py", line 1630, in _run_check_function
    result = eval(function_name + '(*__args)', context)
  File "<string>", line 1, in <module>
  File "PRESUBMIT.py", line 314, in CheckChangeOnCommit
    errs.extend(CheckModesMatch(input_api, output_api))
  File "PRESUBMIT.py", line 283, in CheckModesMatch
    ax_modes_in_js = GetAccessibilityModesFromFile(
  File "PRESUBMIT.py", line 245, in GetAccessibilityModesFromFile
    for line in open(fullpath).readlines():
FileNotFoundError: [Errno 2] No such file or directory: 'chrome/browser/resources/accessibility/accessibility.js'

With this change the exception is handled and presubmits continue after
printing this message:

Evaluation of CheckChangeOnCommit failed: [Errno 2] No such file or directory: 'chrome/browser/resources/accessibility/accessibility.js', Traceback (most recent call last):
  File "presubmit_support.py", line 1630, in _run_check_function
    result = eval(function_name + '(*__args)', context)
  File "<string>", line 1, in <module>
  File "PRESUBMIT.py", line 314, in CheckChangeOnCommit
    errs.extend(CheckModesMatch(input_api, output_api))
  File "PRESUBMIT.py", line 283, in CheckModesMatch
    ax_modes_in_js = GetAccessibilityModesFromFile(
  File "PRESUBMIT.py", line 245, in GetAccessibilityModesFromFile
    for line in open(fullpath).readlines():
FileNotFoundError: [Errno 2] No such file or directory: 'chrome/browser/resources/accessibility/accessibility.js'

That is, the crucial information regarding the failure is printed, but
subsequent presubmits are not skipped.

Bug: 1309977
Change-Id: I7cfeda85c830e6c8e567c0df3c50f27af1dbe835
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3653978
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
Commit-Queue: Bruce Dawson <brucedawson@chromium.org>
3 years ago
..
gstools
OWNERS autoninja: add simple test 3 years ago
PRESUBMIT.py Follow-up to 61bf638 to add the py3-specific PRESUBMIT.py test. 4 years ago
auth_test.py Run spellchecker on depot_tools 5 years ago
autoninja_test.py autoninja: add simple test 3 years ago
bot_update_coverage_test.py Use pylint 2.7 for depot_tools 3 years ago
cipd_bootstrap_test.py [cipd] Take cipd.ps1 out of %PATH%. 5 years ago
detect_host_arch_test.py gclient: Correctly set host_cpu to arm64 on arm macs 4 years ago
download_from_google_storage_unittest.py Skip 'ls' when downloading from gs. 3 years ago
fetch_test.py Add --protocol-override to fetch.py 3 years ago
fix_encoding_test.py Make fix_encoding_test py3 compatible 3 years ago
gclient_cipd_smoketest.py depot_tools: Split gclient_smoketests. 5 years ago
gclient_eval_unittest.py metrics: Don't print notice if reporting build metrics. 4 years ago
gclient_git_mutates_smoketest.py gclient: Split gclient smoke tests. 4 years ago
gclient_git_smoketest.py Use main branch as the default branch 4 years ago
gclient_paths_test.py
gclient_scm_test.py Fix host and repo parsing for download-topics 3 years ago
gclient_smoketest.py depot_tools: Split gclient_smoketests. 5 years ago
gclient_smoketest_base.py Use pylint 2.7 for depot_tools 3 years ago
gclient_test.py Revert "Remove unused functionality in bot_update.py" 3 years ago
gclient_transitions_smoketest.py depot_tools: Split gclient_smoketests. 5 years ago
gclient_utils_test.py update stale codereview.chromium.org links 4 years ago
gerrit_client_test.py Add a 'setlabel' command to gerrit_client.py 4 years ago
gerrit_util_test.py Handle spaces in Gerrit search options 4 years ago
git_cache_test.py add support for main in git_cache 5 years ago
git_cl_creds_check_report.txt git cl: remove check for likely wrong identities. 5 years ago
git_cl_test.py Optimize presubmit --all with --no_diffs option 3 years ago
git_common_test.py Fix git_common_test.py: git checkout -tb -> git checkout -t -b 3 years ago
git_dates_test.py
git_find_releases_test.py Use pylint 2.7 for depot_tools 3 years ago
git_footers_test.py Use main branch as the default branch 4 years ago
git_hyper_blame_test.py Add support for git_hyper_blame for Windows 5 years ago
git_map_test.py Use main branch as the default branch 4 years ago
git_migrate_default_branch_test.py Use pylint 2.7 for depot_tools 3 years ago
git_number_test.py
git_rebase_update_test.py Fix depot_tools tests when running without py2 3 years ago
gsutil_test.py Refactor gsutil and fix concurrecny issue on MacOS 4 years ago
lockfile_test.py Reland "Use OS level locking in git_cache.py" 5 years ago
metrics_test.py Use main branch as the default branch 4 years ago
my_activity_test.py Require certifi package and python3 in my_activity 4 years ago
ninjalog_uploader_test.py fix ninjalog_uploader.py 3 years ago
owners_client_test.py Reland "presubmit: Skip owners checks if code-owners plugin is enabled." 4 years ago
owners_finder_test.py owners_finder: Use code-owners plugin if available. 4 years ago
owners_unittest.py Run spellchecker on depot_tools 5 years ago
presubmit_unittest.py Don't halt presubmits on exceptions 3 years ago
rdb_wrapper_test.py [resultdb] use requests.Session in rdb_wrapper 5 years ago
recipes_test.py add vpython3 to tests that run under vpython3 3 years ago
roll_dep_test.py Fix Python3 integer division issue in roll-dep. 5 years ago
scm_unittest.py Refresh remote HEAD if matches legacy default 4 years ago
split_cl_test.py Update format of `git cl split` 4 years ago
subcommand_test.py Move subcommand_test to py3 5 years ago
subprocess2_test.py Use pylint 2.7 for depot_tools 3 years ago
upload_to_google_storage_unittest.py Set cache-control when uploading to google storage 4 years ago
utils_test.py Add a basic depot_tools version information 3 years ago
watchlists_unittest.py