[test-improver] Improve tests for internal/util TruncateRunes - #10793
Conversation
- Add table-driven cases: multibyte with more bytes than maxRunes but fewer runes, mixed ASCII/multibyte truncation, maxRunes one less than rune count, and single-rune edge cases. - Add TestTruncateRunes_TruncatedResultIsAlwaysValidUTF8 property test verifying truncated output is always valid UTF-8 across ASCII, multibyte, emoji, and malformed-byte inputs. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Expands TruncateRunes tests with boundary, multibyte, and malformed UTF-8 cases.
Changes:
- Adds table-driven truncation edge cases.
- Adds UTF-8 validity invariant coverage.
Show a summary per file
| File | Description |
|---|---|
internal/util/truncate_test.go |
Extends TruncateRunes tests and UTF-8 validation. |
Review details
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 1/1 changed files
- Comments generated: 1
- Review effort level: Balanced
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
The failing check was the Rust guard unit test Merged latest |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
@copilot fix this failing ci check https://github.com/github/gh-aw-mcpg/actions/runs/31213802810/job/92992410203?pr=10793 |
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
Fixed in a35c4b1. Root cause: Overrides are now stored in a thread-local map ( |
🔒 mcpg Read-Only Stress — gVisorSurface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Overall: PASS
References: §31226968355
|
🔒 mcpg Read-Only Stress — default AWFSurface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Overall: PASS References: §31226968339
|
🔒 mcpg Read-Only Stress — docker-sbxSurface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Overall: PASS
|
File analyzed
internal/util/truncate_test.go(tests forinternal/util/truncate.go)Why this file
TruncateRunessat at 93.3% coverage with a documented invariant (invalid-UTF-8 normalization) that lacked broad edge-case testing.Improvements made
TestTruncateRunes:maxRunesbut fewer actual runes (exercises theutf8.RuneCountInStringearly-return fast path).maxRunesexactly one less than the rune count.TestTruncateRunes_TruncatedResultIsAlwaysValidUTF8, which asserts that wheneverTruncateRunesactually truncates a string, the result is always valid UTF-8 — covering ASCII, multibyte (Japanese), emoji, and malformed-byte inputs, guarding the invariant documented in the function's doc comment.Coverage
internal/util99.3% overall;TruncateRunes93.3%.internal/util99.3% overall;TruncateRunes93.3% (the remaining uncovered line is a defensivereturn sfallback at the end of the byte-walk loop that is unreachable given the preceding fast-path checks — kept as documented defensive code, not removed).Test output
All existing passing tests were preserved; only new cases and one new test function were added.