Skip to content

Add shared rstest detection module and public APIs (8.1.1)#171

Merged
leynos merged 7 commits intomainfrom
add-rstest-shared-helpers-6s7gfc
Apr 10, 2026
Merged

Add shared rstest detection module and public APIs (8.1.1)#171
leynos merged 7 commits intomainfrom
add-rstest-shared-helpers-6s7gfc

Conversation

@leynos
Copy link
Copy Markdown
Owner

@leynos leynos commented Mar 26, 2026

Summary

  • Documents the new rstest public APIs exposed by Whitaker-common and adds API re-exports, tests, and a behavioural harness to support roadmap item 8.1.1.

Changes

  • Added new rstest module structure under common/src/rstest including:
    • detection.rs, parameter.rs, mod.rs, and tests.rs
  • Re-exported the new rstest API from the Whitaker-common crate via lib.rs:
    • ExpansionTrace, RstestDetectionOptions, is_rstest_test/is_rstest_test_with, is_rstest_fixture/is_rstest_fixture_with, ParameterBinding, RstestParameter, RstestParameterKind, classify_rstest_parameter, fixture_local_names
  • Updated workspace dependencies and crate naming to reflect the move to Whitaker-common (renamed common to whitaker-common in workspace and code paths)
  • Added unit tests for rstest detection and parameter classification (common/src/rstest/tests.rs)
  • Added behavioural tests for rstest detection (common/tests/rstest_detection_behaviour.rs)
  • Added a behavioural feature file (common/tests/features/rstest_detection.feature)
  • Implemented rstest behavioural harness (common/tests/rstest_detection_behaviour.rs)
  • Introduced a dedicated ExecPlan document for 8.1.1: docs/execplans/8-1-1-shared-rstest-test-and-fixture-detection-helpers.md
  • Updated design and roadmap documentation to reflect the new API and approach:
    • docs/lints-for-rstest-fixtures-and-test-hygiene.md (Implementation decisions for 8.1.1)
    • docs/roadmap.md: mark 8.1.1 as done
  • Kept the ExecPlan as a live reference and aligned tests/docs with the plan requirements.
  • Preserved task references and metadata, including the DevBoxer task link.

Rationale

  • Establishes a pure-library surface in whitaker-common for rstest detection that does not rely on rustc_private, enabling lint items to consume a stable substrate.
  • Separates test/fixture detection from broader generic helpers to prevent semantic leakage and to support future lints that depend on precise distinctions between tests, fixtures, and provider parameters.
  • Provides optional expansion-trace fallback to accompany cases where direct attributes are unavailable, preserving a conservative default while enabling richer detection when metadata is provided.

Plan / Work plan (high level)

  • Stage B: Add failing unit tests that define the 8.1.1 detection contract.
  • Stage C: Add failing rstest-bdd scenarios for the same contract.
  • Stage D: Implement the shared pure-library rstest detection module in whitaker-common.
  • Stage E: Re-export the new API from whitaker-common/src/lib.rs and add Rustdoc examples.
  • Stage F: Record implementation decisions in the design docs.
  • Stage G: Mark roadmap item 8.1.1 done after gates pass.
  • Stage H: Validate with documentation gates and code quality checks.
  • Stage I: Finalize living sections in the ExecPlan.

Acceptance criteria

  • The ExecPlan exists and remains a live reference for 8.1.1.
  • It provides a clear path for implementing the shared rstest detection module in Whitaker-common.
  • The plan references the required gates: unit tests, behavioural tests, API re-export, and documentation updates.
  • Documentation gates align with docs/lints-for-rstest-fixtures-and-test-hygiene.md and docs/roadmap.md.

Context and references

  • Related planning and design documents can be found in:
    • docs/lints-for-rstest-fixtures-and-test-hygiene.md
    • docs/roadmap.md

Notes

  • This PR implements the shared rstest detection module and accompanying tests/docs; it is not a documentation-only change.
  • ◳ Generated by DevBoxer

ℹ️ Tag @devboxerhub to ask questions and address PR feedback

📎 Task: https://www.devboxer.com/task/b1c351db-cf54-4486-b6dd-2b78d41d156a

Summary by Sourcery

