Skip to content

refactor: move test fixtures out of the plugin's build.rs; format generated code #22

Closed

Description

@erikist

Part of #2. Follow-up from the reviews of #18 and #21.

Why

protoc-gen-rust-mcp/build.rs now always:

  • compiles the test-only fixtures (tests/testdata/schemapb, tests/testdata/mcpgen) with protox, pbjson-build and tonic-prost-build
  • runs the generator on them through #[path] includes, because a build script can't depend on the crate it's building

So every cargo build/cargo install of the plugin pulls in those build-dependencies and does fixture work. On a clean release build that took build time from about 3s to about 8s, before the tonic fixtures were added. Separately, the generated *.mcp.rs isn't formatted: there are 300-character lines, while tonic's output is run through prettyplease.

Do

  • Move the fixtures and their build script into a non-published, dev-only workspace crate, e.g. test-fixtures/, with publish = false, that depends on the plugin crate as a normal library dependency. The plugin's own tests use it as a dev-dependency. The plugin crate should end up with no build.rs, or a trivial one.
  • Run the generated MCP code through prettyplease (as protoc-gen-tonic does), or emit it already formatted. Regenerate, and update the golden file if test: golden-file test for the plugin's generated code #8 has landed.
  • Keep every existing test and its coverage.

Acceptance criteria

  • cargo tree -p protoc-gen-rust-mcp -e build,normal shows no protox, pbjson-build or tonic-prost-build.
  • make generate output is rustfmt-clean: rustfmt --check --edition 2024 examples/src/gen/**/*.mcp.rs passes.
  • The checks in AGENTS.md pass, and make generate and the golden file are current.

Activity

  1. erikist commented on Oct 10, 2026

    @erikist
    ContributorAuthor

    🤖 Factory: picked up by dispatcher; working on branch factory/22-refactor-move-test-fixtures-out-of.

  2. erikist commented on Oct 10, 2026

    @erikist
    ContributorAuthor

    🤖 Factory: opened PR #28 implementing this issue.

    Summary: moved tests/testdata/{schemapb,mcpgen} and their proto-compiling build.rs into a new non-published test-fixtures/ workspace crate (which depends on protoc-gen-rust-mcp as a normal dependency); protoc-gen-rust-mcp now has no build.rs and no longer pulls in protox/prost-build/pbjson-build/tonic-prost-build on a plain build. Generated code now goes through prettyplease (like prost-build/tonic-build) plus a final rustfmt pass in make generate, so the committed *.mcp.rs is rustfmt-clean. All existing tests pass unchanged; see the PR for full details and check output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    factory:in-progressAn sf-factory worker is on itfactory:readyReady for the sf-factory to pick up

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions