[Feature]: Support --repeat aggregation in oracletrace run subcommand
#67 opened on Jun 16, 2026
Repository metrics
- Stars
- (21 stars)
- PR merge metrics
- (PR metrics pending)
Description
Summary
Implement median-based repeat aggregation for oracletrace run -- pytest, matching the behavior already available when tracing a script directly.
Problem
--repeat is defined on _BASE_PARSER (shared by both entry points) but aggregation logic exists only in _run_target(). When using oracletrace run --repeat 3 -- pytest, pytest runs once and repeat is silently ignored.
Proposed Solution
- Extract the repeat loop +
FunctionAggregatemedian logic from_run_target()into a shared helper (e.g._aggregate_repeated_runs()) - Update
_run_pytest()to invoke pytest N times when--repeat > 1and aggregate trace data - Preserve current semantics: skip
show_resultswhenruns > 1(same as script mode) - Define exit-code precedence when combining
--repeat, pytest failures, and--fail-on-regression - Add tests and update
docs/docs/cli-reference.md
Use Case
CI pipelines using oracletrace run -- pytest tests/ need median aggregation to reduce OS-level noise — the primary motivation for --repeat in v3.0.0. Without this, CI users cannot benefit from repeat when tracing test suites.
Example (optional)
oracletrace run --repeat 5 --json current.json --compare baseline.json --fail-on-regression -- pytest tests/ -q
# pytest runs 5 times; exported/compared trace uses median total_time and call_count per function
Alternatives Considered
- Document that
--repeatis script-only and reject it onrun— simpler but worse UX since the flag is already accepted. - Require users to shell-loop pytest manually — workable but duplicates logic already in
_run_target().
Additional Context
Verified locally: oracletrace run --repeat 3 -- pytest calls pytest.main() once.
Relevant files:
oracletrace/cli.py—_run_target()(lines 227–253),_run_pytest()(lines 297–318)oracletrace/tracer.py—FunctionAggregatetests/test_cli.py— existing--repeatandrun pytesttestsdocs/docs/cli-reference.md— CI pytest workflow section
Checklist
- I searched existing issues before opening this request
- I described the problem and why this feature is useful
- I provided enough detail for implementation discussion