Add a shared_rstest detection module to the Whitaker-common crate, exposing a stable API for identifying rstest tests, fixtures, and provider parameters, with accompanying tests and documentation updates.

New Features:

  • Introduce the common::rstest module providing strict detection of rstest tests, fixtures, and provider parameters via a pure-library API.
  • Re-export rstest detection types and functions (e.g., ExpansionTrace, RstestDetectionOptions, fixture_local_names) from the Whitaker-common crate.

Enhancements:

  • Document implementation decisions for rstest fixture and test hygiene, including detection semantics and parameter classification rules.
  • Align comments and roadmap status with the current rstest-bdd version and mark roadmap item 8.1.1 as completed.
  • Add an execplan document capturing the plan, constraints, and outcomes for the shared rstest detection helpers.

Tests:

  • Add unit tests for rstest detection and parameter classification in the common::rstest module.
  • Add BDD-style behavioural tests and feature specifications for rstest detection in the common crate.

Task: https://www.devboxer.com/task/61bd4c9f-6b1a-4ce3-92e4-d43cf53a6dea

📎 Task: https://www.devboxer.com/task/db1a1f79-c621-468a-905b-148a563af2f7

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 26, 2026

Walkthrough

Add a new common::rstest module providing strict attribute-based rstest test and fixture detection, parameter classification (fixture-local, provider, unsupported), an optional ExpansionTrace fallback via RstestDetectionOptions, crate-root re-exports, unit and BDD tests, and documentation updates. (50 words)

Changes

Cohort / File(s) Summary
Core rstest module
common/src/rstest/mod.rs, common/src/rstest/detection.rs, common/src/rstest/parameter.rs
Add rstest submodule implementing ExpansionTrace, RstestDetectionOptions, is_rstest_test/_with, is_rstest_fixture/_with, parameter model and classification (ParameterBinding, RstestParameter, RstestParameterKind, classify_rstest_parameter, fixture_local_names).
Crate root re-exports
common/src/lib.rs
Add pub mod rstest; and re-export ExpansionTrace, ParameterBinding, RstestDetectionOptions, RstestParameter, RstestParameterKind, classify_rstest_parameter, fixture_local_names, is_rstest_fixture[_with], and is_rstest_test[_with].
Unit tests
common/src/rstest/tests.rs
Add unit tests for strict detection, provider recognition, unsupported patterns, classification behaviour, fixture_local_names determinism, and expansion-trace fallback gating.
Behavioural (BDD) tests
common/tests/rstest_detection_behaviour.rs, common/tests/features/rstest_detection.feature
Add BDD world, step bindings and 10 scenarios exercising detection, parameter classification, custom provider attributes, multi-frame expansion-trace fallback and mixed-attribute cases.
Docs & configuration
common/Cargo.toml, docs/execplans/..., docs/lints-for-rstest-fixtures-and-test-hygiene.md, docs/roadmap.md
Add ExecPlan and lints docs detailing design and decisions; mark roadmap task 8.1.1 complete; update common/Cargo.toml comment to reference rstest-bdd 0.5.x (comment-only change).

Suggested reviewers

  • codescene-delta-analysis

Poem

✨ Detect the markers, clear and bright,
Fixtures and tests step into light,
Traces whisper when direct paths hide,
Parameters sorted, neat and tried,
Helpers hum and tests take flight.

🚥 Pre-merge checks | ✅ 6 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Developer Documentation ⚠️ Warning New public rstest APIs (ExpansionTrace, RstestDetectionOptions, helper functions) introduced without documentation in a centralised developer's guide or comprehensive rustdoc comments. Document the rstest detection API in a developer's guide or add comprehensive rustdoc comments (///) to all public types and functions in common/src/rstest/ files, explaining purpose, usage, and integration patterns.
✅ Passed checks (6 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Testing ✅ Passed All new functionality is comprehensively guarded by unit and behavioural tests covering public functions, types, and edge cases.
User-Facing Documentation ✅ Passed The rstest detection module is internal lint infrastructure providing shared helpers for future lint implementations, not user-facing functionality exposed to end users.
Module-Level Documentation ✅ Passed All five newly introduced modules carry clear, descriptive module-level docstrings using Rust documentation syntax, adequately communicating purpose and utility to maintainers.
Description check ✅ Passed The PR description accurately describes the changes made, including module structure, re-exports, tests, documentation, and rationale aligned to the roadmap item 8.1.1.
Title check ✅ Passed The title accurately reflects the main objective of the PR: adding a shared rstest detection module with public APIs, and correctly includes the roadmap item reference (8.1.1).

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch add-rstest-shared-helpers-6s7gfc

Comment @coderabbitai help to get the list of available commands and usage tips.

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai bot commented Mar 26, 2026

Reviewer's Guide

Introduces a new shared common::rstest module that provides a pure-library API for strict rstest test/fixture detection and parameter classification, wires it into the common crate’s public surface, and adds unit/BDD-style behavioural tests and documentation/roadmap updates for roadmap item 8.1.1.

Class diagram for the new common::rstest detection and parameter API

classDiagram
    class AttributePath
    class Attribute

    class ExpansionTrace {
        +frames: Vec~AttributePath~
        +new(frames: IntoIterator~AttributePath~) ExpansionTrace
        +frames() [AttributePath]
    }

    class RstestDetectionOptions {
        -provider_param_attributes: Vec~AttributePath~
        -use_expansion_trace_fallback: bool
        +new(provider_param_attributes: Vec~AttributePath~, use_expansion_trace_fallback: bool) RstestDetectionOptions
        +provider_param_attributes() [AttributePath]
        +use_expansion_trace_fallback() bool
    }

    class ParameterBinding {
        <<enumeration>>
        Ident(name: String)
        Unsupported
    }

    class RstestParameter {
        -binding: ParameterBinding
        -attributes: Vec~Attribute~
        +new(binding: ParameterBinding, attributes: Vec~Attribute~) RstestParameter
        +ident(name: String) RstestParameter
        +unsupported() RstestParameter
        +binding() ParameterBinding
        +attributes() [Attribute]
        +binding_name() Option~str~
    }

    class RstestParameterKind {
        <<enumeration>>
        FixtureLocal(name: String)
        Provider
        UnsupportedPattern
    }

    class RstestModuleApi {
        <<module>>
        +is_rstest_test(attrs: [Attribute]) bool
        +is_rstest_test_with(attrs: [Attribute], trace: Option~ExpansionTrace~, options: RstestDetectionOptions) bool
        +is_rstest_fixture(attrs: [Attribute]) bool
        +is_rstest_fixture_with(attrs: [Attribute], trace: Option~ExpansionTrace~, options: RstestDetectionOptions) bool
        +classify_rstest_parameter(parameter: RstestParameter, options: RstestDetectionOptions) RstestParameterKind
        +fixture_local_names(parameters: [RstestParameter], options: RstestDetectionOptions) BTreeSet~String~
    }

    ExpansionTrace --> AttributePath : uses
    RstestDetectionOptions --> AttributePath : uses
    RstestParameter --> ParameterBinding : has
    RstestParameter --> Attribute : has
    RstestParameterKind <.. RstestParameter : classification
    RstestModuleApi --> ExpansionTrace : uses
    RstestModuleApi --> RstestDetectionOptions : uses
    RstestModuleApi --> Attribute : uses
    RstestModuleApi --> RstestParameter : uses
    RstestModuleApi --> RstestParameterKind : returns
Loading

Flow diagram for rstest test and fixture detection with expansion trace fallback

flowchart LR
    A[Start detection
is_rstest_test_with / is_rstest_fixture_with] --> B[Check direct attributes
has_matching_attribute]

    B -->|Match found| C[Return true]
    B -->|No match| D{use_expansion_trace_fallback?}

    D -->|No| E[Return false]
    D -->|Yes and trace present| F[Check expansion frames
has_matching_trace]
    D -->|Yes but no trace| E

    F -->|Frame matches rstest candidate| C
    F -->|No matching frame| E
Loading

File-Level Changes

Change Details Files
Add pure rstest test/fixture detection and parameter classification APIs under a new common::rstest module and re-export them from the common crate.
  • Create detection helpers that match strict rstest test and fixture attributes and optionally consult a pure ExpansionTrace fallback when enabled via options.
  • Define RstestDetectionOptions with defaults for provider-parameter attributes and a flag to control expansion-trace fallback behaviour.
  • Model simplified parameter metadata (binding + attributes) and classify parameters into fixture-local, provider-driven, or unsupported patterns, exposing a fixture_local_names helper that returns deterministic sets.
  • Wire the new rstest module into common/src/lib.rs and publicly re-export the new types and functions as the stable API surface.
common/src/rstest/mod.rs
common/src/rstest/detection.rs
common/src/rstest/parameter.rs
common/src/lib.rs
Add unit tests and BDD behavioural tests to lock in the rstest detection and parameter classification contract.
  • Introduce rstest-based unit tests that cover strict attribute matching, expansion-trace behaviour (enabled/disabled), and parameter classification outcomes including provider attributes and unsupported patterns.
  • Add a BDD harness world object and step definitions that exercise detection helpers via rstest-bdd scenarios, including fixture-local name collection and expansion trace fallback.
  • Define a feature file describing scenarios for detecting tests/fixtures, classifying parameters, and handling expansion traces under different option settings.
common/src/rstest/tests.rs
common/tests/rstest_detection_behaviour.rs
common/tests/features/rstest_detection.feature
Update documentation and project metadata to reflect the new rstest detection substrate and roadmap status.
  • Document the implementation decisions for 8.1.1 in the rstest fixture/test hygiene design doc, including strict attribute sets, provider parameter defaults, expansion-trace modelling, and v1 limitations on bindings.
  • Mark roadmap item 8.1.1 as complete and record the final exec plan for the shared rstest detection helpers, including constraints, decisions, and outcomes.
  • Correct the stale rstest-bdd version comment in common/Cargo.toml to 0.5.x to match the workspace pin.
docs/lints-for-rstest-fixtures-and-test-hygiene.md
docs/roadmap.md
docs/execplans/8-1-1-shared-rstest-test-and-fixture-detection-helpers.md
common/Cargo.toml

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

codescene-delta-analysis[bot]

This comment was marked as outdated.

@leynos leynos changed the title Add ExecPlan for shared rstest test/fixture detection (8.1.1) Implement shared rstest detection module (8.1.1) Mar 28, 2026
codescene-delta-analysis[bot]

This comment was marked as outdated.

@leynos leynos marked this pull request as ready for review April 7, 2026 21:29
sourcery-ai[bot]

This comment was marked as resolved.

@coderabbitai coderabbitai bot added the Roadmap label Apr 7, 2026
@leynos leynos changed the title Implement shared rstest detection module (8.1.1) Add comprehensive tests for rstest detection helpers (8.1.1) Apr 8, 2026
codescene-delta-analysis[bot]

This comment was marked as outdated.

@leynos
Copy link
Copy Markdown
Owner Author

leynos commented Apr 8, 2026

@coderabbitai Please suggest a fix for this issue and supply a prompt for an AI coding agent to enable it to apply the fix. Include the file and symbol names indicated in the issue at the head of your response. Ensure that this is validated against the current version of the codegraph.

If further refinement to address this finding would be deleterious, please supply a clear explanatory one to two paragraph markdown message I can paste into the CodeScene web ui's diagnostic suppression function so this diagnostic can be silenced.

common/src/rstest/tests.rs

Comment on file

fn honours_test_trace_when_fallback_is_enabled() {
    let trace = ExpansionTrace::new([AttributePath::from("rstest")]);
    let options = RstestDetectionOptions::new(Vec::new(), true);

    assert!(is_rstest_test_with(
        &[outer("allow")],
        Some(&trace),
        &options
    ));
}

❌ New issue: Code Duplication
The module contains 5 functions with similar structure: honours_deeply_nested_test_trace,honours_fixture_trace_when_fallback_is_enabled,honours_multi_frame_fixture_trace,honours_multi_frame_test_trace and 1 more functions

@coderabbitai

This comment was marked as resolved.

@leynos
Copy link
Copy Markdown
Owner Author

leynos commented Apr 8, 2026

@coderabbitai Have the following now been resolved?

Annul any requirements that violate the en-GB-oxendict spelling (-ize / -yse / -our) conventions (for example a request to replace "normalize" with "normalise" or "artefact" with "artifact"), or where the requirement unnecessarily increases cyclomatic complexity.

Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="common/src/rstest/tests.rs" line_range="30-32" />
<code_context>
+#[case::tokio("tokio::test", false)]
+#[case::case("case", false)]
+#[case::fixture("rstest::fixture", false)]
+fn detects_strict_rstest_tests(#[case] path: &str, #[case] expected: bool) {
+    assert_eq!(is_rstest_test(&[outer(path)]), expected);
+}
</code_context>
<issue_to_address>
**suggestion (testing):** Add test cases for multiple attributes on the same item (e.g. rstest plus unrelated attributes) to ensure detection still behaves as expected.

These tests only cover a single attribute per item. Please add a few parametrized cases with multiple attributes (e.g., `#[allow(..)]` plus `#[rstest]` or `#[rstest::fixture]`, and with a non-rstest attribute preceding the rstest one) to verify detection works with full attribute lists rather than just singleton or first-position attributes.

```suggestion
fn detects_strict_rstest_tests(#[case] path: &str, #[case] expected: bool) {
    assert_eq!(is_rstest_test(&[outer(path)]), expected);
}

#[rstest]
#[case::rstest("rstest", true)]
#[case::qualified("rstest::rstest", true)]
#[case::plain_test("test", false)]
#[case::tokio("tokio::test", false)]
#[case::case("case", false)]
#[case::fixture("rstest::fixture", false)]
fn detects_strict_rstest_tests_with_multiple_attributes(
    #[case] path: &str,
    #[case] expected: bool,
) {
    // non-rstest attribute preceding the rstest-related attribute
    assert_eq!(is_rstest_test(&[outer("allow"), outer(path)]), expected);
    // non-rstest attribute following the rstest-related attribute
    assert_eq!(is_rstest_test(&[outer(path), outer("allow")]), expected);
}
```
</issue_to_address>

### Comment 2
<location path="common/src/rstest/tests.rs" line_range="66" />
<code_context>
+#[case("rstest::future")]
+#[case("context")]
+#[case("rstest::context")]
+fn classifies_provider_parameters(#[case] path: &str) {
+    let parameter = provider_parameter(path);
+
</code_context>
<issue_to_address>
**suggestion (testing):** Exercise `provider_param_attributes` overrides with a custom `RstestDetectionOptions` to verify extensibility.

To also verify that `RstestDetectionOptions::provider_param_attributes` is respected (not just the built-in defaults), add a test that configures a custom provider attribute (e.g. `custom::provider`), annotates a parameter with it, and asserts it is classified as `Provider`. This helps prevent regressions where only the default attributes are recognized.
</issue_to_address>

### Comment 3
<location path="common/src/rstest/tests.rs" line_range="97-106" />
<code_context>
+}
+
+#[rstest]
+fn honours_test_trace_when_fallback_is_enabled() {
+    let trace = ExpansionTrace::new([AttributePath::from("rstest")]);
+    let options = RstestDetectionOptions::new(Vec::new(), true);
+
+    assert!(is_rstest_test_with(
+        &[outer("allow")],
+        Some(&trace),
+        &options
+    ));
+}
+
+#[rstest]
+fn honours_fixture_trace_when_fallback_is_enabled() {
+    let trace = ExpansionTrace::new([AttributePath::from("fixture")]);
+    let options = RstestDetectionOptions::new(Vec::new(), true);
</code_context>
<issue_to_address>
**suggestion (testing):** Add coverage for expansion traces with multiple frames to ensure matching works beyond the first frame.

Currently both tests use a single-frame `ExpansionTrace`. Because `matches_direct_or_trace` iterates over all frames, please add a test that uses a multi-frame trace (e.g. `"other_macro" -> "rstest"` or `"other_macro" -> "rstest::fixture"`) and asserts detection still works, to cover multi-hop expansions.
</issue_to_address>

### Comment 4
<location path="common/src/rstest/mod.rs" line_range="3" />
<code_context>
+//! Shared helpers for strict `rstest` test, fixture, and parameter detection.
+
+mod detection;
+mod parameter;
+
</code_context>
<issue_to_address>
**issue (review_instructions):** Add both unit and behavioural tests for the new `rstest` detection helpers to satisfy the testing requirements.

You introduce a new `rstest` helper module (`detection`, `parameter`, and their public exports) but there are no corresponding unit tests in `common/src/rstest/tests.rs` and no implemented behavioural specs in the newly added `common/tests/rstest_detection_behaviour.rs`/`.feature` files. Implement focused unit tests for `ExpansionTrace`, `RstestDetectionOptions`, `is_rstest_*` helpers, parameter classification, and fixture name extraction, and add end-to-end behavioural specs that exercise these helpers through their intended usage so that the new feature is fully covered by both unit and behavioural tests.

<details>
<summary>Review instructions:</summary>

**Path patterns:** `**/*`

**Instructions:**
For any new feature or change to an existing feature, both behavioural *and* unit tests are required.

</details>
</issue_to_address>

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 8, 2026

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

Let me read the current state of the files on the PR branch.


🏁 Script executed:

#!/bin/bash
# Read current tests.rs
fd -e rs tests.rs --search-path common/src/rstest | xargs cat

echo "---BEHAVIOUR---"
fd -e rs rstest_detection_behaviour.rs --search-path common/tests | xargs cat

Length of output: 15774


@leynos: All four comments are resolved in the current branch. Here is the breakdown:

Comment Requirement Status
1 Parameterised multiple-attribute cases for detects_strict_rstest_tests detects_strict_rstest_tests_with_multiple_attributes covers attribute-before, attribute-after, and attribute-surrounding cases — exceeding the original suggestion.
2 Custom provider_param_attributes override test classifies_custom_provider_parameters exercises RstestDetectionOptions::new(vec![…], false) with a custom::provider path; rejects_unknown_custom_provider_parameters adds the complementary negative case.
3 Multi-frame ExpansionTrace coverage honours_multi_frame_test_trace, honours_multi_frame_fixture_trace, and honours_deeply_nested_test_trace cover two-frame and four-frame traces for both test and fixture detection.
4 Both unit and behavioural tests required common/src/rstest/tests.rs provides unit coverage; common/tests/rstest_detection_behaviour.rs wires 10 behavioural scenarios (indices 0–9), including new scenarios for multiple attributes, custom providers, and multi-frame traces.

Annulment scan: None of the four comments contains en-GB-oxendict spelling violations (no -ize/-yse/-or substitutions are being demanded), and none introduces gratuitous branching. No requirements need annulling.

The only open item from this thread is the CodeScene duplication finding (five separate trace-fallback functions vs. the merged parameterised form the previous reply proposed). That was raised as a separate concern; if you wish to address it, the AI coding agent prompt from the earlier reply still applies.

@leynos leynos changed the title Add comprehensive tests for rstest detection helpers (8.1.1) Add rstest detection module in common with tests/docs (8.1.1) Apr 8, 2026
codescene-delta-analysis[bot]

This comment was marked as outdated.

codescene-delta-analysis[bot]

This comment was marked as outdated.

@leynos leynos changed the title Add rstest detection module in common with tests/docs (8.1.1) Add shared rstest detection helpers in whitaker-common (8.1.1) Apr 9, 2026
leynos and others added 5 commits April 9, 2026 23:19
Add a new shared pure-library detection module to the `common` crate that
provides strict detection of `#[rstest]` tests, `#[fixture]` functions,
classification of parameters as fixture locals or provider-driven inputs,
and optional fallback detection through expansion-trace metadata. This
module is foundational for downstream hygiene lints and maintains a clear
boundary by avoiding `rustc_private` dependencies.

Includes comprehensive unit and behavioural tests, documentation updates,
and design decision records to ensure correctness and maintainability.

See docs/execplans/8-1-1-shared-rstest-test-and-fixture-detection-helpers.md
for detailed design and roadmap 8.1.1 implementation plan.

Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com>
…cation

- Introduce pure detection helpers for strict `rstest` tests and fixtures.
- Add classification for `rstest` parameters into fixture-local, provider-driven, or unsupported.
- Support optional expansion-trace fallback for detection.
- Add comprehensive unit and behaviour-driven tests covering detection and classification.
- Update `common` crate to re-export new API and document usage.
- Update documentation and roadmap to reflect 8.1.1 completion.
- Upgrade `rstest-bdd` workspace pin to version 0.5.x in `Cargo.toml` (documentation only).

Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com>
…ustom providers

- Added tests for detecting rstest tests with multiple attributes surrounding the rstest attribute.
- Added tests for classifying custom provider parameters and rejecting unknown custom providers.
- Added scenarios and support for multi-frame expansion trace handling in test detection.
- Updated feature file with scenarios covering these cases.
- Extended detection behaviour with helpers for multi-frame traces and custom providers.

Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com>
Refactored multiple specific fallback trace detection tests into a single parameterized test using rstest cases. This reduces duplication and covers various trace scenarios (single frame, multi frame, deeply nested) for both test and fixture detection paths with fallback enabled.

Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com>
Update doc comment examples and integration test imports from
`common::` to `whitaker_common::` to match the crate rename
that landed on main in v0.2.2. The rebase dropped the now-redundant
bulk-rename commit since main already carries the rename, but these
branch-specific files still referenced the old crate name.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@devboxerhub devboxerhub bot force-pushed the add-rstest-shared-helpers-6s7gfc branch from 1f6d192 to 397f30f Compare April 9, 2026 23:38
codescene-delta-analysis[bot]

This comment was marked as outdated.

@leynos leynos changed the title Add shared rstest detection helpers in whitaker-common (8.1.1) Add comprehensive tests for rstest detection helpers (8.1.1) Apr 9, 2026
Copy link
Copy Markdown

@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: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@common/src/rstest/mod.rs`:
- Around line 15-16: The test module wiring (mod tests) is fine but you must
consolidate duplicate fallback-trace unit tests in common/src/rstest/tests.rs by
removing the legacy functions honours_test_trace_when_fallback_is_enabled,
honours_fixture_trace_when_fallback_is_enabled, honours_multi_frame_test_trace,
honours_multi_frame_fixture_trace, and honours_deeply_nested_test_trace and
replace them with a single parameterised #[rstest] test that accepts a case
matrix (use multiple #[case(...)] attributes) covering each scenario; implement
the test function to take the case parameter and assert behavior accordingly so
only one #[rstest] function remains and the old duplicated fn symbols are gone.

In `@common/tests/rstest_detection_behaviour.rs`:
- Around line 51-54: In add_custom_provider_attributes, avoid resetting the
fallback flag by reading the current use_expansion_trace_fallback() from
self.options.borrow() and pass that boolean into RstestDetectionOptions::new
instead of false; update the replace call to use that captured
use_trace_fallback so the existing fallback behavior is preserved when
overriding provider attributes.

In `@docs/execplans/8-1-1-shared-rstest-test-and-fixture-detection-helpers.md`:
- Around line 36-37: Update the US spelling "Behavioral" to en-GB-oxendict
"Behavioural" in the success criteria sentence that begins "3. Behavioural tests
using `rstest-bdd` v0.5.0 exercise the same contract via `common/tests/`";
locate the exact token "Behavioral" and replace it with "Behavioural" so the
document uses en-GB-oxendict spelling throughout.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 61589f7a-7c76-4a17-af89-ab1b1328fe6a

📥 Commits

Reviewing files that changed from the base of the PR and between 6109900 and 397f30f.

📒 Files selected for processing (11)
  • common/Cargo.toml
  • common/src/lib.rs
  • common/src/rstest/detection.rs
  • common/src/rstest/mod.rs
  • common/src/rstest/parameter.rs
  • common/src/rstest/tests.rs
  • common/tests/features/rstest_detection.feature
  • common/tests/rstest_detection_behaviour.rs
  • docs/execplans/8-1-1-shared-rstest-test-and-fixture-detection-helpers.md
  • docs/lints-for-rstest-fixtures-and-test-hygiene.md
  • docs/roadmap.md

The add_custom_provider_attributes method was incorrectly resetting the
use_expansion_trace_fallback flag to false when setting custom provider
attributes. This meant that if trace fallback was enabled before adding
custom providers, it would be silently disabled.

Now the method reads the current fallback setting from the options and
preserves it when creating the new RstestDetectionOptions instance.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
codescene-delta-analysis[bot]

This comment was marked as outdated.

@leynos leynos changed the title Add comprehensive tests for rstest detection helpers (8.1.1) Add shared rstest detection helpers and tests (8.1.1) Apr 10, 2026
Copy link
Copy Markdown

@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

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@common/tests/rstest_detection_behaviour.rs`:
- Around line 244-292: Replace the repeated #[scenario] stubs by generating them
from a local macro or by using a parameterized rstest: create a macro (e.g.,
declare_scenarios!) that takes a list of (index, fn_name) tuples and expands to
multiple #[scenario(path = "tests/features/rstest_detection.feature", index =
N)] fn fn_name(world: DetectionWorld) { let _ = world; }, or alternatively use
#[rstest] to parameterize a single test over the indices and expected case
names; update the current functions (scenario_detects_rstest_test,
scenario_detects_rstest_fixture, scenario_classifies_fixture_local_parameter,
etc.) to be produced by that macro or by one parameterized test so the identical
bodies are removed and maintenance is centralized.
- Around line 232-236: The then_fixture_names assertion mutates DetectionWorld
by calling world.evaluate_fixture_names(); move that evaluation into a new when
step so the then step is pure. Create a new #[when(...)] function (e.g.,
when_fixture_names_evaluated) that calls world.evaluate_fixture_names(), keep
then_fixture_names only reading world.fixture_names (no borrow mutating calls),
and update any scenarios to call the new when step before the then assertion.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: cedc9ce8-f0a6-4998-b3fb-afc6bb5fbb84

📥 Commits

Reviewing files that changed from the base of the PR and between 397f30f and da86271.

📒 Files selected for processing (1)
  • common/tests/rstest_detection_behaviour.rs

Replaced multiple individual scenario functions with a macro to
automatically declare test scenarios in rstest_detection_behaviour.rs.
This reduces boilerplate and improves maintainability without changing
functionality.

Also added a missing step to fixture local parameter classification scenario.

Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com>
@leynos leynos changed the title Add shared rstest detection helpers and tests (8.1.1) Document new rstest public APIs (8.1.1) Apr 10, 2026
@leynos
Copy link
Copy Markdown
Owner Author

leynos commented Apr 10, 2026

@coderabbitai Have the following now been resolved?

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Developer Documentation ⚠️ Warning New public rstest APIs (ExpansionTrace, RstestDetectionOptions, helper functions) introduced without documentation in a centralised developer's guide or comprehensive rustdoc comments. Document the rstest detection API in a developer's guide or add comprehensive rustdoc comments (///) to all public types and functions in common/src/rstest/ files, explaining purpose, usage, and integration patterns.
Title check ⚠️ Warning The title "Document new rstest public APIs (8.1.1)" is misleading; the PR primarily implements a new rstest detection module and re-exports its API, not merely documentation. Retitle to reflect the implementation focus: e.g. "Add shared rstest detection module and public APIs (8.1.1)" or "Implement rstest test/fixture detection helpers in common (8.1.1)".

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 10, 2026

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check rustdoc comments in detection.rs and parameter.rs
echo "=== detection.rs ==="
fd -e rs detection.rs --search-path common/src/rstest | xargs cat

echo ""
echo "=== parameter.rs ==="
fd -e rs parameter.rs --search-path common/src/rstest | xargs cat

echo ""
echo "=== PR title ==="
gh pr view 171 --json title -q '.title'

Length of output: 12658


@leynos: Here is the current status of the two warnings.

Warning Status Evidence
Developer Documentation ✅ Resolved Every public struct, enum, function, and method in detection.rs and parameter.rs carries /// rustdoc comments, including # Examples blocks with runnable code snippets. Both files also have module-level //! docstrings.
Title check ❌ Not resolved The PR title remains "Document new rstest public APIs (8.1.1)" — the misleading title that was flagged.

Update the PR title to something like "Add shared rstest detection module and public APIs (8.1.1)" or "Implement rstest test/fixture detection helpers in common (8.1.1)" to clear the remaining warning.

@leynos leynos changed the title Document new rstest public APIs (8.1.1) Add shared rstest detection module and public APIs (8.1.1) Apr 10, 2026
@leynos leynos merged commit ae46b4f into main Apr 10, 2026
5 checks passed
@leynos leynos deleted the add-rstest-shared-helpers-6s7gfc branch April 10, 2026 02:09
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