diff options
| author | hathach <[email protected]> | 2026-04-29 12:45:55 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2026-04-29 12:45:55 +0700 |
| commit | 6ba8aeff1603ae54e0fcf2309b0f19e335a16cdc (patch) | |
| tree | 366a6617ec5bde8a8faa69f340ab05bc2475b79d /tools | |
| parent | f5d6c6ba91e7176ddf5965608c361ccf5d515bde (diff) | |
metrics_compare_base: catch TimeoutExpired; fix code-size skill docs
- run() now catches subprocess.TimeoutExpired (only triggered by `cmake --build`'s
timeout=600) and returns CompletedProcess(rc=124) so the caller falls through to
error reporting and worktree cleanup instead of crashing with a traceback.
- code-size SKILL.md: document the actual default filter (per-side absolute
<checkout>/src/ path, not the old `tinyusb/src` substring) and adjust the
reporting guidance to match what the report rows actually contain.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/metrics_compare_base.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/tools/metrics_compare_base.py b/tools/metrics_compare_base.py index 0fb767bb7..a541dae79 100644 --- a/tools/metrics_compare_base.py +++ b/tools/metrics_compare_base.py @@ -37,12 +37,20 @@ verbose = False def run(cmd, **kwargs): - """Run a command. cmd must be a list (no shell=True).""" + """Run a command. cmd must be a list (no shell=True). On `timeout=`-induced + TimeoutExpired, return a CompletedProcess with rc=124 instead of letting the + exception propagate, so the caller can fall through to error reporting and + worktree cleanup rather than crashing with a traceback.""" if not isinstance(cmd, list): raise TypeError('run() requires a list, got str — fix the caller') if verbose: print(f' $ {" ".join(shlex.quote(str(c)) for c in cmd)}') - return subprocess.run(cmd, capture_output=True, text=True, **kwargs) + try: + return subprocess.run(cmd, capture_output=True, text=True, **kwargs) + except subprocess.TimeoutExpired as e: + msg = f'Command timed out after {e.timeout}s: {" ".join(shlex.quote(str(c)) for c in cmd)}' + stderr = (e.stderr or '') + ('\n' if e.stderr else '') + msg + return subprocess.CompletedProcess(cmd, 124, stdout=(e.stdout or ''), stderr=stderr) def symlink_deps(main_root, worktree_dir): |
