Skip to content

Organize integration tests#139

Closed
leynos wants to merge 3 commits intomainfrom
codex/refactor-test-organization-into-modules
Closed

Organize integration tests#139
leynos wants to merge 3 commits intomainfrom
codex/refactor-test-organization-into-modules

Conversation

@leynos
Copy link
Copy Markdown
Owner

@leynos leynos commented Jul 29, 2025

Summary

  • split wrap.rs tests into feature modules under tests/wrap/
  • split table.rs tests into feature modules under tests/table/
  • reference the new modules via tests/wrap/mod.rs and tests/table/mod.rs

Testing

  • make fmt
  • make lint
  • make test

https://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:

  • Split wrapping tests into separate feature modules under tests/wrap and reference them via tests/wrap/mod.rs
  • Split table tests into fixtures, reflow, process, html, and data modules under tests/table and reference them via tests/table/mod.rs
  • Remove legacy tests/wrap.rs and tests/table.rs to complete the reorganization

@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented Jul 29, 2025

Reviewer's Guide

This PR reorganizes the integration test suite by replacing two monolithic test files with modular directories under tests/wrap/ and tests/table/, introducing indexed mod.rs files, fixtures modules, and feature-specific test files.

File-Level Changes

Change Details Files
Restructure integration tests into modular subdirectories
  • Remove legacy tests/table.rs and tests/wrap.rs
  • Introduce tests/table/mod.rs and tests/wrap/mod.rs as entry points
  • Split existing tests into dedicated modules under each directory
tests/table.rs
tests/wrap.rs
tests/table/mod.rs
tests/wrap/mod.rs
Add shared table fixtures
  • Create fixtures for various table shapes and edge cases
  • Use a common prelude macro for line vector construction
tests/table/fixtures.rs
Implement wrap tests in feature modules
  • Cover paragraphs, lists, footnotes, blockquotes, hard breaks, and CLI wrap cases
  • Reuse prelude macros and assert helpers in each file
tests/wrap/paragraphs.rs
tests/wrap/lists.rs
tests/wrap/footnotes.rs
tests/wrap/blockquotes.rs
tests/wrap/hard_breaks.rs
tests/wrap/cli.rs
Implement table tests in feature modules
  • Add tests for process_stream, reflow_table, convert_html_tables
  • Include external data-driven tests via data.rs
tests/table/process.rs
tests/table/reflow.rs
tests/table/html.rs
tests/table/data.rs

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jul 29, 2025

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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.

📥 Commits

Reviewing files that changed from the base of the PR and between 50c3651 and 66de6ef.

📒 Files selected for processing (1)
  • tests/wrap/cli.rs (1 hunks)

Summary by CodeRabbit

  • Tests
    • Reorganised and expanded the test suite for table and text wrapping features.
    • Added dedicated test modules for paragraphs, lists, footnotes, blockquotes, hard breaks, and CLI wrapping behaviour.
    • Improved test coverage for table reflow and HTML-to-markdown table conversion, including edge cases and real-world examples.
    • Enhanced tests for list item and blockquote wrapping, inline code handling, and preservation of markdown formatting.
    • Removed legacy integration test files in favour of more modular and comprehensive test cases.

Walkthrough

Split the previously monolithic integration tests for table and wrapping functionalities into multiple focused modules. Remove tests/table.rs and tests/wrap.rs, introducing new submodules for fixtures, reflow, process, HTML conversion, data-driven table tests, and various wrapping scenarios (paragraphs, lists, blockquotes, footnotes, hard breaks, CLI). Add public test fixture functions and modularise all related test logic.

Changes

