From fa7667001a564e7a46bbe07ab24432bcddfc577f Mon Sep 17 00:00:00 2001 From: leynos Date: Sun, 26 Jul 2026 19:15:47 +0200 Subject: [PATCH 1/2] Cover remaining find_footnote_end branches and end-to-end tracing (#306) Close two post-merge testing gaps identified after PR #303 added tracing instrumentation to the inline-wrapping classification pipeline. - Add a direct `#[traced_test]` for `find_footnote_end`'s `footnote_label_span_recognized` branch, asserting the emitted event and structured fields while upholding the content-free logging convention. - Add the first integration-level tracing test driving the public `wrap_text` API with a footnote reference, proving the `fragment classified` / `FootnoteRef` DEBUG event survives through the pipeline. Enable `tracing-test`'s `no-env-filter` feature so the integration test crate captures events emitted from the `mdtablefix` library crate; the default per-crate env filter would otherwise hide the library's instrumentation. Co-Authored-By: Claude Opus 4.8 (1M context) --- Cargo.toml | 5 ++++- src/wrap/tokenize/parsing_tests.rs | 11 +++++++++++ tests/wrap_unit/footnotes.rs | 17 +++++++++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index b820a5be..eb8bfb38 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -40,7 +40,10 @@ tempfile = "3" libc = "0.2.174" predicates = "3" trybuild = "1" -tracing-test = "0.2" +# `no-env-filter` lets integration tests capture tracing events emitted from +# the `mdtablefix` crate; the default filter only records the test crate's own +# events, which would hide the library's instrumentation. +tracing-test = { version = "0.2", features = ["no-env-filter"] } test-macros = { path = "test-macros" } [lints.clippy] diff --git a/src/wrap/tokenize/parsing_tests.rs b/src/wrap/tokenize/parsing_tests.rs index c6fc05c8..f05cdcc6 100644 --- a/src/wrap/tokenize/parsing_tests.rs +++ b/src/wrap/tokenize/parsing_tests.rs @@ -273,6 +273,17 @@ mod tracing_tests { assert!(!logs_contain("[^4]")); } + #[traced_test] + #[test] + fn find_footnote_end_logs_label_span_recognized() { + let _ = find_footnote_end("[^4] tail", 0); + assert!(logs_contain("footnote label span recognized")); + assert!(logs_contain("start=")); + assert!(logs_contain("end=")); + assert!(logs_contain("token_length=4")); + assert!(!logs_contain("[^4]")); + } + #[traced_test] #[test] fn find_footnote_end_logs_unterminated_bracket() { diff --git a/tests/wrap_unit/footnotes.rs b/tests/wrap_unit/footnotes.rs index 0334657b..c86e27ff 100644 --- a/tests/wrap_unit/footnotes.rs +++ b/tests/wrap_unit/footnotes.rs @@ -2,6 +2,7 @@ use mdtablefix::wrap::wrap_text; use rstest::rstest; +use tracing_test::traced_test; /// Keep the pre-split snapshot layout: file names live in `tests/snapshots/` /// and use the legacy `wrap_unit__` prefix without the module @@ -52,6 +53,22 @@ fn wrap_text_preserves_inline_footnote_references(#[case] marker: &str) { ); } +/// Confirms the inline-classification instrumentation is reachable through the +/// public `wrap_text` API, not just via the internal helpers exercised in +/// `src/wrap`. Drives a footnote reference through the wrapping pipeline and +/// asserts the DEBUG `fragment classified` event fires with the `FootnoteRef` +/// kind. +#[traced_test] +#[test] +fn wrap_text_emits_fragment_classification_for_footnote_reference() { + let input = lines_vec!["Some text.[^1]"]; + + let _ = wrap_text(&input, 80); + + assert!(logs_contain("fragment classified")); + assert!(logs_contain("kind=FootnoteRef")); +} + #[test] fn wrap_text_snapshots_inline_footnote_reference_outputs() { let input = lines_vec![concat!( From eb54a4e183187b1193b63a2f8086de2b1843da30 Mon Sep 17 00:00:00 2001 From: leynos Date: Mon, 27 Jul 2026 20:05:46 +0200 Subject: [PATCH 2/2] Tighten footnote span assertions and document no-env-filter Address post-review feedback on the tracing-test additions. - Assert exact span metadata (`start=0`, `end=4`) in the `find_footnote_end` label-span traced test so an incorrect offset fails the test, rather than only checking the fields are present. - Document in the developers' guide why `tracing-test` is enabled with the `no-env-filter` feature: the default per-crate filter hides library events from integration tests under `tests/`. Co-Authored-By: Claude Opus 4.8 (1M context) --- docs/developers-guide.md | 9 +++++++++ src/wrap/tokenize/parsing_tests.rs | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/docs/developers-guide.md b/docs/developers-guide.md index 499253e9..907b9f61 100644 --- a/docs/developers-guide.md +++ b/docs/developers-guide.md @@ -551,6 +551,15 @@ global subscriber or metrics recorder. Executables and test harnesses that want log output must install their own subscriber (e.g. `tracing_subscriber::fmt::init()` in `main`). +`tracing-test` is enabled with its `no-env-filter` feature. By default +`#[traced_test]` installs a per-crate environment filter that only captures +events emitted from the test's own crate, so an integration test under `tests/` +would silently miss events emitted from the `mdtablefix` library crate and its +`logs_contain(...)` assertions would fail even when the event fires. The +`no-env-filter` feature removes that filter, so integration-level traced tests +observe the library's instrumentation. Keep this feature enabled when adding +end-to-end traced tests that assert on library events. + ### Log levels Use `debug!` for high-value classification outcomes: fragment kind, parsed diff --git a/src/wrap/tokenize/parsing_tests.rs b/src/wrap/tokenize/parsing_tests.rs index f05cdcc6..59761cb7 100644 --- a/src/wrap/tokenize/parsing_tests.rs +++ b/src/wrap/tokenize/parsing_tests.rs @@ -278,8 +278,8 @@ mod tracing_tests { fn find_footnote_end_logs_label_span_recognized() { let _ = find_footnote_end("[^4] tail", 0); assert!(logs_contain("footnote label span recognized")); - assert!(logs_contain("start=")); - assert!(logs_contain("end=")); + assert!(logs_contain("start=0")); + assert!(logs_contain("end=4")); assert!(logs_contain("token_length=4")); assert!(!logs_contain("[^4]")); }