Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

Use denormalized path in test (fixes Windows build) #1701

Merged
merged 3 commits into from
Nov 10, 2016

Conversation

IllusionMH
Copy link
Contributor

PR checklist

  • Addresses an existing issue: #0000
  • New feature, bugfix, or enhancement
    • Includes tests
  • Documentation update

What changes did you make?

Currently build fails since normalized path returned from Node.js API (with \ as path separator) is compared to deormalized one (with / as path separator, which is also valid on Windows) which was picked from TypeScript.

This PR fixes build on Windows by converting normalized path to denormalized and using it in comparison.

Is there anything you'd like reviewers to focus on?

I've reviewed 3 possible solutions:

  1. Normalize fileName's when they are stored in RuleFailure class (used only in formatters)

  2. Normalize only absolute fileName's when they are stored in RuleFailure class (probably rare case, but matches problem in test)

  3. Use denormalized path in test

While first two solution fix problem, I think they bring almost no value and will lead to inconsistency in paths output between platforms.

@@ -123,10 +123,12 @@ describe("Executable", function() {
execCli(["-c", "test/files/multiple-fixes-test/tslint.json", tempFile, "--fix"],
(err, stdout) => {
const content = fs.readFileSync(tempFile, "utf8");
// compare against file name which will be retyrned by formatter (used in TypeScript)
Copy link
Contributor

Choose a reason for hiding this comment

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

typo retyrned

fs.unlinkSync(tempFile);
assert.strictEqual(content, "import * as y from \"a_long_module\";\nimport * as x from \"b\";\n");
assert.isNull(err, "process should exit without an error");
assert.strictEqual(stdout, `Fixed 2 error(s) in ${tempFile}`);
assert.strictEqual(stdout, `Fixed 2 error(s) in ${denornalizedFileName}`);
Copy link
Contributor

Choose a reason for hiding this comment

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

typo denornalizedFileName

@IllusionMH
Copy link
Contributor Author

@nchen63 thank you for review. Next time I will look more carefully to avoid such typos.

@nchen63 nchen63 merged commit 2841445 into palantir:master Nov 10, 2016
@nchen63
Copy link
Contributor

nchen63 commented Nov 10, 2016

@IllusionMH no problem. Thanks for the contribution!

@IllusionMH IllusionMH deleted the denormalize-win-path branch January 8, 2017 12:24
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.

2 participants