Cohort / File(s) Change Summary
Table test modularisation
tests/table.rs (removed), tests/table/mod.rs, tests/table/fixtures.rs, tests/table/reflow.rs, tests/table/process.rs, tests/table/html.rs, tests/table/data.rs
Remove monolithic table integration test. Add modular test suite for table handling: fixtures, reflow, process, HTML conversion, and data-driven tests. Introduce public fixture functions and multiple focused test cases for each aspect.
Wrap test modularisation
tests/wrap.rs (removed), tests/wrap/mod.rs, tests/wrap/paragraphs.rs, tests/wrap/lists.rs, tests/wrap/footnotes.rs, tests/wrap/blockquotes.rs, tests/wrap/hard_breaks.rs, tests/wrap/cli.rs
Remove monolithic wrap integration test. Add modular test suite for wrapping: paragraphs, lists, blockquotes, footnotes, hard breaks, and CLI behaviour. Implement focused tests for each scenario.
Test fixture and data-driven additions
tests/table/fixtures.rs, tests/table/data.rs
Add public fixture functions for various table formats and data-driven tests using external files to verify output correctness across scenarios.
Module declarations
tests/table/mod.rs, tests/wrap/mod.rs
Add new module declarations for all submodules, structuring the test suite for clarity and maintainability.

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
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Poem

Split the tests and let them grow,
Each module shines with its own glow.
Tables reflow, wrap lines anew,
Fixtures and data, all neatly in view.
From monolith to modules, the suite takes flight—
Here’s to code that’s tested right!
🧪✨

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch codex/refactor-test-organization-into-modules

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need 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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @leynos - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@leynos
Copy link
Copy Markdown
Owner Author

leynos commented Jul 29, 2025

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jul 29, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@leynos
Copy link
Copy Markdown
Owner Author

leynos commented Jul 29, 2025

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jul 29, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 8

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 35b50b8 and 735e4ae.

📒 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 return in single-line functions.

  • Move conditionals with >2 branches into a predicate function.

  • Avoid unsafe unless 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 rstest fixtures for shared setup and to avoid repetition between tests.

  • Replace duplicated tests with #[rstest(...)] parameterised cases.

  • Prefer mockall for 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.rs
  • tests/wrap/cli.rs
  • tests/wrap/mod.rs
  • tests/wrap/blockquotes.rs
  • tests/table/html.rs
  • tests/wrap/footnotes.rs
  • tests/wrap/hard_breaks.rs
  • tests/wrap/paragraphs.rs
  • tests/wrap/lists.rs
  • tests/table/data.rs
  • tests/table/reflow.rs
  • tests/table/process.rs
  • tests/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 helper

Found assert_wrapped_blockquote implemented 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 presence

Confirm 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_item checking 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 suggestion

The broken_table fixture is defined in tests/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_stream correctly 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.

Comment thread tests/table/data.rs Outdated
Comment thread tests/table/fixtures.rs
Comment thread tests/table/fixtures.rs
Comment thread tests/table/fixtures.rs
Comment thread tests/table/fixtures.rs
Comment thread tests/table/html.rs
Comment thread tests/table/reflow.rs
Comment thread tests/wrap/cli.rs Outdated
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 735e4ae and 50c3651.

📒 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 using Arc to 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 unnecessary mut bindings.
Handle errors with the Result type instead of panicking where feasible.
Avoid unsafe code unless absolutely necessary and document any usage clearly.
Place function attributes after doc comments.
Do not use return in 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.
Prefer expect over allow.
Prefer .expect() over .unwrap().
Use concat!() to combine long string literals rather than escaping newlines with a backslash.
Prefer semantic error enums: Derive std::error::Error (via the thiserror crate) for any condition the caller might inspect, retry, or map to an HTTP status.
Use an opaque error only at the app boundary: Use eyre::Report for 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 to eyre only in the main main() entrypoint or top-level async task.

Files:

  • tests/wrap/cli.rs
  • tests/table/data.rs
  • tests/table/reflow.rs
  • tests/table/html.rs
  • tests/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 return in single-line functions.

  • Move conditionals with >2 branches into a predicate function.

  • Avoid unsafe unless 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 rstest fixtures for shared setup and to avoid repetition between tests.

  • Replace duplicated tests with #[rstest(...)] parameterised cases.

  • Prefer mockall for 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.rs
  • tests/table/data.rs
  • tests/table/reflow.rs
  • tests/table/html.rs
  • tests/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 rstest with 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_widths helper 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_table functionality, 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.

Comment thread tests/wrap/cli.rs Outdated
Comment thread tests/wrap/cli.rs
Comment on lines +10 to +24
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));
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 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.

Suggested change
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.

@leynos
Copy link
Copy Markdown
Owner Author

leynos commented Jul 30, 2025

To be re-attempted

@leynos leynos closed this Jul 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant