apache / apache/kyuubi

assertFileContent ignores trailing extra lines in golden files

Open Beginner friendly
#7,729 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Scala
Stars
2.4k
Forks
1k
PR merge metrics
No merged PRs in 30d

Description

### Describe the bug

`AssertionUtils.assertFileContent` compares a file against expected lines by zipping the two iterators:

```scala
fileLinesIter.zipWithIndex.zip(expectedLinesIter)
.foreach { case ((lineInFile, lineIndex), expectedLine) => ... }
```

`zip` stops at the shorter side, so any file line beyond the expected content is never compared. The length check that follows compares the expected count against `fileLineCount`, but `fileLineCount` only ever reaches the number of pairs `zip` produced, so it already equals the expected count whenever the file is longer. A golden file with stale trailing lines therefore passes even though it no longer matches what the test declares.

`assertFileContent` also backs `assertFileContentSorted` and the SPI/golden-file checks, so a golden file that has gained extra trailing lines (a stale entry left behind after a deletion, say) is not caught.

This runs against the intent of the line-count check added in #5275, which was meant to catch a golden file drifting out of sync with its source.

### Affects Version(s)

master (1.13.0-SNAPSHOT), and earlier releases carrying `kyuubi-util-scala`.

### Are you willing to submit PR?

Yes.

Contributor guide

Open the contributing guide

Research direction

Start at the AssertionUtils.assertFileContent implementation and inspect the tests covering golden-file comparisons, including assertFileContentSorted and SPI checks. Verify that files with extra trailing lines now fail while matching files and existing comparisons still pass; run the relevant Scala tests to confirm the line-count check catches stale content.

Written by the indexing model from the issue text.

Assessment

Tech stack
scala
Domain
testing
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
76/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.