cloudwego / cloudwego/eino

components/document/parser: TestParser fails on Windows checkouts with core.autocrlf=true (CRLF in testdata)

Open Beginner friendly
#1,285 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
13k
Forks
1.1k
Avg merge
4h 6m
Merged PRs (30d)
41

Description

**Describe the bug**

`go test ./components/document/parser/` fails on a Windows host that uses Git's default Windows configuration (`core.autocrlf=true`):

```
--- FAIL: TestParser (0.00s)
--- FAIL: TestParser/Test_default_parser (0.00s)
parser_test.go:61:
Error: Not equal:
expected: "# Title\nhello world"
actual : "# Title\r\nhello world"
```

**Root cause**

`TestParser/Test_default_parser` parses the checked-in `components/document/parser/testdata/test.md` and asserts its exact content (`"# Title\nhello world"`). With `core.autocrlf=true` — the default of the standard Git for Windows installer — the working-tree copy of `testdata/test.md` is materialized with CRLF line endings, and `TextParser` (correctly) returns the file bytes verbatim, so the assertion fails. The outcome of the test therefore depends on the contributor's local git configuration rather than on the code under test.

CI only runs on `ubuntu-latest`, so this is invisible upstream.

**Expected behavior**

The test should pass regardless of how git materialized line endings in the working tree. It can be made hermetic by writing the markdown fixture itself with explicit LF bytes (into `t.TempDir()`) instead of reading a checked-in testdata file for the content assertion.

**Environment**

```
go version go1.27.1 windows/amd64
git config core.autocrlf=true (Git for Windows default)
```

A PR with the hermetic-fixture change follows.

Contributor guide

Open the contributing guide

Research direction

Start with components/document/parser/parser_test.go and the testdata/test.md fixture, then run go test ./components/document/parser/. Verify TestParser/Test_default_parser no longer depends on Git's line-ending conversion and passes on a Windows checkout with core.autocrlf=true.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.