Fix _RunRustFmt command line length issues and Windows compatibility

* Split file paths into batches using _SplitArgsByCmdLineLimit to avoid
  command line length limits.
* Add shell=False to subprocess call, because depot_tools-bundled
  subprocess2 wrapper sets it to True on Windows which prevents the use
  of full 32k command line limit.

Change-Id: Ifdd470087e34b1d9de54309c7915691e3e624f0e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/7062914
Reviewed-by: Scott Lee <ddoman@chromium.org>
Reviewed-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Aleksei Khoroshilov <akhoroshilov@brave.com>
changes/14/7062914/2
Aleksei Khoroshilov 1 day ago committed by LUCI CQ
parent 33eb99bb23
commit 3ed583625f

@ -6922,11 +6922,11 @@ def _RunRustFmt(opts, paths, top_dir, diffs):
cmd = [rustfmt_tool, f'--config-path={rustfmt_toml_path}']
if opts.dry_run:
cmd.append('--check')
cmd += paths
rustfmt_exitcode = subprocess2.call(cmd)
if opts.dry_run and rustfmt_exitcode != 0:
return 2
for paths_batch in _SplitArgsByCmdLineLimit(paths):
rustfmt_exitcode = subprocess2.call(cmd + paths_batch, shell=False)
if opts.dry_run and rustfmt_exitcode != 0:
return 2
return 0

Loading…
Cancel
Save