Skip to content

Running tests with RECORD=true leaves a non-clean working tree #855

@myitcv

Description

@myitcv

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Running the lexer tests against def00e9 with RECORD=true leaves the git working tree in an non-clean state.

To Reproduce

Against commit def00e9:

$ RECORD=true go test ./lexers
ok      github.com/alecthomas/chroma/v2/lexers  1.448s
$ go test ./lexers
ok      github.com/alecthomas/chroma/v2/lexers  1.581s
$ git status
HEAD detached at origin/master
Changes not staged for commit:
        modified:   lexers/testdata/analysis/bash.expected
        modified:   lexers/testdata/analysis/c.ifdef.expected
        modified:   lexers/testdata/analysis/c.ifndef.expected
        modified:   lexers/testdata/analysis/c.include.expected
        modified:   lexers/testdata/analysis/cpp.include.expected
        modified:   lexers/testdata/analysis/cpp.namespace.expected

no changes added to commit

So whilst the lexer tests pass, updating the expectations files results in changes.

This seems less than ideal for people making contributions to the repo, especially if they are updating expectations in specific files because they could easily include unrelated changes in others, without a clear understanding of why there are differences.

According to my analysis there are two reasons behind this:

  • Newlines are not consistently being written to expectation files.
  • The comparison of expected vs actual happens after trimming of space and parsing of values, meaning different byte sequences can be considered equal.

I have a PR that includes a number of commits that propose a solution to this, which I will push up for discussion to complement this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions