Skip to content

[Enhancement] Implement #[fixture] proc-macro via crucible-macros with reset() method generation #775

Description

@ekelemepraise-code

Summary

The README documents a #[fixture] attribute macro:

#[fixture]
pub struct AmmFixture { ... }

But crucible-macros/src/lib.rs does not implement this macro. Users who try to use it get a compile error.

Expected Behaviour

The macro should:

  1. Require AmmFixture::setup() -> Self to be implemented manually
  2. Auto-generate a reset(&mut self) method that calls *self = Self::setup()
  3. Optionally generate a Default impl that calls Self::setup()

Implementation Plan

In crucible-macros/src/lib.rs:

#[proc_macro_attribute]
pub fn fixture(_args: TokenStream, input: TokenStream) -> TokenStream {
    // Parse struct definition
    // Inject reset() method
    // Re-emit struct unchanged
}

Acceptance Criteria

  • #[fixture] attribute macro compiles correctly on a struct
  • reset() method is generated
  • Macro emits a clear error if struct does not implement setup() -> Self
  • Trybuild tests added in crucible-macros/tests/
  • README example updated to show the macro working

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions