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/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 c6fc05c8..59761cb7 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=0")); + assert!(logs_contain("end=4")); + 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!(