Skip to content

gen: support stream tests when Msgsize is omitted - #457

Closed
SAY-5 wants to merge 1 commit into
tinylib:masterfrom
SAY-5:fix-stream-tests-optional-sizer-20261019
Closed

SAY-5 wants to merge 1 commit into
tinylib:masterfrom
SAY-5:fix-stream-tests-optional-sizer-20261019

Conversation

@SAY-5

@SAY-5 SAY-5 commented Oct 19, 2026

Copy link
Copy Markdown

With -marshal=false, //msgp:size ignore Stream produces usable stream methods, but its generated test fails to compile because it still calls the omitted Msgsize method. Check the existing msgp.Sizer interface before performing that optional size check. Encoding, decoding, and skip tests remain intact, including size checks and warnings for generated or manually supplied sizers.

Fixes #140. The regression covers exact and regex ignore directives, normal size generation, and a custom pointer sizer. It checks literal wire bytes, a nonzero stream round trip, and preservation of the custom size warning. The two ignored-size cases fail against the unchanged generator and pass with this change.

Validation on Go 1.26.2 / macOS ARM64:

  • 820 top-level tests, with 1,041 passing test/subtest outcomes across the generator, runtime, setof, and generated fixtures.
  • go vet ./... ./_generated, formatting, and CI-pinned golangci-lint 2.5.0 (./...) pass.

Local limits: Go 1.24/1.25, Linux, TinyGo, race checks, benchmarks, and fuzz campaigns were not run. The runtime run also excludes TestConv32, TestConv64, TestReadIntfRecursion, TestSkipRecursion, 11 examples, and ordinary seeds for five fuzz functions. A combined test invocation stopped at a local resource threshold; the reported results come from subsequent completed sequential runs.

AI assistance: Codex assisted with the implementation, tests, and description. A separate agent independently reviewed the exact change and verification evidence.

@philhofer

Copy link
Copy Markdown
Member

The original bug report wasn't entirely coherent. The implementation of MarshalMsg calls Msgsize, so if the user opts to avoid generating that method, then it needs to be implemented elsewhere.

There's a separate issue where perhaps disabling generation of Marshal/Unmarshal code altogether would cause a problem, as the EncodeDecode generated test depends on Msgsize() existing, but that's a different issue.

@philhofer philhofer closed this Oct 19, 2026
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.

Msgsize and msgp:size ignore directive

3 participants