-
Notifications
You must be signed in to change notification settings - Fork 13
Support for doctests report event #91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Thanks! I'm on vacation at the moment but will take a look soon! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds support for the "report" event that is emitted by Rust edition 2024 doctests. In edition 2024, rustdoc combines doctests into a single binary, which produces an additional { "type": "report" ... } event after execution containing timing information. The implementation correctly handles this event by ignoring it, as all necessary test results are already captured from the standard test events.
Key Changes
- Added
DoctestsReportvariant to theEventenum to deserialize the new report event type - Implemented parsing logic to safely ignore report events since they contain only informational timing data
- Added comprehensive test coverage with a new edition 2024 doctest generator and corresponding test input/output files
Reviewed changes
Copilot reviewed 8 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/main.rs | Added DoctestsReport event variant, parsing logic to ignore it, and test case for edition 2024 doctests |
| src/test_inputs/doctests_edition2024.json | Test input containing edition 2024 doctest events including the new report event |
| src/expected_outputs/doctests_edition2024.out | Expected XML output for the doctests edition 2024 test case |
| test_input_generators/doctests_edition2024/src/main.rs | Empty main function for the test input generator |
| test_input_generators/doctests_edition2024/src/lib.rs | Library with various doctest scenarios (passing, failing, should_panic, ignore) |
| test_input_generators/doctests_edition2024/Cargo.toml | Cargo manifest configured for edition 2024 to generate report events |
| test_input_generators/doctests_edition2024/Cargo.lock | Lock file for the test input generator |
| regenerate_test_inputs.sh | New script to regenerate test inputs from test generators |
| rebuild_expected_outputs.sh | Updated with new exclusion for unknown_type.json and modified error handling |
| .gitignore | Changed from /target/ to **/target/ to ignore all target directories including those in test generators |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| #[serde(rename = "report")] | ||
| DoctestsReport { | ||
| total_time: f64, | ||
| compilation_time: f64, | ||
| } |
Copilot
AI
Jan 2, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The enum variant name DoctestsReport is inconsistent with the existing naming pattern in the Event enum. Other variants like Suite and Test use simple, singular names without additional qualifiers. Consider renaming to just Report to maintain consistency with the existing pattern.
| Duration::nanoseconds(duration_ns) | ||
| } | ||
| }, | ||
| Event::DoctestsReport { .. } => panic!(), |
Copilot
AI
Jan 2, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The panic!() call here could be problematic if get_duration() is ever called on a DoctestsReport event. While this may never happen in the current code flow (since report events are ignored in parsing), it would be more robust to either return a default Duration (like Duration::nanoseconds(0)) or add a comment explaining why this panic is safe. Consider using unreachable!("DoctestsReport events do not have duration") to make the intent clearer.
| Event::DoctestsReport { .. } => panic!(), | |
| Event::DoctestsReport { .. } => unreachable!("DoctestsReport events do not have duration"), |
| if [[ "$f" == 'src/test_inputs/one_suite_no_tests.json' ]]; then continue; fi | ||
| cargo run < "$f" > "${f%.json}.out" || ( echo $f | grep "fail" ) | ||
| if [[ "$f" == 'src/test_inputs/unknown_type.json' ]]; then continue; fi | ||
| cargo run < "$f" > "${f%.json}.out" || true |
Copilot
AI
Jan 2, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change from || ( echo $f | grep "fail" ) to || true changes the error handling behavior. The original version allowed only files with "fail" in their name to fail without causing the script to exit, while the new version suppresses all errors indiscriminately. This could mask legitimate failures when processing test inputs. Consider either reverting to the original pattern or documenting why all failures should now be ignored.
| cargo run < "$f" > "${f%.json}.out" || true | |
| cargo run < "$f" > "${f%.json}.out" || ( echo "$f" | grep "fail" ) |
Fix #90 by handling (ignoring) "report" event