[KYUUBI #7729][UTIL] Fail assertFileContent when the file has trailing extra lines - #7730
Open
LuciferYang wants to merge 1 commit into
Open
Conversation
…railing extra lines
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Why are the changes needed?
Closes #7729.
AssertionUtils.assertFileContentcompares a file against expected lines withfileLinesIter.zipWithIndex.zip(expectedLinesIter).zipstops at the shorter side, so file lines beyond the expected content were never compared, andfileLineCountonly ever reached the number of pairszipproduced. The length checkassertResult(expectedLinesIter.size)(fileLineCount)therefore passed whenever the file was longer, so a golden file with stale trailing lines went unnoticed.This drains the remaining file lines into
fileLineCountafter the comparison, so the length check sees the file's true length and fails when the file is longer than expected. The equal-length and shorter-file cases are unchanged. Consumers regenerate their golden files from the same source they compare against (verifyOrRegenerateGoldenFilewritestoMarkdownand reads it back), so a correctly regenerated file still round-trips to the same length.How was this patch tested?
Added
AssertionUtilsSuite(the module's first self-test for the assertion helpers): a trailing-extra-line case that must throwTestFailedExceptionwith the "Line number is not expected" clue, and an exact-content case that must pass. The trailing case stops failing if the drain loop is reverted.Module green on Zulu 17.0.18 (23/23), scalastyle 0 errors, spotless clean.
Was this patch assisted by generative AI tooling?
Assisted-by: Claude Opus 4.8