Skip to content

Don't normalize whitespace in fourslash tests #18447

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
2 commits merged into from
Sep 14, 2017
Merged

Don't normalize whitespace in fourslash tests #18447

2 commits merged into from
Sep 14, 2017

Conversation

ghost
Copy link

@ghost ghost commented Sep 13, 2017

Fixes #18349

The problem was that the test runner had code to normalize newlines, but it didn't change the index; so it thought that the new cursor was 1 character further along than it really was.

Changed fourslash tests to no longer normalize newlines; discovered a few bugs along the way (#18445) where CRLF characters are inserted into LF documents. (Fourslash tests are parsed with LF newlines even if the test file itself uses CRLF.)

Also had to fix an error related to #18291 where formatting options were being ignored due to an unused parameter.

Since this is just a test fix I don't think it needs a TS2.5 port.

if (this.normalizeNewlines(actualContent) !== this.normalizeNewlines(expectedContent)) {
this.raiseError(`verifyFileAfterApplyingRefactors failed: expected:\n${expectedContent}\nactual:\n${actualContent}`);
if (actualContent !== expectedContent) {
this.raiseError(`verifyFileAfterApplyingRefactors failed: expected:\n${makeWhitespaceVisible(expectedContent)}\nactual:\n${makeWhitespaceVisible(actualContent)}`);
Copy link
Member

Choose a reason for hiding this comment

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

This is going to be a pain because we'll be unable to copy+paste the actual back into the test. If we're going to do this, we should only do it when the files differ only in whitespace

Copy link
Member

@RyanCavanaugh RyanCavanaugh left a comment

Choose a reason for hiding this comment

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

Approve with suggestion

@ghost ghost merged commit d96dfeb into master Sep 14, 2017
@ghost ghost deleted the crlf branch September 14, 2017 15:23
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Apparent off-by-one error for extract method rename
2 participants