gotestyourself / gotestyourself/gotest.tools

golden: CRLF normalization conflicts with git core.autocrlf

Open
#146 5 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Go
Stars
576
Forks
54
Avg merge
6d 3h
Merged PRs (30d)
2

Description

👋 Thank you for working on golden ❤️

We are hitting some unexpected behaviour using golden on Windows. Strings are not being compared as I would expect. Here is some example output:

```
--- FAIL: TestEnvironmentSummary_golden_with_no_extra_settings (0.01s)
parser_test.go:382: assertion failed:
--- expected
+++ actual
@@ -1,15 +1,15 @@
-Using·build·environment·variables↵
-··BASH_ENV=/tmp/.bash_env-qwerasdf↵
-··CI=true↵
-··CIRCLECI=true↵
-··CIRCLE_BRANCH=↵
-··CIRCLE_BUILD_NUM=321↵
-··CIRCLE_BUILD_TOKEN=is-circle-build-token-still-a-thing?↵
-··CIRCLE_JOB=↵
-··CIRCLE_NODE_INDEX=0↵
-··CIRCLE_NODE_TOTAL=0↵
-··CIRCLE_REPOSITORY_URL=https://github.com/sample/example↵
-··CIRCLE_SHA1=↵
-··CIRCLE_SHELL_ENV=/tmp/.bash_env-qwerasdf↵
-··CIRCLE_WORKSPACE_ID=myworkspace↵
+Using·build·environment·variables
+··BASH_ENV=/tmp/.bash_env-qwerasdf
+··CI=true
+··CIRCLECI=true
+··CIRCLE_BRANCH=
+··CIRCLE_BUILD_NUM=321
+··CIRCLE_BUILD_TOKEN=is-circle-build-token-still-a-thing?
+··CIRCLE_JOB=
+··CIRCLE_NODE_INDEX=0
+··CIRCLE_NODE_TOTAL=0
+··CIRCLE_REPOSITORY_URL=https://github.com/sample/example
+··CIRCLE_SHA1=
+··CIRCLE_SHELL_ENV=/tmp/.bash_env-qwerasdf
+··CIRCLE_WORKSPACE_ID=myworkspace
```

What I think is happening is that, on Windows, `git` will by default, automatically convert newline characters to CRLF on checkout (`core.autocrlf`).

So although golden converts the `actual` string to remove CR characters, it does not strip the CR characters from the `expected` string.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.