Skip to content

assertFileContent ignores trailing extra lines in golden files #7729

Description

@LuciferYang

Describe the bug

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

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions