Skip to content
This repository has been archived by the owner on Dec 14, 2018. It is now read-only.

Some Unit Test for Razor Templating are failing, when global .gitgnore config has core.autocrlf = false #1514

Closed
DerAlbertCom opened this issue Nov 6, 2014 · 2 comments

Comments

@DerAlbertCom
Copy link

that's because of the

.gitignore

[core]
    autocrlf = false

the the \r\n and \n problem while comparing input and output.

Steps to reproduce on a windows machine

  • checkout (in my case release)
  • execute build.com
@yishaigalatzer yishaigalatzer added this to the 6.0.0-beta2 milestone Nov 6, 2014
@danroth27 danroth27 modified the milestones: 6.0.0-rc1, 6.0.0-beta2 Dec 11, 2014
@pranavkm
Copy link
Contributor

We decided on using either embedded resource of multiline @ strings in our tests to work around. There's quite a few strings that are constructed at test runtime using Environment.NewLine - these need to be changed.

@pranavkm pranavkm modified the milestones: 6.0.0-rc1, 6.0.0-beta3 Jan 13, 2015
@danroth27 danroth27 modified the milestones: 6.0.0, 6.0.0-rc1 Mar 16, 2015
@danroth27 danroth27 modified the milestones: 6.0.0-beta5, 6.0.0-beta6 May 18, 2015
dougbu added a commit that referenced this issue Jun 22, 2015
- #1514
- refactor `RazorCompilationService` to allow a test subclass that normalizes Razor file line endings
 - add `TestRazorCompilationService` to `RazorPageExecutionInstrumentationWebSite`
 - adjust line endings to match in `RazorPageExecutionInstrumentationTest`
- add `ignoreLineEndingDifferences: true` to `Assert.Equal()` calls
 - responses on Windows can have a mix of line endings
  - `git config` setting affects line endings in .cshtml (and baseline) files
  - however MVC and Razor mix `Environment.NewLine`s into HTTP responses
- update `PrecompilationTest` to split response regardless of line endings
- update `ResourceFile` to normalize all source file streams to LF only
 - ensures consistent checksums and line mappings
 - change `MvcRazorHostTest` to expect new line mappings
 - recreate baseline files to expect new checksums and literal line endings
- use verbatim strings in affected tests
 - careful use of `Environment.NewLine` in expectations is now just noise

nits:
- add doc comments in `RazorCompilationService`
- correct `TagHelpersTest` name to match containing file
- avoid incorrect `using` removal when `GENERATE_BASELINES` is not defined
- remove unnecessary `ResourceFile` normalization of output files
dougbu added a commit that referenced this issue Jun 24, 2015
- #1514
- refactor `RazorCompilationService` to allow a test subclass that normalizes Razor file line endings
 - add `TestRazorCompilationService` to `RazorPageExecutionInstrumentationWebSite`
 - adjust line endings to match in `RazorPageExecutionInstrumentationTest`
- add `ignoreLineEndingDifferences: true` to `Assert.Equal()` calls
 - responses on Windows can have a mix of line endings
  - `git config` setting affects line endings in .cshtml (and baseline) files
  - however MVC and Razor mix `Environment.NewLine`s into HTTP responses
- update `PrecompilationTest` to split response regardless of line endings
- update `ResourceFile` to normalize all source file streams to LF only
 - ensures consistent checksums and line mappings
 - change `MvcRazorHostTest` to expect new line mappings
 - recreate baseline files to expect new checksums and literal line endings
- use verbatim strings in affected tests
 - careful use of `Environment.NewLine` in expectations is now just noise

nits:
- add doc comments in `RazorCompilationService`
- correct `TagHelpersTest` name to match containing file
- avoid incorrect `using` removal when `GENERATE_BASELINES` is not defined
- remove unnecessary `ResourceFile` normalization of output files
@dougbu
Copy link
Member

dougbu commented Jun 24, 2015

9c63d1d

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants