Skip to content

Extend tracing tests: cover all find_footnote_end branches and add end-to-end traced wrapping tests #306

Description

@coderabbitai

Background

PR #303 added tracing instrumentation to the inline-wrapping token- and fragment-classification pipeline. A post-merge review identified two testing gaps that are out of scope for that PR.

Raised by @leynos.


Gap 1 — find_footnote_end branch coverage (error)

find_footnote_end emits three distinct trace! events:

  • prefix_mismatch — input does not begin with [^
  • footnote_label_span_recognised — closing ] found; span computed
  • unterminated_bracket — bracket never closed

The existing tracing_tests module in src/wrap/tokenize/parsing.rs covers only the prefix_mismatch path. Add #[traced_test] tests for the remaining two branches, asserting the expected event messages are emitted:

  • Call find_footnote_end with a well-formed [^label] input and assert logs_contain("footnote label span recognised").
  • Call find_footnote_end with an unterminated [^label input (no closing ]) and assert logs_contain("unterminated_bracket").

Gap 2 — end-to-end tracing tests through the public API (warning)

All current tracing tests exercise internal helpers directly. Add at least one integration-level test that:

  1. Calls wrap_text (the library's public entry point) with content that contains a footnote reference, e.g. "Some text.[^1]".
  2. Uses #[traced_test] so a subscriber is installed.
  3. Asserts that the expected classification debug event (e.g. logs_contain("fragment classified") and logs_contain("FootnoteRef")) is emitted during the wrapping pipeline.

This confirms that the instrumentation is reachable through the public API and not accidentally gated away.


References

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions