Skip to content

Always use line feed for newlines in acceptance tests - #2865

Merged
shreyas-goenka merged 5 commits into
mainfrom
lf-gitattibute
May 19, 2025
Merged

Always use line feed for newlines in acceptance tests#2865
shreyas-goenka merged 5 commits into
mainfrom
lf-gitattibute

Conversation

@shreyas-goenka

@shreyas-goenkashreyas-goenka commented May 13, 2025

Copy link
Copy Markdown
Contributor

Why

Based on feedback in #2720 (comment). We should always treat new lines in acceptance tests in windows as \n. This is important because the characters itself can be semantically important in tests. For example, an additional \r character in windows changes the upload payload if you are uploading the file's content to a workspace.

Tests

Existing workspace-io test should no longer need a custom override for windows.

Comment thread.gitattributes Outdated
bundle/internal/tf/schema/\*.go linguist-generated=true
go.sum linguist-generated=true
bundle/schema/jsonschema.json linguist-generated=true
acceptance/** eol=lf

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make sense to split this file? Move generated .gitattributes into cmd/.gitattributes and keep manually maintained ones at root.

Also, should this setting apply only to acceptance tests or to the whole repo?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this setting apply only to acceptance tests or to the whole repo?

Only acceptance tests. No reason I can think of upfront to apply to the whole repo. That could have adverse consequences of checking out the repo in windows.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move generated .gitattributes into cmd/.gitattributes and keep manually maintained ones at root.

Thanks, good point. It's not possible to split this file because it's generated and controlled by genkit but we can create a separate .gitattributes file in acceptance/

For code ref you can search for this in sourcegraph:

	if err = render.WriteGitAttributesFile(flagDir, filenames); err != nil {
return fmt.Errorf("write git attributes: %w", err)
}

# hello, world\n base64 encoded
[[Repls]]
Old = "aGVsbG8sIHdvcmxkCg=="
New = "[HELLO-WORLD]"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not drop this replacement as well? It's not dynamic, so a comment in the script will do.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's slightly more robust. A comment would be easy to miss if the actual uploaded value changes. People might miss a base64 encoding change if, for example, someone decides to refactor the test.

It's also what we do for base64 encoded strings in other places.

I don't mind either way though, happy to go with a comment too.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me, the less replacements there are, the easier it is to read the test output.

# hello, world\n base64 encoded
[[Repls]]
Old = "aGVsbG8sIHdvcmxkCg=="
New = "[HELLO-WORLD]"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me, the less replacements there are, the easier it is to read the test output.

Comment threadacceptance/.gitattributes Outdated
# This is important because the characters itself can be semantically important in tests.
# For example, an additional \r character in windows changes the upload payload if you are
# uploading the file's content to a workspace.
* text eol=lf

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are binary files in this tree (.whl files, for example).

This rule should only apply to .txt files (and others if we find they exhibit the same problem).

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, thanks! Only applying the annotation to .txt files.

@shreyas-goenka
shreyas-goenka added this pull request to the merge queueMay 19, 2025
Merged via the queue into main with commit 3cc81f3May 19, 2025
@shreyas-goenka
shreyas-goenka deleted the lf-gitattibute branch May 19, 2025 11:48
denik pushed a commit that referenced this pull request May 20, 2026
## Why
Based on feedback in
#2720 (comment). We
should always treat new lines in acceptance tests in windows as `\n`.
This is important because the characters itself can be semantically
important in tests. For example, an additional `\r` character in windows
changes the upload payload if you are uploading the file's content to a
workspace.
## Tests
Existing workspace-io test should no longer need a custom override for
windows.
Sign up for freeto 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.

3 participants

@shreyas-goenka@pietern@denik