Skip to content

[Feature]: Support --repeat aggregation in oracletrace run subcommand #67

Description

@KaykCaputo

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

  1. Extract the repeat loop + FunctionAggregate median logic from _run_target() into a shared helper (e.g. _aggregate_repeated_runs())
  2. Update _run_pytest() to invoke pytest N times when --repeat > 1 and aggregate trace data
  3. Preserve current semantics: skip show_results when runs > 1 (same as script mode)
  4. Define exit-code precedence when combining --repeat, pytest failures, and --fail-on-regression
  5. 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 --repeat is script-only and reject it on run — 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.pyFunctionAggregate
  • tests/test_cli.py — existing --repeat and run pytest tests
  • docs/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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions