Skip to content

mcp: check out testdata fixtures with LF line endings - #1342

Open
PerryLink wants to merge 1 commit into
modelcontextprotocol:mainfrom
PerryLink:fix/testdata-lf-fixtures
Open

PerryLink wants to merge 1 commit into
modelcontextprotocol:mainfrom
PerryLink:fix/testdata-lf-fixtures

Conversation

@PerryLink

Copy link
Copy Markdown

On Windows a default git clone uses core.autocrlf=true, so mcp/testdata/files/info.txt lands on disk with CRLF. TestServerConformance asserts the exact base64 of that file, so the test fails on every such checkout:

--- FAIL: TestServerConformance/resources.txtar
        -               "blob": "Q29udGVudHMK",
        +               "blob": "Q29udGVudHMNCg==",
FAIL	github.com/modelcontextprotocol/go-sdk/mcp

Decoded, those are "Contents\n" and "Contents\r\n" respectively -- the only difference is the checkout, not the content.

A 6-line .gitattributes pins the fixtures (and all *.txtar) to LF, which is what the assertions assume:

git ls-files --eol mcp/testdata/files/info.txt
  without .gitattributes:  i/lf  w/crlf  attr/                -> go test ./mcp/ -run TestServerConformance   FAIL
  with    .gitattributes:  i/lf  w/lf    attr/text eol=lf     -> go test ./mcp/ -run TestServerConformance   ok

go test ./... passes with the change.

Caveat for anyone with an existing Windows clone: the fixture is already on disk as CRLF, so it needs git checkout -- mcp/testdata/files/info.txt (or a fresh clone) before the fix takes effect locally.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant