Skip to content

test: add coverage for metrics timing decorator (metrics.py) #978

@mnadzam

Description

@mnadzam

Description

src/fromager/metrics.py has 52% test coverage but no dedicated tests. Existing coverage comes entirely from indirect execution -- tests that call decorated functions (e.g. download_source()) exercise the wrapper code but never validate timing storage or error behavior. The @timeit() decorator is applied across 3 modules with 8 total uses:

  • build_environment.py (1 use)
  • wheels.py (3 uses)
  • sources.py (4 uses)

summarize() is called from 3 locations in bootstrap.py and build.py to report build performance.

A broken decorator could fail to propagate exceptions or corrupt timing data without any test catching it.

Scope

Function Lines Usage
timeit() 13-59 Decorator, 8 uses across 3 modules
summarize() 62-69 3 call sites
_extract_version_from_return() 72-80 1 (internal)

Acceptance Criteria

  • timeit() -- test that timing data is stored in context after a successful call
  • timeit() -- test that exceptions from the decorated function propagate correctly
  • summarize() -- test log output format with accumulated timings
  • _extract_version_from_return() -- test with iterable containing Version, bare Version, non-iterable, and None

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions