Skip to content

test: golden-file test for the plugin's generated code #8

Closed

Description

@erikist

Part of #2. A golden-file test for the plugin's output, the counterpart of Go's cmd/protoc-gen-go-mcp/golden_test.go at 9e072f9.

Do

  • In cargo test, build a CodeGeneratorRequest for examples/protos/example.proto with source info (comments). Use protox, a pure-Rust protobuf compiler and the counterpart of Go's protocompile, so the test needs neither protoc nor the network.
    • Set compiler_version to 29.3 so the header matches make generate's output.
  • Run generate on it, and compare the produced examples.v1.mcp.rs byte for byte with the committed examples/src/gen/examples.v1.mcp.rs.
  • UPDATE_GOLDEN=1 cargo test -p protoc-gen-rust-mcp golden rewrites the golden file. Document this in AGENTS.md, replacing the "once the golden-file test exists" placeholder: an unexpected change in generated code is a bug until explained.
  • On a mismatch, the failure message shows a readable diff and the update command.

Acceptance criteria

  • The test passes on main's output, and fails with a useful diff if you hand-edit the golden file (show this in the PR).
  • AGENTS.md is updated.
  • The checks in AGENTS.md pass.

Activity

  1. erikist commented on Oct 9, 2026

    @erikist
    ContributorAuthor

    🤖 Factory: picked up by dispatcher; working on branch factory/8-test-golden-file-test-for-the.

  2. erikist commented on Oct 9, 2026

    @erikist
    ContributorAuthor

    🤖 Factory: opened #24 with the golden-file test (protoc-gen-rust-mcp/tests/golden.rs), compiling example.proto in-process via protox, comparing byte for byte against the committed examples.v1.mcp.rs, and UPDATE_GOLDEN=1 cargo test -p protoc-gen-rust-mcp golden to refresh it. AGENTS.md updated to describe it. All four checks pass; PR includes a hand-edit demonstration of the failure diff.

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