Skip to content

Commit 6ba8aef

Browse files
hathachclaude
andcommitted
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) <noreply@anthropic.com>
1 parent f5d6c6b commit 6ba8aef

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

.claude/skills/code-size/SKILL.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Infer from the user's request:
3030
- **Example:** named example → `-e <group>/<name>` (e.g. `-e device/cdc_msc`). "All examples" → omit `-e`.
3131
- **Bloaty:** only with `-e`. Use when the user wants a section/symbol-level breakdown for a single binary.
3232
- **Base ref:** default `master`. Override with `--base-branch <ref>` (tag or commit also works).
33-
- **Filter:** default `tinyusb/src` (only counts TinyUSB stack code, not example/BSP). Change only if asked.
33+
- **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.
3434

3535
## Common invocations
3636

@@ -72,5 +72,5 @@ Use timeouts ≥ 10 minutes (600000 ms) for `--ci`.
7272

7373
After running:
7474
- Show the markdown report's summary table to the user.
75-
- Highlight any rows with non-zero diff in `tinyusb/src` paths — those are the actual stack-size deltas.
75+
- 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.
7676
- If the diff is unexpected, follow up with a single-example `--bloaty` run to localize.

tools/metrics_compare_base.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,20 @@ def tinyusb_src_filter(checkout_dir):
3737

3838

3939
def run(cmd, **kwargs):
40-
"""Run a command. cmd must be a list (no shell=True)."""
40+
"""Run a command. cmd must be a list (no shell=True). On `timeout=`-induced
41+
TimeoutExpired, return a CompletedProcess with rc=124 instead of letting the
42+
exception propagate, so the caller can fall through to error reporting and
43+
worktree cleanup rather than crashing with a traceback."""
4144
if not isinstance(cmd, list):
4245
raise TypeError('run() requires a list, got str — fix the caller')
4346
if verbose:
4447
print(f' $ {" ".join(shlex.quote(str(c)) for c in cmd)}')
45-
return subprocess.run(cmd, capture_output=True, text=True, **kwargs)
48+
try:
49+
return subprocess.run(cmd, capture_output=True, text=True, **kwargs)
50+
except subprocess.TimeoutExpired as e:
51+
msg = f'Command timed out after {e.timeout}s: {" ".join(shlex.quote(str(c)) for c in cmd)}'
52+
stderr = (e.stderr or '') + ('\n' if e.stderr else '') + msg
53+
return subprocess.CompletedProcess(cmd, 124, stdout=(e.stdout or ''), stderr=stderr)
4654

4755

4856
def symlink_deps(main_root, worktree_dir):

0 commit comments

Comments
 (0)