[Feature]: Add integration tests for Tracer profiling engine
Summary
Add integration tests that exercise the core tracing engine (Tracer._trace, get_trace_data, show_results) against real Python code, not just _is_user_code path filtering.
Problem
tests/test_tracer.py covers 12 scenarios for _is_user_code() (stdlib, site-packages, venv markers, symlinks, etc.) but does not verify that profiling actually records function calls, timings, callee relationships, or call-tree output. A regression in _trace() or get_trace_data() would go undetected.
Proposed Solution
Add a new test module (e.g. tests/test_tracer_integration.py) with small fixture scripts that:
- Start/stop a
Traceraroundrunpy.run_path()or an inline function call - Assert
get_trace_data()returns expected function keys, call counts, and total times - Cover
--ignorepattern filtering via_get_key()/_is_ignored() - Cover exception stack unwinding (the fallback path in
_trace()when return frame doesn't match stack top) - Optionally test the public API (
start_trace,stop_trace,show_results) exported fromoracletrace/__init__.py
Use Case
The tracer is the core of OracleTrace. Integration tests give confidence that profiling, aggregation, and filtering work end-to-end — especially after changes to _trace() or user-code detection.
Example (optional)
# Fixture script: calls nested functions with known structure
def outer():
inner()
def inner():
pass
outer()
# Expected trace keys like "script.py:outer", "script.py:inner"
# Expected call_count and callee relationships
Alternatives Considered
- Extend
tests/test_tracer.pyin place — possible, but separation keeps unit vs integration tests clear. - Only add CLI-level tests — CLI tests mock
Tracerand would not catch engine regressions.
Additional Context
Currently untested in oracletrace/tracer.py:
_trace()call/return handling and exception unwind (lines 174–215)get_trace_data()(lines 271–296)show_results()table and logic-flow tree (lines 217–269)- Public helpers
start_trace/stop_trace(lines 302–322)
Checklist
- [x] I searched existing issues before opening this request
- [x] I described the problem and why this feature is useful
- [x] I provided enough detail for implementation discussion