Repository navigation
refactor: move test fixtures out of plugin's build.rs; format generated code (#22) - #28
Merged
Merged
Conversation
added 2 commits
October 10, 2026 02:45
…ed code (#22) - Move tests/testdata/{schemapb,mcpgen} and their proto-compiling build.rs into a new non-published test-fixtures/ workspace crate that depends on protoc-gen-rust-mcp as a normal (build-)dependency. protoc-gen-rust-mcp now has no build.rs at all, and no longer pulls in protox, prost-build, pbjson-build or tonic-prost-build on a plain cargo build/install. - Run generator.rs's output through prettyplease (as prost-build and tonic-build do for their own generated code) before prepending the file header, and have `make generate` pipe the final *.mcp.rs output through rustfmt, so the committed generated code is rustfmt-clean. - Regenerate examples/src/gen and the golden file; golden.rs now rustfmt's the generator's raw output before comparing, matching what make generate produces.
#22) Both were only needed by tests/server_integration.rs when it directly include!d the mcpgen fixture's tonic-generated code; now that code lives in and is only used from test-fixtures, protoc-gen-rust-mcp's own tests no longer reference either crate directly.
3 tasks
Contributor
Author
|
🔍 Review: LGTM. Verified locally: |
This was referenced Oct 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #22
Summary
protoc-gen-rust-mcp/tests/testdata/{schemapb,mcpgen}and theproto-compiling
build.rsthat fed them into a new, non-publishedworkspace crate,
test-fixtures/(publish = false). It depends onprotoc-gen-rust-mcpas a normal (build-)dependency to run the realserver::generate_serviceagainst themcpgenfixture — something theold
build.rscould not do (a build script can't depend on the crateit's building), so it used to
#[path]-include the plugin's ownmodules instead.
protoc-gen-rust-mcpnow has nobuild.rsat all,and depends on
test-fixturesonly as adev-dependency.protoc-gen-rust-mcp/src/schema.rs's tests andprotoc-gen-rust-mcp/tests/server_integration.rsnowuse test_fixtures::{schemapb, mcpgen}instead of their owninclude!(concat!(env!("OUT_DIR"), ...)).protox,prost-build,pbjson-buildandtonic-prost-buildmovedfrom
protoc-gen-rust-mcp's[build-dependencies]totest-fixtures's. A plaincargo build/cargo install -p protoc-gen-rust-mcpno longer compiles them or the two test fixtures.Also dropped the now-dead
tonic-prost/futuresdev-dependencies fromprotoc-gen-rust-mcp(only needed when its tests directlyinclude!dthe fixture's tonic-generated code; that code now lives in and is only
used fromtest-fixtures).generator.rsnow runs each generated module throughprettyplease(
format_rust) before prepending the file header — the same approachprost-build/tonic-builduse for their own generated code (I checkedprost_build::Config::format'ssyn::parse_file(buf).unwrap(); prettyplease::unparse(&file)andtonic_build::manual'sprettyplease::unparsecalls in the vendored registry sources toconfirm the pattern and the header-after-formatting ordering, since
syndrops a file's leading plain//comments).prettyplease'sline-wrapping doesn't always agree with
rustfmt's on every construct(chained calls,
where-clause bounds), somake generate'sMakefiletarget pipes the final
*.mcp.rsoutput through a realrustfmt --edition 2024pass to guarantee the issue'srustfmt --checkcriterion.
golden.rsdoes the same to the generator's raw outputbefore the byte-for-byte comparison, so it keeps enforcing that the
committed file matches what
make generateproduces.// Skipping <method>: ...comment inserver.rsbecame adoc comment (
///):prettypleaseonly preserves doc comments orcomments attached to a node it round-trips, so a plain comment at that
position would have silently disappeared.
examples/src/gen/examples/v1/examples.v1.mcp.rsand thegolden file; the diff is formatting-only (no semantic change — same
cargo testcoverage, including the pbjson-parity test, passesunchanged).
Decisions made
prettyplease: inside the library (generator.rs),not the
protoc-gen-rust-mcpbinary'smain.rs, so both the realgeneration path and
test-fixtures/build.rs's mcpgen-fixture path(which calls
server::generate_servicedirectly) get the sameformatting, and so a future API consumer calling
generator::generatedirectly gets formatted output too.
rustfmtas a final pass, not instead ofprettyplease: keepingprettypleasematches the Go reference ecosystem's establishedpattern (prost-build/tonic-build) for a library-embeddable formatter
with no process-spawn dependency, while the extra
rustfmtpass inmake generate(and ingolden.rs, to keep the golden-file testmeaningful) closes the small formatting gap against
rustfmt --checkthat
prettypleasealone leaves (mostly chained-call andwhere-clause wrapping).rustfmtis already a required toolchaincomponent (
rust-toolchain.toml) and is run bycargo fmt --all --check, so this adds no new toolchain requirement.prettyplease0.3.0 (current on crates.io,cargo info prettyplease) withsyn3 (features = ["parsing"],default-features = false— no need forfull, confirmed bycompiling the real generated module through it).
rustc/cargo1.99.0 and
rustfmt1.10.0-stable, matchingrust-toolchain.toml.Test evidence
Self-review via the
reviewersubagent found no blocking issues; its one"should fix" item (dead
tonic-prost/futuresdev-dependencies) isaddressed in the second commit.
Notes for reviewers
test-fixtures/testdata/{schemapb,mcpgen}are untouched, byte-identicalmoves of the old
protoc-gen-rust-mcp/tests/testdata/*(see therename-detected diff).
examples/src/gen/examples/v1/examples.v1.mcp.rs's diff isformatting-only (re-wrapped lines, one comment style change); no field
names, schema text, or logic changed. The pbjson-parity test
(
schema::tests::parity_with_go_example_input_schemas) still passes,confirming the embedded schema JSON text itself is byte-identical.
Didn't touch
.github/workflows/**,AGENTS.md, ordocs/GOAL.md.Out of scope / follow-ups: none identified beyond the issue.
Factory-authored