Skip to content

THRIFT-6153: Expand Ruby Compact varint write coverage - #4017

Merged
kpumuk merged 1 commit into
apache:masterfrom
kpumuk:rb-compact-varint-tests
Oct 16, 2026
Merged

kpumuk merged 1 commit into
apache:masterfrom
kpumuk:rb-compact-varint-tests

Conversation

@kpumuk

@kpumuk kpumuk commented Oct 16, 2026 •

Copy link
Copy Markdown
Member

The batching regression test added in #3741 covers only maximum-width native i32 and i64 values. It misses shorter varints and the other callers of the same write helpers.

This follow-up uses explicit expected bytes for 47 signed integer values, covering zero, both signs at every width transition, signed extrema, and mixed payload bits. For example, 150 must produce ac 02 and -150 must produce ab 02; the expectations do not implement zigzag or varint encoding. Shared native and pure Ruby coverage checks complete varints arrive in one transport write, including sequence IDs, collection sizes, non-delta field IDs, and binary lengths.

Validation on Ruby 4.0.7, aarch64-linux: the focused spec passes all 51 examples in both modes; the full native suite passes 1,006 examples and the full pure Ruby suite passes 907. The gem build and RuboCop pass (147 files).

Controlled native mutations demonstrate the added coverage against master 5248fb28acda184580bd490cea8a1bea6933535a: splitting only two-byte varints into separate writes passes all 45 existing examples but fails six enhanced examples; encoding i64 zero as 80 00 passes the existing examples but fails one enhanced example. These were injected regressions; the implementation was restored, rebuilt, and retested successfully.

  • Did you create an Apache Jira ticket? (Request account here, not required for trivial changes)
  • If a ticket exists: Does your pull request title follow the pattern "THRIFT-NNNN: describe my issue"?
  • Did you squash your changes to a single commit? (not required, but preferred)
  • Did you do your best to avoid breaking changes? If one was needed, did you label the Jira ticket with "Breaking-Change"?
  • If your change does not involve any code, include [skip ci] anywhere in the commit message to free up build resources.

Client: rb

Assert literal wire bytes and one write per varint across signed width
boundaries, sequence IDs, collection sizes, field IDs, and binary lengths.

Co-Authored-By: OpenAI Codex (gpt-6.1-sol) <codex@openai.com>
Copilot AI balanced review requested due to automatic review settings October 16, 2026 01:36
@mergeable mergeable Bot added the ruby Pull requests that update Ruby code label Oct 16, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The focused test-only changes have independently verified encoding fixtures and no identified blocking issues.

0 open findings

What changed in this PR

Expands Ruby Compact Protocol regression coverage for the varint batching introduced in #3741, without changing production code.

Changes:

  • Adds 47 explicit signed-integer encoding fixtures covering width transitions, extrema, and mixed payload bits.
  • Checks batching across integer writes, sequence IDs, collection sizes, field IDs, and binary lengths.
  • Replaces the native-only regression test with coverage shared by native and pure Ruby implementations.
File Description
lib/​rb/​spec/​compact_protocol_spec.rb Expands expected-byte and transport-write assertions for Compact varints.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@kpumuk
kpumuk merged commit 7941f54 into apache:master Oct 16, 2026
110 checks passed
@kpumuk
kpumuk deleted the rb-compact-varint-tests branch October 16, 2026 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ruby Pull requests that update Ruby code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants