Conversation
Reviewer's GuideThis PR reorganizes the integration test suite by replacing two monolithic test files with modular directories under File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Warning Rate limit exceeded@leynos has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 5 minutes and 34 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (1)
Summary by CodeRabbit
WalkthroughSplit the previously monolithic integration tests for table and wrapping functionalities into multiple focused modules. Remove Changes
Sequence Diagram(s)sequenceDiagram
participant TestRunner
participant Fixtures
participant TableFunctions
participant WrapFunctions
TestRunner->>Fixtures: Load test input data
TestRunner->>TableFunctions: Call reflow_table/process_stream/convert_html_tables
TableFunctions-->>TestRunner: Return processed output
TestRunner->>Fixtures: Load expected output data
TestRunner->>TestRunner: Assert output matches expectation
TestRunner->>WrapFunctions: Call process_stream with wrap scenarios
WrapFunctions-->>TestRunner: Return wrapped output
TestRunner->>TestRunner: Assert output structure and formatting
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Poem
✨ Finishing Touches
🧪 Generate unit tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 8
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (15)
tests/table.rs(0 hunks)tests/table/data.rs(1 hunks)tests/table/fixtures.rs(1 hunks)tests/table/html.rs(1 hunks)tests/table/mod.rs(1 hunks)tests/table/process.rs(1 hunks)tests/table/reflow.rs(1 hunks)tests/wrap.rs(0 hunks)tests/wrap/blockquotes.rs(1 hunks)tests/wrap/cli.rs(1 hunks)tests/wrap/footnotes.rs(1 hunks)tests/wrap/hard_breaks.rs(1 hunks)tests/wrap/lists.rs(1 hunks)tests/wrap/mod.rs(1 hunks)tests/wrap/paragraphs.rs(1 hunks)
💤 Files with no reviewable changes (2)
- tests/table.rs
- tests/wrap.rs
🧰 Additional context used
📓 Path-based instructions (1)
**/*.rs
⚙️ CodeRabbit Configuration File
**/*.rs: * Seek to keep the cyclomatic complexity of functions no more than 12.
Adhere to single responsibility and CQRS
Place function attributes after doc comments.
Do not use
returnin single-line functions.Move conditionals with >2 branches into a predicate function.
Avoid
unsafeunless absolutely necessary.Every module must begin with a
//!doc comment that explains the module's purpose and utility.Comments and docs must follow en-GB-oxendict (-ize / -our) spelling and grammar
Lints must not be silenced except as a last resort.
#[allow]is forbidden.- Only narrowly scoped
#[expect(lint, reason = "...")]is allowed.- No lint groups, no blanket or file-wide suppression.
- Include
FIXME:with link if a fix is expected.Use
rstestfixtures for shared setup and to avoid repetition between tests.Replace duplicated tests with
#[rstest(...)]parameterised cases.Prefer
mockallfor mocks/stubs.Prefer
.expect()over.unwrap()Ensure that any API or behavioural changes are reflected in the documentation in
docs/Ensure that any completed roadmap steps are recorded in the appropriate roadmap in
docs/Files must not exceed 400 lines in length
- Large modules must be decomposed
- Long match statements or dispatch tables should be decomposed by domain and collocated with targets
- Large blocks of inline data (e.g., test fixtures, constants or templates) must be moved to external files and inlined at compile-time or loaded at run-time.
Files:
tests/table/mod.rstests/wrap/cli.rstests/wrap/mod.rstests/wrap/blockquotes.rstests/table/html.rstests/wrap/footnotes.rstests/wrap/hard_breaks.rstests/wrap/paragraphs.rstests/wrap/lists.rstests/table/data.rstests/table/reflow.rstests/table/process.rstests/table/fixtures.rs
🧬 Code Graph Analysis (2)
tests/table/reflow.rs (3)
src/table.rs (1)
reflow_table(166-185)tests/common/mod.rs (1)
broken_table(97-102)tests/table/fixtures.rs (4)
malformed_table(9-12)header_table(15-17)escaped_pipe_table(20-22)indented_table(25-28)
tests/table/process.rs (2)
src/process.rs (1)
process_stream(206-214)tests/table/fixtures.rs (5)
html_table(31-38)html_table_with_attrs(41-48)html_table_uppercase(113-120)html_table_mixed_case(123-130)multiple_tables(133-135)
🔇 Additional comments (27)
tests/wrap/cli.rs (1)
10-25: Well-structured CLI integration test.The test effectively validates the wrapping functionality through the command-line interface, checking both that wrapping occurs and that line limits are respected.
tests/wrap/mod.rs (1)
1-8: Excellent modular test organisation.The module structure clearly separates wrapping test concerns into focused submodules, improving maintainability over the previous monolithic approach.
tests/wrap/paragraphs.rs (2)
1-4: Clear and comprehensive module documentation.The documentation effectively explains the module's purpose and scope, making it easy for future maintainers to understand the test coverage.
12-77: Comprehensive paragraph wrapping test coverage.The tests effectively cover key scenarios including basic wrapping, edge cases with long words, and critical link preservation behaviour. The assertions properly validate both structural and content requirements.
tests/wrap/blockquotes.rs (2)
12-102: Thorough blockquote wrapping test coverage.The tests comprehensively cover blockquote scenarios including nesting, mixed indentation, and whitespace handling. The content preservation verification through string manipulation is well-implemented.
35-35: Confirm existence of assert_wrapped_blockquote helperFound
assert_wrapped_blockquoteimplemented in tests/common/mod.rs:pub fn assert_wrapped_blockquote(output: &[String], prefix: &str, expected: usize) { assert!(!output.is_empty(), "output slice is empty"); assert_eq!(output.len(), expected); assert!(output.iter().all(|l| l.starts_with(prefix))); assert!(output.iter().all(|l| l.len() <= 80)); }No further action required.
tests/wrap/hard_breaks.rs (3)
28-48: Comprehensive edge case coverage for hard breaks.The test thoroughly covers various backslash scenarios and edge cases, ensuring robust handling of hard line break markers.
1-4: Clear module documentation for hard break testing.The documentation effectively communicates the module's focus on hard line break validation with different marker types.
23-25: Confirm external hard-linebreak test data presenceConfirm that both data files exist:
- tests/data/hard_linebreak_input.txt
- tests/data/hard_linebreak_expected.txt
No missing files. Approve the test implementation.
tests/wrap/lists.rs (4)
1-11: Excellent module organisation and documentation.The module doc comment properly explains the purpose and scope, following the required //! format. The import structure is clean and the prelude pattern is well-implemented.
12-19: Clear and focused test implementation.The test follows single responsibility principle with a descriptive name and straightforward logic.
21-34: Excellent use of rstest parameterisation.Perfect implementation of the coding guideline to replace duplicated tests with parameterised cases. The test coverage across different list prefixes is comprehensive.
36-108: Comprehensive test coverage with good practices.All test functions demonstrate:
- Single responsibility principle
- Descriptive naming
- Proper use of
.expect()over.unwrap()- Good edge case coverage including short items that shouldn't wrap
The additional assertion in
test_wrap_long_inline_code_itemchecking line ending is particularly thorough.tests/wrap/footnotes.rs (4)
1-11: Proper module structure and clear documentation.The module doc comment follows the required //! format and clearly explains the footnote wrapping functionality. The import structure is consistent with the other wrap test modules.
12-20: Well-structured footnote wrapping test.Clear test purpose with appropriate use of
concat!for constructing the test input. The test follows single responsibility principle.
22-30: Good coverage of footnotes with inline code.The test properly handles indented footnotes and ensures inline code spans remain intact during wrapping - important edge case coverage.
32-61: Thorough edge case coverage with precise assertions.Both tests provide important coverage:
- Angle-bracketed URL formatting with proper indentation
- Idempotency testing ensuring short footnotes remain unchanged
The use of explicit expected output provides precise verification of formatting behaviour.
tests/table/mod.rs (1)
1-7: LGTM!Clean module organization with proper documentation. The modular structure improves maintainability by separating fixtures, unit tests, integration tests, and data-driven tests.
tests/table/reflow.rs (1)
12-16: Remove incorrect fixture usage suggestionThe
broken_tablefixture is defined intests/common/mod.rs(line 97) and is available across all test modules. No changes required to test references.Likely an incorrect or invalid review comment.
tests/table/process.rs (3)
12-22: LGTM!Excellent use of rstest parameterised testing to cover multiple HTML table variants with a single test function. This approach reduces duplication whilst maintaining comprehensive coverage.
30-37: LGTM!Good test coverage for code fence handling with both backtick and tilde variants. The test correctly verifies that content within code fences remains unchanged.
61-87: LGTM!Comprehensive test that verifies
process_streamcorrectly processes mixed content, transforming only table lines whilst preserving other markdown elements unchanged.tests/table/html.rs (5)
3-11: LGTM!The import structure is well-organised and follows proper Rust conventions with appropriate use of the prelude pattern and fixture imports.
12-21: LGTM!Excellent use of parameterised testing with rstest. The test cases are well-named and cover different standard HTML table scenarios effectively.
23-31: LGTM!Good separation of reduced table scenarios into a dedicated parameterised test. The test organisation is logical and follows the established pattern.
33-63: LGTM!The individual test functions appropriately cover edge cases that don't fit well into parameterised tests. Each test is focused and has a clear, descriptive name.
65-70: LGTM!Excellent use of external data files for test fixtures, following the guideline to move large blocks of inline data to external files. The test is clean and well-structured.
There was a problem hiding this comment.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (5)
tests/table/data.rs(1 hunks)tests/table/fixtures.rs(1 hunks)tests/table/html.rs(1 hunks)tests/table/reflow.rs(1 hunks)tests/wrap/cli.rs(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.rs
📄 CodeRabbit Inference Engine (AGENTS.md)
**/*.rs: Clippy warnings MUST be disallowed.
Fix any warnings emitted during tests in the code itself rather than silencing them.
Where a function is too long, extract meaningfully named helper functions adhering to separation of concerns and CQRS.
Where a function has too many parameters, group related parameters in meaningfully named structs.
Where a function is returning a large error consider usingArcto reduce the amount of data returned.
Write unit and behavioural tests for new functionality. Run both before and after making any change.
Every module must begin with a module level (//!) comment explaining the module's purpose and utility.
Document public APIs using Rustdoc comments (///) so documentation can be generated with cargo doc.
Prefer immutable data and avoid unnecessarymutbindings.
Handle errors with theResulttype instead of panicking where feasible.
Avoidunsafecode unless absolutely necessary and document any usage clearly.
Place function attributes after doc comments.
Do not usereturnin single-line functions.
Use predicate functions for conditional criteria with more than two branches.
Lints must not be silenced except as a last resort.
Lint rule suppressions must be tightly scoped and include a clear reason.
Preferexpectoverallow.
Prefer.expect()over.unwrap().
Useconcat!()to combine long string literals rather than escaping newlines with a backslash.
Prefer semantic error enums: Derivestd::error::Error(via thethiserrorcrate) for any condition the caller might inspect, retry, or map to an HTTP status.
Use an opaque error only at the app boundary: Useeyre::Reportfor human-readable logs; these should not be exposed in public APIs.
Never export the opaque type from a library: Convert to domain enums at API boundaries, and toeyreonly in the mainmain()entrypoint or top-level async task.
Files:
tests/wrap/cli.rstests/table/data.rstests/table/reflow.rstests/table/html.rstests/table/fixtures.rs
⚙️ CodeRabbit Configuration File
**/*.rs: * Seek to keep the cyclomatic complexity of functions no more than 12.
Adhere to single responsibility and CQRS
Place function attributes after doc comments.
Do not use
returnin single-line functions.Move conditionals with >2 branches into a predicate function.
Avoid
unsafeunless absolutely necessary.Every module must begin with a
//!doc comment that explains the module's purpose and utility.Comments and docs must follow en-GB-oxendict (-ize / -our) spelling and grammar
Lints must not be silenced except as a last resort.
#[allow]is forbidden.- Only narrowly scoped
#[expect(lint, reason = "...")]is allowed.- No lint groups, no blanket or file-wide suppression.
- Include
FIXME:with link if a fix is expected.Use
rstestfixtures for shared setup and to avoid repetition between tests.Replace duplicated tests with
#[rstest(...)]parameterised cases.Prefer
mockallfor mocks/stubs.Prefer
.expect()over.unwrap()Ensure that any API or behavioural changes are reflected in the documentation in
docs/Ensure that any completed roadmap steps are recorded in the appropriate roadmap in
docs/Files must not exceed 400 lines in length
- Large modules must be decomposed
- Long match statements or dispatch tables should be decomposed by domain and collocated with targets
- Large blocks of inline data (e.g., test fixtures, constants or templates) must be moved to external files and inlined at compile-time or loaded at run-time.
Files:
tests/wrap/cli.rstests/table/data.rstests/table/reflow.rstests/table/html.rstests/table/fixtures.rs
🧬 Code Graph Analysis (3)
tests/table/data.rs (2)
src/process.rs (1)
process_stream(206-214)src/table.rs (1)
reflow_table(166-185)
tests/table/reflow.rs (3)
src/table.rs (1)
reflow_table(166-185)tests/common/mod.rs (1)
broken_table(97-102)tests/table/fixtures.rs (4)
malformed_table(9-11)header_table(14-16)escaped_pipe_table(19-21)indented_table(24-26)
tests/table/html.rs (2)
src/html.rs (1)
convert_html_tables(299-342)tests/table/fixtures.rs (10)
html_table(29-36)html_table_with_attrs(39-46)html_table_uppercase(109-116)html_table_with_colspan(49-56)html_table_inconsistent_first_row(89-96)html_table_no_header(59-66)html_table_empty_row(69-76)html_table_whitespace_header(79-86)html_table_empty(99-101)html_table_unclosed(104-106)
🔇 Additional comments (7)
tests/table/data.rs (1)
1-35: Excellent implementation of parameterised tests!The use of
rstestwith parameterised test cases effectively eliminates code duplication whilst maintaining clear test coverage. The module documentation is appropriate and the test structure follows Rust testing best practices.tests/table/reflow.rs (2)
12-25: Well-designed helper function eliminates duplication.The
assert_uniform_column_widthshelper function effectively removes the duplicated validation logic identified in previous reviews whilst maintaining clear test readability.
27-82: Comprehensive test coverage with clean structure.The test suite provides thorough coverage of
reflow_tablefunctionality, including edge cases, malformed input handling, and complex table scenarios. The use of rstest fixtures promotes consistency and maintainability.tests/table/html.rs (2)
1-6: Excellent module documentation enhancement.The expanded module documentation clearly describes the scope and coverage of the HTML table conversion tests, addressing the previous review feedback effectively.
16-74: Comprehensive and well-structured test suite.The parameterised test structure effectively organises standard cases versus edge cases, providing thorough coverage of HTML table conversion scenarios whilst maintaining clean, readable test code.
tests/table/fixtures.rs (1)
8-131: Comprehensive and consistent fixture implementation.The fixture definitions provide excellent coverage of various table scenarios with consistent implementation patterns. The direct use of
lines_vec!macro returns maintains clean, readable code throughout all fixtures.tests/wrap/cli.rs (1)
4-7: Import structure follows established test patterns.The prelude import pattern is consistent with the modular test suite organisation and appropriately uses the shared test utilities.
| fn test_cli_wrap_option() { | ||
| let input = "This line is deliberately made much longer than eighty columns so that the \ | ||
| wrapping algorithm is forced to insert a soft line-break somewhere in the middle \ | ||
| of the paragraph when the --wrap flag is supplied."; | ||
| let output = Command::cargo_bin("mdtablefix") | ||
| .expect("Failed to create cargo command for mdtablefix") | ||
| .arg("--wrap") | ||
| .write_stdin(format!("{input}\n")) | ||
| .output() | ||
| .expect("Failed to execute mdtablefix command"); | ||
| assert!(output.status.success()); | ||
| let text = String::from_utf8_lossy(&output.stdout); | ||
| assert!(text.lines().count() > 1, "expected wrapped output on multiple lines"); | ||
| assert!(text.lines().all(|l| l.len() <= 80)); | ||
| } |
There was a problem hiding this comment.
🧹 Nitpick (assertive)
Use concat!() macro for long string literals.
The test logic is excellent and thoroughly validates the CLI wrap functionality. However, replace the backslash-escaped string continuation with the concat!() macro as per coding guidelines.
- let input = "This line is deliberately made much longer than eighty columns so that the \
- wrapping algorithm is forced to insert a soft line-break somewhere in the middle \
- of the paragraph when the --wrap flag is supplied.";
+ let input = concat!(
+ "This line is deliberately made much longer than eighty columns so that the ",
+ "wrapping algorithm is forced to insert a soft line-break somewhere in the middle ",
+ "of the paragraph when the --wrap flag is supplied."
+ );The test effectively validates:
- CLI command execution
- Wrapping behaviour activation
- Output line length constraints
- Multi-line output generation
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| fn test_cli_wrap_option() { | |
| let input = "This line is deliberately made much longer than eighty columns so that the \ | |
| wrapping algorithm is forced to insert a soft line-break somewhere in the middle \ | |
| of the paragraph when the --wrap flag is supplied."; | |
| let output = Command::cargo_bin("mdtablefix") | |
| .expect("Failed to create cargo command for mdtablefix") | |
| .arg("--wrap") | |
| .write_stdin(format!("{input}\n")) | |
| .output() | |
| .expect("Failed to execute mdtablefix command"); | |
| assert!(output.status.success()); | |
| let text = String::from_utf8_lossy(&output.stdout); | |
| assert!(text.lines().count() > 1, "expected wrapped output on multiple lines"); | |
| assert!(text.lines().all(|l| l.len() <= 80)); | |
| } | |
| fn test_cli_wrap_option() { | |
| let input = concat!( | |
| "This line is deliberately made much longer than eighty columns so that the ", | |
| "wrapping algorithm is forced to insert a soft line-break somewhere in the middle ", | |
| "of the paragraph when the --wrap flag is supplied." | |
| ); | |
| let output = Command::cargo_bin("mdtablefix") | |
| .expect("Failed to create cargo command for mdtablefix") | |
| .arg("--wrap") | |
| .write_stdin(format!("{input}\n")) | |
| .output() | |
| .expect("Failed to execute mdtablefix command"); | |
| assert!(output.status.success()); | |
| let text = String::from_utf8_lossy(&output.stdout); | |
| assert!(text.lines().count() > 1, "expected wrapped output on multiple lines"); | |
| assert!(text.lines().all(|l| l.len() <= 80)); | |
| } |
🤖 Prompt for AI Agents
In tests/wrap/cli.rs around lines 10 to 24, replace the backslash-escaped
multiline string literal with the concat!() macro to join string literals at
compile time. This involves rewriting the input string using concat!() with
multiple string slices instead of a single escaped string, adhering to coding
guidelines for long strings.
|
To be re-attempted |
Summary
wrap.rstests into feature modules undertests/wrap/table.rstests into feature modules undertests/table/tests/wrap/mod.rsandtests/table/mod.rsTesting
make fmtmake lintmake testhttps://chatgpt.com/codex/tasks/task_e_6888f6ed2088832281af0eec890409b2
Summary by Sourcery
Reorganize integration tests by splitting monolithic wrap and table test files into feature-based modules and updating directory structure accordingly
Enhancements: