Skip to content
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

Compiler flag to specify line ending #2921

Merged
merged 9 commits into from
May 4, 2015
Merged

Conversation

kmashint
Copy link
Contributor

This is a first pass, unit tests still TODO, of adding a compiler flag to specify the line ending:
#1693
--newLine NEWLINE Emit newline: 'CRLF' (dos) or 'LF' (unix).

I'll next add unit tests as noted in this follow-up issue but please note any comments on code thus far:
#2918

i've signed the contributor agreement.

@msftclas
Copy link

Hi @kmashint, I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution!
You've already signed the contribution license agreement. Thanks!
We will now validate the agreement and then real humans will evaluate your PR.

TTYL, MSBOT;

@DanielRosenwasser DanielRosenwasser changed the title Compiler flag to specify line ending #1693 Compiler flag to specify line ending Apr 26, 2015
"category": "Message",
"code": 6062
},
"Argument for --newLine option must be 'CRLF' or 'LF'.": {
Copy link
Member

Choose a reason for hiding this comment

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

'--newLine' in single quotes.

@kmashint
Copy link
Contributor Author

Adjusted for comments thus far. I'll look into test cases tomorrow.

@@ -91,6 +91,11 @@ module ts {
}
}

let newLine =
Copy link
Contributor

Choose a reason for hiding this comment

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

formatting, and use const.

@mhegazy
Copy link
Contributor

mhegazy commented Apr 27, 2015

Thanks @kmashint for the change. We will need a test for the new flag. to add a test,

  • add a new test file in test\cases\compiler.ts with a comment at the top of // @newline: LF , another one with CRLF, and one for wrong input as well.
  • add handling for the new switch in harnes.ts
    and in fileMetadataNames
  • you would need to pass then the correct newline value to getNewLine in harness.ts
  • jake runtests
  • jake baseline-accept

@kmashint
Copy link
Contributor Author

I found and started to make the harness.ts adjustments; the runtests is taking forever so I'll check in the morning.

@DanielRosenwasser
Copy link
Member

the runtests is taking forever

Yeah, there's been some perf drop in recent versions of Node that will make it...worse. I've been on 0.10.33. I've recently been working to parallelize the tests.

@kmashint
Copy link
Contributor Author

kmashint commented May 1, 2015

Stalled this week catching up on paid work ... should have some time on the weekend to work on unit tests.

@kmashint
Copy link
Contributor Author

kmashint commented May 2, 2015

I thought I had this working locally, but I'll try to find other examples of an expected failure in unit test cases.

  1. compiler tests for tests/cases/compiler/newLineFlagWithCR.ts "before all" hook:
    Error: Unknown option for newLine: CR

@@ -822,7 +825,8 @@ module Harness {
scriptTarget: ts.ScriptTarget,
useCaseSensitiveFileNames: boolean,
// the currentDirectory is needed for rwcRunner to passed in specified current directory to compiler host
currentDirectory?: string): ts.CompilerHost {
currentDirectory?: string,
newLineKind?: ts.NewLineKind): ts.CompilerHost {
Copy link
Member

Choose a reason for hiding this comment

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

Don't use tabs

@kmashint
Copy link
Contributor Author

kmashint commented May 2, 2015

I've introduced a @ normalizenewline option to work as the old one did in contextualTyping.js. I'll adjust for merge conflicts tomorrow.

@kmashint
Copy link
Contributor Author

kmashint commented May 3, 2015

OK, I've rebased my changes on top of microsoft/TypeScript. I tried using @ newline for both the new arguments and the old usage in contextualTyping.js but there were side-effects since the old usage affects not only the JS file but other debugging output files so I adjusted contextualTyping.js to use @ normalizenewline and all tests pass without further special treatment.

@mhegazy mhegazy merged commit be3e3e7 into microsoft:master May 4, 2015
@mhegazy
Copy link
Contributor

mhegazy commented May 4, 2015

Thanks @kmashint!

@kmashint
Copy link
Contributor Author

kmashint commented May 4, 2015

Happy to contribute in a small way, I hope others find it useful as well.

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.

5 participants