Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
9 changes: 9 additions & 0 deletions docs/developers-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions src/wrap/tokenize/parsing_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
17 changes: 17 additions & 0 deletions tests/wrap_unit/footnotes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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__<name>` prefix without the module
Expand Down Expand Up @@ -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!(
Expand Down
Loading