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 | |
| 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]>
| -rw-r--r-- | .claude/skills/code-size/SKILL.md | 4 | ||||
| -rw-r--r-- | tools/metrics_compare_base.py | 12 |
2 files changed, 12 insertions, 4 deletions
diff --git a/.claude/skills/code-size/SKILL.md b/.claude/skills/code-size/SKILL.md index e12a30d86..f3c51ccfa 100644 --- a/.claude/skills/code-size/SKILL.md +++ b/.claude/skills/code-size/SKILL.md @@ -30,7 +30,7 @@ Infer from the user's request: - **Example:** named example → `-e <group>/<name>` (e.g. `-e device/cdc_msc`). "All examples" → omit `-e`. - **Bloaty:** only with `-e`. Use when the user wants a section/symbol-level breakdown for a single binary. - **Base ref:** default `master`. Override with `--base-branch <ref>` (tag or commit also works). -- **Filter:** default `tinyusb/src` (only counts TinyUSB stack code, not example/BSP). Change only if asked. +- **Filter:** default is the absolute path of each side's `<checkout>/src/` directory, which uniquely identifies TinyUSB stack code without matching vendored deps that also have a `src/` (e.g. `pico-sdk/src/`). Override with one or more `-f SUBSTRING` flags to use repo-relative substrings instead. Change only if asked. ## Common invocations @@ -72,5 +72,5 @@ Use timeouts ≥ 10 minutes (600000 ms) for `--ci`. After running: - Show the markdown report's summary table to the user. -- Highlight any rows with non-zero diff in `tinyusb/src` paths — those are the actual stack-size deltas. +- Highlight any rows with non-zero `% diff` — under the default filter every row is a TinyUSB stack source file (e.g. `usbd.c`, `cdc_device.c`, `dcd_<port>.c`), so any non-zero delta is a real stack-size impact. - If the diff is unexpected, follow up with a single-example `--bloaty` run to localize. 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): |
