mruby-string-ext: skip four UTF-8 tests where they cannot run - #7139
Conversation
Four tests in mruby-string-ext keep their `MRB_UTF8_STRING` guard inside
the assertion block, so a build without UTF-8 strings enters the block,
reaches no assertion, and mrbtest reports each of them:
Warn: String#inspect of a binary string escapes every byte => no assertion
Warn: String#chop! on a binary string removes one byte => no assertion
Warn: String#rindex on a binary string counts bytes => no assertion
Warn: a needle that spells no character is found nowhere => no assertion
The `default` gembox does not carry `mruby-encoding`, which is what turns
`MRB_UTF8_STRING` on, so a plain `rake test` ends its run with
`Warning: 4`.
Move the guard out to the `assert` call, the form the rest of the file
already uses for its UTF-8 tests, so a build that cannot run the test does
not define it. The assertions themselves are unchanged.
A default build now reports `Warning: 0` with `OK: 2040` as before, and a
full-core build still runs all four.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughUTF-8-specific tests in ChangesString extension test guards
Estimated code review effort: 1 (Trivial) | ~5 minutes Mergeability Score: ⚪ Minimal · up to This PR prevents four unsupported UTF-8 tests from running on builds that cannot execute them, without changing their assertions or UTF-8-enabled behavior. No actionable merge-blocking risk remains after normal checks and review. Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Four tests in
mrbgems/mruby-string-ext/test/string.rbhold theirMRB_UTF8_STRINGguard inside the assertion block rather than on theassertcall:On a build without
MRB_UTF8_STRINGthe block still runs and reaches no assertion, which mrbtest counts as a warning:MRB_UTF8_STRINGis turned on bymruby-encoding, which thedefaultgembox does not carry, so a plainrake testis one of the builds that reports this.The rest of the file already guards its UTF-8 tests on the
assertcall, so this PR moves these four to the same form:A build that cannot run the test no longer defines it. The assertions themselves are unchanged, and the diff is the removal of the inner
ifplus one level of indentation.The guard is needed in all four cases, since each asserts behaviour that only a UTF-8 build has:
"る".inspectcomes back with every byte escaped without it,chop!cuts a byte instead of a character, and a needle such as"\x81"is searched for as a byte rather than refused as a sequence that spells no character.Testing
rake testwith thedefaultgembox (MRB_UTF8_STRINGoff):The four tests that ran without asserting anything are the only ones that disappear; nothing that used to assert stops asserting.
A
full-corebuild (MRB_UTF8_STRINGon) still runs all four:Total: 2269 / OK: 2259 / KO: 0 / Warning: 0.Summary by CodeRabbit
chop!, binaryrindex, and malformed-needle behavior.