Conversation

kmashint

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

Hi @kmashint, I'm your friendly neigrhood 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;

@DanielRosenwasserDanielRosenwasser 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'.": {

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

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

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

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

@DanielRosenwasser

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

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

@kmashint

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 {

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

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

@kmashint

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.

@mhegazymhegazy merged commit be3e3e7 into microsoft:master May 4, 2015
@mhegazy

Thanks @kmashint!

@kmashint

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 . Already have an account? Sign in.
None yet
None yet

Successfully merging this pull request may close these issues.