Skip to content

test(codegen): hold the field order to the lowest tag - #71

Merged
jonasz-lasut merged 2 commits into
mainfrom
test/codegen-tag-order
Nov 19, 2026
Merged

jonasz-lasut merged 2 commits into
mainfrom
test/codegen-tag-order

Conversation

@jonasz-lasut

@jonasz-lasut jonasz-lasut commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

This follows up on the review of #70. fields_are_encoded_in_tag_order in codegen/src/messages.rs passed with the sort removed, because its fixture already declared the fields in tag order. The fixture now declares them out of order with a oneof that lists its highest tag first, and a second test covers the order Debug prints them in. With the sort removed, with a sort by a oneof's first tag, and with Debug in tag order, one of the two tests fails each time.

CONTRIBUTING.md said a new proto field doesn't need anything beyond cargo run -p codegen. The samples in sdk/tests/generated_messages.rs list every field of a message and stop compiling until someone sets the new one, so that's now a step of its own, and the generated files don't change.

fields_are_encoded_in_tag_order passed with the sort removed, because
its fixture declared the fields in tag order. The fixture now declares
them out of order, with a oneof that lists its highest tag first, so
the declaration order, a sort by a oneof's first tag and the wire order
are three different orders. A second test holds Debug to the
declaration order.

Signed-off-by: Jonasz Małecki <jonasz@upbound.io>
The proto update steps said a new field needs nothing beyond codegen.
The samples in sdk/tests/generated_messages.rs list every field of a
message, so that file stops compiling until the new field is set there.
Say so as a step of its own.

Signed-off-by: Jonasz Małecki <jonasz@upbound.io>
@jonasz-lasut
jonasz-lasut marked this pull request as ready for review November 19, 2026 11:54
@jonasz-lasut
jonasz-lasut merged commit ed562aa into main Nov 19, 2026
5 checks passed
@jonasz-lasut
jonasz-lasut deleted the test/codegen-tag-order branch November 19, 2026 11:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant