Truncate long tokens in default_validator's judge message. #346 #366
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This updates
default_validatorto avoid creating hugejudgemessage.txtwhen the token containing a difference is huge (e.g., the user forgot to output spaces).When printing single tokens, we cut after 30 bytes, and when printing two tokens, we print up to 15 bytes of the common prefix ... first 15 bytes from where the strings first differ.
While we can't assume anything about the output encoding, we make a small attempt not to insert our "..." in the middle of a utf-8 character, as that is by far the most commonly used encoding. (You can still get weird efffects here if using composition characters, as I don't want to add a dependency on a full unicode handling library).
Also adds test cases to cover this truncation behavior, plus some more test cases, so we now at least should have one test case per different judgemessage we currently canemit.
Fixes #346